diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceCall.java b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceCall.java index 2995b04a87018..0bc20202495d4 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceCall.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceCall.java @@ -9,6 +9,7 @@ import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseWithHeaders; import java.util.List; @@ -45,6 +46,36 @@ public static ServiceCall> create(Observable return serviceCall; } + /** + * Creates a ServiceCall from a paging operation that returns a header response. + * + * @param first the observable to the first page + * @param next the observable to poll subsequent pages + * @param callback the client-side callback + * @param the element type + * @param the header object type + * @return the future based ServiceCall + */ + public static ServiceCall> createWithHeaders(Observable, V>> first, final Func1, V>>> next, final ListOperationCallback callback) { + final AzureServiceCall> serviceCall = new AzureServiceCall<>(); + final PagingSubscriber subscriber = new PagingSubscriber<>(serviceCall, new Func1>>>() { + @Override + public Observable>> call(String s) { + return next.call(s) + .map(new Func1, V>, ServiceResponse>>() { + @Override + public ServiceResponse> call(ServiceResponseWithHeaders, V> pageVServiceResponseWithHeaders) { + return pageVServiceResponseWithHeaders; + } + }); + } + }, callback); + serviceCall.setSubscription(first + .single() + .subscribe(subscriber)); + return serviceCall; + } + /** * The subscriber that handles user callback and automatically subscribes to the next page. * diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/RestClient.java b/azure-client-runtime/src/main/java/com/microsoft/azure/RestClient.java index ad9ecf9e92d92..8ff7d89c4c21a 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/RestClient.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/RestClient.java @@ -169,6 +169,7 @@ public Builder(OkHttpClient.Builder httpClientBuilder, Retrofit.Builder retrofit // Set up OkHttp client this.httpClientBuilder = httpClientBuilder .cookieJar(new JavaNetCookieJar(cookieManager)) + .readTimeout(30, TimeUnit.SECONDS) .addInterceptor(userAgentInterceptor); this.retrofitBuilder = retrofitBuilder; this.buildable = new Buildable(); diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroupBase.java b/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroupBase.java index d670876e10b90..46fe8d0f179f2 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroupBase.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroupBase.java @@ -21,6 +21,9 @@ */ public abstract class TaskGroupBase> implements TaskGroup { + /** + * Stores the tasks in this group and their dependency information. + */ private DAGraph> dag; /** @@ -67,7 +70,7 @@ public void execute() throws Exception { @Override public Observable executeAsync() { - return executeReadyTasksAsync(); + return executeReadyTasksAsync().last(); } @Override @@ -98,6 +101,6 @@ public Observable call(T t) { })); nextNode = dag.getNext(); } - return Observable.merge(observables).last(); + return Observable.merge(observables); } } diff --git a/client-runtime/build.gradle b/client-runtime/build.gradle index b828a33f187bc..d64308d3b3f71 100644 --- a/client-runtime/build.gradle +++ b/client-runtime/build.gradle @@ -30,7 +30,6 @@ dependencies { compile 'com.squareup.retrofit2:converter-jackson:2.0.2' compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2' compile 'io.reactivex:rxjava:1.1.8' - compile 'io.reactivex:rxjava-computation-expressions:0.21.0' compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.7.2' compile 'org.apache.commons:commons-lang3:3.4' testCompile 'junit:junit:4.12' diff --git a/client-runtime/pom.xml b/client-runtime/pom.xml index d904227d91514..042de93fc929d 100644 --- a/client-runtime/pom.xml +++ b/client-runtime/pom.xml @@ -83,6 +83,10 @@ io.reactivex rxjava + + com.squareup.retrofit2 + adapter-rxjava + junit junit diff --git a/pom.xml b/pom.xml index 082e2e5bfeb8e..5255bc70f9618 100644 --- a/pom.xml +++ b/pom.xml @@ -126,6 +126,11 @@ rxjava 1.1.8 + + com.squareup.retrofit2 + adapter-rxjava + 2.0.2 + junit junit