例外情况如下:
java.io.IOException: Filesystem closed
at org.apache.hadoop.hdfs.DFSClient.checkOpen(DFSClient.java:815)
at org.apache.hadoop.hdfs.DFSInputStream.readWithStrategy(DFSInputStream.java:868)
at org.apache.hadoop.hdfs.DFSInputStream.read(DFSInputStream.java:934)
at java.io.DataInputStream.read(DataInputStream.java:100)
at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:91)
at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:59)
at com.tencent.oceanus.utils.HdfsFileSystem.getFileV2(HdfsFileSystem.java:94)
at com.tencent.oceanus.utils.Utils.setLocalFilePath(Utils.java:2910)
at com.tencent.oceanus.server.jobs.JobManager.compile(JobManager.java:231)
at com.tencent.oceanus.server.jobs.transitions.StartTransitionCallback$StartThread.start(StartTransitionCallback.java:236)
at com.tencent.oceanus.server.jobs.transitions.StartTransitionCallback$StartThread.run(StartTransitionCallback.java:142)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
这是我的密码。我应该如何修改我的代码?
文件存储在hdfs上,我应该使用hadoop的api吗?或者如何让错误报告更清楚?
我测试了“so”文件,它可以被读取。这个so文件需要被读取,因为使用了jni。
我试过很多次了,请帮帮我。
package com.tencent.wxapp.core.jni;
import java.io.*;
import java.util.List;
public class JNI{
public native byte[] call(List<String> jList);
static{
InputStream is = JNI.class.getResourceAsStream("/JNIdll.so");
File file = null;
try {
file = File.createTempFile("lib", ".so");
} catch (IOException e) {
e.printStackTrace();
}
OutputStream os = null;
try {
os = new FileOutputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] buffer = new byte[1024];
int length = 0;
while (true) {
try {
if (!((length = is.read(buffer)) != -1)) break;
} catch (IOException e) {
e.printStackTrace();
}
try {
os.write(buffer, 0, length);
} catch (IOException e) {
e.printStackTrace();
}
}
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
System.load(file.getAbsolutePath());
file.deleteOnExit();
}
}
暂无答案!
目前还没有任何答案,快来回答吧!