diff --git a/demos/googleappengine/pom.xml b/demos/googleappengine/pom.xml index ce378227d5..abcd66b18b 100644 --- a/demos/googleappengine/pom.xml +++ b/demos/googleappengine/pom.xml @@ -53,12 +53,6 @@ jclouds-compute ${project.version} - - org.jclouds.provider - aws-s3 - ${project.version} - runtime - org.jclouds.provider hpcloud-objectstorage @@ -369,8 +363,6 @@ - ${test.aws-s3.identity} - ${test.aws-s3.credential} ${test.hpcloud-objectstorage.identity} ${test.hpcloud-objectstorage.credential} ${appengine.sdk.root} diff --git a/demos/googleappengine/src/main/appengine/appengine-web.xml b/demos/googleappengine/src/main/appengine/appengine-web.xml index 662e689c2c..e2440d86da 100644 --- a/demos/googleappengine/src/main/appengine/appengine-web.xml +++ b/demos/googleappengine/src/main/appengine/appengine-web.xml @@ -25,5 +25,6 @@ - true + + false diff --git a/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllResourcesController.java b/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllResourcesController.java index 1be0d9ca74..1d9f450eaf 100644 --- a/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllResourcesController.java +++ b/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllResourcesController.java @@ -23,7 +23,6 @@ import static com.google.common.collect.Iterables.size; import static com.google.common.collect.Iterables.transform; import java.io.IOException; -import java.util.List; import java.util.Set; import java.util.concurrent.CancellationException; import java.util.concurrent.TimeUnit; @@ -50,7 +49,6 @@ import com.google.common.base.Stopwatch; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.collect.Lists; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -116,9 +114,8 @@ public class GetAllResourcesController extends HttpServlet { request.setAttribute("resources", results); } - private Set>> allResourcesWithinDeadline( - Iterable>>> asyncResources) { - Builder>> resourcesWeCanList = addToBuilderOnComplete(asyncResources); + private Set allResourcesWithinDeadline(Iterable> asyncResources) { + Builder resourcesWeCanList = addToBuilderOnComplete(asyncResources); // only serve resources that made it by the timeout blockUntilAllDoneOrCancelOnTimeout(asyncResources); @@ -126,22 +123,20 @@ public class GetAllResourcesController extends HttpServlet { return resourcesWeCanList.build(); } - private Builder>> addToBuilderOnComplete( - Iterable>>> asyncResources) { - - final Builder>> resourcesWeCanList = ImmutableSet - .>> builder(); + private Builder addToBuilderOnComplete(Iterable> asyncResources) { - for (final ListenableFuture>> asyncResource : asyncResources) { - Futures.addCallback(asyncResource, new FutureCallback>>() { - public void onSuccess(Iterable> result) { + final Builder resourcesWeCanList = ImmutableSet. builder(); + + for (final ListenableFuture asyncResource : asyncResources) { + Futures.addCallback(asyncResource, new FutureCallback() { + public void onSuccess(T result) { if (result != null) resourcesWeCanList.add(result); } public void onFailure(Throwable t) { if (!(t instanceof CancellationException)) - logger.info("exception getting resource %s: %s", asyncResource, t.getMessage()); + logger.error(t, "exception getting resource %s: %s", asyncResource, t.getMessage()); } }, currentRequestExecutorService); @@ -149,27 +144,27 @@ public class GetAllResourcesController extends HttpServlet { return resourcesWeCanList; } - private void blockUntilAllDoneOrCancelOnTimeout( - Iterable>>> asyncResources) { - List>>> remaining = Lists - .newArrayList(asyncResources); - - while (remaining.size() > 0) { - ListenableFuture resource = remaining.remove(0); - if (remainingMillis.get() <= 0) { - if (!resource.isDone()) - resource.cancel(true); - continue; + // ensure we don't violate our request timeouts. + private void blockUntilAllDoneOrCancelOnTimeout(Iterable> asyncResources) { + try { + for (ListenableFuture asyncResource : asyncResources) { + if (remainingMillis.get() > 0) { + try { + asyncResource.get(remainingMillis.get(), TimeUnit.MILLISECONDS); + } catch (Exception e) { + logger.info("exception getting resource %s: %s", asyncResource, e.getMessage()); + } + } } - - try { - resource.get(remainingMillis.get(), TimeUnit.MILLISECONDS); - } catch (Exception e) { - logger.info("exception getting resource %s: %s", resource, e.getMessage()); - if (!resource.isDone()) - resource.cancel(true); + } finally { + if (remainingMillis.get() < 0) { + for (ListenableFuture asyncResource : asyncResources) { + if (!asyncResource.isDone()) + asyncResource.cancel(true); + } } } + } } \ No newline at end of file