diff --git a/compute/src/main/java/org/jclouds/compute/callables/BlockUntilInitScriptStatusIsZeroThenReturnOutput.java b/compute/src/main/java/org/jclouds/compute/callables/BlockUntilInitScriptStatusIsZeroThenReturnOutput.java index 1d964534e4..ded9d6d971 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/BlockUntilInitScriptStatusIsZeroThenReturnOutput.java +++ b/compute/src/main/java/org/jclouds/compute/callables/BlockUntilInitScriptStatusIsZeroThenReturnOutput.java @@ -28,8 +28,6 @@ import java.util.concurrent.TimeoutException; import javax.annotation.PostConstruct; import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; import org.jclouds.Constants; import org.jclouds.compute.domain.ExecResponse; @@ -43,7 +41,9 @@ import org.jclouds.ssh.SshClient; import com.google.common.base.Predicate; import com.google.common.base.Throwables; import com.google.common.util.concurrent.AbstractFuture; +import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; +import com.google.inject.name.Named; /** * A future that works in tandem with a task that was invoked by {@link InitBuilder} @@ -69,11 +69,12 @@ public class BlockUntilInitScriptStatusIsZeroThenReturnOutput extends AbstractFu @Inject public BlockUntilInitScriptStatusIsZeroThenReturnOutput( @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, + ComputeServiceConstants.InitStatusProperties properties, final ScriptStatusReturnsZero stateRunning, @Assisted final SudoAwareInitManager commandRunner) { long retryMaxWait = TimeUnit.DAYS.toMillis(365); // arbitrarily high value, but Long.MAX_VALUE doesn't work! - long retryPeriod = 500; - long retryMaxPeriod = 5000; + long retryInitialPeriod = properties.initStatusInitialPeriod; + long retryMaxPeriod = properties.initStatusMaxPeriod; this.commandRunner = checkNotNull(commandRunner, "commandRunner"); this.userThreads = checkNotNull(userThreads, "userThreads"); @@ -83,7 +84,7 @@ public class BlockUntilInitScriptStatusIsZeroThenReturnOutput extends AbstractFu public boolean apply(String arg0) { return commandRunner.runAction(arg0).getOutput().trim().equals(""); } - }, retryMaxWait, retryPeriod, retryMaxPeriod, TimeUnit.MILLISECONDS) { + }, retryMaxWait, retryInitialPeriod, retryMaxPeriod, TimeUnit.MILLISECONDS) { /** * make sure we stop the retry loop if someone cancelled the future, this keeps threads * from being consumed on dead tasks diff --git a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java index 745af1cd2f..649a00aca4 100644 --- a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java +++ b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java @@ -36,9 +36,13 @@ public interface ComputeServiceConstants { public static final String PROPERTY_TIMEOUT_NODE_SUSPENDED = "jclouds.compute.timeout.node-suspended"; public static final String PROPERTY_TIMEOUT_SCRIPT_COMPLETE = "jclouds.compute.timeout.script-complete"; public static final String PROPERTY_TIMEOUT_PORT_OPEN = "jclouds.compute.timeout.port-open"; + + public static final String PROPERTY_INIT_STATUS_INITIAL_PERIOD = "jclouds.compute.init-status.initial-period"; + public static final String PROPERTY_INIT_STATUS_MAX_PERIOD = "jclouds.compute.init-status.max-period"; + /** - * comma-separated nodes that we shouldn't attempt to list as they are dead in the provider for - * some reason. + * comma-separated nodes that we shouldn't attempt to list as they are dead + * in the provider for some reason. */ public static final String PROPERTY_BLACKLIST_NODES = "jclouds.compute.blacklist-nodes"; @@ -53,6 +57,17 @@ public interface ComputeServiceConstants { */ public static final String PROPERTY_OS_VERSION_MAP_JSON = "jclouds.compute.os-version-map-json"; + @Singleton + public static class InitStatusProperties { + @Inject(optional = true) + @Named(PROPERTY_INIT_STATUS_INITIAL_PERIOD) + public long initStatusInitialPeriod = 500; + + @Inject(optional = true) + @Named(PROPERTY_INIT_STATUS_MAX_PERIOD) + public long initStatusMaxPeriod = 5000; + } + @Singleton public static class ReferenceData { @Inject(optional = true)