JCLOUDS-40 unasync Fallback.

This commit is contained in:
Adrian Cole 2014-10-06 13:35:44 -07:00
parent 66b7bd1634
commit a164c071a9
11 changed files with 30 additions and 111 deletions

View File

@ -17,23 +17,16 @@
package org.jclouds.openstack.neutron.v2.fallbacks; package org.jclouds.openstack.neutron.v2.fallbacks;
import com.google.common.util.concurrent.ListenableFuture; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import org.jclouds.Fallback; import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.FloatingIPs; import org.jclouds.openstack.neutron.v2.domain.FloatingIPs;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
public class EmptyFloatingIPsFallback implements Fallback<FloatingIPs> { public class EmptyFloatingIPsFallback implements Fallback<FloatingIPs> {
public ListenableFuture<FloatingIPs> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public FloatingIPs createOrPropagate(Throwable t) throws Exception { public FloatingIPs createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -17,23 +17,16 @@
package org.jclouds.openstack.neutron.v2.fallbacks; package org.jclouds.openstack.neutron.v2.fallbacks;
import com.google.common.util.concurrent.ListenableFuture; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import org.jclouds.Fallback; import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.Networks; import org.jclouds.openstack.neutron.v2.domain.Networks;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
public class EmptyNetworksFallback implements Fallback<Networks> { public class EmptyNetworksFallback implements Fallback<Networks> {
public ListenableFuture<Networks> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public Networks createOrPropagate(Throwable t) throws Exception { public Networks createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -17,23 +17,16 @@
package org.jclouds.openstack.neutron.v2.fallbacks; package org.jclouds.openstack.neutron.v2.fallbacks;
import com.google.common.util.concurrent.ListenableFuture; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import org.jclouds.Fallback; import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.Ports; import org.jclouds.openstack.neutron.v2.domain.Ports;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
public class EmptyPortsFallback implements Fallback<Ports> { public class EmptyPortsFallback implements Fallback<Ports> {
public ListenableFuture<Ports> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public Ports createOrPropagate(Throwable t) throws Exception { public Ports createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -17,23 +17,16 @@
package org.jclouds.openstack.neutron.v2.fallbacks; package org.jclouds.openstack.neutron.v2.fallbacks;
import com.google.common.util.concurrent.ListenableFuture; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import org.jclouds.Fallback; import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.Routers; import org.jclouds.openstack.neutron.v2.domain.Routers;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
public class EmptyRoutersFallback implements Fallback<Routers> { public class EmptyRoutersFallback implements Fallback<Routers> {
public ListenableFuture<Routers> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public Routers createOrPropagate(Throwable t) throws Exception { public Routers createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -19,21 +19,14 @@ package org.jclouds.openstack.neutron.v2.fallbacks;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate; import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404; import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType; import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import org.jclouds.Fallback; import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.Rules; import org.jclouds.openstack.neutron.v2.domain.Rules;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import com.google.common.util.concurrent.ListenableFuture;
public class EmptyRulesFallback implements Fallback<Rules> { public class EmptyRulesFallback implements Fallback<Rules> {
public ListenableFuture<Rules> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public Rules createOrPropagate(Throwable t) throws Exception { public Rules createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -17,23 +17,16 @@
package org.jclouds.openstack.neutron.v2.fallbacks; package org.jclouds.openstack.neutron.v2.fallbacks;
import com.google.common.util.concurrent.ListenableFuture; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import org.jclouds.Fallback; import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.SecurityGroups; import org.jclouds.openstack.neutron.v2.domain.SecurityGroups;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
public class EmptySecurityGroupsFallback implements Fallback<SecurityGroups> { public class EmptySecurityGroupsFallback implements Fallback<SecurityGroups> {
public ListenableFuture<SecurityGroups> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public SecurityGroups createOrPropagate(Throwable t) throws Exception { public SecurityGroups createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -17,23 +17,16 @@
package org.jclouds.openstack.neutron.v2.fallbacks; package org.jclouds.openstack.neutron.v2.fallbacks;
import com.google.common.util.concurrent.ListenableFuture; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import org.jclouds.Fallback; import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.Subnets; import org.jclouds.openstack.neutron.v2.domain.Subnets;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
public class EmptySubnetsFallback implements Fallback<Subnets> { public class EmptySubnetsFallback implements Fallback<Subnets> {
public ListenableFuture<Subnets> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public Subnets createOrPropagate(Throwable t) throws Exception { public Subnets createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -19,7 +19,6 @@ package org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate; import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404; import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType; import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
@ -27,14 +26,7 @@ import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors; import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import com.google.common.util.concurrent.ListenableFuture;
public class EmptyHealthMonitorsFallback implements Fallback<HealthMonitors> { public class EmptyHealthMonitorsFallback implements Fallback<HealthMonitors> {
public ListenableFuture<HealthMonitors> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public HealthMonitors createOrPropagate(Throwable t) throws Exception { public HealthMonitors createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -19,7 +19,6 @@ package org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate; import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404; import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType; import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
@ -27,14 +26,7 @@ import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members; import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import com.google.common.util.concurrent.ListenableFuture;
public class EmptyMembersFallback implements Fallback<Members> { public class EmptyMembersFallback implements Fallback<Members> {
public ListenableFuture<Members> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public Members createOrPropagate(Throwable t) throws Exception { public Members createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -19,7 +19,6 @@ package org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate; import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404; import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType; import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
@ -27,14 +26,7 @@ import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools; import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import com.google.common.util.concurrent.ListenableFuture;
public class EmptyPoolsFallback implements Fallback<Pools> { public class EmptyPoolsFallback implements Fallback<Pools> {
public ListenableFuture<Pools> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public Pools createOrPropagate(Throwable t) throws Exception { public Pools createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)

View File

@ -19,7 +19,6 @@ package org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate; import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.http.HttpUtils.contains404; import static org.jclouds.http.HttpUtils.contains404;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType; import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
@ -27,14 +26,7 @@ import org.jclouds.Fallback;
import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs; import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import com.google.common.util.concurrent.ListenableFuture;
public class EmptyVIPsFallback implements Fallback<VIPs> { public class EmptyVIPsFallback implements Fallback<VIPs> {
public ListenableFuture<VIPs> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}
@Override @Override
public VIPs createOrPropagate(Throwable t) throws Exception { public VIPs createOrPropagate(Throwable t) throws Exception {
if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null) if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)