mirror of https://github.com/apache/jclouds.git
Issue 781:update to guava 11.0-rc1
This commit is contained in:
parent
40d2abbac5
commit
beb87a2131
|
@ -45,7 +45,7 @@ import org.jclouds.util.CredentialUtils;
|
||||||
|
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ import com.google.inject.Provider;
|
||||||
*/
|
*/
|
||||||
public class ComputeTask extends Task {
|
public class ComputeTask extends Task {
|
||||||
|
|
||||||
private final Cache<URI, ComputeServiceContext> computeMap;
|
private final LoadingCache<URI, ComputeServiceContext> computeMap;
|
||||||
private String provider;
|
private String provider;
|
||||||
private String actions;
|
private String actions;
|
||||||
private NodeElement nodeElement;
|
private NodeElement nodeElement;
|
||||||
|
@ -71,7 +71,7 @@ public class ComputeTask extends Task {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public ComputeTask(@Nullable Cache<URI, ComputeServiceContext> computeMap) {
|
public ComputeTask(@Nullable LoadingCache<URI, ComputeServiceContext> computeMap) {
|
||||||
this.computeMap = computeMap != null ? computeMap : buildComputeMap(projectProvider);
|
this.computeMap = computeMap != null ? computeMap : buildComputeMap(projectProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.jclouds.tools.ant.logging.config.AntLoggingModule;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -67,7 +67,7 @@ public class ComputeTaskUtils {
|
||||||
* allows access to the ant project to retrieve default properties needed for compute
|
* allows access to the ant project to retrieve default properties needed for compute
|
||||||
* providers.
|
* providers.
|
||||||
*/
|
*/
|
||||||
static Cache<URI, ComputeServiceContext> buildComputeMap(final Provider<Project> projectProvider) {
|
static LoadingCache<URI, ComputeServiceContext> buildComputeMap(final Provider<Project> projectProvider) {
|
||||||
return CacheBuilder.newBuilder().build(new CacheLoader<URI, ComputeServiceContext>() {
|
return CacheBuilder.newBuilder().build(new CacheLoader<URI, ComputeServiceContext>() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.atmos.options.PutOptions.Builder.publicRead;
|
import static org.jclouds.atmos.options.PutOptions.Builder.publicRead;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -64,6 +63,8 @@ import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +82,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
private final Crypto crypto;
|
private final Crypto crypto;
|
||||||
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
||||||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||||
private final Map<String, Boolean> isPublic;
|
private final LoadingCache<String, Boolean> isPublic;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
||||||
|
@ -91,7 +92,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
||||||
DirectoryEntryListToResourceMetadataList container2ResourceList, Crypto crypto,
|
DirectoryEntryListToResourceMetadataList container2ResourceList, Crypto crypto,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
|
BlobToHttpGetOptions blob2ObjectGetOptions, Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
|
||||||
Map<String, Boolean> isPublic) {
|
LoadingCache<String, Boolean> isPublic) {
|
||||||
super(context, blobUtils, service, defaultLocation, locations);
|
super(context, blobUtils, service, defaultLocation, locations);
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.sync = checkNotNull(sync, "sync");
|
this.sync = checkNotNull(sync, "sync");
|
||||||
|
@ -238,10 +239,10 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
public ListenableFuture<String> putBlob(final String container, final Blob blob) {
|
public ListenableFuture<String> putBlob(final String container, final Blob blob) {
|
||||||
final org.jclouds.atmos.options.PutOptions options = new org.jclouds.atmos.options.PutOptions();
|
final org.jclouds.atmos.options.PutOptions options = new org.jclouds.atmos.options.PutOptions();
|
||||||
try {
|
try {
|
||||||
if (isPublic.get(container + "/"))
|
if (isPublic.getUnchecked(container + "/"))
|
||||||
options.publicRead();
|
options.publicRead();
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
// MapMaker
|
// nulls not permitted
|
||||||
}
|
}
|
||||||
return Futures.makeListenable(service.submit(new Callable<String>() {
|
return Futures.makeListenable(service.submit(new Callable<String>() {
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.atmos.blobstore;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.atmos.options.PutOptions.Builder.publicRead;
|
import static org.jclouds.atmos.options.PutOptions.Builder.publicRead;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -54,6 +53,8 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -69,7 +70,7 @@ public class AtmosBlobStore extends BaseBlobStore {
|
||||||
private final Crypto crypto;
|
private final Crypto crypto;
|
||||||
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
||||||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||||
private final Map<String, Boolean> isPublic;
|
private final LoadingCache<String, Boolean> isPublic;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
||||||
|
@ -78,7 +79,7 @@ public class AtmosBlobStore extends BaseBlobStore {
|
||||||
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
||||||
DirectoryEntryListToResourceMetadataList container2ResourceList, Crypto crypto,
|
DirectoryEntryListToResourceMetadataList container2ResourceList, Crypto crypto,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
|
BlobToHttpGetOptions blob2ObjectGetOptions, Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
|
||||||
Map<String, Boolean> isPublic) {
|
LoadingCache<String, Boolean> isPublic) {
|
||||||
super(context, blobUtils, defaultLocation, locations);
|
super(context, blobUtils, defaultLocation, locations);
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.sync = checkNotNull(sync, "sync");
|
this.sync = checkNotNull(sync, "sync");
|
||||||
|
@ -212,10 +213,10 @@ public class AtmosBlobStore extends BaseBlobStore {
|
||||||
public String putBlob(final String container, final Blob blob) {
|
public String putBlob(final String container, final Blob blob) {
|
||||||
final org.jclouds.atmos.options.PutOptions options = new org.jclouds.atmos.options.PutOptions();
|
final org.jclouds.atmos.options.PutOptions options = new org.jclouds.atmos.options.PutOptions();
|
||||||
try {
|
try {
|
||||||
if (isPublic.get(container + "/"))
|
if (isPublic.getUnchecked(container + "/"))
|
||||||
options.publicRead();
|
options.publicRead();
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
// MapMaker
|
// nulls not permitted
|
||||||
}
|
}
|
||||||
return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob, options);
|
return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob, options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmos.blobstore.config;
|
package org.jclouds.atmos.blobstore.config;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -39,8 +38,9 @@ import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||||
import org.jclouds.location.config.JustProviderLocationModule;
|
import org.jclouds.location.config.JustProviderLocationModule;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
|
@ -68,16 +68,18 @@ public class AtmosBlobStoreContextModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Map<String, Boolean> isPublic(final AtmosClient client) {
|
protected LoadingCache<String, Boolean> isPublic(final AtmosClient client) {
|
||||||
return new MapMaker().expireAfterWrite(30, TimeUnit.SECONDS).makeComputingMap(new Function<String, Boolean>() {
|
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(new CacheLoader<String, Boolean>() {
|
||||||
public Boolean apply(String directory) {
|
|
||||||
return client.isPublic(directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "isPublic()";
|
return "isPublic()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean load(String arg0) throws Exception {
|
||||||
|
return client.isPublic(arg0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class BYONComputeServiceContextModule extends
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
Supplier provideApi(Supplier<Cache<String, Node>> in) {
|
Supplier provideApi(Supplier<LoadingCache<String, Node>> in) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.google.common.annotations.Beta;
|
||||||
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.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
@ -41,9 +41,9 @@ import com.google.inject.TypeLiteral;
|
||||||
@ConfiguresNodeStore
|
@ConfiguresNodeStore
|
||||||
@Beta
|
@Beta
|
||||||
public class CacheNodeStoreModule extends AbstractModule {
|
public class CacheNodeStoreModule extends AbstractModule {
|
||||||
private final Cache<String, Node> backing;
|
private final LoadingCache<String, Node> backing;
|
||||||
|
|
||||||
public CacheNodeStoreModule(Cache<String, Node> backing) {
|
public CacheNodeStoreModule(LoadingCache<String, Node> backing) {
|
||||||
this.backing = checkNotNull(backing, "backing");
|
this.backing = checkNotNull(backing, "backing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +55,10 @@ public class CacheNodeStoreModule extends AbstractModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(new TypeLiteral<Cache<String, Node>>() {
|
bind(new TypeLiteral<LoadingCache<String, Node>>() {
|
||||||
}).toInstance(backing);
|
}).toInstance(backing);
|
||||||
bind(new TypeLiteral<Supplier<Cache<String, Node>>>() {
|
bind(new TypeLiteral<Supplier<LoadingCache<String, Node>>>() {
|
||||||
}).toInstance(Suppliers.<Cache<String, Node>> ofInstance(backing));
|
}).toInstance(Suppliers.<LoadingCache<String, Node>> ofInstance(backing));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -27,7 +27,7 @@ import java.lang.annotation.Target;
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* designates the module configures a {@code Cache<String, Node>}
|
* designates the module configures a {@code LoadingCache<String, Node>}
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,7 +38,7 @@ import com.google.common.annotations.Beta;
|
||||||
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.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.io.InputSupplier;
|
import com.google.common.io.InputSupplier;
|
||||||
|
@ -67,9 +67,9 @@ public class YamlNodeStoreModule extends AbstractModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(new TypeLiteral<Supplier<Cache<String, Node>>>() {
|
bind(new TypeLiteral<Supplier<LoadingCache<String, Node>>>() {
|
||||||
}).to(NodesParsedFromSupplier.class);
|
}).to(NodesParsedFromSupplier.class);
|
||||||
bind(new TypeLiteral<Function<InputStream, Cache<String, Node>>>() {
|
bind(new TypeLiteral<Function<InputStream, LoadingCache<String, Node>>>() {
|
||||||
}).to(NodesFromYamlStream.class);
|
}).to(NodesFromYamlStream.class);
|
||||||
bind(new TypeLiteral<Function<YamlNode, InputStream>>() {
|
bind(new TypeLiteral<Function<YamlNode, InputStream>>() {
|
||||||
}).toInstance(org.jclouds.byon.domain.YamlNode.yamlNodeToInputStream);
|
}).toInstance(org.jclouds.byon.domain.YamlNode.yamlNodeToInputStream);
|
||||||
|
@ -103,7 +103,7 @@ public class YamlNodeStoreModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Cache<String, Node> provideNodeStore(Map<String, YamlNode> backing, Function<Node, YamlNode> yamlSerializer,
|
protected LoadingCache<String, Node> provideNodeStore(Map<String, YamlNode> backing, Function<Node, YamlNode> yamlSerializer,
|
||||||
Function<YamlNode, Node> yamlDeserializer) {
|
Function<YamlNode, Node> yamlDeserializer) {
|
||||||
return CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(new TransformingMap<String, YamlNode, Node>(backing, yamlDeserializer, yamlSerializer))));
|
return CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(new TransformingMap<String, YamlNode, Node>(backing, yamlDeserializer, yamlSerializer))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
|
|
||||||
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.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -69,7 +69,7 @@ import com.google.common.collect.Maps;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class NodesFromYamlStream implements Function<InputStream, Cache<String, Node>> {
|
public class NodesFromYamlStream implements Function<InputStream, LoadingCache<String, Node>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type-safe config class for YAML
|
* Type-safe config class for YAML
|
||||||
|
@ -80,7 +80,7 @@ public class NodesFromYamlStream implements Function<InputStream, Cache<String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cache<String, Node> apply(InputStream source) {
|
public LoadingCache<String, Node> apply(InputStream source) {
|
||||||
|
|
||||||
Constructor constructor = new Constructor(Config.class);
|
Constructor constructor = new Constructor(Config.class);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class NodesFromYamlStream implements Function<InputStream, Cache<String,
|
||||||
return node.getId();
|
return node.getId();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Cache<String, Node> cache = CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(backingMap)));
|
LoadingCache<String, Node> cache = CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(backingMap)));
|
||||||
for (String node : backingMap.keySet())
|
for (String node : backingMap.keySet())
|
||||||
cache.getUnchecked(node);
|
cache.getUnchecked(node);
|
||||||
return cache;
|
return cache;
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.jclouds.location.suppliers.JustProvider;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -52,12 +52,12 @@ import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BYONComputeServiceAdapter implements JCloudsNativeComputeServiceAdapter {
|
public class BYONComputeServiceAdapter implements JCloudsNativeComputeServiceAdapter {
|
||||||
private final Supplier<Cache<String, Node>> nodes;
|
private final Supplier<LoadingCache<String, Node>> nodes;
|
||||||
private final NodeToNodeMetadata converter;
|
private final NodeToNodeMetadata converter;
|
||||||
private final JustProvider locationSupplier;
|
private final JustProvider locationSupplier;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BYONComputeServiceAdapter(Supplier<Cache<String, Node>> nodes, NodeToNodeMetadata converter,
|
public BYONComputeServiceAdapter(Supplier<LoadingCache<String, Node>> nodes, NodeToNodeMetadata converter,
|
||||||
JustProvider locationSupplier) {
|
JustProvider locationSupplier) {
|
||||||
this.nodes = checkNotNull(nodes, "nodes");
|
this.nodes = checkNotNull(nodes, "nodes");
|
||||||
this.converter = checkNotNull(converter, "converter");
|
this.converter = checkNotNull(converter, "converter");
|
||||||
|
|
|
@ -33,29 +33,29 @@ import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class NodesParsedFromSupplier implements Supplier<Cache<String, Node>> {
|
public class NodesParsedFromSupplier implements Supplier<LoadingCache<String, Node>> {
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final Supplier<InputStream> supplier;
|
private final Supplier<InputStream> supplier;
|
||||||
private final Function<InputStream, Cache<String, Node>> parser;
|
private final Function<InputStream, LoadingCache<String, Node>> parser;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
NodesParsedFromSupplier(@Provider Supplier<InputStream> supplier, Function<InputStream, Cache<String, Node>> parser) {
|
NodesParsedFromSupplier(@Provider Supplier<InputStream> supplier, Function<InputStream, LoadingCache<String, Node>> parser) {
|
||||||
this.supplier = checkNotNull(supplier, "supplier");
|
this.supplier = checkNotNull(supplier, "supplier");
|
||||||
this.parser = checkNotNull(parser, "parser");
|
this.parser = checkNotNull(parser, "parser");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cache<String, Node> get() {
|
public LoadingCache<String, Node> get() {
|
||||||
Cache<String, Node> nodes = parser.apply(supplier.get());
|
LoadingCache<String, Node> nodes = parser.apply(supplier.get());
|
||||||
checkState(nodes != null && nodes.size() > 0, "no nodes parsed from supplier: %s", supplier);
|
checkState(nodes != null && nodes.size() > 0, "no nodes parsed from supplier: %s", supplier);
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.jclouds.domain.LoginCredentials;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -79,7 +79,7 @@ public class BYONComputeServiceTest {
|
||||||
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Supplier<Cache<String, Node>> supplier = (Supplier<Cache<String, Node>>) context.getProviderSpecificContext()
|
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
|
||||||
.getApi();
|
.getApi();
|
||||||
|
|
||||||
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
|
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
|
||||||
|
@ -107,7 +107,7 @@ public class BYONComputeServiceTest {
|
||||||
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Supplier<Cache<String, Node>> supplier = (Supplier<Cache<String, Node>>) context.getProviderSpecificContext()
|
Supplier<LoadingCache<String, Node>> supplier = (Supplier<LoadingCache<String, Node>>) context.getProviderSpecificContext()
|
||||||
.getApi();
|
.getApi();
|
||||||
|
|
||||||
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
|
assertEquals(supplier.get().size(), context.getComputeService().listNodes().size());
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.testng.annotations.Test;
|
||||||
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.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -70,9 +70,9 @@ public class CacheNodeStoreModuleTest {
|
||||||
Map<String, Node> map = Maps.newConcurrentMap();
|
Map<String, Node> map = Maps.newConcurrentMap();
|
||||||
|
|
||||||
Injector injector = createInjectorWithProvidedMap(map);
|
Injector injector = createInjectorWithProvidedMap(map);
|
||||||
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Cache<String, Node>>() {
|
assertEquals(injector.getInstance(Key.get(new TypeLiteral<LoadingCache<String, Node>>() {
|
||||||
})).asMap(), map);
|
})).asMap(), map);
|
||||||
Cache<String, Node> store = getStore(injector);
|
LoadingCache<String, Node> store = getStore(injector);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
check(map, store, "test" + i, "instance1" + i, "instancename" + i);
|
check(map, store, "test" + i, "instance1" + i, "instancename" + i);
|
||||||
|
@ -92,7 +92,7 @@ public class CacheNodeStoreModuleTest {
|
||||||
public void testProvidedCacheConsistentAcrossMultipleInjectors() throws IOException {
|
public void testProvidedCacheConsistentAcrossMultipleInjectors() throws IOException {
|
||||||
Map<String, Node> map = Maps.newConcurrentMap();
|
Map<String, Node> map = Maps.newConcurrentMap();
|
||||||
|
|
||||||
Cache<String, Node> cache = CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(map)));
|
LoadingCache<String, Node> cache = CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(map)));
|
||||||
|
|
||||||
put(map, getStore(createInjectorWithProvidedCache(cache)), "test", "instance1", "instancename");
|
put(map, getStore(createInjectorWithProvidedCache(cache)), "test", "instance1", "instancename");
|
||||||
checkConsistent(map, getStore(createInjectorWithProvidedCache(cache)), "test", "instance1", "instancename");
|
checkConsistent(map, getStore(createInjectorWithProvidedCache(cache)), "test", "instance1", "instancename");
|
||||||
|
@ -101,8 +101,8 @@ public class CacheNodeStoreModuleTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cache<String, Node> getStore(Injector injector) {
|
private LoadingCache<String, Node> getStore(Injector injector) {
|
||||||
return injector.getInstance(Key.get(new TypeLiteral<Cache<String, Node>>() {
|
return injector.getInstance(Key.get(new TypeLiteral<LoadingCache<String, Node>>() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ public class CacheNodeStoreModuleTest {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Injector createInjectorWithProvidedCache(Cache<String, Node> cache) {
|
private Injector createInjectorWithProvidedCache(LoadingCache<String, Node> cache) {
|
||||||
return Guice.createInjector(new CacheNodeStoreModule(cache), new AbstractModule() {
|
return Guice.createInjector(new CacheNodeStoreModule(cache), new AbstractModule() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -130,14 +130,14 @@ public class CacheNodeStoreModuleTest {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check(Map<String, Node> map, Cache<String, Node> store, String key, String id, String name)
|
private void check(Map<String, Node> map, LoadingCache<String, Node> store, String key, String id, String name)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
put(map, store, key, id, name);
|
put(map, store, key, id, name);
|
||||||
checkConsistent(map, store, key, id, name);
|
checkConsistent(map, store, key, id, name);
|
||||||
remove(map, store, key);
|
remove(map, store, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void remove(Map<String, Node> map, Cache<String, Node> store, String key) {
|
private void remove(Map<String, Node> map, LoadingCache<String, Node> store, String key) {
|
||||||
store.invalidate(key);
|
store.invalidate(key);
|
||||||
assertEquals(store.size(), 0);
|
assertEquals(store.size(), 0);
|
||||||
map.remove(key);
|
map.remove(key);
|
||||||
|
@ -151,7 +151,7 @@ public class CacheNodeStoreModuleTest {
|
||||||
assertEquals(map.get(key), null);
|
assertEquals(map.get(key), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkConsistent(Map<String, Node> map, Cache<String, Node> store, String key, String id, String name)
|
private void checkConsistent(Map<String, Node> map, LoadingCache<String, Node> store, String key, String id, String name)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
assertEquals(map.size(), 1);
|
assertEquals(map.size(), 1);
|
||||||
if (store.size() == 0)
|
if (store.size() == 0)
|
||||||
|
@ -162,7 +162,7 @@ public class CacheNodeStoreModuleTest {
|
||||||
assertEquals(store.getUnchecked(key), Node.builder().id(id).name(name).build());
|
assertEquals(store.getUnchecked(key), Node.builder().id(id).name(name).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void put(Map<String, Node> map, Cache<String, Node> store, String key, String id, String name) {
|
private void put(Map<String, Node> map, LoadingCache<String, Node> store, String key, String id, String name) {
|
||||||
assertEquals(store.size(), 0);
|
assertEquals(store.size(), 0);
|
||||||
assertEquals(map.size(), 0);
|
assertEquals(map.size(), 0);
|
||||||
map.put(key, Node.builder().id(id).name(name).build());
|
map.put(key, Node.builder().id(id).name(name).build());
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.io.InputSupplier;
|
import com.google.common.io.InputSupplier;
|
||||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
@ -85,7 +85,7 @@ public class YamlNodeStoreModuleTest {
|
||||||
Injector injector = createInjectorWithProvidedMap(map);
|
Injector injector = createInjectorWithProvidedMap(map);
|
||||||
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Map<String, InputStream>>() {
|
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Map<String, InputStream>>() {
|
||||||
}, Names.named("yaml"))), map);
|
}, Names.named("yaml"))), map);
|
||||||
Cache<String, Node> store = getStore(injector);
|
LoadingCache<String, Node> store = getStore(injector);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
check(map, store, "test" + i, "instance1" + i, "instancename" + i);
|
check(map, store, "test" + i, "instance1" + i, "instancename" + i);
|
||||||
|
@ -114,8 +114,8 @@ public class YamlNodeStoreModuleTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Cache<String, Node> getStore(Injector injector) {
|
protected LoadingCache<String, Node> getStore(Injector injector) {
|
||||||
return injector.getInstance(Key.get(new TypeLiteral<Cache<String, Node>>() {
|
return injector.getInstance(Key.get(new TypeLiteral<LoadingCache<String, Node>>() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,14 +148,14 @@ public class YamlNodeStoreModuleTest {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void check(Map<String, InputStream> map, Cache<String, Node> store, String key, String id, String name)
|
protected void check(Map<String, InputStream> map, LoadingCache<String, Node> store, String key, String id, String name)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
put(map, store, key, id, name);
|
put(map, store, key, id, name);
|
||||||
checkConsistent(map, store, key, id, name);
|
checkConsistent(map, store, key, id, name);
|
||||||
remove(map, store, key);
|
remove(map, store, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void remove(Map<String, InputStream> map, Cache<String, Node> store, String key) {
|
protected void remove(Map<String, InputStream> map, LoadingCache<String, Node> store, String key) {
|
||||||
store.invalidate(key);
|
store.invalidate(key);
|
||||||
assertEquals(store.size(), 0);
|
assertEquals(store.size(), 0);
|
||||||
map.remove(key);
|
map.remove(key);
|
||||||
|
@ -169,7 +169,7 @@ public class YamlNodeStoreModuleTest {
|
||||||
assertEquals(map.get(key), null);
|
assertEquals(map.get(key), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkConsistent(Map<String, InputStream> map, Cache<String, Node> store, String key, String id,
|
protected void checkConsistent(Map<String, InputStream> map, LoadingCache<String, Node> store, String key, String id,
|
||||||
String name) throws IOException {
|
String name) throws IOException {
|
||||||
assertEquals(map.size(), 1);
|
assertEquals(map.size(), 1);
|
||||||
if (store.size() == 0)
|
if (store.size() == 0)
|
||||||
|
@ -187,7 +187,7 @@ public class YamlNodeStoreModuleTest {
|
||||||
assertEquals(Strings2.toStringAndClose(map.get(key)), String.format("id: %s\nname: %s\n", id, name));
|
assertEquals(Strings2.toStringAndClose(map.get(key)), String.format("id: %s\nname: %s\n", id, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void put(Map<String, InputStream> map, Cache<String, Node> store, String key, String id, String name) {
|
protected void put(Map<String, InputStream> map, LoadingCache<String, Node> store, String key, String id, String name) {
|
||||||
assertEquals(store.size(), 0);
|
assertEquals(store.size(), 0);
|
||||||
assertEquals(map.size(), 0);
|
assertEquals(map.size(), 0);
|
||||||
map.put(key, new ByteArrayInputStream(String.format("id: %s\nname: %s\n", id, name).getBytes()));
|
map.put(key, new ByteArrayInputStream(String.format("id: %s\nname: %s\n", id, name).getBytes()));
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.jclouds.cloudfiles.blobstore.config;
|
package org.jclouds.cloudfiles.blobstore.config;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -34,8 +33,9 @@ import org.jclouds.openstack.swift.blobstore.SwiftBlobStore;
|
||||||
import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
|
import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
|
||||||
import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata;
|
import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,9 +46,10 @@ public class CloudFilesBlobStoreContextModule extends SwiftBlobStoreContextModul
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Map<String, URI> cdnContainer(final CloudFilesClient client) {
|
protected LoadingCache<String, URI> cdnContainer(final CloudFilesClient client) {
|
||||||
return new MapMaker().expireAfterWrite(30, TimeUnit.SECONDS).makeComputingMap(new Function<String, URI>() {
|
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(new CacheLoader<String, URI>() {
|
||||||
public URI apply(String container) {
|
@Override
|
||||||
|
public URI load(String container) {
|
||||||
ContainerCDNMetadata md = client.getCDNMetadata(container);
|
ContainerCDNMetadata md = client.getCDNMetadata(container);
|
||||||
return md != null ? md.getCDNUri() : null;
|
return md != null ? md.getCDNUri() : null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.jclouds.cloudfiles.blobstore.functions;
|
package org.jclouds.cloudfiles.blobstore.functions;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -27,6 +26,7 @@ import javax.inject.Singleton;
|
||||||
import org.jclouds.cloudfiles.CloudFilesClient;
|
import org.jclouds.cloudfiles.CloudFilesClient;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -34,11 +34,11 @@ import com.google.common.base.Function;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class EnableCDNAndCache implements Function<String, URI> {
|
public class EnableCDNAndCache implements Function<String, URI> {
|
||||||
private final Map<String, URI> cdnContainer;
|
private final LoadingCache<String, URI> cdnContainer;
|
||||||
private final CloudFilesClient sync;
|
private final CloudFilesClient sync;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public EnableCDNAndCache(CloudFilesClient sync, Map<String, URI> cdnContainer) {
|
public EnableCDNAndCache(CloudFilesClient sync, LoadingCache<String, URI> cdnContainer) {
|
||||||
this.sync = sync;
|
this.sync = sync;
|
||||||
this.cdnContainer = cdnContainer;
|
this.cdnContainer = cdnContainer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.jclouds.cloudfiles.blobstore.functions;
|
package org.jclouds.cloudfiles.blobstore.functions;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
|
@ -29,17 +28,19 @@ import javax.ws.rs.core.UriBuilder;
|
||||||
import org.jclouds.openstack.swift.domain.ObjectInfo;
|
import org.jclouds.openstack.swift.domain.ObjectInfo;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PublicUriForObjectInfo implements Function<ObjectInfo, URI> {
|
public class PublicUriForObjectInfo implements Function<ObjectInfo, URI> {
|
||||||
private final Map<String, URI> cdnContainer;
|
private final LoadingCache<String, URI> cdnContainer;
|
||||||
private final Provider<UriBuilder> uriBuilders;
|
private final Provider<UriBuilder> uriBuilders;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PublicUriForObjectInfo(Map<String, URI> cdnContainer, Provider<UriBuilder> uriBuilders) {
|
public PublicUriForObjectInfo(LoadingCache<String, URI> cdnContainer, Provider<UriBuilder> uriBuilders) {
|
||||||
this.cdnContainer = cdnContainer;
|
this.cdnContainer = cdnContainer;
|
||||||
this.uriBuilders = uriBuilders;
|
this.uriBuilders = uriBuilders;
|
||||||
}
|
}
|
||||||
|
@ -48,10 +49,10 @@ public class PublicUriForObjectInfo implements Function<ObjectInfo, URI> {
|
||||||
if (from == null)
|
if (from == null)
|
||||||
return null;
|
return null;
|
||||||
try {
|
try {
|
||||||
return uriBuilders.get().uri(cdnContainer.get(from.getContainer())).path(from.getName()).replaceQuery("")
|
return uriBuilders.get().uri(cdnContainer.getUnchecked(from.getContainer())).path(from.getName()).replaceQuery("")
|
||||||
.build();
|
.build();
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
// MapMaker constructed maps are not allowed to return null;
|
// nulls not permitted from cache loader
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ import org.jclouds.logging.Logger;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
@ -86,7 +86,7 @@ public class CloudSigmaComputeServiceAdapter implements
|
||||||
private final Predicate<DriveInfo> driveNotClaimed;
|
private final Predicate<DriveInfo> driveNotClaimed;
|
||||||
private final JustProvider locationSupplier;
|
private final JustProvider locationSupplier;
|
||||||
private final String defaultVncPassword;
|
private final String defaultVncPassword;
|
||||||
private final Cache<String, DriveInfo> cache;
|
private final LoadingCache<String, DriveInfo> cache;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -96,7 +96,7 @@ public class CloudSigmaComputeServiceAdapter implements
|
||||||
@Inject
|
@Inject
|
||||||
public CloudSigmaComputeServiceAdapter(CloudSigmaClient client, Predicate<DriveInfo> driveNotClaimed,
|
public CloudSigmaComputeServiceAdapter(CloudSigmaClient client, Predicate<DriveInfo> driveNotClaimed,
|
||||||
JustProvider locationSupplier, @Named(CloudSigmaConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
|
JustProvider locationSupplier, @Named(CloudSigmaConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
|
||||||
Cache<String, DriveInfo> cache, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
LoadingCache<String, DriveInfo> cache, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
this.driveNotClaimed = checkNotNull(driveNotClaimed, "driveNotClaimed");
|
this.driveNotClaimed = checkNotNull(driveNotClaimed, "driveNotClaimed");
|
||||||
this.locationSupplier = checkNotNull(locationSupplier, "locationSupplier");
|
this.locationSupplier = checkNotNull(locationSupplier, "locationSupplier");
|
||||||
|
|
|
@ -56,7 +56,7 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
@ -108,7 +108,7 @@ public class CloudSigmaComputeServiceContextModule
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Cache<String, DriveInfo> cache(GetDrive getDrive) {
|
protected LoadingCache<String, DriveInfo> cache(GetDrive getDrive) {
|
||||||
return CacheBuilder.newBuilder().build(getDrive);
|
return CacheBuilder.newBuilder().build(getDrive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -114,10 +114,10 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final Cache<String, DriveInfo> cache;
|
private final LoadingCache<String, DriveInfo> cache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DeviceToVolume(Cache<String, DriveInfo> cache) {
|
public DeviceToVolume(LoadingCache<String, DriveInfo> cache) {
|
||||||
this.cache = checkNotNull(cache, "cache");
|
this.cache = checkNotNull(cache, "cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final Cache<String, DriveInfo> cache;
|
private final LoadingCache<String, DriveInfo> cache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GetImageIdFromServer(Cache<String, DriveInfo> cache) {
|
public GetImageIdFromServer(LoadingCache<String, DriveInfo> cache) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExc
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -173,7 +173,7 @@ public class CloudStackComputeServiceContextModule
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Cache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine(
|
protected LoadingCache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine(
|
||||||
CacheLoader<Long, Set<IPForwardingRule>> getIPForwardingRules) {
|
CacheLoader<Long, Set<IPForwardingRule>> getIPForwardingRules) {
|
||||||
return CacheBuilder.newBuilder().build(getIPForwardingRules);
|
return CacheBuilder.newBuilder().build(getIPForwardingRules);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
|
@ -74,13 +74,13 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
||||||
private final FindLocationForVirtualMachine findLocationForVirtualMachine;
|
private final FindLocationForVirtualMachine findLocationForVirtualMachine;
|
||||||
private final FindHardwareForVirtualMachine findHardwareForVirtualMachine;
|
private final FindHardwareForVirtualMachine findHardwareForVirtualMachine;
|
||||||
private final FindImageForVirtualMachine findImageForVirtualMachine;
|
private final FindImageForVirtualMachine findImageForVirtualMachine;
|
||||||
private final Cache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine;
|
private final LoadingCache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
VirtualMachineToNodeMetadata(FindLocationForVirtualMachine findLocationForVirtualMachine,
|
VirtualMachineToNodeMetadata(FindLocationForVirtualMachine findLocationForVirtualMachine,
|
||||||
FindHardwareForVirtualMachine findHardwareForVirtualMachine,
|
FindHardwareForVirtualMachine findHardwareForVirtualMachine,
|
||||||
FindImageForVirtualMachine findImageForVirtualMachine,
|
FindImageForVirtualMachine findImageForVirtualMachine,
|
||||||
Cache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine) {
|
LoadingCache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine) {
|
||||||
this.findLocationForVirtualMachine = checkNotNull(findLocationForVirtualMachine, "findLocationForVirtualMachine");
|
this.findLocationForVirtualMachine = checkNotNull(findLocationForVirtualMachine, "findLocationForVirtualMachine");
|
||||||
this.findHardwareForVirtualMachine = checkNotNull(findHardwareForVirtualMachine, "findHardwareForVirtualMachine");
|
this.findHardwareForVirtualMachine = checkNotNull(findHardwareForVirtualMachine, "findHardwareForVirtualMachine");
|
||||||
this.findImageForVirtualMachine = checkNotNull(findImageForVirtualMachine, "findImageForVirtualMachine");
|
this.findImageForVirtualMachine = checkNotNull(findImageForVirtualMachine, "findImageForVirtualMachine");
|
||||||
|
|
|
@ -61,7 +61,7 @@ import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -86,7 +86,7 @@ public class CloudStackComputeServiceAdapter implements
|
||||||
private final BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult;
|
private final BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult;
|
||||||
private final Factory staticNATVMInNetwork;
|
private final Factory staticNATVMInNetwork;
|
||||||
private final CreatePortForwardingRulesForIP setupPortForwardingRulesForIP;
|
private final CreatePortForwardingRulesForIP setupPortForwardingRulesForIP;
|
||||||
private final Cache<Long, Set<IPForwardingRule>> vmToRules;
|
private final LoadingCache<Long, Set<IPForwardingRule>> vmToRules;
|
||||||
private final Map<String, Credentials> credentialStore;
|
private final Map<String, Credentials> credentialStore;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -94,7 +94,7 @@ public class CloudStackComputeServiceAdapter implements
|
||||||
@Memoized Supplier<Map<Long, Network>> networkSupplier,
|
@Memoized Supplier<Map<Long, Network>> networkSupplier,
|
||||||
BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult,
|
BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult,
|
||||||
StaticNATVirtualMachineInNetwork.Factory staticNATVMInNetwork,
|
StaticNATVirtualMachineInNetwork.Factory staticNATVMInNetwork,
|
||||||
CreatePortForwardingRulesForIP setupPortForwardingRulesForIP, Cache<Long, Set<IPForwardingRule>> vmToRules,
|
CreatePortForwardingRulesForIP setupPortForwardingRulesForIP, LoadingCache<Long, Set<IPForwardingRule>> vmToRules,
|
||||||
Map<String, Credentials> credentialStore) {
|
Map<String, Credentials> credentialStore) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
this.jobComplete = checkNotNull(jobComplete, "jobComplete");
|
this.jobComplete = checkNotNull(jobComplete, "jobComplete");
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.jclouds.cloudstack.strategy.BlockUntilJobCompletesAndReturnResult;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -54,12 +54,12 @@ public class CreatePortForwardingRulesForIP {
|
||||||
|
|
||||||
private final CloudStackClient client;
|
private final CloudStackClient client;
|
||||||
private final BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult;
|
private final BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult;
|
||||||
private final Cache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine;
|
private final LoadingCache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CreatePortForwardingRulesForIP(CloudStackClient client,
|
public CreatePortForwardingRulesForIP(CloudStackClient client,
|
||||||
BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult,
|
BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult,
|
||||||
Cache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine) {
|
LoadingCache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
this.blockUntilJobCompletesAndReturnResult = checkNotNull(blockUntilJobCompletesAndReturnResult,
|
this.blockUntilJobCompletesAndReturnResult = checkNotNull(blockUntilJobCompletesAndReturnResult,
|
||||||
"blockUntilJobCompletesAndReturnResult");
|
"blockUntilJobCompletesAndReturnResult");
|
||||||
|
|
|
@ -67,7 +67,7 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -119,7 +119,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Cache<Long, Set<IPForwardingRule>> getIPForwardingRuleByVirtualMachine(
|
protected LoadingCache<Long, Set<IPForwardingRule>> getIPForwardingRuleByVirtualMachine(
|
||||||
GetIPForwardingRulesByVirtualMachine getIPForwardingRule) {
|
GetIPForwardingRulesByVirtualMachine getIPForwardingRule) {
|
||||||
return CacheBuilder.newBuilder().build(getIPForwardingRule);
|
return CacheBuilder.newBuilder().build(getIPForwardingRule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||||
|
@ -81,7 +81,7 @@ import com.google.common.collect.ImmutableMultimap.Builder;
|
||||||
public class EC2ComputeService extends BaseComputeService {
|
public class EC2ComputeService extends BaseComputeService {
|
||||||
private final EC2Client ec2Client;
|
private final EC2Client ec2Client;
|
||||||
private final ConcurrentMap<RegionAndName, KeyPair> credentialsMap;
|
private final ConcurrentMap<RegionAndName, KeyPair> credentialsMap;
|
||||||
private final Cache<RegionAndName, String> securityGroupMap;
|
private final LoadingCache<RegionAndName, String> securityGroupMap;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2ComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
|
protected EC2ComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
|
||||||
|
@ -98,7 +98,7 @@ public class EC2ComputeService extends BaseComputeService {
|
||||||
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
|
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
|
||||||
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
|
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, EC2Client ec2Client,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, EC2Client ec2Client,
|
||||||
ConcurrentMap<RegionAndName, KeyPair> credentialsMap, @Named("SECURITY") Cache<RegionAndName, String> securityGroupMap) {
|
ConcurrentMap<RegionAndName, KeyPair> credentialsMap, @Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap) {
|
||||||
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
|
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
|
||||||
runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, startNodeStrategy, stopNodeStrategy,
|
runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, startNodeStrategy, stopNodeStrategy,
|
||||||
templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended,
|
templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended,
|
||||||
|
|
|
@ -44,7 +44,7 @@ import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
@ -81,7 +81,7 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
|
||||||
@Override
|
@Override
|
||||||
protected Supplier<Set<? extends Image>> supplyNonParsingImageCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
protected Supplier<Set<? extends Image>> supplyNonParsingImageCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
final Supplier<Set<? extends Image>> imageSupplier, Injector injector) {
|
final Supplier<Set<? extends Image>> imageSupplier, Injector injector) {
|
||||||
final Supplier<Cache<RegionAndName, ? extends Image>> cache = injector.getInstance(Key.get(new TypeLiteral<Supplier<Cache<RegionAndName, ? extends Image>>>() {}));
|
final Supplier<LoadingCache<RegionAndName, ? extends Image>> cache = injector.getInstance(Key.get(new TypeLiteral<Supplier<LoadingCache<RegionAndName, ? extends Image>>>() {}));
|
||||||
return new Supplier<Set<? extends Image>>() {
|
return new Supplier<Set<? extends Image>>() {
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Image> get() {
|
public Set<? extends Image> get() {
|
||||||
|
@ -92,7 +92,7 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Cache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
|
protected Supplier<LoadingCache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
|
||||||
final RegionAndNameToImageSupplier supplier) {
|
final RegionAndNameToImageSupplier supplier) {
|
||||||
return supplier;
|
return supplier;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ import org.jclouds.rest.internal.RestContextImpl;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -128,7 +128,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Cache<RunningInstance, Credentials> credentialsMap(CacheLoader<RunningInstance, Credentials> in) {
|
protected LoadingCache<RunningInstance, Credentials> credentialsMap(CacheLoader<RunningInstance, Credentials> in) {
|
||||||
return CacheBuilder.newBuilder().build(in);
|
return CacheBuilder.newBuilder().build(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("SECURITY")
|
@Named("SECURITY")
|
||||||
protected Cache<RegionAndName, String> securityGroupMap(CacheLoader<RegionAndName, String> in) {
|
protected LoadingCache<RegionAndName, String> securityGroupMap(CacheLoader<RegionAndName, String> in) {
|
||||||
return CacheBuilder.newBuilder().build(in);
|
return CacheBuilder.newBuilder().build(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.ec2.domain.RunningInstance;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,11 +44,11 @@ import com.google.common.cache.CacheLoader;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class CredentialsForInstance extends CacheLoader<RunningInstance, Credentials> {
|
public class CredentialsForInstance extends CacheLoader<RunningInstance, Credentials> {
|
||||||
private final ConcurrentMap<RegionAndName, KeyPair> credentialsMap;
|
private final ConcurrentMap<RegionAndName, KeyPair> credentialsMap;
|
||||||
private final Supplier<Cache<RegionAndName, ? extends Image>> imageMap;
|
private final Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CredentialsForInstance(ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
|
CredentialsForInstance(ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
|
||||||
Supplier<Cache<RegionAndName, ? extends Image>> imageMap) {
|
Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap) {
|
||||||
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
||||||
this.imageMap = imageMap;
|
this.imageMap = imageMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,8 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -75,13 +76,13 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
|
|
||||||
protected final Supplier<Set<? extends Location>> locations;
|
protected final Supplier<Set<? extends Location>> locations;
|
||||||
protected final Supplier<Set<? extends Hardware>> hardware;
|
protected final Supplier<Set<? extends Hardware>> hardware;
|
||||||
protected final Supplier<Cache<RegionAndName, ? extends Image>> imageMap;
|
protected final Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap;
|
||||||
protected final Map<String, Credentials> credentialStore;
|
protected final Map<String, Credentials> credentialStore;
|
||||||
protected final Map<InstanceState, NodeState> instanceToNodeState;
|
protected final Map<InstanceState, NodeState> instanceToNodeState;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected RunningInstanceToNodeMetadata(Map<InstanceState, NodeState> instanceToNodeState,
|
protected RunningInstanceToNodeMetadata(Map<InstanceState, NodeState> instanceToNodeState,
|
||||||
Map<String, Credentials> credentialStore, Supplier<Cache<RegionAndName, ? extends Image>> imageMap,
|
Map<String, Credentials> credentialStore, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware) {
|
@Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware) {
|
||||||
this.locations = checkNotNull(locations, "locations");
|
this.locations = checkNotNull(locations, "locations");
|
||||||
this.hardware = checkNotNull(hardware, "hardware");
|
this.hardware = checkNotNull(hardware, "hardware");
|
||||||
|
@ -133,7 +134,7 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
Image image = imageMap.get().getUnchecked(regionAndName);
|
Image image = imageMap.get().getUnchecked(regionAndName);
|
||||||
if (image != null)
|
if (image != null)
|
||||||
builder.operatingSystem(image.getOperatingSystem());
|
builder.operatingSystem(image.getOperatingSystem());
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
logger.debug("image not found for %s: %s", regionAndName, e);
|
logger.debug("image not found for %s: %s", regionAndName, e);
|
||||||
} catch (UncheckedExecutionException e) {
|
} catch (UncheckedExecutionException e) {
|
||||||
logger.debug("error getting image for %s: %s", regionAndName, e);
|
logger.debug("error getting image for %s: %s", regionAndName, e);
|
||||||
|
|
|
@ -39,7 +39,8 @@ import org.jclouds.ec2.compute.domain.RegionAndName;
|
||||||
import org.jclouds.util.Throwables2;
|
import org.jclouds.util.Throwables2;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
|
|
||||||
|
@ -49,13 +50,13 @@ import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
*/
|
*/
|
||||||
public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
|
public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
|
||||||
|
|
||||||
private final Supplier<Cache<RegionAndName, ? extends Image>> lazyImageCache;
|
private final Supplier<LoadingCache<RegionAndName, ? extends Image>> lazyImageCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
protected EC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||||
Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
|
Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
|
||||||
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Supplier<Cache<RegionAndName, ? extends Image>> imageMap) {
|
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap) {
|
||||||
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider);
|
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider);
|
||||||
this.lazyImageCache = imageMap;
|
this.lazyImageCache = imageMap;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +81,7 @@ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
|
||||||
throw new NoSuchElementException(String.format("imageId(%s/%s) not found", key.getRegion(), key.getName()));
|
throw new NoSuchElementException(String.format("imageId(%s/%s) not found", key.getRegion(), key.getName()));
|
||||||
}
|
}
|
||||||
throw new NoSuchElementException(String.format("could not get imageId(%s/%s)", key.getRegion(), key.getName()));
|
throw new NoSuchElementException(String.format("could not get imageId(%s/%s)", key.getRegion(), key.getName()));
|
||||||
} catch (NullPointerException nex) {
|
} catch (CacheLoader.InvalidCacheLoadException nex) {
|
||||||
throw new NoSuchElementException(String.format("imageId(%s/%s) not found", key.getRegion(), key.getName()));
|
throw new NoSuchElementException(String.format("imageId(%s/%s) not found", key.getRegion(), key.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
|
||||||
|
@ -59,14 +59,14 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public final ConcurrentMap<RegionAndName, KeyPair> credentialsMap;
|
public final ConcurrentMap<RegionAndName, KeyPair> credentialsMap;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public final Cache<RegionAndName, String> securityGroupMap;
|
public final LoadingCache<RegionAndName, String> securityGroupMap;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public final Provider<RunInstancesOptions> optionsProvider;
|
public final Provider<RunInstancesOptions> optionsProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions(Function<RegionAndName, KeyPair> makeKeyPair,
|
public CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions(Function<RegionAndName, KeyPair> makeKeyPair,
|
||||||
ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
|
ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
|
||||||
@Named("SECURITY") Cache<RegionAndName, String> securityGroupMap,
|
@Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap,
|
||||||
Provider<RunInstancesOptions> optionsProvider) {
|
Provider<RunInstancesOptions> optionsProvider) {
|
||||||
this.makeKeyPair = checkNotNull(makeKeyPair, "makeKeyPair");
|
this.makeKeyPair = checkNotNull(makeKeyPair, "makeKeyPair");
|
||||||
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
||||||
|
|
|
@ -52,7 +52,7 @@ import org.jclouds.logging.Logger;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
@ -78,7 +78,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final ComputeUtils utils;
|
final ComputeUtils utils;
|
||||||
final InstancePresent instancePresent;
|
final InstancePresent instancePresent;
|
||||||
final Cache<RunningInstance, Credentials> instanceToCredentials;
|
final LoadingCache<RunningInstance, Credentials> instanceToCredentials;
|
||||||
final Map<String, Credentials> credentialStore;
|
final Map<String, Credentials> credentialStore;
|
||||||
final Provider<TemplateBuilder> templateBuilderProvider;
|
final Provider<TemplateBuilder> templateBuilderProvider;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen
|
||||||
Provider<TemplateBuilder> templateBuilderProvider,
|
Provider<TemplateBuilder> templateBuilderProvider,
|
||||||
CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
|
CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
|
||||||
InstancePresent instancePresent, Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
|
InstancePresent instancePresent, Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
|
||||||
Cache<RunningInstance, Credentials> instanceToCredentials, Map<String, Credentials> credentialStore,
|
LoadingCache<RunningInstance, Credentials> instanceToCredentials, Map<String, Credentials> credentialStore,
|
||||||
ComputeUtils utils) {
|
ComputeUtils utils) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
this.templateBuilderProvider = checkNotNull(templateBuilderProvider, "templateBuilderProvider");
|
this.templateBuilderProvider = checkNotNull(templateBuilderProvider, "templateBuilderProvider");
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -65,11 +65,11 @@ public class EC2ImageSupplier implements Supplier<Set<? extends Image>> {
|
||||||
private final DescribeImagesParallel describer;
|
private final DescribeImagesParallel describer;
|
||||||
private final String[] amiOwners;
|
private final String[] amiOwners;
|
||||||
private final EC2ImageParser parser;
|
private final EC2ImageParser parser;
|
||||||
private final Supplier<Cache<RegionAndName, ? extends Image>> cache;
|
private final Supplier<LoadingCache<RegionAndName, ? extends Image>> cache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2ImageSupplier(@Region Set<String> regions, DescribeImagesParallel describer,
|
protected EC2ImageSupplier(@Region Set<String> regions, DescribeImagesParallel describer,
|
||||||
@Named(PROPERTY_EC2_AMI_OWNERS) String[] amiOwners, Supplier<Cache<RegionAndName, ? extends Image>> cache,
|
@Named(PROPERTY_EC2_AMI_OWNERS) String[] amiOwners, Supplier<LoadingCache<RegionAndName, ? extends Image>> cache,
|
||||||
EC2ImageParser parser) {
|
EC2ImageParser parser) {
|
||||||
this.regions = regions;
|
this.regions = regions;
|
||||||
this.describer = describer;
|
this.describer = describer;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.ec2.compute.domain.RegionAndName;
|
import org.jclouds.ec2.compute.domain.RegionAndName;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ import com.google.common.cache.CacheLoader;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class RegionAndNameToImageSupplier implements Supplier<Cache<RegionAndName, ? extends Image>> {
|
public class RegionAndNameToImageSupplier implements Supplier<LoadingCache<RegionAndName, ? extends Image>> {
|
||||||
private final Cache<RegionAndName, Image> cache;
|
private final LoadingCache<RegionAndName, Image> cache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected RegionAndNameToImageSupplier(CacheLoader<RegionAndName, Image> regionAndIdToImage,
|
protected RegionAndNameToImageSupplier(CacheLoader<RegionAndName, Image> regionAndIdToImage,
|
||||||
|
@ -49,7 +49,7 @@ public class RegionAndNameToImageSupplier implements Supplier<Cache<RegionAndNam
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cache<RegionAndName, ? extends Image> get() {
|
public LoadingCache<RegionAndName, ? extends Image> get() {
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ 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.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -169,7 +169,7 @@ public class EC2TemplateBuilderTest {
|
||||||
new RegionAndName(image.getLocation().getId(), image.getProviderId()), image);
|
new RegionAndName(image.getLocation().getId(), image.getProviderId()), image);
|
||||||
|
|
||||||
// weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
|
// weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
|
||||||
Supplier<Cache<RegionAndName, ? extends Image>> imageCache = Suppliers.<Cache<RegionAndName, ? extends Image>> ofInstance(
|
Supplier<LoadingCache<RegionAndName, ? extends Image>> imageCache = Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(
|
||||||
CacheBuilder.newBuilder().<RegionAndName,Image>build(CacheLoader.from(Functions.forMap(imageMap))));
|
CacheBuilder.newBuilder().<RegionAndName,Image>build(CacheLoader.from(Functions.forMap(imageMap))));
|
||||||
|
|
||||||
Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/cc-image").build();
|
Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/cc-image").build();
|
||||||
|
@ -197,14 +197,14 @@ public class EC2TemplateBuilderTest {
|
||||||
// weird compilation error means have to cast this - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
|
// weird compilation error means have to cast this - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ImmutableMap<RegionAndName, Image> imageMap = (ImmutableMap<RegionAndName, Image>) ImagesToRegionAndIdMap.imagesToMap(images.get());
|
ImmutableMap<RegionAndName, Image> imageMap = (ImmutableMap<RegionAndName, Image>) ImagesToRegionAndIdMap.imagesToMap(images.get());
|
||||||
Supplier<Cache<RegionAndName, ? extends Image>> imageCache = Suppliers.<Cache<RegionAndName, ? extends Image>> ofInstance(
|
Supplier<LoadingCache<RegionAndName, ? extends Image>> imageCache = Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(
|
||||||
CacheBuilder.newBuilder().<RegionAndName,Image>build(CacheLoader.from(Functions.forMap(imageMap))));
|
CacheBuilder.newBuilder().<RegionAndName,Image>build(CacheLoader.from(Functions.forMap(imageMap))));
|
||||||
|
|
||||||
return newTemplateBuilder(images, imageCache);
|
return newTemplateBuilder(images, imageCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private TemplateBuilder newTemplateBuilder(Supplier<Set<? extends Image>> images, Supplier<Cache<RegionAndName, ? extends Image>> imageCache) {
|
private TemplateBuilder newTemplateBuilder(Supplier<Set<? extends Image>> images, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageCache) {
|
||||||
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
||||||
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
||||||
TemplateOptions defaultOptions = createMock(TemplateOptions.class);
|
TemplateOptions defaultOptions = createMock(TemplateOptions.class);
|
||||||
|
|
|
@ -47,7 +47,7 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -201,7 +201,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Cache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(nullReturningFunction);
|
LoadingCache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(nullReturningFunction);
|
||||||
|
|
||||||
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small32().build()), ImmutableSet
|
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small32().build()), ImmutableSet
|
||||||
.of(provider), ImmutableMap.<String, Credentials> of(),
|
.of(provider), ImmutableMap.<String, Credentials> of(),
|
||||||
|
@ -235,13 +235,13 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
return ImagesToRegionAndIdMap.imagesToMap(images).get(from);
|
return ImagesToRegionAndIdMap.imagesToMap(images).get(from);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Cache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(getRealImage);
|
LoadingCache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(getRealImage);
|
||||||
return createNodeParser(hardware, locations, credentialStore, instanceToNodeState, instanceToImage);
|
return createNodeParser(hardware, locations, credentialStore, instanceToNodeState, instanceToImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
private RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
||||||
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
|
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
|
||||||
Map<InstanceState, NodeState> instanceToNodeState, Cache<RegionAndName, Image> instanceToImage) {
|
Map<InstanceState, NodeState> instanceToNodeState, LoadingCache<RegionAndName, Image> instanceToImage) {
|
||||||
Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
|
Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -259,7 +259,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
};
|
};
|
||||||
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(instanceToNodeState, credentialStore,
|
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(instanceToNodeState, credentialStore,
|
||||||
Suppliers.<Cache<RegionAndName, ? extends Image>> ofInstance(instanceToImage), locationSupplier,
|
Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(instanceToImage), locationSupplier,
|
||||||
hardwareSupplier);
|
hardwareSupplier);
|
||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.testng.annotations.Test;
|
||||||
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.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -73,7 +73,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
||||||
@Memoized Supplier<Set<? extends Hardware>> sizes, Location defaultLocation,
|
@Memoized Supplier<Set<? extends Hardware>> sizes, Location defaultLocation,
|
||||||
Provider<TemplateOptions> optionsProvider, Provider<TemplateBuilder> templateBuilderProvider) {
|
Provider<TemplateOptions> optionsProvider, Provider<TemplateBuilder> templateBuilderProvider) {
|
||||||
|
|
||||||
Cache<RegionAndName, ? extends Image> imageMap;
|
LoadingCache<RegionAndName, ? extends Image> imageMap;
|
||||||
if (knownImage != null) {
|
if (knownImage != null) {
|
||||||
final RegionAndName knownRegionAndName = new RegionAndName(knownImage.getLocation().getId(), knownImage.getProviderId());
|
final RegionAndName knownRegionAndName = new RegionAndName(knownImage.getLocation().getId(), knownImage.getProviderId());
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EC2TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(defaultLocation),
|
return new EC2TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(defaultLocation),
|
||||||
optionsProvider, templateBuilderProvider, Suppliers.<Cache<RegionAndName, ? extends Image>>ofInstance(imageMap));
|
optionsProvider, templateBuilderProvider, Suppliers.<LoadingCache<RegionAndName, ? extends Image>>ofInstance(imageMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -48,7 +48,7 @@ import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
||||||
private CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions setupStrategy() {
|
private CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions setupStrategy() {
|
||||||
Function<RegionAndName, KeyPair> makeKeyPair = createMock(Function.class);
|
Function<RegionAndName, KeyPair> makeKeyPair = createMock(Function.class);
|
||||||
ConcurrentMap<RegionAndName, KeyPair> credentialsMap = createMock(ConcurrentMap.class);
|
ConcurrentMap<RegionAndName, KeyPair> credentialsMap = createMock(ConcurrentMap.class);
|
||||||
Cache<RegionAndName, String> securityGroupMap = createMock(Cache.class);
|
LoadingCache<RegionAndName, String> securityGroupMap = createMock(LoadingCache.class);
|
||||||
return new CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions(makeKeyPair, credentialsMap,
|
return new CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions(makeKeyPair, credentialsMap,
|
||||||
securityGroupMap, OPTIONS_PROVIDER);
|
securityGroupMap, OPTIONS_PROVIDER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ import org.jclouds.ec2.options.RunInstancesOptions;
|
||||||
import org.jclouds.ec2.services.InstanceClient;
|
import org.jclouds.ec2.services.InstanceClient;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
@ -222,7 +222,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest {
|
||||||
CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize = createMock(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class);
|
CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize = createMock(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class);
|
||||||
InstancePresent instancePresent = createMock(InstancePresent.class);
|
InstancePresent instancePresent = createMock(InstancePresent.class);
|
||||||
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata = createMock(RunningInstanceToNodeMetadata.class);
|
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata = createMock(RunningInstanceToNodeMetadata.class);
|
||||||
Cache<RunningInstance, Credentials> instanceToCredentials = createMock(Cache.class);
|
LoadingCache<RunningInstance, Credentials> instanceToCredentials = createMock(LoadingCache.class);
|
||||||
Map<String, Credentials> credentialStore = createMock(Map.class);
|
Map<String, Credentials> credentialStore = createMock(Map.class);
|
||||||
ComputeUtils utils = createMock(ComputeUtils.class);
|
ComputeUtils utils = createMock(ComputeUtils.class);
|
||||||
return new EC2CreateNodesInGroupThenAddToSet(client, Providers.<TemplateBuilder> of(template),
|
return new EC2CreateNodesInGroupThenAddToSet(client, Providers.<TemplateBuilder> of(template),
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.jclouds.rest.RestContextSpec;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -68,7 +68,7 @@ public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
Cache<RegionAndName, Image> provide(){
|
LoadingCache<RegionAndName, Image> provide(){
|
||||||
return CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image>() {
|
return CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -61,7 +61,7 @@ import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
@ -79,7 +79,7 @@ public class ElasticStackComputeServiceAdapter implements
|
||||||
private final ElasticStackClient client;
|
private final ElasticStackClient client;
|
||||||
private final Predicate<DriveInfo> driveNotClaimed;
|
private final Predicate<DriveInfo> driveNotClaimed;
|
||||||
private final Map<String, WellKnownImage> preinstalledImages;
|
private final Map<String, WellKnownImage> preinstalledImages;
|
||||||
private final Cache<String, DriveInfo> cache;
|
private final LoadingCache<String, DriveInfo> cache;
|
||||||
private final JustProvider locationSupplier;
|
private final JustProvider locationSupplier;
|
||||||
private final String defaultVncPassword;
|
private final String defaultVncPassword;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
|
@ -90,7 +90,7 @@ public class ElasticStackComputeServiceAdapter implements
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ElasticStackComputeServiceAdapter(ElasticStackClient client, Predicate<DriveInfo> driveNotClaimed,
|
public ElasticStackComputeServiceAdapter(ElasticStackClient client, Predicate<DriveInfo> driveNotClaimed,
|
||||||
JustProvider locationSupplier, Map<String, WellKnownImage> preinstalledImages, Cache<String, DriveInfo> cache,
|
JustProvider locationSupplier, Map<String, WellKnownImage> preinstalledImages, LoadingCache<String, DriveInfo> cache,
|
||||||
@Named(ElasticStackConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
|
@Named(ElasticStackConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
|
|
|
@ -59,7 +59,7 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -106,7 +106,7 @@ public class ElasticStackComputeServiceContextModule
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Cache<String, DriveInfo> cache(GetDrive getDrive) {
|
protected LoadingCache<String, DriveInfo> cache(GetDrive getDrive) {
|
||||||
return CacheBuilder.newBuilder().build(getDrive);
|
return CacheBuilder.newBuilder().build(getDrive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -114,10 +114,10 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final Cache<String, DriveInfo> cache;
|
private final LoadingCache<String, DriveInfo> cache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DeviceToVolume(Cache<String, DriveInfo> cache) {
|
public DeviceToVolume(LoadingCache<String, DriveInfo> cache) {
|
||||||
this.cache = checkNotNull(cache, "cache");
|
this.cache = checkNotNull(cache, "cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final Cache<String, DriveInfo> cache;
|
private final LoadingCache<String, DriveInfo> cache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GetImageIdFromServer(Cache<String, DriveInfo> cache) {
|
public GetImageIdFromServer(LoadingCache<String, DriveInfo> cache) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,11 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import sun.awt.image.ImageWatched;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Dmitri Babaev
|
* @author Dmitri Babaev
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.s3.blobstore;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
@ -56,12 +55,12 @@ import org.jclouds.s3.blobstore.functions.ContainerToBucketListOptions;
|
||||||
import org.jclouds.s3.blobstore.functions.ObjectToBlob;
|
import org.jclouds.s3.blobstore.functions.ObjectToBlob;
|
||||||
import org.jclouds.s3.blobstore.functions.ObjectToBlobMetadata;
|
import org.jclouds.s3.blobstore.functions.ObjectToBlobMetadata;
|
||||||
import org.jclouds.s3.domain.AccessControlList;
|
import org.jclouds.s3.domain.AccessControlList;
|
||||||
import org.jclouds.s3.domain.AccessControlList.GroupGranteeURI;
|
|
||||||
import org.jclouds.s3.domain.AccessControlList.Permission;
|
|
||||||
import org.jclouds.s3.domain.BucketMetadata;
|
import org.jclouds.s3.domain.BucketMetadata;
|
||||||
import org.jclouds.s3.domain.CannedAccessPolicy;
|
import org.jclouds.s3.domain.CannedAccessPolicy;
|
||||||
import org.jclouds.s3.domain.ListBucketResponse;
|
import org.jclouds.s3.domain.ListBucketResponse;
|
||||||
import org.jclouds.s3.domain.ObjectMetadata;
|
import org.jclouds.s3.domain.ObjectMetadata;
|
||||||
|
import org.jclouds.s3.domain.AccessControlList.GroupGranteeURI;
|
||||||
|
import org.jclouds.s3.domain.AccessControlList.Permission;
|
||||||
import org.jclouds.s3.options.ListBucketOptions;
|
import org.jclouds.s3.options.ListBucketOptions;
|
||||||
import org.jclouds.s3.options.PutBucketOptions;
|
import org.jclouds.s3.options.PutBucketOptions;
|
||||||
import org.jclouds.s3.options.PutObjectOptions;
|
import org.jclouds.s3.options.PutObjectOptions;
|
||||||
|
@ -69,6 +68,8 @@ import org.jclouds.s3.util.S3Utils;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
private final BlobToObject blob2Object;
|
private final BlobToObject blob2Object;
|
||||||
private final ObjectToBlobMetadata object2BlobMd;
|
private final ObjectToBlobMetadata object2BlobMd;
|
||||||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||||
private final Map<String, AccessControlList> bucketAcls;
|
private final LoadingCache<String, AccessControlList> bucketAcls;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected S3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
protected S3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
||||||
|
@ -98,7 +99,7 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions,
|
BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions,
|
||||||
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd,
|
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd,
|
||||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider, Map<String, AccessControlList> bucketAcls) {
|
Provider<FetchBlobMetadata> fetchBlobMetadataProvider, LoadingCache<String, AccessControlList> bucketAcls) {
|
||||||
super(context, blobUtils, service, defaultLocation, locations);
|
super(context, blobUtils, service, defaultLocation, locations);
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.async = checkNotNull(async, "async");
|
this.async = checkNotNull(async, "async");
|
||||||
|
@ -233,11 +234,11 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
public ListenableFuture<String> putBlob(String container, Blob blob) {
|
public ListenableFuture<String> putBlob(String container, Blob blob) {
|
||||||
PutObjectOptions options = new PutObjectOptions();
|
PutObjectOptions options = new PutObjectOptions();
|
||||||
try {
|
try {
|
||||||
AccessControlList acl = bucketAcls.get(container);
|
AccessControlList acl = bucketAcls.getUnchecked(container);
|
||||||
if (acl != null && acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
|
if (acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
|
||||||
options.withAcl(CannedAccessPolicy.PUBLIC_READ);
|
options.withAcl(CannedAccessPolicy.PUBLIC_READ);
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
// MapMaker
|
// nulls not permitted from cache loader
|
||||||
}
|
}
|
||||||
return async.putObject(container, blob2Object.apply(blob), options);
|
return async.putObject(container, blob2Object.apply(blob), options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.s3.blobstore;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -51,10 +50,10 @@ import org.jclouds.s3.blobstore.functions.ContainerToBucketListOptions;
|
||||||
import org.jclouds.s3.blobstore.functions.ObjectToBlob;
|
import org.jclouds.s3.blobstore.functions.ObjectToBlob;
|
||||||
import org.jclouds.s3.blobstore.functions.ObjectToBlobMetadata;
|
import org.jclouds.s3.blobstore.functions.ObjectToBlobMetadata;
|
||||||
import org.jclouds.s3.domain.AccessControlList;
|
import org.jclouds.s3.domain.AccessControlList;
|
||||||
import org.jclouds.s3.domain.AccessControlList.GroupGranteeURI;
|
|
||||||
import org.jclouds.s3.domain.AccessControlList.Permission;
|
|
||||||
import org.jclouds.s3.domain.BucketMetadata;
|
import org.jclouds.s3.domain.BucketMetadata;
|
||||||
import org.jclouds.s3.domain.CannedAccessPolicy;
|
import org.jclouds.s3.domain.CannedAccessPolicy;
|
||||||
|
import org.jclouds.s3.domain.AccessControlList.GroupGranteeURI;
|
||||||
|
import org.jclouds.s3.domain.AccessControlList.Permission;
|
||||||
import org.jclouds.s3.options.ListBucketOptions;
|
import org.jclouds.s3.options.ListBucketOptions;
|
||||||
import org.jclouds.s3.options.PutBucketOptions;
|
import org.jclouds.s3.options.PutBucketOptions;
|
||||||
import org.jclouds.s3.options.PutObjectOptions;
|
import org.jclouds.s3.options.PutObjectOptions;
|
||||||
|
@ -63,6 +62,8 @@ import org.jclouds.util.Assertions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +81,7 @@ public class S3BlobStore extends BaseBlobStore {
|
||||||
private final ObjectToBlobMetadata object2BlobMd;
|
private final ObjectToBlobMetadata object2BlobMd;
|
||||||
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
||||||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||||
private final Map<String, AccessControlList> bucketAcls;
|
private final LoadingCache<String, AccessControlList> bucketAcls;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected S3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
protected S3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
|
||||||
|
@ -88,7 +89,7 @@ public class S3BlobStore extends BaseBlobStore {
|
||||||
BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions,
|
BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions,
|
||||||
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd,
|
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd,
|
||||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider, Map<String, AccessControlList> bucketAcls) {
|
Provider<FetchBlobMetadata> fetchBlobMetadataProvider, LoadingCache<String, AccessControlList> bucketAcls) {
|
||||||
super(context, blobUtils, defaultLocation, locations);
|
super(context, blobUtils, defaultLocation, locations);
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.sync = checkNotNull(sync, "sync");
|
this.sync = checkNotNull(sync, "sync");
|
||||||
|
@ -233,11 +234,11 @@ public class S3BlobStore extends BaseBlobStore {
|
||||||
public String putBlob(String container, Blob blob) {
|
public String putBlob(String container, Blob blob) {
|
||||||
PutObjectOptions options = new PutObjectOptions();
|
PutObjectOptions options = new PutObjectOptions();
|
||||||
try {
|
try {
|
||||||
AccessControlList acl = bucketAcls.get(container);
|
AccessControlList acl = bucketAcls.getUnchecked(container);
|
||||||
if (acl != null && acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
|
if (acl != null && acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
|
||||||
options.withAcl(CannedAccessPolicy.PUBLIC_READ);
|
options.withAcl(CannedAccessPolicy.PUBLIC_READ);
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
// MapMaker
|
// nulls not permitted from cache loader
|
||||||
}
|
}
|
||||||
return sync.putObject(container, blob2Object.apply(blob), options);
|
return sync.putObject(container, blob2Object.apply(blob), options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.s3.blobstore.config;
|
package org.jclouds.s3.blobstore.config;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -42,7 +41,9 @@ import org.jclouds.s3.domain.AccessControlList;
|
||||||
import org.jclouds.s3.domain.BucketMetadata;
|
import org.jclouds.s3.domain.BucketMetadata;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
|
@ -79,10 +80,11 @@ public class S3BlobStoreContextModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Map<String, AccessControlList> bucketAcls(final S3Client client) {
|
protected LoadingCache<String, AccessControlList> bucketAcls(final S3Client client) {
|
||||||
return new MapMaker().expireAfterWrite(30, TimeUnit.SECONDS).makeComputingMap(
|
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(
|
||||||
new Function<String, AccessControlList>() {
|
new CacheLoader<String, AccessControlList>() {
|
||||||
public AccessControlList apply(String bucketName) {
|
@Override
|
||||||
|
public AccessControlList load(String bucketName) {
|
||||||
return client.getBucketACL(bucketName);
|
return client.getBucketACL(bucketName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.s3.blobstore.functions;
|
package org.jclouds.s3.blobstore.functions;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -34,6 +32,8 @@ import org.jclouds.s3.domain.AccessControlList.GroupGranteeURI;
|
||||||
import org.jclouds.s3.domain.AccessControlList.Permission;
|
import org.jclouds.s3.domain.AccessControlList.Permission;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -41,11 +41,11 @@ import com.google.common.base.Function;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ObjectToBlobMetadata implements Function<ObjectMetadata, MutableBlobMetadata> {
|
public class ObjectToBlobMetadata implements Function<ObjectMetadata, MutableBlobMetadata> {
|
||||||
private final IfDirectoryReturnNameStrategy ifDirectoryReturnName;
|
private final IfDirectoryReturnNameStrategy ifDirectoryReturnName;
|
||||||
private final Map<String, AccessControlList> bucketAcls;
|
private final LoadingCache<String, AccessControlList> bucketAcls;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ObjectToBlobMetadata(IfDirectoryReturnNameStrategy ifDirectoryReturnName,
|
public ObjectToBlobMetadata(IfDirectoryReturnNameStrategy ifDirectoryReturnName,
|
||||||
Map<String, AccessControlList> bucketAcls) {
|
LoadingCache<String, AccessControlList> bucketAcls) {
|
||||||
this.ifDirectoryReturnName = ifDirectoryReturnName;
|
this.ifDirectoryReturnName = ifDirectoryReturnName;
|
||||||
this.bucketAcls = bucketAcls;
|
this.bucketAcls = bucketAcls;
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,11 @@ public class ObjectToBlobMetadata implements Function<ObjectMetadata, MutableBlo
|
||||||
MutableBlobMetadata to = new MutableBlobMetadataImpl();
|
MutableBlobMetadata to = new MutableBlobMetadataImpl();
|
||||||
HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
|
HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
|
||||||
try {
|
try {
|
||||||
AccessControlList bucketAcl = bucketAcls.get(from.getBucket());
|
AccessControlList bucketAcl = bucketAcls.getUnchecked(from.getBucket());
|
||||||
if (bucketAcl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
|
if (bucketAcl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
|
||||||
to.setPublicUri(from.getUri());
|
to.setPublicUri(from.getUri());
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
// MapMaker cannot return null, but a call to get acls can
|
// nulls not permitted from cache loader
|
||||||
}
|
}
|
||||||
to.setUri(from.getUri());
|
to.setUri(from.getUri());
|
||||||
to.setContainer(from.getBucket());
|
to.setContainer(from.getBucket());
|
||||||
|
|
|
@ -109,7 +109,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>10.0.1</version>
|
<version>11.0-rc1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,12 @@ import java.util.concurrent.TimeUnit;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.internal.ClassMethodArgs;
|
import org.jclouds.internal.ClassMethodArgs;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.util.Throwables2;
|
import org.jclouds.util.Throwables2;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
@ -50,12 +48,11 @@ import com.google.inject.ProvisionException;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class SyncProxy implements InvocationHandler {
|
public class SyncProxy implements InvocationHandler {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T proxy(Class<T> clazz, Object async,
|
public static <T> T proxy(Class<T> clazz, Object async,
|
||||||
@Named("sync") Cache<ClassMethodArgs, Object> delegateMap,
|
@Named("sync") LoadingCache<ClassMethodArgs, Object> delegateMap,
|
||||||
Map<Class<?>, Class<?>> sync2Async, Map<String, Long> timeouts) throws IllegalArgumentException, SecurityException,
|
Map<Class<?>, Class<?>> sync2Async, Map<String, Long> timeouts) throws IllegalArgumentException, SecurityException,
|
||||||
NoSuchMethodException {
|
NoSuchMethodException {
|
||||||
return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz },
|
return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz },
|
||||||
|
@ -67,13 +64,13 @@ public class SyncProxy implements InvocationHandler {
|
||||||
private final Map<Method, Method> methodMap;
|
private final Map<Method, Method> methodMap;
|
||||||
private final Map<Method, Method> syncMethodMap;
|
private final Map<Method, Method> syncMethodMap;
|
||||||
private final Map<Method, Long> timeoutMap;
|
private final Map<Method, Long> timeoutMap;
|
||||||
private final Cache<ClassMethodArgs, Object> delegateMap;
|
private final LoadingCache<ClassMethodArgs, Object> delegateMap;
|
||||||
private final Map<Class<?>, Class<?>> sync2Async;
|
private final Map<Class<?>, Class<?>> sync2Async;
|
||||||
private static final Set<Method> objectMethods = ImmutableSet.of(Object.class.getMethods());
|
private static final Set<Method> objectMethods = ImmutableSet.copyOf(Object.class.getMethods());
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SyncProxy(Class<?> declaring, Object async,
|
private SyncProxy(Class<?> declaring, Object async,
|
||||||
@Named("sync") Cache<ClassMethodArgs, Object> delegateMap, Map<Class<?>,
|
@Named("sync") LoadingCache<ClassMethodArgs, Object> delegateMap, Map<Class<?>,
|
||||||
Class<?>> sync2Async, final Map<String, Long> timeouts)
|
Class<?>> sync2Async, final Map<String, Long> timeouts)
|
||||||
throws SecurityException, NoSuchMethodException {
|
throws SecurityException, NoSuchMethodException {
|
||||||
this.delegateMap = delegateMap;
|
this.delegateMap = delegateMap;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
@ -56,7 +56,7 @@ public class EnumTypeAdapterThatReturnsFromValue<T extends Enum<T>> implements J
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Cache<Class<?>, Method> classToConvert = CacheBuilder.newBuilder()
|
private final static LoadingCache<Class<?>, Method> classToConvert = CacheBuilder.newBuilder()
|
||||||
.build(new CacheLoader<Class<?>, Method>() {
|
.build(new CacheLoader<Class<?>, Method>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
import org.jclouds.internal.ClassMethodArgs;
|
import org.jclouds.internal.ClassMethodArgs;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
@ -59,8 +59,8 @@ public class ClientProvider<S, A> implements Provider<S> {
|
||||||
@Singleton
|
@Singleton
|
||||||
public S get() {
|
public S get() {
|
||||||
A client = (A) injector.getInstance(Key.get(asyncClientType));
|
A client = (A) injector.getInstance(Key.get(asyncClientType));
|
||||||
Cache<ClassMethodArgs, Object> delegateMap = injector.getInstance(Key.get(
|
LoadingCache<ClassMethodArgs, Object> delegateMap = injector.getInstance(Key.get(
|
||||||
new TypeLiteral<Cache<ClassMethodArgs, Object>>() {
|
new TypeLiteral<LoadingCache<ClassMethodArgs, Object>>() {
|
||||||
}, Names.named("sync")));
|
}, Names.named("sync")));
|
||||||
try {
|
try {
|
||||||
return (S) SyncProxy.proxy(syncClientType, client, delegateMap, sync2Async,
|
return (S) SyncProxy.proxy(syncClientType, client, delegateMap, sync2Async,
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
import org.jclouds.internal.ClassMethodArgs;
|
import org.jclouds.internal.ClassMethodArgs;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,13 +48,13 @@ import com.google.common.cache.CacheLoader;
|
||||||
public class CreateClientForCaller extends CacheLoader<ClassMethodArgs, Object> {
|
public class CreateClientForCaller extends CacheLoader<ClassMethodArgs, Object> {
|
||||||
@Inject
|
@Inject
|
||||||
Injector injector;
|
Injector injector;
|
||||||
private final Cache<ClassMethodArgs, Object> asyncMap;
|
private final LoadingCache<ClassMethodArgs, Object> asyncMap;
|
||||||
private final Provider<Cache<ClassMethodArgs, Object>> delegateMap;
|
private final Provider<LoadingCache<ClassMethodArgs, Object>> delegateMap;
|
||||||
Map<Class<?>, Class<?>> sync2Async;
|
Map<Class<?>, Class<?>> sync2Async;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CreateClientForCaller(@Named("async") Cache<ClassMethodArgs, Object> asyncMap,
|
CreateClientForCaller(@Named("async") LoadingCache<ClassMethodArgs, Object> asyncMap,
|
||||||
@Named("sync") Provider<Cache<ClassMethodArgs, Object>> delegateMap) {
|
@Named("sync") Provider<LoadingCache<ClassMethodArgs, Object>> delegateMap) {
|
||||||
this.asyncMap = asyncMap;
|
this.asyncMap = asyncMap;
|
||||||
this.delegateMap = delegateMap;
|
this.delegateMap = delegateMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.internal.RestContextImpl;
|
import org.jclouds.rest.internal.RestContextImpl;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
@ -125,7 +125,7 @@ public class RestClientModule<S, A> extends AbstractModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("sync")
|
@Named("sync")
|
||||||
Cache<ClassMethodArgs, Object> provideSyncDelegateMap(
|
LoadingCache<ClassMethodArgs, Object> provideSyncDelegateMap(
|
||||||
CreateClientForCaller createClientForCaller) {
|
CreateClientForCaller createClientForCaller) {
|
||||||
createClientForCaller.sync2Async = delegates;
|
createClientForCaller.sync2Async = delegates;
|
||||||
return CacheBuilder.newBuilder().build(createClientForCaller);
|
return CacheBuilder.newBuilder().build(createClientForCaller);
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.rest.internal.SeedAnnotationCache;
|
import org.jclouds.rest.internal.SeedAnnotationCache;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -77,14 +77,14 @@ public class RestModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Cache<Class<?>, Boolean> seedAnnotationCache(SeedAnnotationCache seedAnnotationCache) {
|
protected LoadingCache<Class<?>, Boolean> seedAnnotationCache(SeedAnnotationCache seedAnnotationCache) {
|
||||||
return CacheBuilder.newBuilder().build(seedAnnotationCache);
|
return CacheBuilder.newBuilder().build(seedAnnotationCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("async")
|
@Named("async")
|
||||||
Cache<ClassMethodArgs, Object> provideAsyncDelegateMap(CreateAsyncClientForCaller createAsyncClientForCaller) {
|
LoadingCache<ClassMethodArgs, Object> provideAsyncDelegateMap(CreateAsyncClientForCaller createAsyncClientForCaller) {
|
||||||
return CacheBuilder.newBuilder().build(createAsyncClientForCaller);
|
return CacheBuilder.newBuilder().build(createAsyncClientForCaller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ public class RestModule extends AbstractModule {
|
||||||
// cannot use child injectors due to the super coarse guice lock on
|
// cannot use child injectors due to the super coarse guice lock on
|
||||||
// Singleton
|
// Singleton
|
||||||
util.setCaller(from);
|
util.setCaller(from);
|
||||||
Cache<ClassMethodArgs, Object> delegateMap = injector.getInstance(Key.get(
|
LoadingCache<ClassMethodArgs, Object> delegateMap = injector.getInstance(Key.get(
|
||||||
new TypeLiteral<Cache<ClassMethodArgs, Object>>() {
|
new TypeLiteral<LoadingCache<ClassMethodArgs, Object>>() {
|
||||||
}, Names.named("async")));
|
}, Names.named("async")));
|
||||||
AsyncRestClientProxy proxy = new AsyncRestClientProxy(injector, factory, util, typeLiteral, delegateMap);
|
AsyncRestClientProxy proxy = new AsyncRestClientProxy(injector, factory, util, typeLiteral, delegateMap);
|
||||||
injector.injectMembers(proxy);
|
injector.injectMembers(proxy);
|
||||||
|
|
|
@ -48,7 +48,7 @@ import org.jclouds.util.Throwables2;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
|
@ -76,12 +76,12 @@ public class AsyncRestClientProxy<T> implements InvocationHandler {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
private final Cache<ClassMethodArgs, Object> delegateMap;
|
private final LoadingCache<ClassMethodArgs, Object> delegateMap;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Inject
|
@Inject
|
||||||
public AsyncRestClientProxy(Injector injector, Factory factory, RestAnnotationProcessor<T> util,
|
public AsyncRestClientProxy(Injector injector, Factory factory, RestAnnotationProcessor<T> util,
|
||||||
TypeLiteral<T> typeLiteral, @Named("async") Cache<ClassMethodArgs, Object> delegateMap) {
|
TypeLiteral<T> typeLiteral, @Named("async") LoadingCache<ClassMethodArgs, Object> delegateMap) {
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
this.annotationProcessor = util;
|
this.annotationProcessor = util;
|
||||||
this.declaring = (Class<T>) typeLiteral.getRawType();
|
this.declaring = (Class<T>) typeLiteral.getRawType();
|
||||||
|
|
|
@ -142,7 +142,7 @@ import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -174,24 +174,24 @@ public class RestAnnotationProcessor<T> {
|
||||||
private final Class<T> declaring;
|
private final Class<T> declaring;
|
||||||
|
|
||||||
// TODO replace with Table object
|
// TODO replace with Table object
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToBinderParamAnnotation = createMethodToIndexOfParamToAnnotation(BinderParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToBinderParamAnnotation = createMethodToIndexOfParamToAnnotation(BinderParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToWrapWithAnnotation = createMethodToIndexOfParamToAnnotation(WrapWith.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToWrapWithAnnotation = createMethodToIndexOfParamToAnnotation(WrapWith.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToHeaderParamAnnotations = createMethodToIndexOfParamToAnnotation(HeaderParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToHeaderParamAnnotations = createMethodToIndexOfParamToAnnotation(HeaderParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToEndpointAnnotations = createMethodToIndexOfParamToAnnotation(Endpoint.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToEndpointAnnotations = createMethodToIndexOfParamToAnnotation(Endpoint.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToEndpointParamAnnotations = createMethodToIndexOfParamToAnnotation(EndpointParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToEndpointParamAnnotations = createMethodToIndexOfParamToAnnotation(EndpointParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToMatrixParamAnnotations = createMethodToIndexOfParamToAnnotation(MatrixParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToMatrixParamAnnotations = createMethodToIndexOfParamToAnnotation(MatrixParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToFormParamAnnotations = createMethodToIndexOfParamToAnnotation(FormParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToFormParamAnnotations = createMethodToIndexOfParamToAnnotation(FormParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToQueryParamAnnotations = createMethodToIndexOfParamToAnnotation(QueryParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToQueryParamAnnotations = createMethodToIndexOfParamToAnnotation(QueryParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToPathParamAnnotations = createMethodToIndexOfParamToAnnotation(PathParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToPathParamAnnotations = createMethodToIndexOfParamToAnnotation(PathParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToPostParamAnnotations = createMethodToIndexOfParamToAnnotation(PayloadParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToPostParamAnnotations = createMethodToIndexOfParamToAnnotation(PayloadParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToPartParamAnnotations = createMethodToIndexOfParamToAnnotation(PartParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToPartParamAnnotations = createMethodToIndexOfParamToAnnotation(PartParam.class);
|
||||||
static final Cache<Method, Cache<Integer, Set<Annotation>>> methodToIndexOfParamToParamParserAnnotations = createMethodToIndexOfParamToAnnotation(ParamParser.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToParamParserAnnotations = createMethodToIndexOfParamToAnnotation(ParamParser.class);
|
||||||
static final Map<MethodKey, Method> delegationMap = newHashMap();
|
static final Map<MethodKey, Method> delegationMap = newHashMap();
|
||||||
|
|
||||||
static Cache<Method, Cache<Integer, Set<Annotation>>> createMethodToIndexOfParamToAnnotation(
|
static LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> createMethodToIndexOfParamToAnnotation(
|
||||||
final Class<? extends Annotation> annotation) {
|
final Class<? extends Annotation> annotation) {
|
||||||
return CacheBuilder.newBuilder().build(new CacheLoader<Method, Cache<Integer, Set<Annotation>>>() {
|
return CacheBuilder.newBuilder().build(new CacheLoader<Method, LoadingCache<Integer, Set<Annotation>>>() {
|
||||||
public Cache<Integer, Set<Annotation>> load(Method method) {
|
public LoadingCache<Integer, Set<Annotation>> load(Method method) {
|
||||||
return CacheBuilder.newBuilder().build(CacheLoader.from(new GetAnnotationsForMethodParameterIndex(method, annotation)));
|
return CacheBuilder.newBuilder().build(CacheLoader.from(new GetAnnotationsForMethodParameterIndex(method, annotation)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -229,7 +229,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static final Cache<Method, Set<Integer>> methodToIndexesOfOptions = CacheBuilder.newBuilder().build(
|
static final LoadingCache<Method, Set<Integer>> methodToIndexesOfOptions = CacheBuilder.newBuilder().build(
|
||||||
new CacheLoader<Method, Set<Integer>>() {
|
new CacheLoader<Method, Set<Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Set<Integer> load(Method method) {
|
public Set<Integer> load(Method method) {
|
||||||
|
@ -246,7 +246,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
private final ParseSax.Factory parserFactory;
|
private final ParseSax.Factory parserFactory;
|
||||||
private final HttpUtils utils;
|
private final HttpUtils utils;
|
||||||
private final Provider<UriBuilder> uriBuilderProvider;
|
private final Provider<UriBuilder> uriBuilderProvider;
|
||||||
private final Cache<Class<?>, Boolean> seedAnnotationCache;
|
private final LoadingCache<Class<?>, Boolean> seedAnnotationCache;
|
||||||
private final String apiVersion;
|
private final String apiVersion;
|
||||||
private char[] skips;
|
private char[] skips;
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Inject
|
@Inject
|
||||||
public RestAnnotationProcessor(Injector injector, Cache<Class<?>, Boolean> seedAnnotationCache,
|
public RestAnnotationProcessor(Injector injector, LoadingCache<Class<?>, Boolean> seedAnnotationCache,
|
||||||
@Named(Constants.PROPERTY_API_VERSION) String apiVersion, ParseSax.Factory parserFactory, HttpUtils utils,
|
@Named(Constants.PROPERTY_API_VERSION) String apiVersion, ParseSax.Factory parserFactory, HttpUtils utils,
|
||||||
TypeLiteral<T> typeLiteral) throws ExecutionException {
|
TypeLiteral<T> typeLiteral) throws ExecutionException {
|
||||||
this.declaring = (Class<T>) typeLiteral.getRawType();
|
this.declaring = (Class<T>) typeLiteral.getRawType();
|
||||||
|
@ -1010,7 +1010,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Integer, Set<Annotation>> indexWithOnlyOneAnnotation(Method method, String description,
|
public static Map<Integer, Set<Annotation>> indexWithOnlyOneAnnotation(Method method, String description,
|
||||||
Cache<Method, Cache<Integer, Set<Annotation>>> toRefine) throws ExecutionException {
|
LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> toRefine) throws ExecutionException {
|
||||||
Map<Integer, Set<Annotation>> indexToPayloadAnnotation = indexWithAtLeastOneAnnotation(method, toRefine);
|
Map<Integer, Set<Annotation>> indexToPayloadAnnotation = indexWithAtLeastOneAnnotation(method, toRefine);
|
||||||
if (indexToPayloadAnnotation.size() > 1) {
|
if (indexToPayloadAnnotation.size() > 1) {
|
||||||
throw new IllegalStateException(String.format(
|
throw new IllegalStateException(String.format(
|
||||||
|
@ -1021,7 +1021,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Integer, Set<Annotation>> indexWithAtLeastOneAnnotation(Method method,
|
private static Map<Integer, Set<Annotation>> indexWithAtLeastOneAnnotation(Method method,
|
||||||
Cache<Method, Cache<Integer, Set<Annotation>>> toRefine) throws ExecutionException {
|
LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> toRefine) throws ExecutionException {
|
||||||
Map<Integer, Set<Annotation>> indexToPayloadAnnotation = filterValues(toRefine.get(method).asMap(),
|
Map<Integer, Set<Annotation>> indexToPayloadAnnotation = filterValues(toRefine.get(method).asMap(),
|
||||||
new Predicate<Set<Annotation>>() {
|
new Predicate<Set<Annotation>>() {
|
||||||
public boolean apply(Set<Annotation> input) {
|
public boolean apply(Set<Annotation> input) {
|
||||||
|
@ -1061,7 +1061,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
final Object... args) throws ExecutionException {
|
final Object... args) throws ExecutionException {
|
||||||
Multimap<String, String> headers = LinkedHashMultimap.create();
|
Multimap<String, String> headers = LinkedHashMultimap.create();
|
||||||
addHeaderIfAnnotationPresentOnMethod(headers, method, tokenValues);
|
addHeaderIfAnnotationPresentOnMethod(headers, method, tokenValues);
|
||||||
Cache<Integer, Set<Annotation>> indexToHeaderParam = methodToIndexOfParamToHeaderParamAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToHeaderParam = methodToIndexOfParamToHeaderParamAnnotations.get(method);
|
||||||
for (Entry<Integer, Set<Annotation>> entry : indexToHeaderParam.asMap().entrySet()) {
|
for (Entry<Integer, Set<Annotation>> entry : indexToHeaderParam.asMap().entrySet()) {
|
||||||
for (Annotation key : entry.getValue()) {
|
for (Annotation key : entry.getValue()) {
|
||||||
String value = args[entry.getKey()].toString();
|
String value = args[entry.getKey()].toString();
|
||||||
|
@ -1128,7 +1128,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
List<? extends Part> getParts(Method method, Object[] args, Iterable<Entry<String, String>> iterable) throws ExecutionException {
|
List<? extends Part> getParts(Method method, Object[] args, Iterable<Entry<String, String>> iterable) throws ExecutionException {
|
||||||
List<Part> parts = newLinkedList();
|
List<Part> parts = newLinkedList();
|
||||||
Cache<Integer, Set<Annotation>> indexToPartParam = methodToIndexOfParamToPartParamAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToPartParam = methodToIndexOfParamToPartParamAnnotations.get(method);
|
||||||
for (Entry<Integer, Set<Annotation>> entry : indexToPartParam.asMap().entrySet()) {
|
for (Entry<Integer, Set<Annotation>> entry : indexToPartParam.asMap().entrySet()) {
|
||||||
for (Annotation key : entry.getValue()) {
|
for (Annotation key : entry.getValue()) {
|
||||||
PartParam param = (PartParam) key;
|
PartParam param = (PartParam) key;
|
||||||
|
@ -1168,9 +1168,9 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
private Multimap<String, String> getPathParamKeyValues(Method method, Object... args) throws ExecutionException {
|
private Multimap<String, String> getPathParamKeyValues(Method method, Object... args) throws ExecutionException {
|
||||||
Multimap<String, String> pathParamValues = LinkedHashMultimap.create();
|
Multimap<String, String> pathParamValues = LinkedHashMultimap.create();
|
||||||
Cache<Integer, Set<Annotation>> indexToPathParam = methodToIndexOfParamToPathParamAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToPathParam = methodToIndexOfParamToPathParamAnnotations.get(method);
|
||||||
|
|
||||||
Cache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
||||||
for (Entry<Integer, Set<Annotation>> entry : indexToPathParam.asMap().entrySet()) {
|
for (Entry<Integer, Set<Annotation>> entry : indexToPathParam.asMap().entrySet()) {
|
||||||
for (Annotation key : entry.getValue()) {
|
for (Annotation key : entry.getValue()) {
|
||||||
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
||||||
|
@ -1205,9 +1205,9 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
private Multimap<String, String> getMatrixParamKeyValues(Method method, Object... args) throws ExecutionException {
|
private Multimap<String, String> getMatrixParamKeyValues(Method method, Object... args) throws ExecutionException {
|
||||||
Multimap<String, String> matrixParamValues = LinkedHashMultimap.create();
|
Multimap<String, String> matrixParamValues = LinkedHashMultimap.create();
|
||||||
Cache<Integer, Set<Annotation>> indexToMatrixParam = methodToIndexOfParamToMatrixParamAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToMatrixParam = methodToIndexOfParamToMatrixParamAnnotations.get(method);
|
||||||
|
|
||||||
Cache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
||||||
for (Entry<Integer, Set<Annotation>> entry : indexToMatrixParam.asMap().entrySet()) {
|
for (Entry<Integer, Set<Annotation>> entry : indexToMatrixParam.asMap().entrySet()) {
|
||||||
for (Annotation key : entry.getValue()) {
|
for (Annotation key : entry.getValue()) {
|
||||||
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
||||||
|
@ -1234,9 +1234,9 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
private Multimap<String, String> getFormParamKeyValues(Method method, Object... args) throws ExecutionException {
|
private Multimap<String, String> getFormParamKeyValues(Method method, Object... args) throws ExecutionException {
|
||||||
Multimap<String, String> formParamValues = LinkedHashMultimap.create();
|
Multimap<String, String> formParamValues = LinkedHashMultimap.create();
|
||||||
Cache<Integer, Set<Annotation>> indexToFormParam = methodToIndexOfParamToFormParamAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToFormParam = methodToIndexOfParamToFormParamAnnotations.get(method);
|
||||||
|
|
||||||
Cache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
||||||
for (Entry<Integer, Set<Annotation>> entry : indexToFormParam.asMap().entrySet()) {
|
for (Entry<Integer, Set<Annotation>> entry : indexToFormParam.asMap().entrySet()) {
|
||||||
for (Annotation key : entry.getValue()) {
|
for (Annotation key : entry.getValue()) {
|
||||||
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
||||||
|
@ -1265,9 +1265,9 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
private Multimap<String, String> getQueryParamKeyValues(Method method, Object... args) throws ExecutionException {
|
private Multimap<String, String> getQueryParamKeyValues(Method method, Object... args) throws ExecutionException {
|
||||||
Multimap<String, String> queryParamValues = LinkedHashMultimap.create();
|
Multimap<String, String> queryParamValues = LinkedHashMultimap.create();
|
||||||
Cache<Integer, Set<Annotation>> indexToQueryParam = methodToIndexOfParamToQueryParamAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToQueryParam = methodToIndexOfParamToQueryParamAnnotations.get(method);
|
||||||
|
|
||||||
Cache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
||||||
for (Entry<Integer, Set<Annotation>> entry : indexToQueryParam.asMap().entrySet()) {
|
for (Entry<Integer, Set<Annotation>> entry : indexToQueryParam.asMap().entrySet()) {
|
||||||
for (Annotation key : entry.getValue()) {
|
for (Annotation key : entry.getValue()) {
|
||||||
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
||||||
|
@ -1294,8 +1294,8 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
private Map<String, String> buildPostParams(Method method, Object... args) throws ExecutionException {
|
private Map<String, String> buildPostParams(Method method, Object... args) throws ExecutionException {
|
||||||
Map<String, String> postParams = newHashMap();
|
Map<String, String> postParams = newHashMap();
|
||||||
Cache<Integer, Set<Annotation>> indexToPathParam = methodToIndexOfParamToPostParamAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToPathParam = methodToIndexOfParamToPostParamAnnotations.get(method);
|
||||||
Cache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
LoadingCache<Integer, Set<Annotation>> indexToParamExtractor = methodToIndexOfParamToParamParserAnnotations.get(method);
|
||||||
for (Entry<Integer, Set<Annotation>> entry : indexToPathParam.asMap().entrySet()) {
|
for (Entry<Integer, Set<Annotation>> entry : indexToPathParam.asMap().entrySet()) {
|
||||||
for (Annotation key : entry.getValue()) {
|
for (Annotation key : entry.getValue()) {
|
||||||
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.net.URLEncoder;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class Patterns {
|
||||||
public static final Pattern TRAILING_SLASHES = Pattern.compile("[/]*$");
|
public static final Pattern TRAILING_SLASHES = Pattern.compile("[/]*$");
|
||||||
public static final Pattern REST_CONTEXT_BUILDER = Pattern.compile("(.*ContextBuilder)<([^,]+), ?([^>]+)>");
|
public static final Pattern REST_CONTEXT_BUILDER = Pattern.compile("(.*ContextBuilder)<([^,]+), ?([^>]+)>");
|
||||||
|
|
||||||
public final static Cache<Character, Pattern> CHAR_TO_ENCODED_PATTERN = CacheBuilder.newBuilder()
|
public final static LoadingCache<Character, Pattern> CHAR_TO_ENCODED_PATTERN = CacheBuilder.newBuilder()
|
||||||
.<Character, Pattern> build(new CacheLoader<Character, Pattern>() {
|
.<Character, Pattern> build(new CacheLoader<Character, Pattern>() {
|
||||||
@Override
|
@Override
|
||||||
public Pattern load(Character plain) throws ExecutionException {
|
public Pattern load(Character plain) throws ExecutionException {
|
||||||
|
@ -63,7 +63,7 @@ public class Patterns {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public final static Cache<Character, Pattern> CHAR_TO_PATTERN = CacheBuilder.newBuilder()
|
public final static LoadingCache<Character, Pattern> CHAR_TO_PATTERN = CacheBuilder.newBuilder()
|
||||||
.<Character, Pattern> build(new CacheLoader<Character, Pattern>() {
|
.<Character, Pattern> build(new CacheLoader<Character, Pattern>() {
|
||||||
@Override
|
@Override
|
||||||
public Pattern load(Character plain) {
|
public Pattern load(Character plain) {
|
||||||
|
@ -71,7 +71,7 @@ public class Patterns {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public final static Cache<String, Pattern> TOKEN_TO_PATTERN = CacheBuilder.newBuilder()
|
public final static LoadingCache<String, Pattern> TOKEN_TO_PATTERN = CacheBuilder.newBuilder()
|
||||||
.<String, Pattern> build(new CacheLoader<String, Pattern>() {
|
.<String, Pattern> build(new CacheLoader<String, Pattern>() {
|
||||||
@Override
|
@Override
|
||||||
public Pattern load(String tokenValue) {
|
public Pattern load(String tokenValue) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -183,7 +183,7 @@ public class SyncProxyTest {
|
||||||
|
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
public void setUp() throws IllegalArgumentException, SecurityException, NoSuchMethodException {
|
public void setUp() throws IllegalArgumentException, SecurityException, NoSuchMethodException {
|
||||||
Cache<ClassMethodArgs, Object> cache = CacheBuilder.newBuilder().build(
|
LoadingCache<ClassMethodArgs, Object> cache = CacheBuilder.newBuilder().build(
|
||||||
CacheLoader.from(Functions.<Object> constant(null)));
|
CacheLoader.from(Functions.<Object> constant(null)));
|
||||||
sync = SyncProxy.proxy(Sync.class, new Async(), cache, ImmutableMap.<Class<?>, Class<?>> of(),
|
sync = SyncProxy.proxy(Sync.class, new Async(), cache, ImmutableMap.<Class<?>, Class<?>> of(),
|
||||||
ImmutableMap.of("Sync.takeXMillisecondsPropOverride", 250L));
|
ImmutableMap.of("Sync.takeXMillisecondsPropOverride", 250L));
|
||||||
|
@ -258,7 +258,7 @@ public class SyncProxyTest {
|
||||||
@Test(enabled = false, expectedExceptions = IllegalArgumentException.class)
|
@Test(enabled = false, expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testWrongTypedException() throws IllegalArgumentException, SecurityException, NoSuchMethodException,
|
public void testWrongTypedException() throws IllegalArgumentException, SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Cache<ClassMethodArgs, Object> cache = CacheBuilder.newBuilder().build(
|
LoadingCache<ClassMethodArgs, Object> cache = CacheBuilder.newBuilder().build(
|
||||||
CacheLoader.from(Functions.<Object> constant(null)));
|
CacheLoader.from(Functions.<Object> constant(null)));
|
||||||
SyncProxy.proxy(SyncWrongException.class, new Async(), cache, ImmutableMap.<Class<?>, Class<?>> of(),
|
SyncProxy.proxy(SyncWrongException.class, new Async(), cache, ImmutableMap.<Class<?>, Class<?>> of(),
|
||||||
ImmutableMap.<String, Long> of());
|
ImmutableMap.<String, Long> of());
|
||||||
|
@ -278,7 +278,7 @@ public class SyncProxyTest {
|
||||||
@Test(enabled = false, expectedExceptions = IllegalArgumentException.class)
|
@Test(enabled = false, expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testNoTimeOutException() throws IllegalArgumentException, SecurityException, NoSuchMethodException,
|
public void testNoTimeOutException() throws IllegalArgumentException, SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Cache<ClassMethodArgs, Object> cache = CacheBuilder.newBuilder().build(
|
LoadingCache<ClassMethodArgs, Object> cache = CacheBuilder.newBuilder().build(
|
||||||
CacheLoader.from(Functions.<Object> constant(null)));
|
CacheLoader.from(Functions.<Object> constant(null)));
|
||||||
SyncProxy.proxy(SyncNoTimeOut.class, new Async(), cache, ImmutableMap.<Class<?>, Class<?>> of(),
|
SyncProxy.proxy(SyncNoTimeOut.class, new Async(), cache, ImmutableMap.<Class<?>, Class<?>> of(),
|
||||||
ImmutableMap.<String, Long> of());
|
ImmutableMap.<String, Long> of());
|
||||||
|
@ -299,7 +299,7 @@ public class SyncProxyTest {
|
||||||
|
|
||||||
@Test(enabled = false, expectedExceptions = RuntimeException.class)
|
@Test(enabled = false, expectedExceptions = RuntimeException.class)
|
||||||
public void testClassOverridePropTimeout() throws Exception {
|
public void testClassOverridePropTimeout() throws Exception {
|
||||||
Cache<ClassMethodArgs, Object> cache = CacheBuilder.newBuilder().build(
|
LoadingCache<ClassMethodArgs, Object> cache = CacheBuilder.newBuilder().build(
|
||||||
CacheLoader.from(Functions.<Object> constant(null)));
|
CacheLoader.from(Functions.<Object> constant(null)));
|
||||||
final SyncClassOverride sync2 = SyncProxy.proxy(SyncClassOverride.class, new Async(), cache,
|
final SyncClassOverride sync2 = SyncProxy.proxy(SyncClassOverride.class, new Async(), cache,
|
||||||
ImmutableMap.<Class<?>, Class<?>> of(), ImmutableMap.<String, Long> of("SyncClassOverride", 100L));
|
ImmutableMap.<Class<?>, Class<?>> of(), ImmutableMap.<String, Long> of("SyncClassOverride", 100L));
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
|
@ -37,7 +37,7 @@ import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
public class CacheLearningTest {
|
public class CacheLearningTest {
|
||||||
@Test
|
@Test
|
||||||
public void howTo() throws ExecutionException {
|
public void howTo() throws ExecutionException {
|
||||||
Cache<String, String> cache = CacheBuilder.newBuilder().build(new CacheLoader<String, String>() {
|
LoadingCache<String, String> cache = CacheBuilder.newBuilder().build(new CacheLoader<String, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String load(String key) throws Exception {
|
public String load(String key) throws Exception {
|
||||||
|
@ -57,8 +57,15 @@ public class CacheLearningTest {
|
||||||
try {
|
try {
|
||||||
cache.get("foo");
|
cache.get("foo");
|
||||||
assert false : "expected exception on miss";
|
assert false : "expected exception on miss";
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
assertEquals(e.getMessage(), "testLoader returned null for key foo.");
|
assertEquals(e.getMessage(), "CacheLoader returned null for key foo.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
cache.getUnchecked("foo");
|
||||||
|
assert false : "expected exception on miss";
|
||||||
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
|
assertEquals(e.getMessage(), "CacheLoader returned null for key foo.");
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(cache.asMap().keySet().size(), 0);
|
assertEquals(cache.asMap().keySet().size(), 0);
|
||||||
|
|
|
@ -74,7 +74,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -85,7 +85,7 @@ import com.google.common.collect.Iterables;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AWSEC2ComputeService extends EC2ComputeService {
|
public class AWSEC2ComputeService extends EC2ComputeService {
|
||||||
|
|
||||||
private final Cache<RegionAndName, String> placementGroupMap;
|
private final LoadingCache<RegionAndName, String> placementGroupMap;
|
||||||
private final Predicate<PlacementGroup> placementGroupDeleted;
|
private final Predicate<PlacementGroup> placementGroupDeleted;
|
||||||
private final AWSEC2Client ec2Client;
|
private final AWSEC2Client ec2Client;
|
||||||
private final AWSEC2AsyncClient aclient;
|
private final AWSEC2AsyncClient aclient;
|
||||||
|
@ -108,8 +108,8 @@ public class AWSEC2ComputeService extends EC2ComputeService {
|
||||||
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
|
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, AWSEC2Client ec2Client,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, AWSEC2Client ec2Client,
|
||||||
ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
|
ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
|
||||||
@Named("SECURITY") Cache<RegionAndName, String> securityGroupMap,
|
@Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap,
|
||||||
@Named("PLACEMENT") Cache<RegionAndName, String> placementGroupMap,
|
@Named("PLACEMENT") LoadingCache<RegionAndName, String> placementGroupMap,
|
||||||
@Named("DELETED") Predicate<PlacementGroup> placementGroupDeleted,
|
@Named("DELETED") Predicate<PlacementGroup> placementGroupDeleted,
|
||||||
@Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames, AWSEC2AsyncClient aclient) {
|
@Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames, AWSEC2AsyncClient aclient) {
|
||||||
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
|
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.ec2.compute.domain.RegionAndName;
|
||||||
import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
|
import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -46,7 +46,7 @@ public class AWSEC2TemplateBuilderImpl extends EC2TemplateBuilderImpl {
|
||||||
protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||||
Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
|
Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
|
||||||
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Supplier<Cache<RegionAndName, ? extends Image>> imageMap) {
|
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap) {
|
||||||
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap);
|
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ import org.jclouds.rest.suppliers.SetAndThrowAuthorizationExceptionSupplier;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
@ -116,7 +116,7 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext
|
||||||
@Override
|
@Override
|
||||||
protected Supplier<Set<? extends Image>> supplyNonParsingImageCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
protected Supplier<Set<? extends Image>> supplyNonParsingImageCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
final Supplier<Set<? extends Image>> imageSupplier, Injector injector) {
|
final Supplier<Set<? extends Image>> imageSupplier, Injector injector) {
|
||||||
final Supplier<Cache<RegionAndName, ? extends Image>> cache = injector.getInstance(Key.get(new TypeLiteral<Supplier<Cache<RegionAndName, ? extends Image>>>() {}));
|
final Supplier<LoadingCache<RegionAndName, ? extends Image>> cache = injector.getInstance(Key.get(new TypeLiteral<Supplier<LoadingCache<RegionAndName, ? extends Image>>>() {}));
|
||||||
return new Supplier<Set<? extends Image>>() {
|
return new Supplier<Set<? extends Image>>() {
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Image> get() {
|
public Set<? extends Image> get() {
|
||||||
|
@ -158,7 +158,7 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Cache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
|
protected Supplier<LoadingCache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
|
||||||
final RegionAndNameToImageSupplier supplier) {
|
final RegionAndNameToImageSupplier supplier) {
|
||||||
return supplier;
|
return supplier;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ import org.jclouds.rest.internal.RestContextImpl;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -116,7 +116,7 @@ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDep
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("PLACEMENT")
|
@Named("PLACEMENT")
|
||||||
protected Cache<RegionAndName, String> placementGroupMap(CreatePlacementGroupIfNeeded in) {
|
protected LoadingCache<RegionAndName, String> placementGroupMap(CreatePlacementGroupIfNeeded in) {
|
||||||
return CacheBuilder.newBuilder().build(in);
|
return CacheBuilder.newBuilder().build(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.jclouds.ec2.domain.InstanceState;
|
||||||
import org.jclouds.ec2.domain.RunningInstance;
|
import org.jclouds.ec2.domain.RunningInstance;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -53,7 +53,7 @@ public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetad
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected AWSRunningInstanceToNodeMetadata(Map<InstanceState, NodeState> instanceToNodeState,
|
protected AWSRunningInstanceToNodeMetadata(Map<InstanceState, NodeState> instanceToNodeState,
|
||||||
Map<String, Credentials> credentialStore, Supplier<Cache<RegionAndName, ? extends Image>> imageMap,
|
Map<String, Credentials> credentialStore, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware) {
|
@Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware) {
|
||||||
super(instanceToNodeState, credentialStore, imageMap, locations, hardware);
|
super(instanceToNodeState, credentialStore, imageMap, locations, hardware);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupT
|
||||||
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
|
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
|
||||||
AWSEC2InstancePresent instancePresent,
|
AWSEC2InstancePresent instancePresent,
|
||||||
Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
|
Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
|
||||||
Cache<RunningInstance, Credentials> instanceToCredentials, Map<String, Credentials> credentialStore,
|
LoadingCache<RunningInstance, Credentials> instanceToCredentials, Map<String, Credentials> credentialStore,
|
||||||
ComputeUtils utils, SpotInstanceRequestToAWSRunningInstance spotConverter) {
|
ComputeUtils utils, SpotInstanceRequestToAWSRunningInstance spotConverter) {
|
||||||
super(client, templateBuilderProvider, createKeyPairAndSecurityGroupsAsNeededAndReturncustomize, instancePresent,
|
super(client, templateBuilderProvider, createKeyPairAndSecurityGroupsAsNeededAndReturncustomize, instancePresent,
|
||||||
runningInstanceToNodeMetadata, instanceToCredentials, credentialStore, utils);
|
runningInstanceToNodeMetadata, instanceToCredentials, credentialStore, utils);
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.jclouds.logging.Logger;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -59,7 +59,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final Cache<RegionAndName, String> placementGroupMap;
|
final LoadingCache<RegionAndName, String> placementGroupMap;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded;
|
final CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -68,9 +68,9 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions
|
||||||
@Inject
|
@Inject
|
||||||
public CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(
|
public CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(
|
||||||
Function<RegionAndName, KeyPair> makeKeyPair, ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
|
Function<RegionAndName, KeyPair> makeKeyPair, ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
|
||||||
@Named("SECURITY") Cache<RegionAndName, String> securityGroupMap,
|
@Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap,
|
||||||
Provider<RunInstancesOptions> optionsProvider,
|
Provider<RunInstancesOptions> optionsProvider,
|
||||||
@Named("PLACEMENT") Cache<RegionAndName, String> placementGroupMap,
|
@Named("PLACEMENT") LoadingCache<RegionAndName, String> placementGroupMap,
|
||||||
CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded,
|
CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded,
|
||||||
Function<RegionNameAndPublicKeyMaterial, KeyPair> importExistingKeyPair) {
|
Function<RegionNameAndPublicKeyMaterial, KeyPair> importExistingKeyPair) {
|
||||||
super(makeKeyPair, credentialsMap, securityGroupMap, optionsProvider);
|
super(makeKeyPair, credentialsMap, securityGroupMap, optionsProvider);
|
||||||
|
|
|
@ -47,7 +47,7 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -75,13 +75,13 @@ public class AWSEC2ImageSupplier implements Supplier<Set<? extends Image>> {
|
||||||
private final String amiQuery;
|
private final String amiQuery;
|
||||||
private final Iterable<String> clusterRegions;
|
private final Iterable<String> clusterRegions;
|
||||||
private final String ccAmiQuery;
|
private final String ccAmiQuery;
|
||||||
private final Supplier<Cache<RegionAndName, ? extends Image>> cache;
|
private final Supplier<LoadingCache<RegionAndName, ? extends Image>> cache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected AWSEC2ImageSupplier(@Region Set<String> regions,
|
protected AWSEC2ImageSupplier(@Region Set<String> regions,
|
||||||
@Named(PROPERTY_EC2_AMI_QUERY) String amiQuery, @Named(PROPERTY_EC2_CC_REGIONS) String clusterRegions,
|
@Named(PROPERTY_EC2_AMI_QUERY) String amiQuery, @Named(PROPERTY_EC2_CC_REGIONS) String clusterRegions,
|
||||||
@Named(PROPERTY_EC2_CC_AMI_QUERY) String ccAmiQuery,
|
@Named(PROPERTY_EC2_CC_AMI_QUERY) String ccAmiQuery,
|
||||||
Supplier<Cache<RegionAndName, ? extends Image>> cache,
|
Supplier<LoadingCache<RegionAndName, ? extends Image>> cache,
|
||||||
CallForImages.Factory factory, @ClusterCompute Set<String> clusterComputeIds,
|
CallForImages.Factory factory, @ClusterCompute Set<String> clusterComputeIds,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -160,7 +160,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
final Map<RegionAndName, ? extends Image> backing = ImagesToRegionAndIdMap.imagesToMap(images);
|
final Map<RegionAndName, ? extends Image> backing = ImagesToRegionAndIdMap.imagesToMap(images);
|
||||||
|
|
||||||
Cache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image> (){
|
LoadingCache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image> (){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image load(RegionAndName key) throws Exception {
|
public Image load(RegionAndName key) throws Exception {
|
||||||
|
@ -175,7 +175,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
private AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
private AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
||||||
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
|
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
|
||||||
Map<InstanceState, NodeState> instanceToNodeState, Cache<RegionAndName, ? extends Image> instanceToImage) {
|
Map<InstanceState, NodeState> instanceToNodeState, LoadingCache<RegionAndName, ? extends Image> instanceToImage) {
|
||||||
Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
|
Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -193,7 +193,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
};
|
};
|
||||||
AWSRunningInstanceToNodeMetadata parser = new AWSRunningInstanceToNodeMetadata(instanceToNodeState,
|
AWSRunningInstanceToNodeMetadata parser = new AWSRunningInstanceToNodeMetadata(instanceToNodeState,
|
||||||
credentialStore, Suppliers.<Cache<RegionAndName, ? extends Image>> ofInstance(instanceToImage),
|
credentialStore, Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(instanceToImage),
|
||||||
locationSupplier, hardwareSupplier);
|
locationSupplier, hardwareSupplier);
|
||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
@ -934,8 +934,8 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
||||||
private CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions setupStrategy() {
|
private CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions setupStrategy() {
|
||||||
Function<RegionAndName, KeyPair> makeKeyPair = createMock(Function.class);
|
Function<RegionAndName, KeyPair> makeKeyPair = createMock(Function.class);
|
||||||
ConcurrentMap<RegionAndName, KeyPair> credentialsMap = createMock(ConcurrentMap.class);
|
ConcurrentMap<RegionAndName, KeyPair> credentialsMap = createMock(ConcurrentMap.class);
|
||||||
Cache<RegionAndName, String> securityGroupMap = createMock(Cache.class);
|
LoadingCache<RegionAndName, String> securityGroupMap = createMock(LoadingCache.class);
|
||||||
Cache<RegionAndName, String> placementGroupMap = createMock(Cache.class);
|
LoadingCache<RegionAndName, String> placementGroupMap = createMock(LoadingCache.class);
|
||||||
Function<RegionNameAndPublicKeyMaterial, KeyPair> importExistingKeyPair = createMock(Function.class);
|
Function<RegionNameAndPublicKeyMaterial, KeyPair> importExistingKeyPair = createMock(Function.class);
|
||||||
CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded = createMock(CreatePlacementGroupIfNeeded.class);
|
CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded = createMock(CreatePlacementGroupIfNeeded.class);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.jclouds.rest.RestContextSpec;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -70,7 +70,7 @@ public abstract class BaseAWSEC2AsyncClientTest<T> extends RestClientTest<T> {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
Cache<RegionAndName, Image> provide(){
|
LoadingCache<RegionAndName, Image> provide(){
|
||||||
return CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image>() {
|
return CacheBuilder.newBuilder().build(new CacheLoader<RegionAndName, Image>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.blobstore;
|
package org.jclouds.aws.s3.blobstore;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
@ -48,6 +47,7 @@ import org.jclouds.s3.blobstore.functions.ObjectToBlobMetadata;
|
||||||
import org.jclouds.s3.domain.AccessControlList;
|
import org.jclouds.s3.domain.AccessControlList;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +65,7 @@ public class AWSS3AsyncBlobStore extends S3AsyncBlobStore {
|
||||||
BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions,
|
BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions,
|
||||||
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd,
|
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd,
|
||||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider, Map<String, AccessControlList> bucketAcls,
|
Provider<FetchBlobMetadata> fetchBlobMetadataProvider, LoadingCache<String, AccessControlList> bucketAcls,
|
||||||
Provider<AsyncMultipartUploadStrategy> multipartUploadStrategy) {
|
Provider<AsyncMultipartUploadStrategy> multipartUploadStrategy) {
|
||||||
super(context, blobUtils, service, defaultLocation, locations, async, sync, bucket2ResourceMd,
|
super(context, blobUtils, service, defaultLocation, locations, async, sync, bucket2ResourceMd,
|
||||||
container2BucketListOptions, bucket2ResourceList, object2Blob, blob2ObjectGetOptions, blob2Object,
|
container2BucketListOptions, bucket2ResourceList, object2Blob, blob2ObjectGetOptions, blob2Object,
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.blobstore;
|
package org.jclouds.aws.s3.blobstore;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -44,6 +43,7 @@ import org.jclouds.s3.blobstore.functions.ObjectToBlobMetadata;
|
||||||
import org.jclouds.s3.domain.AccessControlList;
|
import org.jclouds.s3.domain.AccessControlList;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proived AWS S3 specific extensions.
|
* Proived AWS S3 specific extensions.
|
||||||
|
@ -60,7 +60,7 @@ public class AWSS3BlobStore extends S3BlobStore {
|
||||||
BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions,
|
BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions,
|
||||||
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd,
|
BlobToHttpGetOptions blob2ObjectGetOptions, BlobToObject blob2Object, ObjectToBlobMetadata object2BlobMd,
|
||||||
Provider<FetchBlobMetadata> fetchBlobMetadataProvider, Map<String, AccessControlList> bucketAcls,
|
Provider<FetchBlobMetadata> fetchBlobMetadataProvider, LoadingCache<String, AccessControlList> bucketAcls,
|
||||||
Provider<MultipartUploadStrategy> multipartUploadStrategy) {
|
Provider<MultipartUploadStrategy> multipartUploadStrategy) {
|
||||||
super(context, blobUtils, defaultLocation, locations, sync, bucket2ResourceMd, container2BucketListOptions,
|
super(context, blobUtils, defaultLocation, locations, sync, bucket2ResourceMd, container2BucketListOptions,
|
||||||
bucket2ResourceList, object2Blob, blob2ObjectGetOptions, blob2Object, object2BlobMd,
|
bucket2ResourceList, object2Blob, blob2ObjectGetOptions, blob2Object, object2BlobMd,
|
||||||
|
|
|
@ -74,12 +74,6 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
<version>1.2.16</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.azureblob.blobstore.config;
|
package org.jclouds.azureblob.blobstore.config;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -40,8 +39,9 @@ import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||||
import org.jclouds.location.config.JustProviderLocationModule;
|
import org.jclouds.location.config.JustProviderLocationModule;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
|
@ -69,10 +69,11 @@ public class AzureBlobStoreContextModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Map<String, PublicAccess> containerAcls(final AzureBlobClient client) {
|
protected LoadingCache<String, PublicAccess> containerAcls(final AzureBlobClient client) {
|
||||||
return new MapMaker().expireAfterWrite(30, TimeUnit.SECONDS).makeComputingMap(
|
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(
|
||||||
new Function<String, PublicAccess>() {
|
new CacheLoader<String, PublicAccess>() {
|
||||||
public PublicAccess apply(String container) {
|
@Override
|
||||||
|
public PublicAccess load(String container) {
|
||||||
return client.getPublicAccessForContainer(container);
|
return client.getPublicAccessForContainer(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ package org.jclouds.azureblob.blobstore.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -34,6 +32,8 @@ import org.jclouds.blobstore.strategy.IfDirectoryReturnNameStrategy;
|
||||||
import org.jclouds.http.HttpUtils;
|
import org.jclouds.http.HttpUtils;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -41,11 +41,11 @@ import com.google.common.base.Function;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BlobPropertiesToBlobMetadata implements Function<BlobProperties, MutableBlobMetadata> {
|
public class BlobPropertiesToBlobMetadata implements Function<BlobProperties, MutableBlobMetadata> {
|
||||||
private final IfDirectoryReturnNameStrategy ifDirectoryReturnName;
|
private final IfDirectoryReturnNameStrategy ifDirectoryReturnName;
|
||||||
private final Map<String, PublicAccess> containerAcls;
|
private final LoadingCache<String, PublicAccess> containerAcls;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BlobPropertiesToBlobMetadata(IfDirectoryReturnNameStrategy ifDirectoryReturnName,
|
public BlobPropertiesToBlobMetadata(IfDirectoryReturnNameStrategy ifDirectoryReturnName,
|
||||||
Map<String, PublicAccess> containerAcls) {
|
LoadingCache<String, PublicAccess> containerAcls) {
|
||||||
this.ifDirectoryReturnName = checkNotNull(ifDirectoryReturnName, "ifDirectoryReturnName");
|
this.ifDirectoryReturnName = checkNotNull(ifDirectoryReturnName, "ifDirectoryReturnName");
|
||||||
this.containerAcls = checkNotNull(containerAcls, "containerAcls");
|
this.containerAcls = checkNotNull(containerAcls, "containerAcls");
|
||||||
}
|
}
|
||||||
|
@ -61,12 +61,13 @@ public class BlobPropertiesToBlobMetadata implements Function<BlobProperties, Mu
|
||||||
to.setName(from.getName());
|
to.setName(from.getName());
|
||||||
to.setContainer(from.getContainer());
|
to.setContainer(from.getContainer());
|
||||||
to.setUri(from.getUrl());
|
to.setUri(from.getUrl());
|
||||||
|
if (from.getContainer() != null)
|
||||||
try {
|
try {
|
||||||
PublicAccess containerAcl = containerAcls.get(from.getContainer());
|
PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer());
|
||||||
if (containerAcl != null && containerAcl != PublicAccess.PRIVATE)
|
if (containerAcl != PublicAccess.PRIVATE)
|
||||||
to.setPublicUri(from.getUrl());
|
to.setPublicUri(from.getUrl());
|
||||||
} catch (NullPointerException e) {
|
} catch (CacheLoader.InvalidCacheLoadException e) {
|
||||||
// MapMaker cannot return null, but a call to get acls can
|
// nulls not permitted from cache loader
|
||||||
}
|
}
|
||||||
String directoryName = ifDirectoryReturnName.execute(to);
|
String directoryName = ifDirectoryReturnName.execute(to);
|
||||||
if (directoryName != null) {
|
if (directoryName != null) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
|
|
||||||
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.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -47,7 +47,7 @@ import com.google.common.collect.Maps;
|
||||||
* @author Andrea Turli
|
* @author Andrea Turli
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ImageFromYamlStream implements Function<InputStream, Cache<String, Image>> {
|
public class ImageFromYamlStream implements Function<InputStream, LoadingCache<String, Image>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type-safe config class for YAML
|
* Type-safe config class for YAML
|
||||||
|
@ -63,7 +63,7 @@ public class ImageFromYamlStream implements Function<InputStream, Cache<String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cache<String, Image> apply(InputStream source) {
|
public LoadingCache<String, Image> apply(InputStream source) {
|
||||||
|
|
||||||
Constructor constructor = new Constructor(Config.class);
|
Constructor constructor = new Constructor(Config.class);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class ImageFromYamlStream implements Function<InputStream, Cache<String,
|
||||||
return image.getId();
|
return image.getId();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Cache<String, Image> cache = CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(backingMap)));
|
LoadingCache<String, Image> cache = CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(backingMap)));
|
||||||
for (String node : backingMap.keySet())
|
for (String node : backingMap.keySet())
|
||||||
cache.getUnchecked(node);
|
cache.getUnchecked(node);
|
||||||
return cache;
|
return cache;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
|
||||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
@ -85,7 +85,7 @@ public class TestUtils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ComputeServiceContext computeServiceForVirtualBox(Cache<String, Node> cache) {
|
public static ComputeServiceContext computeServiceForVirtualBox(LoadingCache<String, Node> cache) {
|
||||||
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
||||||
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule(),
|
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule(),
|
||||||
new CacheNodeStoreModule(cache)));
|
new CacheNodeStoreModule(cache)));
|
||||||
|
|
Loading…
Reference in New Issue