mirror of https://github.com/apache/jclouds.git
Issue 763: set image cache expiry using PROPERTY_SESSION_INTERVAL
This commit is contained in:
parent
a45e16ebb3
commit
741773f9ab
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.ec2.compute.config;
|
||||
|
||||
import static com.google.common.collect.Iterables.toArray;
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -37,7 +36,6 @@ import org.jclouds.ec2.compute.domain.RegionAndName;
|
|||
import org.jclouds.ec2.compute.functions.RegionAndIdToImage;
|
||||
import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||
import org.jclouds.rest.suppliers.SetAndThrowAuthorizationExceptionSupplier;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
@ -69,7 +67,7 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
|
|||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Cache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final RegionAndNameToImageSupplier supplier) {
|
||||
final RegionAndNameToImageSupplier supplier) {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.ec2.compute.suppliers;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
|
@ -38,8 +43,9 @@ public class RegionAndNameToImageSupplier implements Supplier<Cache<RegionAndNam
|
|||
private final Cache<RegionAndName, Image> cache;
|
||||
|
||||
@Inject
|
||||
protected RegionAndNameToImageSupplier(CacheLoader<RegionAndName, Image> regionAndIdToImage) {
|
||||
cache = CacheBuilder.newBuilder().build(regionAndIdToImage);
|
||||
protected RegionAndNameToImageSupplier(CacheLoader<RegionAndName, Image> regionAndIdToImage,
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long expirationSecs) {
|
||||
cache = CacheBuilder.newBuilder().expireAfterWrite(expirationSecs, TimeUnit.SECONDS).build(regionAndIdToImage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,13 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.compute.config;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.ec2.AWSEC2PropertiesBuilder;
|
||||
|
@ -131,7 +129,7 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext
|
|||
@Provides
|
||||
@Singleton
|
||||
protected Supplier<Cache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final RegionAndNameToImageSupplier supplier) {
|
||||
final RegionAndNameToImageSupplier supplier) {
|
||||
return supplier;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue