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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hdfs user 连接_通过API访问HDFS

發布時間:2025/3/20 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hdfs user 连接_通过API访问HDFS 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

通過API操作HDFS

今天的主要內容

HDFS獲取文件系統

HDFS文件上傳

HDFS文件下載

HDFS目錄創建

HDFS文件夾刪除

HDFS文件名更改

HDFS文件詳情查看

定位文件讀取

FileSystem類的學習

1. HDFS獲取文件系統

//獲取文件系統

@Test

public void initHDFS() throws Exception{

//1. 獲取文件系統

Configuration configuration = new Configuration();

FileSystem fileSystem = FileSystem.get(configuration);

//2. 打印文件系統到控制臺

System.out.println(fileSystem.toString());

}

2. HDFS文件上傳(測試參數優先級)

@Test

public void putFileToHdfs() throws Exception{

Configuration conf = new Configuration();

conf.set("dfs.replication", "2"); //代碼優先級是最高的

conf.set("fs.defaultFS", "hdfs://10.9.190.111:9000");

FileSystem fileSystem = FileSystem.get(conf);

//上傳文件

fileSystem.copyFromLocalFile(new Path("hdfs.txt"), new Path("/user/anna/hdfs/test.txt"));

//關閉資源

fileSystem.close();

}

參數優先級:(1)客戶端代碼中設置的值 >(2)classpath 下的用戶自定義配置文件 > (3)然后是服務器的默認配置

3. HDFS文件下載

public void copyToLocalFile(boolean delSrc,Path src,Path dst,boolean useRawLocalFileSystem)

throws IOException

delSrc - whether to delete the src

src - path

dst - path

useRawLocalFileSystem - whether to use RawLocalFileSystem as local file system or not.

@Test

public void testCopyToLocalFile() throws Exception{

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://10.9.190.111:9000");

FileSystem fileSystem = FileSystem.get(conf);

///下載文件

fileSystem.copyToLocalFile(false,new Path("/user/anna/hdfs/test.txt"), new Path("test.txt"),true);

//關閉資源

fileSystem.close();

}

4. HDFS目錄創建

@Test

public void testMakedir() throws Exception{

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://10.9.190.111:9000");

FileSystem fileSystem = FileSystem.get(conf);

//目錄創建

fileSystem.mkdirs(new Path("/user/anna/test/hahaha"));

//關閉資源

fileSystem.close();

}

5. HDFS文件夾刪除

@Test

public void testDelete() throws Exception{

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://10.9.190.111:9000");

FileSystem fileSystem = FileSystem.get(conf);

//文件夾刪除

fileSystem.delete(new Path("/user/anna/test/hahaha"),true); //true表示遞歸刪除

//關閉資源

fileSystem.close();

}

6. HDFS文件名更改

@Test

public void testRename() throws Exception{

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://10.9.190.111:9000");

FileSystem fileSystem = FileSystem.get(conf);

//文件名稱更改

fileSystem.rename(new Path("/user/anna/test/copy.txt"), new Path("/user/anna/test/copyRename.txt"));

//關閉資源

fileSystem.close();

}

7. HDFS文件詳情查看

幾種實現方法

1. public abstract FileStatus[] listStatus(Path f) throws FileNotFoundException,IOException

* 返回FileStatus型數組

2. public FileStatus[] listStatus(Path f,PathFilter filter) throws FileNotFoundException,IOException

3. public FileStatus[] listStatus(Path[] files,PathFilter filter) throws FileNotFoundException,IOException

* 此時注意PathFilter是一個接口,里面只有一個方法:accept,本質是對文件進行篩選

* Enumerate all files found in the list of directories passed in, calling listStatus(path, filter) on each one.

注意:以上方法返回的文件按照字母表順序排列

代碼:FileStatus[] listStatus(Path f)

//FileStatus[] listStatus(Path f)的使用

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

//listStatus獲取/test目錄下信息

FileStatus[] fileStatuses = fileSystem.listStatus(new Path("/test"));

//遍歷輸出文件夾下文件

for(FileStatus fileStatus :fileStatuses) {

System.out.println(fileStatus.getPath() + " " + new Date(fileStatus.getAccessTime()) + " " +

fileStatus.getBlockSize() + " " + fileStatus.getPermission());

}

}catch(Exception e) {

e.printStackTrace();

}

/*

在JDK1.8中輸出結果為:

----------------------------------------------------------------------------

hdfs://10.9.190.90:9000/test/hadoop-2.7.3.tar.gz 2012-07-26 134217728 rw-r--r--

hdfs://10.9.190.90:9000/test/hello.txt 2012-07-26 134217728 rw-r--r--

hdfs://10.9.190.90:9000/test/test2 1970-01-01 0 rwxr-xr-x

----------------------------------------------------------------------------

*/

代碼:FileStatus[] listStatus(Path f,PathFilter filter)

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

//列出目錄下后綴為.md的文件相關信息

FileStatus[] statuses = fileSystem.listStatus(new Path("/test/test2"), new PathFilter() {

@Override

public boolean accept(Path path) {

// TODO Auto-generated method stub

String string = path.toString();

if(string.endsWith(".md"))

return true;

else

return false;

}

});

//列出文件信息

for(FileStatus status : statuses) {

System.out.println("Path : " + status.getPath() + " Permisson : " + status.getPermission() +

" Replication : " + status.getReplication());

}

}catch(Exception e) {

e.printStackTrace();

}

7. 定位文件讀取

8. FileSystem類的學習

FileSystem的學習

今天的主要內容

對照官方文檔進行FileSystem類的學習

FileSystem中的方法

* boolean exists(Path p)

* boolean isDirectory(Path p)

* boolean isFile(Path p)

* FileStatus getFileStatus(Path p)

* Path getHomeDirectory()

* FileStatus[] listStatus(Path path, PathFilter filter)

FileStatus[] listStatus(Path path)

FileStatus[] listStatus(Path[] paths, PathFilter filter)

FileStatus[] listStatus(Path[] paths)

* RemoteIterator[LocatedFileStatus] listLocatedStatus(Path path, PathFilter filter)

RemoteIterator[LocatedFileStatus] listLocatedStatus(Path path)

RemoteIterator[LocatedFileStatus] listFiles(Path path, boolean recursive)

* BlockLocation[] getFileBlockLocations(FileStatus f, int s, int l)

BlockLocation[] getFileBlockLocations(Path P, int S, int L)

* long getDefaultBlockSize()

long getDefaultBlockSize(Path p)

long getBlockSize(Path p)

* boolean mkdirs(Path p, FsPermission permission)

* FSDataOutputStream create(Path, ...)

FSDataOutputStream append(Path p, int bufferSize, Progressable progress)

FSDataInputStream open(Path f, int bufferSize)

* boolean delete(Path p, boolean recursive)

* boolean rename(Path src, Path d)

* void concat(Path p, Path sources[])

* boolean truncate(Path p, long newLength)

* interface RemoteIterator

boolean hasNext()

E next()

* interface StreamCapabilities

boolean hasCapability(capability)

準備工作

start-dfs.sh啟動hadoop集群

eclipse進行hdfs文件系統的訪問

導入相應的jar包

創建與hdfs的連接并獲取FileSystem文件對象

第一種方式

* public static FileSystem get(Configuration conf) throws IOException

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000"); //namenode上的IP地址 端口為:9000

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

第二種方式

* public static FileSystem get(URI uri,Configuration conf,String user)

throws IOException,

InterruptedException

URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());

FileSystem fileSystem = FileSystem.get(new URI("hdfs://10.9.190.90:9000"),new Configuration(),"root");

//此時工作目錄會相應更改為/user/root

兩種方式比較

第二種方式可能會拋出InterruptedException異常,因為

the static FileSystem get(URI uri, Configuration conf,String user) method MAY return a pre-existing instance of a filesystem client class—a class that may also be in use in other threads. The implementations of FileSystem shipped with Apache Hadoop do not make any attempt to synchronize access to the working directory field.(此時get方法可能會返回一個已經存在FileSystem對象,也就是存在線程異步問題,所以我們盡量用前一種方式來完成FileSystem對象的創建)

org.apache.hadoop.fs.FileSystem簡介

The abstract FileSystem class is the original class to access Hadoop filesystems; non-abstract subclasses exist for all Hadoop-supported filesystems.(抽象基類FileSystem定義了對hadoop文件系統的操作)

All operations that take a Path to this interface MUST support relative paths. In such a case, they must be resolved relative to the working directory defined by setWorkingDirectory().(setWorkingDirectory()方法默認工作目錄)

FileSystem中的getWorkingDirector()返回當前系統的工作目錄

代碼

//獲得與hdfs文件系統的連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://10.9.190.90:9000");

//獲取文件系統對象

FileSystem fileSystem = FileSystem.get(conf);

//獲取當前工作目錄

System.out.println("=========獲取當前工作目錄=============");

System.out.println(fileSystem.getWorkingDirectory());

//設置新的工作目錄

//System.out.println("=========設置新的工作目錄=============");

fileSystem.setWorkingDirectory(new Path("hdfs://10.9.190.90:9000/user/anna")); //Path在hdfs中的作用和File作用類似,代表路徑

結果

=========獲取當前工作目錄=============

hdfs://10.9.190.90:9000/user/root

=========獲取設置后工作目錄=============

hdfs://10.9.190.90:9000/user/anna

FileSystem方法——判斷功能

預備知識

import org.apache.hadoop.fs.Path;類似于java.io.File代表hdfs的文件路徑

方法

public boolean exists(Path f) throws IOException

判斷文件是否存在

public boolean isDirectory(Path f) throws IOException

判斷是否為目錄

public boolean isFile(Path f) throws IOException

判斷是否為文件

練習

try {

//獲得與hdfs文件系統的連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://10.9.190.90:9000");

//獲取連接對象

FileSystem fileSystem = FileSystem.get(conf);

//判斷文件是否存在

System.out.println(fileSystem.exists(new Path("/test"))); //true

//判斷是否為目錄

System.out.println(fileSystem.isDirectory(new Path("/test"))); //true

//判斷是否為文件

System.out.println(fileSystem.isFile(new Path("/test"))); //false

}catch(Exception e) {

e.printStackTrace();

}

FileSystem方法——獲取功能—文件信息獲取

方法

public abstract FileStatus getFileStatus(Path f) throws IOException

Return a file status object that represents the path.

返回的是FileStatus對象類型

public Path getHomeDirectory()

Return the current user's home directory in this FileSystem. The default implementation returns "/user/$USER/".

返回當前用戶的home目錄

練習

try {

//獲得與hdfs文件系統的連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://10.9.190.90:9000");

//獲取連接對象

FileSystem fileSystem = FileSystem.get(conf);

//獲取當前用戶的home目錄

System.out.println("========當前用戶的home目錄============");

Path path = fileSystem.getHomeDirectory();

System.out.println(path);

//獲取文件狀態對象

System.out.println("============文件信息===============");

FileStatus status = fileSystem.getFileStatus(new Path("/eclipse"));

System.out.println("Path : " + status.getPath());

System.out.println("isFile ? " + status.isFile());

System.out.println("Block size : " + status.getBlockSize());

System.out.println("Perssions : " + status.getPermission());

System.out.println("Replication : " + status.getReplication());

System.out.println("isSymlink : " + status.isSymlink());

}catch(Exception e) {

e.printStackTrace();

}

/*

在JDK1.8中輸出結果為:

* ------------------------------------------------

* ========當前用戶的home目錄============

hdfs://10.9.190.90:9000/user/anna

============文件信息===============

Path : hdfs://10.9.190.90:9000/eclipse

isFile ? true

Block size : 134217728

Perssions : rw-r--r--

Replication : 3

isSymlink : false

------------------------------------------------

*/

FileStatus中常用方法

public Path getPath()

public boolean isFile()

public boolean isSymlink()

public long getBlockSize()

public short getReplication()

public FsPermission getPermission()

FileSystem方法——獲取功能——文件夾遍歷1

方法

public abstract FileStatus[] listStatus(Path f) throws FileNotFoundException,IOException

返回FileStatus型數組

public FileStatus[] listStatus(Path f,PathFilter filter)

throws FileNotFoundException,IOException

public FileStatus[] listStatus(Path[] files,PathFilter filter)

throws FileNotFoundException,IOException

此時注意PathFilter是一個接口,里面只有一個方法:accept,本質是對文件進行篩選

Enumerate all files found in the list of directories passed in, calling listStatus(path, filter) on each one.

注意:以上方法返回的文件按照字母表順序排列

練習1——FileStatus[] listStatus(Path f)的使用

//FileStatus[] listStatus(Path f)的使用

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

//listStatus獲取/test目錄下信息

FileStatus[] fileStatuses = fileSystem.listStatus(new Path("/test"));

//遍歷輸出文件夾下文件

for(FileStatus fileStatus :fileStatuses) {

System.out.println(fileStatus.getPath() + " " + new Date(fileStatus.getAccessTime()) + " " +

fileStatus.getBlockSize() + " " + fileStatus.getPermission());

}

}catch(Exception e) {

e.printStackTrace();

}

/*

在JDK1.8中輸出結果為:

----------------------------------------------------------------------------

hdfs://10.9.190.90:9000/test/hadoop-2.7.3.tar.gz 2012-07-26 134217728 rw-r--r--

hdfs://10.9.190.90:9000/test/hello.txt 2012-07-26 134217728 rw-r--r--

hdfs://10.9.190.90:9000/test/test2 1970-01-01 0 rwxr-xr-x

----------------------------------------------------------------------------

*/

練習2——FileStatus[] listStatus(Path f,PathFilter filter)的使用

需求:列出/test/test2目錄下以.md結尾的問價信息

代碼:

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

//列出目錄下后綴為.md的文件相關信息

FileStatus[] statuses = fileSystem.listStatus(new Path("/test/test2"), new PathFilter() {

@Override

public boolean accept(Path path) {

// TODO Auto-generated method stub

String string = path.toString();

if(string.endsWith(".md"))

return true;

else

return false;

}

});

//列出文件信息

for(FileStatus status : statuses) {

System.out.println("Path : " + status.getPath() + " Permisson : " + status.getPermission() +

" Replication : " + status.getReplication());

}

}catch(Exception e) {

e.printStackTrace();

}

注意問題

By the time the listStatus() operation returns to the caller, there is no guarantee that the information contained in the response is current. The details MAY be out of date, including the contents of any directory, the attributes of any files, and the existence of the path supplied.(listStatus()方法線程不安全)

FileSystem方法——獲取功能——文件夾遍歷2

方法

public org.apache.hadoop.fs.RemoteIterator listLocatedStatus(Path f)

throws FileNotFoundException, IOException

protected org.apache.hadoop.fs.RemoteIterator listLocatedStatus(Path f,PathFilter filter)

throws FileNotFoundException, IOException

注意:此方法是protected的,protected權限是:本類,同一包下(子類或無關類),不同包下子類

注意:LocatedFileStatus是FileStatus的子類

使用

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

//列出目錄下后綴為.md的文件相關信息

RemoteIterator iterator = fileSystem.listLocatedStatus(new Path("/test/test2"));

while(iterator.hasNext()) {

LocatedFileStatus status = iterator.next();

System.out.println("Path : " + status.getPath() + " Permisson : " + status.getPermission() +

" Replication : " + status.getReplication());

}

}catch(Exception e) {

e.printStackTrace();

}

/*

* 在JDK1.8中輸出結果為:

* ---------------------------------------------------------------------------------------------

* Path : hdfs://10.9.190.90:9000/test/test2/Map.md Permisson : rw-r--r-- Replication : 3

Path : hdfs://10.9.190.90:9000/test/test2/biji.md Permisson : rw-r--r-- Replication : 3

Path : hdfs://10.9.190.90:9000/test/test2/haha.txt Permisson : rw-r--r-- Replication : 3

---------------------------------------------------------------------------------------------

* */

與listStatus(Path p)不同的是

listStatus返回的是FileStatus[]數組類型,遍歷時可通過數組for-each進行遍歷

listLocatedStatus(Path p)返回的是LocatedFileStatus類型的RemoteIterator集合,通過迭代器進行遍歷輸出

但是要注意的是listLocatedStatus()方法本質上內部還是listStatus(Path p)實現的

FileSystem方法——獲取功能——文件夾遍歷3

方法

public org.apache.hadoop.fs.RemoteIterator listFiles(Path f,boolean recursive)

throws FileNotFoundException,IOException

遞歸遍歷出文件夾內容以及子文件夾中內容

使用

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

//列出目錄下后綴為.md的文件相關信息

RemoteIterator iterator = fileSystem.listFiles(new Path("/test"),true);

while(iterator.hasNext()) {

LocatedFileStatus status = iterator.next();

System.out.println("Path : " + status.getPath() + " Permisson : " + status.getPermission() +

" Replication : " + status.getReplication());

}

}catch(Exception e) {

e.printStackTrace();

}

/*

* 在JDK1.8中輸出結果為:

* ---------------------------------------------------------------------------------------------------

* Path : hdfs://10.9.190.90:9000/test/hadoop-2.7.3.tar.gz Permisson : rw-r--r-- Replication : 3

Path : hdfs://10.9.190.90:9000/test/hello.txt Permisson : rw-r--r-- Replication : 3

Path : hdfs://10.9.190.90:9000/test/test2/Map.md Permisson : rw-r--r-- Replication : 3

Path : hdfs://10.9.190.90:9000/test/test2/biji.md Permisson : rw-r--r-- Replication : 3

Path : hdfs://10.9.190.90:9000/test/test2/haha.txt Permisson : rw-r--r-- Replication : 3

---------------------------------------------------------------------------------------------------

* */

FileSystem方法——獲取功能——獲取文件block的位置

方法

public BlockLocation[] getFileBlockLocations(Path p,long start,long len) throws IOException

public BlockLocation[] getFileBlockLocations(FileStatus file,long start,long len) throws IOException

使用

//查看/test/hadoop的block存放位置

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

FileStatus status = fileSystem.getFileStatus(new Path("/test/hadoop"));

BlockLocation[] locations = fileSystem.getFileBlockLocations(status, 0,status.getLen());

for(BlockLocation location : locations) {

System.out.println("host : " + location.getHosts() + " name : " + location.getNames() + " length : " + location.getLength());

}

}catch(Exception e) {

e.printStackTrace();

}

/*

在JDK1.8中輸出結果為:

------------------------------------------------------------------------------

host : [Ljava.lang.String;@18ece7f4 name : [Ljava.lang.String;@3cce57c7 length : 134217728

host : [Ljava.lang.String;@1cf56a1c name : [Ljava.lang.String;@33f676f6 length : 79874467

------------------------------------------------------------------------------

*/

FileSystem方法——獲取功能——獲取到某文件的輸出流

方法

public FSDataOutputStream create(Path f) throws IOException

public FSDataOutputStream create(Path f,boolean overwrite)

throws IOException

overwrite - if a file with this name already exists, then if true, the file will be overwritten, and if false an exception will be thrown.

public FSDataOutputStream create(Path f,

Progressable progress)

throws IOException

Create an FSDataOutputStream at the indicated Path with write-progress reporting. Files are overwritten by default.

public FSDataOutputStream create(Path f,boolean overwrite,int bufferSize)

throws IOException

public FSDataOutputStream create(Path f,boolean overwrite,int bufferSize, Progressable progress)throws IOException

FSDataOutputStream append(Path p, int bufferSize, Progressable progress)

使用——將本地E:/hzy.jpg上傳到hdfs的/1.jpg

public static void main(String[] args) {

BufferedInputStream in = null;

FSDataOutputStream out = null;

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

//獲取本地文件輸入流

File file = new File("E:/hzy.jpg");

in = new BufferedInputStream(new FileInputStream(file));

final long fileSize = file.length();

//獲取到/test/hello.txt的輸出流

out = fileSystem.create(new Path("/1.jpg"),new Progressable() {

long fileCount = 0;

@Override

public void progress() {

// TODO Auto-generated method stub

fileCount++;

System.out.println("總進度:" + (fileCount/fileSize)*100 + " %");

}

});

//拷貝

int len = 0;

while((len = in.read()) != -1) {

out.write(len); //此時也可以用:IOUtils.copyBytes(in,out,conf);

}

in.close();

out.close();

}catch(Exception e) {

e.printStackTrace();

}finally {

if(in != null) {

try {

in.close();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

if (out != null) {

try {

out.close();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}

FileSystem方法——獲取功能——獲取到某文件的輸入流——讀取文件

方法

public FSDataInputStream open(Path f) throws IOException

public abstract FSDataInputStream open(Path f,int bufferSize)throws IOException

使用——將hdfs中的1.jpg拷貝到本地E:/hzy2.jpg

try {

//創建與HDFS連接

Configuration conf = new Configuration();

conf.set("fs.defaultFS","hdfs://10.9.190.90:9000");

//獲得fileSystem

FileSystem fileSystem = FileSystem.get(conf);

//獲取hdfs文件輸入流

FSDataInputStream in = fileSystem.open(new Path("/1.jpg"));

//獲取本地輸出流

BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File("E:/hzyCopy.jpg")));

int len = 0;

byte[] bArr = new byte[1024*3];

while((len = in.read(bArr)) != -1) {

out.write(bArr,0,len);

}

in.close();

out.close();

}catch(Exception e) {

e.printStackTrace();

}

}

FileSystem方法——創建功能

public boolean mkdirs(Path f) throws IOException

FileSystem方法——刪除功能

public abstract boolean delete(Path f,boolean recursive) throws IOException

設計線程同步問題

FileSystem方法——重命名功能

public abstract boolean rename(Path src,Path dst)throws IOException

FileSystem其他方法

public void concat(Path trg,Path[] psrcs)throws IOException

Concat existing files together.

public boolean truncate(Path f,long newLength)throws IOException

interface RemoteIterator

定義

public interface RemoteIterator {

boolean hasNext() throws IOException;

E next() throws IOException;

}

The primary use of RemoteIterator in the filesystem APIs is to list files on (possibly remote) filesystems.

使用

//listLocatedFileStatus(Path f)

public org.apache.hadoop.fs.RemoteIterator listLocatedStatus(Path f)

throws FileNotFoundException,IOException

//listLocatedStatus(Path f,PathFilter filter)

protected org.apache.hadoop.fs.RemoteIterator listLocatedStatus(Path f,PathFilter filter)

throws FileNotFoundException,IOException

//listStatusIterator(Path p)

public org.apache.hadoop.fs.RemoteIterator listStatusIterator(Path p)

throws FileNotFoundException,IOException

//listFiles(Path f,boolean recursive)

public org.apache.hadoop.fs.RemoteIterator listFiles(Path f,boolean recursive)

throws FileNotFoundException,IOException

interface StreamCapabilities

方法

public interface StreamCapabilities {

boolean hasCapability(String capability);

}

使用

hadoop2.7.3中無此方法,在2.9.1中才有

總結

以上是生活随笔為你收集整理的hdfs user 连接_通过API访问HDFS的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 全黄一级播放 | 另类专区欧美 | 日韩精品一区二区亚洲av | 国产成人无码精品久久二区三 | 欧美三级三级三级爽爽爽 | 免费在线黄网站 | 欧美在线色图 | 欧美三级理论片 | 日韩va在线 | 51福利视频 | 日本大奶视频 | 综合色吧 | 欧美自拍偷拍 | 国产视频一区二区三区四区五区 | av生活片 | 在线观看亚洲区 | 老女人做爰全过程免费的视频 | 久久久亚洲精品无码 | 国产精品欧美久久久久天天影视 | 欧美日韩久 | 国产欧美一区二区 | 午夜久| 免费av导航 | 亚洲熟乱| 激情欧美一区二区三区精品 | 波多野结衣中文在线 | 亚洲影院在线 | 在线不卡的av| www.youjizz日本 | 国产专区一区二区三区 | 国产激情无码一区二区 | 成人va视频 | 在线免费观看欧美大片 | 在线观看自拍 | 亚洲av综合色区无码一区爱av | 国产精品丝袜黑色高跟鞋 | 妞妞影视| 8x8x永久免费视频 | 天堂在线观看 | 99久久久无码国产精品性波多 | av调教 | 国产色频 | 免费看的毛片 | 亚洲综合中文 | 日本黄色www | 国产精品一卡 | 国产一区二区三区在线观看免费 | 日韩av一卡二卡 | 免费操片 | 日韩国产亚洲欧美 | 综合图区亚洲 | 久久99久久98精品免观看软件 | 91中文国产 | 欧美小视频在线 | 欧美bbbbb性bbbbb视频 | 欧美大片一区二区三区 | 黑人借宿巨大中文字幕 | jizz中文字幕 | 国产精品国产三级国产aⅴ中文 | 国产精品区在线观看 | 日韩射| 黄色av在| 精品视频站长推荐 | 在线免费看av片 | 国产伦精品一区二区三区在线 | 欧美片网站yy | 色偷偷av一区二区三区 | 天天干天天爱天天操 | 女人扒开屁股让男人桶 | 国内精品国产成人国产三级 | 欧美成人二区 | 看全色黄大色黄大片大学生 | 成人做爰www免费看视频网站 | 日韩av不卡一区 | 依依成人综合网 | 国产一线二线在线观看 | 乱亲女h秽乱长久久久 | 精品免费一区二区三区 | 美女黄色一级 | av在线二区 | 张柏芝亚洲一区二区三区 | 黄色avv| 人妻少妇偷人精品无码 | av网站免费播放 | 精品无人国产偷自产在线 | 欧美熟妇精品一区二区蜜桃视频 | 操一操视频 | 韩国三级一区 | 强开小嫩苞一区二区三区网站 | 香蕉视频啪啪 | 亚洲国产传媒 | 蜜桃久久一区二区三区 | 天天操穴 | 岛国精品在线播放 | 欧美乱码精品一区二区三区 | 日本日皮视频 | 日韩欧美一级大片 | 亚洲精品亚洲人成人网 | 九一爱爱 |