From 117bd1ba6b74534aa2c63c250b9b32565c2f7178 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 15 Jun 2010 00:26:59 -0400 Subject: [PATCH] Issue 210: updated aws demo with timeouts --- .../config/GuiceServletConfig.java | 10 ++++++++ .../ComputeServiceContextToStatusResult.java | 23 ++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java b/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java index 45ddfc0170..86ee6ac182 100755 --- a/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java +++ b/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java @@ -18,6 +18,11 @@ */ package org.jclouds.samples.googleappengine.config; +import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_RUNNING; +import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_TERMINATED; +import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_PORT_OPEN; +import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_SCRIPT_COMPLETE; + import java.io.IOException; import java.io.InputStream; import java.util.Map; @@ -56,6 +61,11 @@ public class GuiceServletConfig extends GuiceServletContextListener { @Override public void contextInitialized(ServletContextEvent servletContextEvent) { Properties props = loadJCloudsProperties(servletContextEvent); + props.setProperty(PROPERTY_TIMEOUT_NODE_TERMINATED, "25000"); + props.setProperty(PROPERTY_TIMEOUT_NODE_RUNNING, "25000"); + props.setProperty(PROPERTY_TIMEOUT_SCRIPT_COMPLETE, "25000"); + props.setProperty(PROPERTY_TIMEOUT_PORT_OPEN, "25000"); + ImmutableSet modules = ImmutableSet . of(new GoogleAppEngineConfigurationModule()); try { diff --git a/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/ComputeServiceContextToStatusResult.java b/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/ComputeServiceContextToStatusResult.java index 755a433328..3f9c8cfe42 100644 --- a/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/ComputeServiceContextToStatusResult.java +++ b/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/ComputeServiceContextToStatusResult.java @@ -19,22 +19,21 @@ package org.jclouds.samples.googleappengine.functions; import java.util.Map; -import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.domain.ComputeMetadata; +import org.jclouds.compute.options.TemplateOptions; import org.jclouds.logging.Logger; import org.jclouds.samples.googleappengine.domain.StatusResult; import com.google.common.base.Function; -import com.google.common.collect.Iterables; @Singleton -public class ComputeServiceContextToStatusResult implements Function { +public class ComputeServiceContextToStatusResult implements + Function { @Inject private Map contexts; @@ -44,14 +43,22 @@ public class ComputeServiceContextToStatusResult implements Function nodes = context.getComputeService().listNodes(); - if (nodes.size() > 0) - name = Iterables.get(nodes, 0).getProviderId(); + // set options that don't block so that we can avoid + // DeadLineExceededExceptions + TemplateOptions options = context.getComputeService() + .templateOptions().blockUntilRunning(false); + + // set the name to the default template to show that + // it works + name = context.getComputeService().templateBuilder().options(options) + .build().toString(); + status = ((System.currentTimeMillis() - start) + "ms"); } catch (Exception e) { logger.error(e, "Error listing service %s", contextName);