Get the App
SLTechnology News&Howtos  ›  Servers  › 

What are the basic commands commonly used in HDFS

Shulou Source: shulou.com Published: 2022-06-01 02:54:58 09月22日 Update

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)

Tags: Files videos clusters directories articles video streams commands frequently used location content name time node path success not much most real-time more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Tech Info Shulou Information Docker macOS