mirror of https://github.com/apache/jclouds.git
Merge branch 'ahc-fixes' of https://github.com/neotyk/jclouds
* 'ahc-fixes' of https://github.com/neotyk/jclouds: Big file upload and download fixes
This commit is contained in:
commit
46145b0a34
|
@ -42,13 +42,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ning</groupId>
|
<groupId>com.ning</groupId>
|
||||||
<artifactId>async-http-client</artifactId>
|
<artifactId>async-http-client</artifactId>
|
||||||
<version>1.3.1</version>
|
<version>1.4.0</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion> <!-- we use guava -->
|
|
||||||
<groupId>com.google.collections</groupId>
|
|
||||||
<artifactId>google-collections</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mortbay.jetty</groupId>
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
|
|
@ -19,33 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.http.ning;
|
package org.jclouds.http.ning;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Throwables.propagate;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
|
||||||
|
|
||||||
import org.jclouds.crypto.CryptoStreams;
|
|
||||||
import org.jclouds.http.HttpCommand;
|
|
||||||
import org.jclouds.http.HttpCommandExecutorService;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
|
||||||
import org.jclouds.http.HttpRequestFilter;
|
|
||||||
import org.jclouds.http.HttpResponse;
|
|
||||||
import org.jclouds.http.HttpUtils;
|
|
||||||
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
|
||||||
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
|
||||||
import org.jclouds.http.internal.BaseHttpCommandExecutorService;
|
|
||||||
import org.jclouds.io.Payload;
|
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.LinkedHashMultimap;
|
import com.google.common.collect.LinkedHashMultimap;
|
||||||
|
@ -59,7 +32,31 @@ import com.ning.http.client.AsyncHttpClient;
|
||||||
import com.ning.http.client.Request;
|
import com.ning.http.client.Request;
|
||||||
import com.ning.http.client.RequestBuilder;
|
import com.ning.http.client.RequestBuilder;
|
||||||
import com.ning.http.client.Response;
|
import com.ning.http.client.Response;
|
||||||
import com.ning.http.client.Request.EntityWriter;
|
import org.jclouds.crypto.CryptoStreams;
|
||||||
|
import org.jclouds.http.HttpCommand;
|
||||||
|
import org.jclouds.http.HttpCommandExecutorService;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpRequestFilter;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.http.HttpUtils;
|
||||||
|
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
||||||
|
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
||||||
|
import org.jclouds.http.internal.BaseHttpCommandExecutorService;
|
||||||
|
import org.jclouds.io.Payload;
|
||||||
|
import org.jclouds.io.Payloads;
|
||||||
|
import org.jclouds.io.payloads.FilePayload;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Throwables.propagate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Todo Write me
|
* Todo Write me
|
||||||
|
@ -128,21 +125,7 @@ public class NingHttpCommandExecutorService implements HttpCommandExecutorServic
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class ConvertToNingRequest implements Function<HttpRequest, Request> {
|
public static class ConvertToNingRequest implements Function<HttpRequest, Request> {
|
||||||
|
|
||||||
private static class PayloadEntityWriter implements EntityWriter {
|
public Request apply(HttpRequest request) {
|
||||||
private final Payload payload;
|
|
||||||
|
|
||||||
public PayloadEntityWriter(Payload payload) {
|
|
||||||
this.payload = payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeEntity(OutputStream out) throws IOException {
|
|
||||||
payload.writeTo(out);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Request apply(HttpRequest request) {
|
|
||||||
|
|
||||||
for (HttpRequestFilter filter : request.getFilters()) {
|
for (HttpRequestFilter filter : request.getFilters()) {
|
||||||
filter.filter(request);
|
filter.filter(request);
|
||||||
|
@ -188,9 +171,13 @@ public class NingHttpCommandExecutorService implements HttpCommandExecutorServic
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPayload(RequestBuilder requestBuilder, Payload payload) {
|
void setPayload(RequestBuilder requestBuilder, Payload payload) {
|
||||||
requestBuilder.setBody(new PayloadEntityWriter(payload));
|
if (payload instanceof FilePayload) {
|
||||||
}
|
requestBuilder.setBody(((FilePayload) payload).getRawContent());
|
||||||
|
} else {
|
||||||
|
requestBuilder.setBody(payload.getInput());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
@ -62,10 +62,4 @@ public class NingHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorS
|
||||||
props.setProperty(PROPERTY_IO_WORKER_THREADS, 3 + "");
|
props.setProperty(PROPERTY_IO_WORKER_THREADS, 3 + "");
|
||||||
props.setProperty(PROPERTY_USER_THREADS, 0 + "");
|
props.setProperty(PROPERTY_USER_THREADS, 0 + "");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// OOM
|
|
||||||
@Test(enabled = false, invocationCount = 1, timeOut = 5000)
|
|
||||||
public void testGetBigFile() throws ExecutionException, InterruptedException, TimeoutException, IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue