In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what the basic HDFS commands are commonly used, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
One: check the last modification time of the HDFS file
Public class Test6GetLTime {/ * View the last modification time of the HDFS file * * / public static void main (String [] args) {try {Configuration conf = new Configuration (); URI uri = new URI ("hdfs://192.168.226.129:9000") FileSystem fs = FileSystem.get (uri, conf); Path dfs = new Path ("hdfs://192.168.226.129:9000/"); FileStatus fileStatus = fs.getFileStatus (dfs); long modificationTime = fileStatus.getModificationTime () System.out.println ("Modefication time is:" + modificationTime);} catch (IllegalArgumentException e) {e.printStackTrace ();} catch (URISyntaxException e) {e.printStackTrace ();} catch (IOException e) {e.printStackTrace () }}}
Second: find the location of a file in the HDFS cluster
Public class Test7FileLocation {/ * find the location of a file in the HDFS cluster * * / public static void main (String [] args) {try {Configuration conf = new Configuration (); URI uri = new URI ("hdfs://192.168.226.129:9000") FileSystem fs = FileSystem.get (uri, conf); Path dfs = new Path ("hdfs://192.168.226.129:9000/rootdir/ssh.txt"); FileStatus fileStatus = fs.getFileStatus (dfs); BlockLocation [] blkLocations = fs.getFileBlockLocations (fileStatus,0, fileStatus.getLen ()) Int blockLen = blkLocations.length; System.out.println ("blockLen of length:" + blockLen); for (int item0)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.