Issue 803: changes needed when guice is in production mode

This commit is contained in:
Adrian Cole 2012-01-07 06:08:32 -08:00
parent cc5aa5cee2
commit f390f314ee
27 changed files with 169 additions and 149 deletions

View File

@ -18,17 +18,19 @@
*/ */
package org.jclouds.cloudloadbalancers.loadbalancer.functions; package org.jclouds.cloudloadbalancers.loadbalancer.functions;
import java.util.Map; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.domain.VirtualIP; import org.jclouds.cloudloadbalancers.domain.VirtualIP;
import org.jclouds.collect.Memoized;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
import org.jclouds.loadbalancer.domain.LoadBalancerType; import org.jclouds.loadbalancer.domain.LoadBalancerType;
import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl;
import org.jclouds.location.predicates.LocationPredicates;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -41,20 +43,20 @@ import com.google.common.collect.Iterables;
*/ */
@Singleton @Singleton
public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> { public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> {
protected final Supplier<Map<String, ? extends Location>> locationMap; protected final Supplier<Set<? extends Location>> locations;
protected final Supplier<Location> defaultLocationSupplier; protected final Supplier<Location> defaultLocationSupplier;
@Inject @Inject
public LoadBalancerToLoadBalancerMetadata(Supplier<Location> defaultLocationSupplier, public LoadBalancerToLoadBalancerMetadata(Supplier<Location> defaultLocationSupplier,
Supplier<Map<String, ? extends Location>> locationMap) { @Memoized Supplier<Set<? extends Location>> locations) {
this.locationMap = locationMap; this.locations = locations;
this.defaultLocationSupplier = defaultLocationSupplier; this.defaultLocationSupplier = defaultLocationSupplier;
} }
@Override @Override
public LoadBalancerMetadata apply(LoadBalancer input) { public LoadBalancerMetadata apply(LoadBalancer input) {
Location location = locationMap.get().get(input.getRegion()); Location location = Iterables.find(locations.get(), LocationPredicates.idEquals(input.getRegion()));
String id = input.getRegion() + "/" + input.getId(); String id = input.getRegion() + "/" + input.getId();
// TODO Builder // TODO Builder

View File

@ -19,6 +19,11 @@
package org.jclouds.cloudloadbalancers; package org.jclouds.cloudloadbalancers;
import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.cloudloadbalancers.reference.RackspaceConstants.PROPERTY_ACCOUNT_ID;
import static org.jclouds.cloudloadbalancers.reference.Region.DFW;
import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.io.IOException; import java.io.IOException;
@ -84,9 +89,12 @@ public class CloudLoadBalancersAsyncClientTest extends BaseCloudLoadBalancersAsy
@Override @Override
protected Properties getProperties() { protected Properties getProperties() {
Properties overrides = new Properties(); Properties overrides = new Properties();
overrides.setProperty(PROPERTY_REGIONS, "US"); overrides.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com");
overrides.setProperty(PROPERTY_API_VERSION, "1"); overrides.setProperty(PROPERTY_API_VERSION, "1");
overrides.setProperty(provider + ".endpoint", "https://auth"); overrides.setProperty(PROPERTY_REGIONS, "DFW");
overrides.setProperty(PROPERTY_REGION + "." + DFW + "." + ENDPOINT, String
.format("https://dfw.loadbalancers.api.rackspacecloud.com/v{%s}/{%s}", PROPERTY_API_VERSION,
PROPERTY_ACCOUNT_ID));
overrides.setProperty(provider + ".contextbuilder", CloudLoadBalancersContextBuilder.class.getName()); overrides.setProperty(provider + ".contextbuilder", CloudLoadBalancersContextBuilder.class.getName());
return overrides; return overrides;
} }

View File

@ -28,22 +28,33 @@ import java.util.Properties;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule; import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.cloudloadbalancers.functions.ConvertLB;
import org.jclouds.cloudloadbalancers.reference.Region; import org.jclouds.cloudloadbalancers.reference.Region;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.internal.ClassMethodArgs; import org.jclouds.internal.ClassMethodArgs;
import org.jclouds.json.config.GsonModule.DateAdapter;
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse;
import org.jclouds.openstack.config.OpenStackAuthenticationModule;
import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestContextImpl;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.google.inject.util.Types;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -58,11 +69,39 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClien
bindRegionsToProvider(Regions.class); bindRegionsToProvider(Regions.class);
} }
//TODO: replace this with Expect test
@SuppressWarnings("unchecked")
@Override
protected void configure() {
// following from CloudLoadBalancersRestClientModule, except we are hard-coding the auth response
install(new OpenStackAuthenticationModule() {
@Override
protected Supplier<AuthenticationResponse> provideAuthenticationResponseCache(
final GetAuthenticationResponse getAuthenticationResponse) {
return Suppliers.ofInstance(new AuthenticationResponse("token", ImmutableMap.<String, URI> of()));
}
});
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
bindRegionsToProvider();
install(new FactoryModuleBuilder().build(ConvertLB.Factory.class));
// following from RestClientModule
bind(new TypeLiteral<RestContext>() {
}).to(
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(
RestContextImpl.class, syncClientType, asyncClientType))).in(
Scopes.SINGLETON);
bindAsyncClient();
bindClient();
bindErrorHandlers();
bindRetryHandlers();
}
static class Regions implements javax.inject.Provider<Map<String, URI>> { static class Regions implements javax.inject.Provider<Map<String, URI>> {
@Override @Override
public Map<String, URI> get() { public Map<String, URI> get() {
return ImmutableMap.<String, URI> of("DFW", return ImmutableMap.<String, URI> of("DFW", URI
URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234")); .create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234"));
} }
} }
@ -95,8 +134,8 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClien
super.setupFactory(); super.setupFactory();
try { try {
processor.setCaller(new ClassMethodArgs(CloudLoadBalancersAsyncClient.class, processor.setCaller(new ClassMethodArgs(CloudLoadBalancersAsyncClient.class,
CloudLoadBalancersAsyncClient.class.getMethod("getLoadBalancerClient", String.class), CloudLoadBalancersAsyncClient.class.getMethod("getLoadBalancerClient", String.class),
new Object[] { Region.DFW })); new Object[] { Region.DFW }));
} catch (Exception e) { } catch (Exception e) {
Throwables.propagate(e); Throwables.propagate(e);
} }

View File

@ -21,17 +21,17 @@ package org.jclouds.cloudstack.filters;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.net.URI; import java.net.URI;
import java.util.List;
import java.util.Map;
import org.jclouds.PropertiesBuilder; import org.jclouds.PropertiesBuilder;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.jclouds.rest.RequestSigner; import org.jclouds.rest.RequestSigner;
import org.jclouds.rest.RestContextBuilder; import org.jclouds.rest.RestContextBuilder;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -48,8 +48,8 @@ import com.google.inject.Module;
@Test(groups = "unit", testName = "QuerySignerTest") @Test(groups = "unit", testName = "QuerySignerTest")
public class QuerySignerTest { public class QuerySignerTest {
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
public static final RestContextSpec<Map, List> DUMMY_SPEC = new RestContextSpec<Map, List>("cloudstack", public static final RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> DUMMY_SPEC = new RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient>("cloudstack",
"http://localhost:8080/client/api", "2.2", "", "", "apiKey", "secretKey", Map.class, List.class, "http://localhost:8080/client/api", "2.2", "", "", "apiKey", "secretKey", IntegrationTestClient.class, IntegrationTestAsyncClient.class,
PropertiesBuilder.class, (Class) RestContextBuilder.class, ImmutableList.<Module> of(new MockModule(), PropertiesBuilder.class, (Class) RestContextBuilder.class, ImmutableList.<Module> of(new MockModule(),
new NullLoggingModule(), new AbstractModule() { new NullLoggingModule(), new AbstractModule() {
@Override @Override

View File

@ -21,8 +21,6 @@ package org.jclouds.blobstore.config;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import javax.inject.Singleton;
import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.AsyncBlobStore;
import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobRequestSigner;
import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.BlobStore;
@ -36,7 +34,6 @@ import org.jclouds.domain.Location;
import org.jclouds.location.config.JustProviderLocationModule; import org.jclouds.location.config.JustProviderLocationModule;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes; import com.google.inject.Scopes;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
@ -63,13 +60,9 @@ public class TransientBlobStoreContextModule extends AbstractModule {
install(new BlobStoreObjectModule()); install(new BlobStoreObjectModule());
install(new BlobStoreMapModule()); install(new BlobStoreMapModule());
install(new JustProviderLocationModule()); install(new JustProviderLocationModule());
bind(BlobStore.class).to(TransientBlobStore.class);
bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT);
bind(BlobRequestSigner.class).to(TransientBlobRequestSigner.class); bind(BlobRequestSigner.class).to(TransientBlobRequestSigner.class);
} }
@Provides
@Singleton
BlobStore provide(TransientBlobStore in) {
return in;
}
} }

View File

@ -17,15 +17,13 @@
* under the License. * under the License.
*/ */
package org.jclouds.aws.filters; package org.jclouds.aws.filters;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.util.List;
import java.util.Map;
import org.jclouds.PropertiesBuilder; import org.jclouds.PropertiesBuilder;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.RequestSigner; import org.jclouds.rest.RequestSigner;
import org.jclouds.rest.RestContextBuilder; import org.jclouds.rest.RestContextBuilder;
@ -49,8 +47,9 @@ import com.google.inject.name.Names;
@Test(groups = "unit", testName = "FormSignerTest") @Test(groups = "unit", testName = "FormSignerTest")
public class FormSignerTest { public class FormSignerTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static final RestContextSpec<Map, List> DUMMY_SPEC = new RestContextSpec<Map, List>("provider", "endpoint", public static final RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> DUMMY_SPEC = new RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient>(
"apiVersion", "buildVersion", "", "identity", "credential", Map.class, List.class, PropertiesBuilder.class, "provider", "endpoint", "apiVersion", "buildVersion", "", "identity", "credential",
IntegrationTestClient.class, IntegrationTestAsyncClient.class, PropertiesBuilder.class,
(Class) RestContextBuilder.class, ImmutableList.<Module> of(new MockModule(), new NullLoggingModule(), (Class) RestContextBuilder.class, ImmutableList.<Module> of(new MockModule(), new NullLoggingModule(),
new AbstractModule() { new AbstractModule() {
@Override @Override

View File

@ -22,8 +22,6 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.List;
import java.util.Map;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
@ -31,6 +29,8 @@ import javax.ws.rs.core.HttpHeaders;
import org.jclouds.PropertiesBuilder; import org.jclouds.PropertiesBuilder;
import org.jclouds.azure.storage.config.AzureStorageRestClientModule; import org.jclouds.azure.storage.config.AzureStorageRestClientModule;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.RestContextBuilder; import org.jclouds.rest.RestContextBuilder;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
@ -137,10 +137,11 @@ public class SharedKeyLiteAuthenticationTest {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static final RestContextSpec<Map, List> DUMMY_SPEC = new RestContextSpec<Map, List>("provider", "endpoint", public static final RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> DUMMY_SPEC = new RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient>(
"apiVersion", "buildVersion", "", "identity", "credential", Map.class, List.class, PropertiesBuilder.class, "provider", "endpoint", "apiVersion", "buildVersion", "", "identity", "credential", IntegrationTestClient.class,
(Class) RestContextBuilder.class, ImmutableList.<Module> of(new MockModule(), new NullLoggingModule(), IntegrationTestAsyncClient.class, PropertiesBuilder.class, (Class) RestContextBuilder.class, ImmutableList
new AzureStorageRestClientModule<Exception, RuntimeException>(Exception.class, .<Module> of(new MockModule(), new NullLoggingModule(),
RuntimeException.class))); new AzureStorageRestClientModule<IntegrationTestClient, IntegrationTestAsyncClient>(IntegrationTestClient.class,
IntegrationTestAsyncClient.class)));
} }

View File

@ -104,7 +104,7 @@ public class OpenStackAuthenticationModule extends AbstractModule {
@Provides @Provides
@Singleton @Singleton
Supplier<AuthenticationResponse> provideAuthenticationResponseCache( protected Supplier<AuthenticationResponse> provideAuthenticationResponseCache(
final GetAuthenticationResponse getAuthenticationResponse) { final GetAuthenticationResponse getAuthenticationResponse) {
return Suppliers.memoizeWithExpiration(new RetryOnTimeOutExceptionSupplier<AuthenticationResponse>( return Suppliers.memoizeWithExpiration(new RetryOnTimeOutExceptionSupplier<AuthenticationResponse>(
getAuthenticationResponse), 23, TimeUnit.HOURS); getAuthenticationResponse), 23, TimeUnit.HOURS);

View File

@ -26,7 +26,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.jclouds.Constants; import org.jclouds.Constants;
@ -109,8 +108,7 @@ public class BlockUntilInitScriptStatusIsZeroThenReturnOutput extends AbstractFu
* Submits a thread that will either set the result of the future or the exception that took * Submits a thread that will either set the result of the future or the exception that took
* place * place
*/ */
@PostConstruct public BlockUntilInitScriptStatusIsZeroThenReturnOutput init() {
BlockUntilInitScriptStatusIsZeroThenReturnOutput init() {
userThreads.submit(new Runnable() { userThreads.submit(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -21,7 +21,6 @@ package org.jclouds.compute.callables;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Named; import javax.inject.Named;
@ -61,7 +60,6 @@ public class SudoAwareInitManager {
this.init = checkNotNull(init, "init"); this.init = checkNotNull(init, "init");
} }
@PostConstruct
public SudoAwareInitManager init() { public SudoAwareInitManager init() {
ssh = sshFactory.apply(node); ssh = sshFactory.apply(node);
return this; return this;

View File

@ -81,7 +81,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
install(new LocationModule(authException)); configureLocationModule();
install(new ComputeServiceTimeoutsModule()); install(new ComputeServiceTimeoutsModule());
bind(new TypeLiteral<Function<NodeMetadata, SshClient>>() { bind(new TypeLiteral<Function<NodeMetadata, SshClient>>() {
}).to(CreateSshClientOncePortIsListeningOnNode.class); }).to(CreateSshClientOncePortIsListeningOnNode.class);
@ -115,6 +115,10 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
install(new FactoryModuleBuilder().build(BlockUntilInitScriptStatusIsZeroThenReturnOutput.Factory.class)); install(new FactoryModuleBuilder().build(BlockUntilInitScriptStatusIsZeroThenReturnOutput.Factory.class));
} }
protected void configureLocationModule() {
install(new LocationModule(authException));
}
@Singleton @Singleton
static class RunScriptOnNodeFactoryImpl implements RunScriptOnNode.Factory { static class RunScriptOnNodeFactoryImpl implements RunScriptOnNode.Factory {

View File

@ -18,11 +18,15 @@
*/ */
package org.jclouds.compute.config; package org.jclouds.compute.config;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import java.util.Set; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.collect.Memoized;
import org.jclouds.collect.TransformingSetSupplier; import org.jclouds.collect.TransformingSetSupplier;
import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
@ -41,10 +45,13 @@ import org.jclouds.compute.strategy.SuspendNodeStrategy;
import org.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies; import org.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Functions; import com.google.common.base.Functions;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.Scopes; import com.google.inject.Scopes;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
@ -64,33 +71,39 @@ public class ComputeServiceAdapterContextModule<S, A, N, H, I, L> extends BaseCo
this.asyncClientType = asyncClientType; this.asyncClientType = asyncClientType;
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings( { "unchecked", "rawtypes" })
@Override @Override
protected void configure() { protected void configure() {
super.configure(); super.configure();
bind(new TypeLiteral<ComputeServiceContext>() { bind(new TypeLiteral<ComputeServiceContext>() {
}).to((TypeLiteral) TypeLiteral.get(Types.newParameterizedType(ComputeServiceContextImpl.class, syncClientType, }).to(
asyncClientType))).in(Scopes.SINGLETON); (TypeLiteral) TypeLiteral.get(Types.newParameterizedType(ComputeServiceContextImpl.class,
syncClientType, asyncClientType))).in(Scopes.SINGLETON);
}
@Override
protected void configureLocationModule() {
// configuring below
} }
@Provides @Provides
@Singleton @Singleton
protected Supplier<Set<? extends Location>> provideLocations(final ComputeServiceAdapter<N, H, I, L> adapter, @Memoized
Function<L, Location> transformer) { protected Supplier<Set<? extends Location>> supplyLocationCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
return new TransformingSetSupplier<L, Location>(new Supplier<Iterable<L>>() { final ComputeServiceAdapter<N, H, I, L> adapter, final Function<L, Location> transformer) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Set<? extends Location>>(authException,
@Override seconds, new Supplier<Set<? extends Location>>() {
public Iterable<L> get() { @Override
return adapter.listLocations(); public Set<? extends Location> get() {
} return ImmutableSet.<Location> copyOf(Iterables.transform(adapter.listLocations(), transformer));
}
}, transformer); });
} }
@Provides @Provides
@Singleton @Singleton
protected Supplier<Set<? extends Hardware>> provideHardware(final ComputeServiceAdapter<N, H, I, L> adapter, protected Supplier<Set<? extends Hardware>> provideHardware(final ComputeServiceAdapter<N, H, I, L> adapter,
Function<H, Hardware> transformer) { Function<H, Hardware> transformer) {
return new TransformingSetSupplier<H, Hardware>(new Supplier<Iterable<H>>() { return new TransformingSetSupplier<H, Hardware>(new Supplier<Iterable<H>>() {
@Override @Override
@ -104,7 +117,7 @@ public class ComputeServiceAdapterContextModule<S, A, N, H, I, L> extends BaseCo
@Provides @Provides
@Singleton @Singleton
protected Supplier<Set<? extends Image>> provideImages(final ComputeServiceAdapter<N, H, I, L> adapter, protected Supplier<Set<? extends Image>> provideImages(final ComputeServiceAdapter<N, H, I, L> adapter,
Function<I, Image> transformer, AddDefaultCredentialsToImage addDefaultCredentialsToImage) { Function<I, Image> transformer, AddDefaultCredentialsToImage addDefaultCredentialsToImage) {
return new TransformingSetSupplier<I, Image>(new Supplier<Iterable<I>>() { return new TransformingSetSupplier<I, Image>(new Supplier<Iterable<I>>() {
@Override @Override
@ -139,7 +152,7 @@ public class ComputeServiceAdapterContextModule<S, A, N, H, I, L> extends BaseCo
@Provides @Provides
@Singleton @Singleton
protected CreateNodeWithGroupEncodedIntoName defineAddNodeWithTagStrategy( protected CreateNodeWithGroupEncodedIntoName defineAddNodeWithTagStrategy(
AdaptingComputeServiceStrategies<N, H, I, L> in) { AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in; return in;
} }

View File

@ -25,9 +25,9 @@ import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -43,18 +43,18 @@ import com.google.inject.Inject;
@Singleton @Singleton
public class NodePresentAndInIntendedState implements Predicate<NodeMetadata> { public class NodePresentAndInIntendedState implements Predicate<NodeMetadata> {
private final ComputeService client; private final GetNodeMetadataStrategy client;
private final NodeState intended; private final NodeState intended;
private final Set<NodeState> invalids; private final Set<NodeState> invalids;
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@Inject @Inject
public NodePresentAndInIntendedState(NodeState intended, ComputeService client) { public NodePresentAndInIntendedState(NodeState intended, GetNodeMetadataStrategy client) {
this(intended, ImmutableSet.of(NodeState.ERROR), client); this(intended, ImmutableSet.of(NodeState.ERROR), client);
} }
public NodePresentAndInIntendedState(NodeState intended, Set<NodeState> invalids, ComputeService client) { public NodePresentAndInIntendedState(NodeState intended, Set<NodeState> invalids, GetNodeMetadataStrategy client) {
this.intended = intended; this.intended = intended;
this.client = client; this.client = client;
this.invalids = invalids; this.invalids = invalids;
@ -75,6 +75,6 @@ public class NodePresentAndInIntendedState implements Predicate<NodeMetadata> {
private NodeMetadata refresh(NodeMetadata node) { private NodeMetadata refresh(NodeMetadata node) {
if (node == null || node.getId() == null) if (node == null || node.getId() == null)
return null; return null;
return client.getNodeMetadata(node.getId()); return client.getNode(node.getId());
} }
} }

View File

@ -20,8 +20,8 @@ package org.jclouds.compute.predicates;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -36,7 +36,7 @@ import com.google.inject.Inject;
public class NodeRunning extends NodePresentAndInIntendedState { public class NodeRunning extends NodePresentAndInIntendedState {
@Inject @Inject
public NodeRunning(ComputeService client) { public NodeRunning(GetNodeMetadataStrategy client) {
super(NodeState.RUNNING, ImmutableSet.of(NodeState.ERROR, NodeState.TERMINATED), client); super(NodeState.RUNNING, ImmutableSet.of(NodeState.ERROR, NodeState.TERMINATED), client);
} }
} }

View File

@ -20,8 +20,8 @@ package org.jclouds.compute.predicates;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -35,7 +35,7 @@ import com.google.inject.Inject;
public class NodeSuspended extends NodePresentAndInIntendedState { public class NodeSuspended extends NodePresentAndInIntendedState {
@Inject @Inject
public NodeSuspended(ComputeService client) { public NodeSuspended(GetNodeMetadataStrategy client) {
super(NodeState.SUSPENDED, client); super(NodeState.SUSPENDED, client);
} }
} }

View File

@ -23,9 +23,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -40,13 +40,13 @@ import com.google.inject.Inject;
@Singleton @Singleton
public class NodeTerminated implements Predicate<NodeMetadata> { public class NodeTerminated implements Predicate<NodeMetadata> {
private final ComputeService client; private final GetNodeMetadataStrategy client;
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@Inject @Inject
public NodeTerminated(ComputeService client) { public NodeTerminated(GetNodeMetadataStrategy client) {
this.client = client; this.client = client;
} }
@ -61,6 +61,6 @@ public class NodeTerminated implements Predicate<NodeMetadata> {
} }
private NodeMetadata refresh(NodeMetadata node) { private NodeMetadata refresh(NodeMetadata node) {
return client.getNodeMetadata(node.getId()); return client.getNode(node.getId());
} }
} }

View File

@ -18,9 +18,6 @@
*/ */
package org.jclouds.ssh; package org.jclouds.ssh;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
@ -56,10 +53,8 @@ public interface SshClient {
ExecResponse exec(String command); ExecResponse exec(String command);
@PostConstruct
void connect(); void connect();
@PreDestroy
void disconnect(); void disconnect();
void put(String path, String contents); void put(String path, String contents);

View File

@ -22,9 +22,9 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.replay;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -38,15 +38,15 @@ import org.testng.annotations.Test;
public class NodePredicatesTest { public class NodePredicatesTest {
private NodeMetadata node; private NodeMetadata node;
private ComputeService computeService; private GetNodeMetadataStrategy computeService;
@BeforeMethod @BeforeMethod
public void setUp() throws Exception { public void setUp() throws Exception {
node = createMock(NodeMetadata.class); node = createMock(NodeMetadata.class);
computeService = createMock(ComputeService.class); computeService = createMock(GetNodeMetadataStrategy.class);
expect(node.getId()).andReturn("myid").anyTimes(); expect(node.getId()).andReturn("myid").anyTimes();
expect(computeService.getNodeMetadata("myid")).andReturn(node).anyTimes(); expect(computeService.getNode("myid")).andReturn(node).anyTimes();
expect(node.getLocation()).andReturn(null).anyTimes(); expect(node.getLocation()).andReturn(null).anyTimes();
} }

View File

@ -38,9 +38,9 @@ import org.jclouds.Constants;
import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.MoreExecutors;
import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.Closer;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.ExecutionList; import com.google.common.util.concurrent.ExecutionList;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.ProvisionException;
import com.google.inject.Stage; import com.google.inject.Stage;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
import com.google.inject.spi.InjectionListener; import com.google.inject.spi.InjectionListener;
@ -143,9 +143,9 @@ public class LifeCycleModule extends AbstractModule {
method.invoke(injectee); method.invoke(injectee);
} catch (InvocationTargetException ie) { } catch (InvocationTargetException ie) {
Throwable e = ie.getTargetException(); Throwable e = ie.getTargetException();
throw new ProvisionException(e.getMessage(), e); throw Throwables.propagate(e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new ProvisionException(e.getMessage(), e); throw Throwables.propagate(e);
} }
} }
}, MoreExecutors.sameThreadExecutor()); }, MoreExecutors.sameThreadExecutor());

View File

@ -20,7 +20,6 @@ package org.jclouds.location.config;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -32,10 +31,7 @@ import org.jclouds.domain.Location;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import com.google.common.base.Function;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.Maps;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides; import com.google.inject.Provides;
@ -54,27 +50,6 @@ public class LocationModule extends AbstractModule {
this.authException = authException; this.authException = authException;
} }
@Provides
@Singleton
protected Supplier<Map<String, ? extends Location>> provideLocationMap(
@Memoized Supplier<Set<? extends Location>> locations) {
return Suppliers.compose(new Function<Set<? extends Location>, Map<String, ? extends Location>>() {
@Override
public Map<String, ? extends Location> apply(Set<? extends Location> from) {
return Maps.uniqueIndex(from, new Function<Location, String>() {
@Override
public String apply(Location from) {
return from.getId();
}
});
}
}, locations);
}
@Provides @Provides
@Singleton @Singleton
@Memoized @Memoized

View File

@ -68,6 +68,30 @@ public class LocationPredicates {
} }
} }
public static Predicate<Location> idEquals(String id) {
return new IdEquals(id);
}
static class IdEquals implements Predicate<Location> {
private final String id;
IdEquals(String id) {
this.id = checkNotNull(id, "id");
}
@Override
public boolean apply(Location input) {
return input.getId().equals(id);
}
@Override
public String toString() {
return "idEquals(" + id + ")";
}
}
public static Predicate<Location> isZoneOrRegionWhereRegionIdEquals(String region) { public static Predicate<Location> isZoneOrRegionWhereRegionIdEquals(String region) {
return new IsZoneOrRegionWhereRegionIdEquals(region); return new IsZoneOrRegionWhereRegionIdEquals(region);
} }

View File

@ -2426,8 +2426,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
@BeforeClass @BeforeClass
void setupFactory() { void setupFactory() {
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "", "userfoo", RestContextSpec<Callee, AsyncCallee> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "", "userfoo",
null, String.class, Integer.class, null, Callee.class, AsyncCallee.class,
ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(), new AbstractModule() { ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
@Override @Override

View File

@ -35,7 +35,6 @@ import java.io.InputStream;
import java.net.ConnectException; import java.net.ConnectException;
import java.util.Arrays; import java.util.Arrays;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Named; import javax.inject.Named;
@ -224,7 +223,6 @@ public class JschSshClient implements SshClient {
return null; return null;
} }
@PostConstruct
public void connect() { public void connect() {
acquire(sessionConnection); acquire(sessionConnection);
} }

View File

@ -36,7 +36,6 @@ import java.net.ConnectException;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Named; import javax.inject.Named;
@ -248,7 +247,6 @@ public class SshjSshClient implements SshClient {
return null; return null;
} }
@PostConstruct
public void connect() { public void connect() {
try { try {
ssh = acquire(sshConnection); ssh = acquire(sshConnection);

View File

@ -20,7 +20,6 @@ package org.jclouds.loadbalancer.config;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -32,10 +31,7 @@ import org.jclouds.domain.Location;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import com.google.common.base.Function;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.Maps;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides; import com.google.inject.Provides;
@ -52,27 +48,6 @@ public abstract class BaseLoadBalancerServiceContextModule extends AbstractModul
} }
@Provides
@Singleton
protected Supplier<Map<String, ? extends Location>> provideLocationMap(
@Memoized Supplier<Set<? extends Location>> locations) {
return Suppliers.compose(new Function<Set<? extends Location>, Map<String, ? extends Location>>() {
@Override
public Map<String, ? extends Location> apply(Set<? extends Location> from) {
return Maps.uniqueIndex(from, new Function<Location, String>() {
@Override
public String apply(Location from) {
return from.getId();
}
});
}
}, locations);
}
@Provides @Provides
@Singleton @Singleton
@Memoized @Memoized

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
package org.jclouds.gogrid.compute.functions; package org.jclouds.gogrid.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName; import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName;
@ -38,6 +37,7 @@ import org.jclouds.compute.domain.NodeState;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.gogrid.domain.Server; import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.domain.ServerState; import org.jclouds.gogrid.domain.ServerState;
import org.jclouds.location.predicates.LocationPredicates;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -57,7 +57,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
private final Map<ServerState, NodeState> serverStateToNodeState; private final Map<ServerState, NodeState> serverStateToNodeState;
private final Supplier<Set<? extends Image>> images; private final Supplier<Set<? extends Image>> images;
private final Supplier<Set<? extends Hardware>> hardwares; private final Supplier<Set<? extends Hardware>> hardwares;
private final Supplier<Map<String, ? extends Location>> locations; private final Supplier<Set<? extends Location>> locations;
static class FindImageForServer implements Predicate<Image> { static class FindImageForServer implements Predicate<Image> {
private final Server instance; private final Server instance;
@ -92,7 +92,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
@Inject @Inject
ServerToNodeMetadata(Map<ServerState, NodeState> serverStateToNodeState, ServerToNodeMetadata(Map<ServerState, NodeState> serverStateToNodeState,
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares, @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares,
Supplier<Map<String, ? extends Location>> locations) { @Memoized Supplier<Set<? extends Location>> locations) {
this.serverStateToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState"); this.serverStateToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState");
this.images = checkNotNull(images, "images"); this.images = checkNotNull(images, "images");
this.hardwares = checkNotNull(hardwares, "hardwares"); this.hardwares = checkNotNull(hardwares, "hardwares");
@ -104,7 +104,8 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
NodeMetadataBuilder builder = new NodeMetadataBuilder(); NodeMetadataBuilder builder = new NodeMetadataBuilder();
builder.ids(from.getId() + ""); builder.ids(from.getId() + "");
builder.name(from.getName()); builder.name(from.getName());
builder.location(locations.get().get(from.getDatacenter().getId() + "")); Location location = Iterables.find(locations.get(), LocationPredicates.idEquals(from.getDatacenter().getId() + ""));
builder.location(location);
builder.group(parseGroupFromName(from.getName())); builder.group(parseGroupFromName(from.getName()));
builder.hardware(parseHardware(from)); builder.hardware(parseHardware(from));
builder.imageId(from.getImage().getId() + ""); builder.imageId(from.getImage().getId() + "");

View File

@ -44,7 +44,6 @@ import org.jclouds.gogrid.domain.ServerState;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**
@ -73,7 +72,7 @@ public class ServerToNodeMetadataTest {
expect(serverStateToNodeState.get(ServerState.ON)).andReturn(NodeState.RUNNING); expect(serverStateToNodeState.get(ServerState.ON)).andReturn(NodeState.RUNNING);
Location location = new LocationBuilder().scope(LocationScope.ZONE).id("1").description("US-West-1").build(); Location location = new LocationBuilder().scope(LocationScope.ZONE).id("1").description("US-West-1").build();
Map<String, ? extends Location> locations = ImmutableMap.<String, Location> of("1", location); Set< ? extends Location> locations = ImmutableSet.< Location> of( location);
expect(server.getIp()).andReturn(new Ip("127.0.0.1")); expect(server.getIp()).andReturn(new Ip("127.0.0.1"));
@ -94,7 +93,7 @@ public class ServerToNodeMetadataTest {
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers
.<Set<? extends Image>> ofInstance(images), Suppliers .<Set<? extends Image>> ofInstance(images), Suppliers
.<Set<? extends Hardware>> ofInstance(GoGridHardwareSupplier.H_ALL), Suppliers .<Set<? extends Hardware>> ofInstance(GoGridHardwareSupplier.H_ALL), Suppliers
.<Map<String, ? extends Location>> ofInstance(locations)); .<Set<? extends Location>> ofInstance(locations));
NodeMetadata metadata = parser.apply(server); NodeMetadata metadata = parser.apply(server);
assertEquals(metadata.getLocation(), location); assertEquals(metadata.getLocation(), location);