日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

HDFS-windows下测试hdfs命令

發布時間:2023/12/9 windows 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HDFS-windows下测试hdfs命令 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
public class HdfsClient1 {private FileSystem fs;//初始化一個FileSystem@Beforepublic void init() throws URISyntaxException, IOException, InterruptedException {//1:獲取文件系統URI uri = new URI("hdfs://myhadoop105:9820");Configuration conf = new Configuration();conf.set("dfs.replication","6");String user = "atguigu";fs = FileSystem.get(uri, conf, user);}@Afterpublic void closeResources() throws IOException {//3:關閉資源fs.close();}@Testpublic void testMkdir() throws IOException {fs.mkdirs(new Path("/hdfs/windowsOperator/operator01"));}@Testpublic void testPut() throws IOException {fs.copyFromLocalFile(false , false , new Path("G:/code/test/day08課堂記錄.txt") , new Path("/hdfs/windowsOperator/operator01"));}@Testpublic void testGet() throws IOException {fs.copyToLocalFile(new Path("/hdfs/windowsOperator/operator01"),new Path("G:\\code\\test\\test"));}@Testpublic void testMove() throws IOException {fs.rename(new Path("/hdfs/windowsOperator/day08課堂記錄.txt"),new Path("/hdfs/windowsOperator/day08"));}@Testpublic void testDelete() throws IOException {fs.delete(new Path("/hdfs/windowsOperator/operator01"),true);}@Testpublic void testIsFile() throws IOException {FileStatus[] fileStatuses = fs.listStatus(new Path("/"));for (FileStatus fileStatus : fileStatuses) {//判斷是否是文件if (fileStatus.isFile()){System.out.println("-:"+fileStatus.getPath().getName());}else {System.out.println("d:" + fileStatus.getPath().getName());}}}@Testpublic void testListFiles() throws IOException {// f:要查看的目錄路徑// r:是否遞歸查看RemoteIterator<LocatedFileStatus> listFiles = fs.listFiles(new Path("/"), true);while (listFiles.hasNext()){LocatedFileStatus fileStatus = listFiles.next();System.out.println("-------------------------" + fileStatus.getPath() + "--------------------");System.out.println(fileStatus.getPermission());System.out.println(fileStatus.getOwner());System.out.println(fileStatus.getGroup());System.out.println(fileStatus.getLen());System.out.println(fileStatus.getModificationTime());System.out.println(fileStatus.getReplication());System.out.println(fileStatus.getBlockLocations());System.out.println(fileStatus.getPath().getName());//快信息BlockLocation[] blockLocations = fileStatus.getBlockLocations();System.out.println(Arrays.toString(blockLocations));}}}

總結

以上是生活随笔為你收集整理的HDFS-windows下测试hdfs命令的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。