Issue 746: add properties for initStatusInitialPeriod and initStatusMaxPeriod

This commit is contained in:
Aled Sage 2011-12-16 23:59:33 +00:00
parent aa94c60df9
commit 570fab3dea
2 changed files with 23 additions and 7 deletions

View File

@ -28,8 +28,6 @@ import java.util.concurrent.TimeoutException;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.compute.domain.ExecResponse; 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.Predicate;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.util.concurrent.AbstractFuture; import com.google.common.util.concurrent.AbstractFuture;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; 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} * 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 @Inject
public BlockUntilInitScriptStatusIsZeroThenReturnOutput( public BlockUntilInitScriptStatusIsZeroThenReturnOutput(
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads,
ComputeServiceConstants.InitStatusProperties properties,
final ScriptStatusReturnsZero stateRunning, @Assisted final SudoAwareInitManager commandRunner) { final ScriptStatusReturnsZero stateRunning, @Assisted final SudoAwareInitManager commandRunner) {
long retryMaxWait = TimeUnit.DAYS.toMillis(365); // arbitrarily high value, but Long.MAX_VALUE doesn't work! long retryMaxWait = TimeUnit.DAYS.toMillis(365); // arbitrarily high value, but Long.MAX_VALUE doesn't work!
long retryPeriod = 500; long retryInitialPeriod = properties.initStatusInitialPeriod;
long retryMaxPeriod = 5000; long retryMaxPeriod = properties.initStatusMaxPeriod;
this.commandRunner = checkNotNull(commandRunner, "commandRunner"); this.commandRunner = checkNotNull(commandRunner, "commandRunner");
this.userThreads = checkNotNull(userThreads, "userThreads"); this.userThreads = checkNotNull(userThreads, "userThreads");
@ -83,7 +84,7 @@ public class BlockUntilInitScriptStatusIsZeroThenReturnOutput extends AbstractFu
public boolean apply(String arg0) { public boolean apply(String arg0) {
return commandRunner.runAction(arg0).getOutput().trim().equals(""); 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 * make sure we stop the retry loop if someone cancelled the future, this keeps threads
* from being consumed on dead tasks * from being consumed on dead tasks

View File

@ -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_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_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_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 * comma-separated nodes that we shouldn't attempt to list as they are dead
* some reason. * in the provider for some reason.
*/ */
public static final String PROPERTY_BLACKLIST_NODES = "jclouds.compute.blacklist-nodes"; 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"; 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 @Singleton
public static class ReferenceData { public static class ReferenceData {
@Inject(optional = true) @Inject(optional = true)