JCLOUDS-40 clear remaining references to Async.

This commit is contained in:
Adrian Cole 2014-10-10 17:54:48 -07:00
parent 3e082c8945
commit d735a9fa21
19 changed files with 29 additions and 305 deletions

View File

@ -97,8 +97,8 @@ public class AtmosBlobStore extends BaseBlobStore {
} }
/** /**
* This implementation invokes {@link AtmosAsyncClient#deletePath} followed by * This implementation invokes {@link AtmosClient#deletePath} followed by
* {@link AtmosAsyncClient#pathExists} until it is true. * {@link AtmosClient#pathExists} until it is true.
*/ */
protected boolean deleteAndVerifyContainerGone(final String container) { protected boolean deleteAndVerifyContainerGone(final String container) {
sync.deletePath(container + "/"); sync.deletePath(container + "/");

View File

@ -16,14 +16,6 @@
*/ */
package org.jclouds.ec2.domain; package org.jclouds.ec2.domain;
/**
*
* An attribute of an AMI.
*
* @see EC2AsyncClient#modifyImageAttribute
* @see EC2AsyncClient#resetImageAttribute
* @see EC2AsyncClient#describeImageAttribute
*/
public enum ImageAttribute { public enum ImageAttribute {
/** /**

View File

@ -20,14 +20,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
/**
*
* The current state of the instance..
*
* @see EC2AsyncClient#describeInstances
* @see EC2AsyncClient#runInstances
* @see EC2AsyncClient#terminateInstances
*/
public enum InstanceState { public enum InstanceState {
/** /**

View File

@ -16,14 +16,6 @@
*/ */
package org.jclouds.ec2.domain; package org.jclouds.ec2.domain;
/**
*
* The type of the instance. Description accurate as of 8-15-2009 release.
*
* @see EC2AsyncClient#describeInstances
* @see EC2AsyncClient#runInstances
* @see EC2AsyncClient#terminateInstances
*/
public class InstanceType { public class InstanceType {
/** /**

View File

@ -31,11 +31,10 @@
:sshj 'org.jclouds.sshj.config.SshjSshClientModule :sshj 'org.jclouds.sshj.config.SshjSshClientModule
:enterprise 'org.jclouds.enterprise.config.EnterpriseConfigurationModule :enterprise 'org.jclouds.enterprise.config.EnterpriseConfigurationModule
:apachehc 'org.jclouds.http.apachehc.config.ApacheHCHttpCommandExecutorServiceModule :apachehc 'org.jclouds.http.apachehc.config.ApacheHCHttpCommandExecutorServiceModule
:ning 'org.jclouds.http.ning.config.NingHttpCommandExecutorServiceModule :okhttp 'org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule
:bouncycastle 'org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule :bouncycastle 'org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule
:joda 'org.jclouds.date.joda.config.JodaDateServiceModule :joda 'org.jclouds.date.joda.config.JodaDateServiceModule
:gae 'org.jclouds.gae.config.GoogleAppEngineConfigurationModule :gae 'org.jclouds.gae.config.GoogleAppEngineConfigurationModule})
:gae-async 'org.jclouds.gae.config.AsyncGoogleAppEngineConfigurationModule})
(defn- instantiate [sym] (defn- instantiate [sym]
(let [loader (.getContextClassLoader (Thread/currentThread))] (let [loader (.getContextClassLoader (Thread/currentThread))]

View File

@ -45,7 +45,7 @@ public interface View {
* *
* ex. * ex.
* <pre> * <pre>
* RestContext<NovaApi, NovaAsyncApi> backendApi = computeContext.unwrap(NovaApiMetadata.CONTEXT_TOKEN); * ApiContext<NovaApi> backendApi = computeContext.unwrap(new TypeToken<ApiContext<NovaApi>>(){});
* </pre> * </pre>
* @param type * @param type
* the type of the context to be returned. The backend context must * the type of the context to be returned. The backend context must

View File

@ -256,7 +256,7 @@ public interface ApiMetadata {
URI getDocumentation(); URI getDocumentation();
/** /**
* @return the primary context of this api, for example {@code RestContext<EC2Client, EC2AsyncClient>} * @return the primary context of this api, for example {@code ApiContext<EC2Api>}
*/ */
TypeToken<? extends Context> getContext(); TypeToken<? extends Context> getContext();

View File

@ -1,57 +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.rest;
import org.jclouds.Context;
import org.jclouds.rest.internal.RestContextImpl;
import com.google.inject.ImplementedBy;
/**
* Represents an authenticated context to the cloud.
*
* <h2>Note</h2> Please issue {@link #close()} when you are finished with this context in order to
* release resources.
*
*
*
* @deprecated please use {@link org.jclouds.ContextBuilder#buildApi()} as
* async interface will be removed in jclouds 1.7.
*/
@Deprecated
@ImplementedBy(RestContextImpl.class)
public interface RestContext<S, A> extends Context {
/**
* low-level api to the cloud. Threadsafe implementations will return a singleton.
*
* @return a connection to the cloud where all methods return {@link Future}s
* @deprecated please use {@link org.jclouds.ContextBuilder#buildApi()} as
* async interface will be removed in jclouds 1.7.
*/
@Deprecated
A getAsyncApi();
/**
* reflects a tuned connection to the cloud which calls {@link #getAsyncApi()} with predetermined
* timeouts.
*
* @return a connection to the cloud where all methods block
*/
S getApi();
}

View File

@ -44,7 +44,7 @@ public interface InvocationConfig {
String getCommandName(Invocation invocation); String getCommandName(Invocation invocation);
/** /**
* fallback used for Sync or Async commands. * fallback used for commands when exceptions are encountered.
*/ */
Fallback<?> getFallback(Invocation invocation); Fallback<?> getFallback(Invocation invocation);
} }

View File

@ -65,8 +65,7 @@ public class ReadAnnotationsAndProperties implements InvocationConfig {
timeoutMillis = timeoutMillis.or(defaultMillis); timeoutMillis = timeoutMillis.or(defaultMillis);
} else { } else {
// TODO: remove old logic once Named annotations are on all methods // TODO: remove old logic once Named annotations are on all methods
String className = invoked.getOwnerType().getRawType().getSimpleName().replace("AsyncClient", "Client") String className = invoked.getOwnerType().getRawType().getSimpleName();
.replace("AsyncApi", "Api");
timeoutMillis = timeoutMillis.or(fromNullable(timeouts.get(className))).or(defaultMillis); timeoutMillis = timeoutMillis.or(fromNullable(timeouts.get(className))).or(defaultMillis);
} }
if (timeoutMillis.isPresent()) if (timeoutMillis.isPresent())
@ -81,8 +80,7 @@ public class ReadAnnotationsAndProperties implements InvocationConfig {
return invoked.getAnnotation(Named.class).value(); return invoked.getAnnotation(Named.class).value();
} else { } else {
// TODO: remove old logic once Named annotations are on all methods // TODO: remove old logic once Named annotations are on all methods
String className = invoked.getOwnerType().getRawType().getSimpleName().replace("AsyncClient", "Client") String className = invoked.getOwnerType().getRawType().getSimpleName();
.replace("AsyncApi", "Api");
return className + "." + invoked.getName(); return className + "." + invoked.getName();
} }
} }

View File

@ -1,87 +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.rest.internal;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.getUnchecked;
import java.lang.reflect.InvocationTargetException;
import javax.annotation.Resource;
import javax.inject.Inject;
import org.jclouds.logging.Logger;
import org.jclouds.reflect.Invocation;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.reflect.Invokable;
import com.google.common.util.concurrent.ListenableFuture;
/**
*
* @deprecated will be removed in jclouds 1.7, as async interfaces are no longer supported.
*/
@Deprecated
public final class InvokeAndCallGetOnFutures<R> implements Function<Invocation, Object> {
@Resource
private Logger logger = Logger.NULL;
private final Function<Invocation, Invocation> sync2async;
private final R receiver;
/**
* @param receiver
* will have any methods that return {@link ListenableFuture} unwrapped.
* @return blocking invocation handler
*/
@Inject
@VisibleForTesting
InvokeAndCallGetOnFutures(Function<Invocation, Invocation> sync2async, R receiver) {
this.sync2async = sync2async;
this.receiver = receiver;
}
@SuppressWarnings("unchecked")
@Override
public Object apply(Invocation in) {
@SuppressWarnings("rawtypes")
Invokable target = sync2async.apply(in).getInvokable();
Object returnVal;
try {
returnVal = target.invoke(receiver, in.getArgs().toArray());
} catch (InvocationTargetException e) {
throw propagate(e.getCause());
} catch (IllegalAccessException e) {
throw new Error("Method became inaccessible: " + toString(), e);
}
if (!isFuture(target))
return returnVal;
return getUnchecked(ListenableFuture.class.cast(returnVal));
}
private boolean isFuture(Invokable<?, ?> target) {
return target.getReturnType().getRawType().isAssignableFrom(ListenableFuture.class);
}
@Override
public String toString() {
return String.format("InvokeAndCallGetOnFutures(%s)", receiver);
}
}

View File

@ -1,69 +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.rest.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import org.jclouds.annotations.Name;
import org.jclouds.domain.Credentials;
import org.jclouds.internal.ContextImpl;
import org.jclouds.lifecycle.Closer;
import org.jclouds.location.Provider;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.Utils;
import com.google.common.base.Supplier;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
/**
* @deprecated please use {@link org.jclouds.ContextBuilder#buildApi()} as
* async interface will be removed in jclouds 1.7.
*/
@Deprecated
@Singleton
public class RestContextImpl<S, A> extends ContextImpl implements RestContext<S, A> {
private final A asyncApi;
private final S syncApi;
@Inject
protected RestContextImpl(@Name String name, ProviderMetadata providerMetadata,
@Provider Supplier<Credentials> creds, Utils utils, Closer closer, Injector injector, TypeLiteral<S> syncApi,
TypeLiteral<A> asyncApi) {
super(name, providerMetadata, creds, utils, closer);
checkNotNull(injector, "injector");
this.asyncApi = injector.getInstance(Key.get(checkNotNull(asyncApi, "asyncApi")));
this.syncApi = injector.getInstance(Key.get(checkNotNull(syncApi, "syncApi")));
}
@Override
public A getAsyncApi() {
return asyncApi;
}
@Override
public S getApi() {
return syncApi;
}
}

View File

@ -34,7 +34,6 @@ import org.testng.annotations.Test;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
@ -46,15 +45,9 @@ public class ReadAnnotationsAndPropertiesTest {
public interface ThingApi { public interface ThingApi {
HttpResponse get(); HttpResponse get();
HttpResponse namedGet();
}
public interface ThingAsyncApi {
ListenableFuture<HttpResponse> get();
@Named("ns:get") @Named("ns:get")
@Fallback(FalseOnNotFoundOr404.class) @Fallback(FalseOnNotFoundOr404.class)
ListenableFuture<HttpResponse> namedGet(); HttpResponse namedGet();
} }
private Invocation asyncGet; private Invocation asyncGet;
@ -63,14 +56,13 @@ public class ReadAnnotationsAndPropertiesTest {
@BeforeClass @BeforeClass
void setupInvocations() throws SecurityException, NoSuchMethodException { void setupInvocations() throws SecurityException, NoSuchMethodException {
asyncGet = Invocation.create(method(ThingAsyncApi.class, "get"), ImmutableList.of()); asyncGet = Invocation.create(method(ThingApi.class, "get"), ImmutableList.of());
asyncNamedGet = Invocation.create(method(ThingAsyncApi.class, "namedGet"), ImmutableList.of()); asyncNamedGet = Invocation.create(method(ThingApi.class, "namedGet"), ImmutableList.of());
defaultFallback = new NullOnNotFoundOr404(); defaultFallback = new NullOnNotFoundOr404();
} }
/** /**
* this functionality will be removed once Named annotations are on all async * this functionality will be removed once Named annotations are on all classes.
* classes.
*/ */
public void testInvocationsSetDefaultTimeoutOnAsyncMethods() throws Exception { public void testInvocationsSetDefaultTimeoutOnAsyncMethods() throws Exception {
final Properties props = new Properties(); final Properties props = new Properties();

View File

@ -43,30 +43,30 @@ import com.google.common.collect.ImmutableList;
public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest { public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest {
// feature present in base api // feature present in base api
interface KeyPairAsyncApi { interface KeyPairApi {
} }
@SinceApiVersion("2010-08-31") @SinceApiVersion("2010-08-31")
interface TagAsyncApi { interface TagApi {
} }
@SinceApiVersion("2011-01-01") @SinceApiVersion("2011-01-01")
interface VpcAsyncApi { interface VpcApi {
} }
interface EC2AsyncApi { interface EC2Api {
@Delegate @Delegate
Optional<TagAsyncApi> getTagApiForRegion(String region); Optional<TagApi> getTagApiForRegion(String region);
@Delegate @Delegate
Optional<KeyPairAsyncApi> getKeyPairApiForRegion(String region); Optional<KeyPairApi> getKeyPairApiForRegion(String region);
@Delegate @Delegate
Optional<VpcAsyncApi> getVpcApiForRegion(String region); Optional<VpcApi> getVpcApiForRegion(String region);
} }
@ -148,21 +148,21 @@ public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest
} }
InvocationSuccess getFloatingIPApi() { InvocationSuccess getFloatingIPApi() {
return getApi("Tag", TagAsyncApi.class); return getApi("Tag", TagApi.class);
} }
InvocationSuccess getKeyPairApi() { InvocationSuccess getKeyPairApi() {
return getApi("KeyPair", KeyPairAsyncApi.class); return getApi("KeyPair", KeyPairApi.class);
} }
InvocationSuccess getVpcApi() { InvocationSuccess getVpcApi() {
return getApi("Vpc", VpcAsyncApi.class); return getApi("Vpc", VpcApi.class);
} }
InvocationSuccess getApi(String name, Class<?> target) { InvocationSuccess getApi(String name, Class<?> target) {
try { try {
return InvocationSuccess.create( return InvocationSuccess.create(
Invocation.create(method(EC2AsyncApi.class, "get" + name + "ApiForRegion", String.class), Invocation.create(method(EC2Api.class, "get" + name + "ApiForRegion", String.class),
ImmutableList.<Object> of("region")), "present"); ImmutableList.<Object> of("region")), "present");
} catch (Exception e) { } catch (Exception e) {
throw propagate(e); throw propagate(e);

View File

@ -19,19 +19,14 @@ package org.jclouds.gae;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import org.jclouds.concurrent.SingleThreaded;
import org.jclouds.concurrent.config.ConfiguresExecutorService;
import org.jclouds.gae.config.GoogleAppEngineConfigurationModule; import org.jclouds.gae.config.GoogleAppEngineConfigurationModule;
import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest; import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest;
import org.jclouds.http.HttpCommandExecutorService;
import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
import org.testng.SkipException; import org.testng.SkipException;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper; import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import com.google.appengine.tools.development.testing.LocalURLFetchServiceTestConfig; import com.google.appengine.tools.development.testing.LocalURLFetchServiceTestConfig;
import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
/** /**
@ -69,27 +64,10 @@ public class GaeHttpCommandExecutorServiceIntegrationTest extends BaseHttpComman
protected Module createConnectionModule() { protected Module createConnectionModule() {
setupApiProxy(); setupApiProxy();
return new AsyncGoogleAppEngineConfigurationModule(); return new GoogleAppEngineConfigurationModule();
}
@ConfiguresHttpCommandExecutorService
@ConfiguresExecutorService
@SingleThreaded
public class AsyncGoogleAppEngineConfigurationModule extends GoogleAppEngineConfigurationModule {
public AsyncGoogleAppEngineConfigurationModule() {
super();
}
protected HttpCommandExecutorService providerHttpCommandExecutorService(Injector injector) {
return injector.getInstance(GaeHttpCommandExecutorService.class);
}
} }
@Override @Override
protected void addOverrideProperties(Properties props) { protected void addOverrideProperties(Properties props) {
} }
} }

View File

@ -77,7 +77,7 @@ public class AWSS3ClientTest extends S3ClientTest<AWSS3Client> {
@Override @Override
public void testCopyObjectInvalidName() throws ArrayIndexOutOfBoundsException, SecurityException, public void testCopyObjectInvalidName() throws ArrayIndexOutOfBoundsException, SecurityException,
IllegalArgumentException, NoSuchMethodException, IOException { IllegalArgumentException, NoSuchMethodException, IOException {
// For AWS S3, S3AsyncClientTest#testCopyObjectInvalidName() will not throw an exception // For AWS S3, S3ClientTest#testCopyObjectInvalidName() will not throw an exception
Invokable<?, ?> method = method(AWSS3Client.class, "copyObject", String.class, String.class, String.class, Invokable<?, ?> method = method(AWSS3Client.class, "copyObject", String.class, String.class, String.class,
String.class, String.class,
CopyObjectOptions[].class); CopyObjectOptions[].class);

View File

@ -44,7 +44,7 @@ import com.google.common.collect.Iterables;
/** /**
* Tests annotation parsing of {@code EmailAccountApi} * Tests annotation parsing of {@code EmailAccountApi}
*/ */
@Test(groups = "unit", testName = "EmailAccountAsyncApiTest") @Test(groups = "unit", testName = "EmailAccountApiExpectTest")
public class EmailAccountApiExpectTest extends BaseGleSYSApiExpectTest { public class EmailAccountApiExpectTest extends BaseGleSYSApiExpectTest {
public void testListWhenResponseIs2xx() throws Exception { public void testListWhenResponseIs2xx() throws Exception {

View File

@ -28,10 +28,7 @@ import org.testng.annotations.Test;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
/** @Test(groups = "unit", testName = "DatacenterApiExpectTest")
* Tests annotation parsing of {@code DatacenterAsyncClient}
*/
@Test(groups = "unit")
public class DatacenterApiExpectTest extends BaseSoftLayerApiExpectTest { public class DatacenterApiExpectTest extends BaseSoftLayerApiExpectTest {
public void testListDatacentersWhenResponseIs2xx() { public void testListDatacentersWhenResponseIs2xx() {

View File

@ -26,10 +26,7 @@ import org.testng.annotations.Test;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
/** @Test(groups = "unit", testName = "SoftwareDescriptionApiExpectTest")
* Tests annotation parsing of {@code DatacenterAsyncClient}
*/
@Test(groups = "unit")
public class SoftwareDescriptionApiExpectTest extends BaseSoftLayerApiExpectTest { public class SoftwareDescriptionApiExpectTest extends BaseSoftLayerApiExpectTest {
public void testGetAllObjectsWhenResponseIs2xx() { public void testGetAllObjectsWhenResponseIs2xx() {