Skip to content
Snippets Groups Projects
Commit e3b7cdae authored by felmer's avatar felmer
Browse files

SSDM-7643: RemoteFastDownloadServer: maximum 1000 chunks, buffer 1GB

parent 50483d85
No related branches found
No related tags found
No related merge requests found
......@@ -28,11 +28,15 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.commons.io.FileUtils;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.util.FutureResponseListener;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -137,6 +141,7 @@ class RemoteFastDownloadServer implements IDownloadServer
ParameterBuilder builder = new ParameterBuilder()
.method(FastDownloadMethod.DOWNLOAD_METHOD)
.downloadSession(downloadSessionId)
.numberOfChunks(1000)
.downloadStream(streamId);
Request request = createRequest(builder.parameters);
try
......@@ -187,7 +192,8 @@ class RemoteFastDownloadServer implements IDownloadServer
{
try
{
ContentResponse response = request.send();
ContentResponse response = send(request);
// ContentResponse response = request.send();
String mediaType = response.getMediaType();
if (mediaType != null && mediaType.equals("application/json"))
{
......@@ -205,6 +211,32 @@ class RemoteFastDownloadServer implements IDownloadServer
}
}
private ContentResponse send(Request request) throws InterruptedException, TimeoutException, ExecutionException
{
FutureResponseListener listener = new FutureResponseListener(request, (int) (FileUtils.ONE_GB));
request.send(listener);
// The following code has been copied from HttpRequest.send()
try
{
return listener.get();
} catch (ExecutionException x)
{
if (x.getCause() instanceof TimeoutException)
{
TimeoutException t = (TimeoutException) (x.getCause());
request.abort(t);
throw t;
}
request.abort(x);
throw x;
} catch (Throwable x)
{
request.abort(x);
throw x;
}
}
private DownloadSessionId createDownloadSessionId(String id)
{
DownloadSessionId downloadSessionId = new DownloadSessionId();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment