20,808
社区成员
发帖
与我相关
我的任务
分享
public class TestHDFS {
public static void main(String[] args) throws Exception{
long start = System.currentTimeMillis();
Configuration configuration = new Configuration();
configuration.set("dfs.support.append","true");
FileSystem fs = FileSystem.get(configuration);
Path target = new Path("/2.csv");
FSDataOutputStream append = fs.append(target);
BufferedReader br = new BufferedReader(new FileReader(new File("./2.csv")));
String line = "";
while((line=br.readLine())!=null){
append.writeChars(line);
append.flush();
}
append.close();
br.close();
long end = System.currentTimeMillis();
System.out.println("耗时"+(end-start)+"ms");
}
}
错误提示:
Exception in thread "main" java.io.IOException: Not supported
at org.apache.hadoop.fs.ChecksumFileSystem.append(ChecksumFileSystem.java:290)
at org.apache.hadoop.fs.FileSystem.append(FileSystem.java:650)
at test.TestHDFS.main(TestHDFS.java:21)
因为公司用的HADOOP是别人封装的,配置文件完全不知道在哪里,所以这里只能在代码上设置conf修改
谢谢拉[/quote][/quote]
嗯 非常感谢您,不过这个ChecksumFileSystem和DistributedFileSystem不都是FileSystem的子类吗?
我用的是FileSystem 请问DistributedFileSystem 和 ChecksumFileSystem 有什么区别吗?
谢谢您了
/** {@inheritDoc} */
public FSDataOutputStream append(Path f, int bufferSize,
Progressable progress) throws IOException {
throw new IOException("Not supported");
}
代码
public class TestHDFS {
public static void main(String[] args) throws Exception{
long start = System.currentTimeMillis();
Configuration configuration = new Configuration();
configuration.set("dfs.support.append","true");
FileSystem fs = FileSystem.get(configuration);
Path target = new Path("/2.csv");
FSDataOutputStream append = fs.append(target);
BufferedReader br = new BufferedReader(new FileReader(new File("./2.csv")));
String line = "";
while((line=br.readLine())!=null){
append.writeChars(line);
append.flush();
}
append.close();
br.close();
long end = System.currentTimeMillis();
System.out.println("耗时"+(end-start)+"ms");
}
}
错误提示:
Exception in thread "main" java.io.IOException: Not supported
at org.apache.hadoop.fs.ChecksumFileSystem.append(ChecksumFileSystem.java:290)
at org.apache.hadoop.fs.FileSystem.append(FileSystem.java:650)
at test.TestHDFS.main(TestHDFS.java:21)
因为公司用的HADOOP是别人封装的,配置文件完全不知道在哪里,所以这里只能在代码上设置conf修改
谢谢拉[/quote]public class TestHDFS {
public static void main(String[] args) throws Exception{
long start = System.currentTimeMillis();
Configuration configuration = new Configuration();
configuration.set("dfs.support.append","true");
FileSystem fs = FileSystem.get(configuration);
Path target = new Path("/2.csv");
FSDataOutputStream append = fs.append(target);
BufferedReader br = new BufferedReader(new FileReader(new File("./2.csv")));
String line = "";
while((line=br.readLine())!=null){
append.writeChars(line);
append.flush();
}
append.close();
br.close();
long end = System.currentTimeMillis();
System.out.println("耗时"+(end-start)+"ms");
}
}
错误提示:
Exception in thread "main" java.io.IOException: Not supported
at org.apache.hadoop.fs.ChecksumFileSystem.append(ChecksumFileSystem.java:290)
at org.apache.hadoop.fs.FileSystem.append(FileSystem.java:650)
at test.TestHDFS.main(TestHDFS.java:21)
因为公司用的HADOOP是别人封装的,配置文件完全不知道在哪里,所以这里只能在代码上设置conf修改
谢谢拉