shuyun123 / seaweedfs-java-client Goto Github PK
View Code? Open in Web Editor NEWseaweedfs-java-clinet
seaweedfs-java-clinet
the function :fetchSystemTopologyStatus cause nullPointerException at dc.setFree((Integer) rawDc.get("Free"));
/dir/status reutnr json changed
http://192.168.0.106:9333/dir/status
{
"Topology": {
"DataCenters": [{
"Id": "dc1",
"Racks": [{
"DataNodes": [{
"EcShards": 0,
"Max": 20,
"PublicUrl": "xxxxx:9222",
"Url": "xxxx:9222",
"VolumeIds": " 1-7",
"Volumes": 7
}],
"Id": "rack1"
}]
}],
"Free": 13,
"Layouts": [{
"collection": "",
"replication": "000",
"ttl": "",
"writables": [7, 4, 3, 6, 2, 1, 5]
}],
"Max": 20
},
"Version": "30GB 2.77 5cf332357bd0d006fb23d026abc632135ccb7114"
}
帮忙回答一下
https://github.com/chrislusf/seaweedfs/wiki/Large-File-Handling
just add cm=true...
/**
* Get file status without file stream.
*
* @param fileId File id.
* @return File status.
* @throws IOException Http connection is fail or server response within some error message.
*/
public FileHandleStatus getFileStatus(String fileId) throws IOException {
final String targetUrl = getTargetUrl(fileId);
HeaderResponse headerResponse = volumeWrapper.getFileStatusHeader(targetUrl, fileId);
try {
return new FileHandleStatus(fileId,
headerDateFormat.parse(headerResponse.getLastHeader("Last-Modified").getValue()).getTime(),
headerResponse.getLastHeader("Content-Disposition").getValue()
.substring(10, headerResponse.getLastHeader("Content-Disposition").getValue().length() - 1),
headerResponse.getLastHeader("Content-Type").getValue(),
Long.parseLong(headerResponse.getLastHeader("Content-Length").getValue()));
} catch (ParseException e) {
throw new SeaweedfsException("Could not parse last modified time [" +
headerResponse.getLastHeader("Last-Modified").getValue() + "] to long value");
}
}
headerResponse.getLastHeader("Content-Type").getValue()
Raises java.lang.NullPointerException
when the MIME type is empty in file.
2018-05-24 17:40:52.433 INFO 2780 --- [ main] n.a.seaweedfs.core.MasterWrapper : datacenter DataCenter{id='DefaultDataCenter', free=0, max=10, racks=[Rack{id='DefaultRack', free=0, max=10, dataNodes=[DataNode{url='http://192.168.220.1:9080', pubilcUrl='http://192.168.220.1:9080', volumes=5, free=0, max=5}, DataNode{url='http://192.168.220.1:9081', pubilcUrl='http://192.168.220.1:9081', volumes=5, free=0, max=5}]}]} url ?dataCenter=DefaultDataCenter&
2018-05-24 17:40:52.964 ERROR 2780 --- [ main] n.anumbrella.seaweedfs.core.Connection : request url http://192.168.220.1:9080/5,0f090cfcea
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_152]
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_152]
at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[na:1.8.0_152]
at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_152]
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[httpcore-4.4.9.jar:4.4.9]
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[httpcore-4.4.9.jar:4.4.9]
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282) ~[httpcore-4.4.9.jar:4.4.9]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.9.jar:4.4.9]
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) ~[httpcore-4.4.9.jar:4.4.9]
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.9.jar:4.4.9]
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.9.jar:4.4.9]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.client.cache.CachingExec.callBackend(CachingExec.java:592) ~[httpclient-cache-4.5.5.jar:4.5.5]
at org.apache.http.impl.client.cache.CachingExec.execute(CachingExec.java:269) ~[httpclient-cache-4.5.5.jar:4.5.5]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.5.jar:4.5.5]
at net.anumbrella.seaweedfs.core.Connection.fetchJsonResultByRequest(Connection.java:489) ~[seaweedfs-java-client-0.0.1.RELEASE.jar:na]
at net.anumbrella.seaweedfs.core.VolumeWrapper.uploadFile(VolumeWrapper.java:65) [seaweedfs-java-client-0.0.1.RELEASE.jar:na]
at net.anumbrella.seaweedfs.core.FileTemplate.saveFileByStream(FileTemplate.java:94) [seaweedfs-java-client-0.0.1.RELEASE.jar:na]
at net.anumbrella.seaweedfs.core.FileTemplate.saveFileByStream(FileTemplate.java:67) [seaweedfs-java-client-0.0.1.RELEASE.jar:na]
at com.um.springbootwebflux.SpringbootWebfluxApplicationTests.uploadDir(SpringbootWebfluxApplicationTests.java:62) [test-classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.junit.runner.JUnitCore.run(JUnitCore.java:137) [junit-4.12.jar:4.12]
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) [junit-rt.jar:na]
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) [junit-rt.jar:na]
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) [junit-rt.jar:na]
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) [junit-rt.jar:na]
上传图片报了java.net.SocketTimeoutException: Read timed out异常,代码如下:
@Test
public void uploadDir(){
File file = new File("C:\\Users\\mone\\Pictures\\line");
File[] fileArray = file.listFiles();
FileInputStream inputStream;
FileSource fileSource = new FileSource();
fileSource.setHost("192.168.220.1");
fileSource.setPort(9333);
try {
fileSource.startup();
for(int i=0;i<fileArray.length;i++){
if(fileArray[i].isFile()) {
inputStream = new FileInputStream(fileArray[i]);
FileTemplate template = new FileTemplate(fileSource.getConnection());
FileHandleStatus status = template.saveFileByStream(fileName,inputStream);
System.out.println(status.getContentType());
System.out.println(status.getFileId());
System.out.println(status.getFileName());
System.out.println(status.getLastModified());
System.out.println(status.getSize());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
seaweedfs断开后,不支持自动重新连接
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.