Updated NovaComputeService and FloatingIp cache to deal with extensibility

This commit is contained in:
Andrew Donald Kennedy 2012-08-23 07:29:40 +03:00
parent 931aa7838a
commit 7d70b5ddc3
5 changed files with 10 additions and 10 deletions

View File

@ -155,7 +155,7 @@ public class NovaComputeService extends BaseComputeService {
Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
if (keyPairApi.isPresent()) {
for (String group : groups) {
for (Map<String, KeyPair> view : keyPairApi.get().listKeyPairs()) {
for (Map<String, ? extends KeyPair> view : keyPairApi.get().listKeyPairs()) {
for (KeyPair pair : Iterables.filter(view.values(),
KeyPairPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());

View File

@ -129,7 +129,7 @@ public class NovaComputeServiceContextModule extends
bind(TemplateOptions.class).to(NovaTemplateOptions.class);
bind(new TypeLiteral<CacheLoader<ZoneAndId, Iterable<FloatingIP>>>() {
bind(new TypeLiteral<CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>>>() {
}).annotatedWith(Names.named("FLOATINGIP")).to(LoadFloatingIpsForInstance.class);
bind(new TypeLiteral<Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>>() {
@ -163,8 +163,8 @@ public class NovaComputeServiceContextModule extends
@Provides
@Singleton
@Named("FLOATINGIP")
protected LoadingCache<ZoneAndId, Iterable<FloatingIP>> instanceToFloatingIps(
@Named("FLOATINGIP") CacheLoader<ZoneAndId, Iterable<FloatingIP>> in) {
protected LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> instanceToFloatingIps(
@Named("FLOATINGIP") CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> in) {
return CacheBuilder.newBuilder().build(in);
}

View File

@ -61,11 +61,11 @@ public class AllocateAndAddFloatingIpToNode implements
private final Predicate<AtomicReference<NodeMetadata>> nodeRunning;
private final NovaApi novaApi;
private final LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache;
private final LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache;
@Inject
public AllocateAndAddFloatingIpToNode(@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
NovaApi novaApi, @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache) {
NovaApi novaApi, @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
this.nodeRunning = checkNotNull(nodeRunning, "nodeRunning");
this.novaApi = checkNotNull(novaApi, "novaApi");
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");

View File

@ -47,11 +47,11 @@ public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId
protected Logger logger = Logger.NULL;
private final NovaApi novaApi;
private final LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache;
private final LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache;
@Inject
public RemoveFloatingIpFromNodeAndDeallocate(NovaApi novaApi,
@Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache) {
@Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
this.novaApi = checkNotNull(novaApi, "novaApi");
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
}

View File

@ -40,7 +40,7 @@ import com.google.common.collect.Iterables;
* @author Adam Lowe
*/
@Singleton
public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<FloatingIP>> {
public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> {
private final NovaApi api;
@Inject
@ -49,7 +49,7 @@ public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<
}
@Override
public Iterable<FloatingIP> load(final ZoneAndId key) throws Exception {
public Iterable<? extends FloatingIP> load(final ZoneAndId key) throws Exception {
String zone = key.getZone();
Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
if (ipApiOptional.isPresent()) {