1. 问题背景:
Java程序访问Hadoop的分布式文件系统(hdfs),如下面语句:
private List<String> readCsvFile(String path) throws IOException {
CosmosLogin.loginFromPasswd(ROLE_NAME + "@XXX.COM", ROLE_PASSWORD);
HdfsConfiguration hdfsConf = new HdfsConfiguration();
hdfsConf.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
hdfsConf.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
FileSystem fs = FileSystem.get(hdfsConf);
List<String> lines = new ArrayList<String>();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(fs.open(new Path(path))));
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
reader.close();
} finally {
fs.close();
}
return lines;
}
每次访问到标红语句 FileSystem.get(hdfsConf) 时抛出运行时异常&#x