You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2014/10/07 00:31:21 UTC
[44/52] [abbrv] JCLOUDS-153 remove IO Executor and usage of it.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/drivers/gae/src/test/java/org/jclouds/gae/AsyncGaeHttpCommandExecutorServiceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/drivers/gae/src/test/java/org/jclouds/gae/AsyncGaeHttpCommandExecutorServiceIntegrationTest.java b/drivers/gae/src/test/java/org/jclouds/gae/AsyncGaeHttpCommandExecutorServiceIntegrationTest.java
deleted file mode 100644
index c3b63c0..0000000
--- a/drivers/gae/src/test/java/org/jclouds/gae/AsyncGaeHttpCommandExecutorServiceIntegrationTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gae;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import org.jclouds.concurrent.SingleThreaded;
-import org.jclouds.concurrent.config.ConfiguresExecutorService;
-import org.jclouds.gae.config.GoogleAppEngineConfigurationModule;
-import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest;
-import org.jclouds.http.HttpCommandExecutorService;
-import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
-import org.testng.SkipException;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
-import com.google.appengine.tools.development.testing.LocalURLFetchServiceTestConfig;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-
-/**
- *
- * Integration test for the URLFetchService
- */
-@Test
-public class AsyncGaeHttpCommandExecutorServiceIntegrationTest extends BaseHttpCommandExecutorServiceIntegrationTest {
-
- @BeforeMethod
- public void setupApiProxy() {
- LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalURLFetchServiceTestConfig());
- helper.setUp();
- }
-
- @Override
- public void testPostAsInputStream() {
- throw new SkipException("streams aren't supported");
- }
-
- @Override
- public void testPostAsInputStreamDoesNotRetryOnFailure() throws Exception {
- throw new SkipException("streams aren't supported");
- }
-
- @Override
- public void testGetBigFile() {
- throw new SkipException("test data is too big for GAE");
- }
-
- @Override
- public void testUploadBigFile() throws IOException {
- throw new SkipException("test data is too big for GAE");
- }
-
- protected Module createConnectionModule() {
- setupApiProxy();
- return new AsyncGoogleAppEngineConfigurationModule();
- }
-
- @ConfiguresHttpCommandExecutorService
- @ConfiguresExecutorService
- @SingleThreaded
- public class AsyncGoogleAppEngineConfigurationModule extends GoogleAppEngineConfigurationModule {
-
- public AsyncGoogleAppEngineConfigurationModule() {
- super();
- }
-
- protected HttpCommandExecutorService providerHttpCommandExecutorService(Injector injector) {
- return injector.getInstance(AsyncGaeHttpCommandExecutorService.class);
- }
-
- }
-
- @Override
- protected void addOverrideProperties(Properties props) {
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/drivers/gae/src/test/java/org/jclouds/gae/GaeHttpCommandExecutorServiceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/drivers/gae/src/test/java/org/jclouds/gae/GaeHttpCommandExecutorServiceIntegrationTest.java b/drivers/gae/src/test/java/org/jclouds/gae/GaeHttpCommandExecutorServiceIntegrationTest.java
new file mode 100644
index 0000000..d7e30bf
--- /dev/null
+++ b/drivers/gae/src/test/java/org/jclouds/gae/GaeHttpCommandExecutorServiceIntegrationTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gae;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.jclouds.concurrent.SingleThreaded;
+import org.jclouds.concurrent.config.ConfiguresExecutorService;
+import org.jclouds.gae.config.GoogleAppEngineConfigurationModule;
+import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest;
+import org.jclouds.http.HttpCommandExecutorService;
+import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
+import org.testng.SkipException;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
+import com.google.appengine.tools.development.testing.LocalURLFetchServiceTestConfig;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+
+/**
+ *
+ * Integration test for the URLFetchService
+ */
+@Test
+public class GaeHttpCommandExecutorServiceIntegrationTest extends BaseHttpCommandExecutorServiceIntegrationTest {
+
+ @BeforeMethod
+ public void setupApiProxy() {
+ LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalURLFetchServiceTestConfig());
+ helper.setUp();
+ }
+
+ @Override
+ public void testPostAsInputStream() {
+ throw new SkipException("streams aren't supported");
+ }
+
+ @Override
+ public void testPostAsInputStreamDoesNotRetryOnFailure() throws Exception {
+ throw new SkipException("streams aren't supported");
+ }
+
+ @Override
+ public void testGetBigFile() {
+ throw new SkipException("test data is too big for GAE");
+ }
+
+ @Override
+ public void testUploadBigFile() throws IOException {
+ throw new SkipException("test data is too big for GAE");
+ }
+
+ protected Module createConnectionModule() {
+ setupApiProxy();
+ return new AsyncGoogleAppEngineConfigurationModule();
+ }
+
+ @ConfiguresHttpCommandExecutorService
+ @ConfiguresExecutorService
+ @SingleThreaded
+ public class AsyncGoogleAppEngineConfigurationModule extends GoogleAppEngineConfigurationModule {
+
+ public AsyncGoogleAppEngineConfigurationModule() {
+ super();
+ }
+
+ protected HttpCommandExecutorService providerHttpCommandExecutorService(Injector injector) {
+ return injector.getInstance(GaeHttpCommandExecutorService.class);
+ }
+
+ }
+
+ @Override
+ protected void addOverrideProperties(Properties props) {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/drivers/okhttp/src/main/java/org/jclouds/http/okhttp/OkHttpCommandExecutorService.java
----------------------------------------------------------------------
diff --git a/drivers/okhttp/src/main/java/org/jclouds/http/okhttp/OkHttpCommandExecutorService.java b/drivers/okhttp/src/main/java/org/jclouds/http/okhttp/OkHttpCommandExecutorService.java
index dadd623..edecc29 100644
--- a/drivers/okhttp/src/main/java/org/jclouds/http/okhttp/OkHttpCommandExecutorService.java
+++ b/drivers/okhttp/src/main/java/org/jclouds/http/okhttp/OkHttpCommandExecutorService.java
@@ -27,7 +27,6 @@ import javax.inject.Singleton;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
-import org.jclouds.Constants;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpUtils;
import org.jclouds.http.IOExceptionRetryHandler;
@@ -40,7 +39,6 @@ import org.jclouds.io.ContentMetadataCodec;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.net.HttpHeaders;
-import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.inject.Inject;
import com.squareup.okhttp.OkHttpClient;
@@ -53,12 +51,11 @@ public class OkHttpCommandExecutorService extends JavaUrlHttpCommandExecutorServ
@Inject
public OkHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
- @Named(Constants.PROPERTY_IO_WORKER_THREADS) ListeningExecutorService ioExecutor,
DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
DelegatingErrorHandler errorHandler, HttpWire wire, @Named("untrusted") HostnameVerifier verifier,
@Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider, Function<URI, Proxy> proxyForURI)
throws SecurityException, NoSuchFieldException {
- super(utils, contentMetadataCodec, ioExecutor, retryHandler, ioRetryHandler, errorHandler, wire, verifier,
+ super(utils, contentMetadataCodec, retryHandler, ioRetryHandler, errorHandler, wire, verifier,
untrustedSSLContextProvider, proxyForURI);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/drivers/okhttp/src/test/java/org/jclouds/http/okhttp/OkHttpCommandExecutorServiceTest.java
----------------------------------------------------------------------
diff --git a/drivers/okhttp/src/test/java/org/jclouds/http/okhttp/OkHttpCommandExecutorServiceTest.java b/drivers/okhttp/src/test/java/org/jclouds/http/okhttp/OkHttpCommandExecutorServiceTest.java
index deb2106..f201416 100644
--- a/drivers/okhttp/src/test/java/org/jclouds/http/okhttp/OkHttpCommandExecutorServiceTest.java
+++ b/drivers/okhttp/src/test/java/org/jclouds/http/okhttp/OkHttpCommandExecutorServiceTest.java
@@ -17,7 +17,6 @@
package org.jclouds.http.okhttp;
import static com.google.common.io.Closeables.close;
-import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS;
import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT;
import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST;
import static org.jclouds.Constants.PROPERTY_USER_THREADS;
@@ -57,8 +56,6 @@ public class OkHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorSer
protected void addOverrideProperties(final Properties props) {
props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 50 + "");
props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + "");
- // IO workers not used in this executor
- props.setProperty(PROPERTY_IO_WORKER_THREADS, 0 + "");
props.setProperty(PROPERTY_USER_THREADS, 5 + "");
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java
----------------------------------------------------------------------
diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java
index bb25f2f..9694274 100644
--- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java
+++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java
@@ -67,7 +67,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra
@VisibleForTesting
static final int DEFAULT_MAX_PERCENT_RETRIES = 10;
- private final ListeningExecutorService ioExecutor;
+ private final ListeningExecutorService executor;
@Inject(optional = true)
@Named("jclouds.mpu.parallel.degree")
@@ -96,10 +96,10 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra
@Inject
public ParallelMultipartUploadStrategy(AWSS3BlobStore blobstore, PayloadSlicer slicer,
- @Named(Constants.PROPERTY_IO_WORKER_THREADS) ListeningExecutorService ioExecutor) {
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService executor) {
this.blobstore = checkNotNull(blobstore, "blobstore");
this.slicer = checkNotNull(slicer, "slicer");
- this.ioExecutor = checkNotNull(ioExecutor, "ioExecutor");
+ this.executor = checkNotNull(executor, "executor");
}
protected void prepareUploadPart(final String container, final String key,
@@ -118,7 +118,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra
final Payload chunkedPart = slicer.slice(payload, offset, size);
logger.debug(String.format("async uploading part %s of %s to container %s with uploadId %s", part, key, container, uploadId));
final long start = System.currentTimeMillis();
- final ListenableFuture<String> futureETag = ioExecutor.submit(new Callable<String>() {
+ final ListenableFuture<String> futureETag = executor.submit(new Callable<String>() {
@Override public String call() throws Exception {
return client.uploadPart(container, key, part, uploadId, chunkedPart);
}
@@ -148,13 +148,13 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra
latch.countDown();
}
}
- }, ioExecutor);
+ }, executor);
futureParts.put(part, futureETag);
}
@Override
public ListenableFuture<String> execute(final String container, final Blob blob, final PutOptions options) {
- return ioExecutor.submit(new Callable<String>() {
+ return executor.submit(new Callable<String>() {
@Override
public String call() throws Exception {
String key = blob.getMetadata().getName();
@@ -242,7 +242,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra
// recursively call this execute method again; instead mark as not multipart
// because it can all fit in one go.
final PutOptions nonMultipartOptions = PutOptions.Builder.multipart(false);
- ListenableFuture<String> futureETag = ioExecutor.submit(new Callable<String>() {
+ ListenableFuture<String> futureETag = executor.submit(new Callable<String>() {
@Override public String call() throws Exception {
return blobstore.putBlob(container, blob, nonMultipartOptions);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java
----------------------------------------------------------------------
diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java
index d96c311..71ae0ea 100644
--- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java
+++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyMockTest.java
@@ -127,8 +127,8 @@ public class SequentialMultipartUploadStrategyMockTest {
}
}
- private static final Set<Module> modules = ImmutableSet.<Module> of(new ExecutorServiceModule(newDirectExecutorService(),
- newDirectExecutorService()));
+ private static final Set<Module> modules = ImmutableSet.<Module>of(
+ new ExecutorServiceModule(newDirectExecutorService()));
static SequentialMultipartUploadStrategy mockSequentialMultipartUploadStrategy(String uri, int partSize) {
Properties overrides = new Properties();
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/providers/dynect/src/main/java/org/jclouds/dynect/v3/config/DynECTHttpApiModule.java
----------------------------------------------------------------------
diff --git a/providers/dynect/src/main/java/org/jclouds/dynect/v3/config/DynECTHttpApiModule.java b/providers/dynect/src/main/java/org/jclouds/dynect/v3/config/DynECTHttpApiModule.java
index 1d96c7b..48bb9f8 100644
--- a/providers/dynect/src/main/java/org/jclouds/dynect/v3/config/DynECTHttpApiModule.java
+++ b/providers/dynect/src/main/java/org/jclouds/dynect/v3/config/DynECTHttpApiModule.java
@@ -30,7 +30,6 @@ import javax.inject.Singleton;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
-import org.jclouds.Constants;
import org.jclouds.concurrent.SingleThreaded;
import org.jclouds.dynect.v3.DynECTApi;
import org.jclouds.dynect.v3.features.SessionApi;
@@ -57,7 +56,6 @@ import org.jclouds.rest.config.HttpApiModule;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
-import com.google.common.util.concurrent.ListeningExecutorService;
/**
* Configures the DynECT connection.
@@ -102,12 +100,11 @@ public class DynECTHttpApiModule extends HttpApiModule<DynECTApi> {
@Inject
private SillyRabbit200sAreForSuccess(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
- @Named(Constants.PROPERTY_IO_WORKER_THREADS) ListeningExecutorService ioExecutor,
DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
DelegatingErrorHandler errorHandler, HttpWire wire, @Named("untrusted") HostnameVerifier verifier,
@Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider, Function<URI, Proxy> proxyForURI)
throws SecurityException, NoSuchFieldException {
- super(utils, contentMetadataCodec, ioExecutor, retryHandler, ioRetryHandler, errorHandler, wire, verifier,
+ super(utils, contentMetadataCodec, retryHandler, ioRetryHandler, errorHandler, wire, verifier,
untrustedSSLContextProvider, proxyForURI);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java
----------------------------------------------------------------------
diff --git a/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java b/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java
index 97c7611..c5bd5b3 100644
--- a/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java
+++ b/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java
@@ -39,7 +39,7 @@ import com.squareup.okhttp.mockwebserver.MockWebServer;
public class DynectApiMockTest {
private static final Set<Module> modules = ImmutableSet.<Module> of(
- new ExecutorServiceModule(newDirectExecutorService(), newDirectExecutorService()));
+ new ExecutorServiceModule(newDirectExecutorService()));
static DynECTApi mockDynectApi(String uri) {
Properties overrides = new Properties();
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0a236f59/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/BaseHPCloudObjectStorageMockTest.java
----------------------------------------------------------------------
diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/BaseHPCloudObjectStorageMockTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/BaseHPCloudObjectStorageMockTest.java
index fa6105f..4074229 100644
--- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/BaseHPCloudObjectStorageMockTest.java
+++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/BaseHPCloudObjectStorageMockTest.java
@@ -46,7 +46,7 @@ public class BaseHPCloudObjectStorageMockTest {
.credentials("jclouds:joe", "letmein") //
.endpoint(uri) //
.overrides(overrides) //
- .modules(ImmutableSet.<Module> of(new ExecutorServiceModule(newDirectExecutorService(), newDirectExecutorService()))) //
+ .modules(ImmutableSet.<Module> of(new ExecutorServiceModule(newDirectExecutorService()))) //
.buildApi(HPCloudObjectStorageApi.class);
}