cleared up javadoc on blockUntilRunning and blockOnComplete

This commit is contained in:
Adrian Cole 2011-08-11 15:55:44 +01:00
parent 46a42c22d8
commit 69e7b101bb
3 changed files with 50 additions and 21 deletions

View File

@ -185,6 +185,15 @@ public class RunScriptOptions {
return this; return this;
} }
/**
* As of version 1.1.0, we cannot kick off a script unless a node is in
* RUNNING state.
*
* @param blockOnComplete (default true)
* false means kick off the script in the background, but don't
* wait for it to finish. (as of version 1.1.0, implemented as
* nohup)
*/
public RunScriptOptions blockOnComplete(boolean blockOnComplete) { public RunScriptOptions blockOnComplete(boolean blockOnComplete) {
this.blockOnComplete = blockOnComplete; this.blockOnComplete = blockOnComplete;
return this; return this;
@ -233,9 +242,7 @@ public class RunScriptOptions {
} }
/** /**
* Whether to wait until the script has completed. By default, true. * @see #blockOnComplete(boolean)
*
* @return value
*/ */
public boolean shouldBlockOnComplete() { public boolean shouldBlockOnComplete() {
return blockOnComplete; return blockOnComplete;
@ -277,6 +284,9 @@ public class RunScriptOptions {
return options.runAsRoot(value); return options.runAsRoot(value);
} }
/**
* @see RunScriptOptions#blockOnComplete(boolean)
*/
public static RunScriptOptions blockOnComplete(boolean value) { public static RunScriptOptions blockOnComplete(boolean value) {
RunScriptOptions options = new RunScriptOptions(); RunScriptOptions options = new RunScriptOptions();
return options.blockOnComplete(value); return options.blockOnComplete(value);

View File

@ -25,6 +25,7 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set; import java.util.Set;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statement;
@ -148,6 +149,9 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
throw new IllegalArgumentException("script is immutable"); throw new IllegalArgumentException("script is immutable");
} }
/**
* unsupported as objects of this class are immutable
*/
@Override @Override
public TemplateOptions runScript(Statement script) { public TemplateOptions runScript(Statement script) {
throw new IllegalArgumentException("script is immutable"); throw new IllegalArgumentException("script is immutable");
@ -219,6 +223,9 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
throw new IllegalArgumentException("publicKey is immutable"); throw new IllegalArgumentException("publicKey is immutable");
} }
/**
* unsupported as objects of this class are immutable
*/
@Override @Override
public TemplateOptions blockUntilRunning(boolean blockUntilRunning) { public TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
throw new IllegalArgumentException("blockUntilRunning is immutable"); throw new IllegalArgumentException("blockUntilRunning is immutable");
@ -314,6 +321,9 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
return includeMetadata; return includeMetadata;
} }
/**
* @see TemplateOptions#blockUntilRunning(boolean)
*/
public boolean shouldBlockUntilRunning() { public boolean shouldBlockUntilRunning() {
return blockUntilRunning; return blockUntilRunning;
} }
@ -323,11 +333,9 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
/** /**
* This script will be executed as the root user upon system startup. This script gets a
* prologue, so no #!/bin/bash required, path set up, etc
* <p/> * <p/>
* please use alternative that uses the {@link org.jclouds.scriptbuilder.domain.Statement} object * please use alternative that uses the {@link org.jclouds.scriptbuilder.domain.Statement} object
* * @see TemplateOptions#runScript(Statement)
* @see org.jclouds.io.Payloads * @see org.jclouds.io.Payloads
*/ */
@Deprecated @Deprecated
@ -336,9 +344,7 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
/** /**
* This script will be executed as the root user upon system startup. This script gets a * @see TemplateOptions#runScript(Statement)
* prologue, so no #!/bin/bash required, path set up, etc
*
* @see org.jclouds.io.Payloads * @see org.jclouds.io.Payloads
*/ */
public TemplateOptions runScript(Payload script) { public TemplateOptions runScript(Payload script) {
@ -350,6 +356,11 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
} }
/**
* This script will be executed as the root user upon system startup. This script gets a
* prologue, so no #!/bin/bash required, path set up, etc
*
*/
public TemplateOptions runScript(Statement script) { public TemplateOptions runScript(Statement script) {
this.script = checkNotNull(script, "script"); this.script = checkNotNull(script, "script");
return this; return this;
@ -488,7 +499,7 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
/** /**
* @see TemplateOptions#blockUntilRunning * @see TemplateOptions#blockUntilRunning(boolean)
*/ */
public static TemplateOptions blockUntilRunning(boolean blockUntilRunning) { public static TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
TemplateOptions options = new TemplateOptions(); TemplateOptions options = new TemplateOptions();
@ -496,10 +507,9 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
/** /**
* please use alternative that uses the {@link org.jclouds.io.Payload} object * please use alternative that uses the {@link Statement) object
* *
* @see org.jclouds.io.Payloads * @see TemplateOptions#runScript(Statement)
* @see #runScript(Payload)
*/ */
@Deprecated @Deprecated
public static TemplateOptions runScript(byte[] script) { public static TemplateOptions runScript(byte[] script) {
@ -508,7 +518,7 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
/** /**
* @see TemplateOptions#runScript * @see TemplateOptions#runScript(Statement)
* @see org.jclouds.io.Payloads * @see org.jclouds.io.Payloads
*/ */
public static TemplateOptions runScript(Payload script) { public static TemplateOptions runScript(Payload script) {
@ -517,8 +527,7 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
/** /**
* @see TemplateOptions#runScript * @see TemplateOptions#runScript(Statement)
* @see org.jclouds.io.Payloads
*/ */
public static TemplateOptions runScript(Statement script) { public static TemplateOptions runScript(Statement script) {
TemplateOptions options = new TemplateOptions(); TemplateOptions options = new TemplateOptions();
@ -587,6 +596,16 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
+ ", metadata/details: " + includeMetadata + "]"; + ", metadata/details: " + includeMetadata + "]";
} }
/**
* <h4>Note</h4> As of version 1.1.0, this option is incompatible with
* {@link TemplateOptions#runScript(Statement)} and
* {@link RunScriptOptions#blockOnComplete(boolean)}, as all current
* implementations utilize ssh in order to execute scripts.
*
* @param blockUntilRunning
* (default true) whether to block until the nodes in this template
* are in {@link NodeState#RUNNING} state
*/
public TemplateOptions blockUntilRunning(boolean blockUntilRunning) { public TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
this.blockUntilRunning = blockUntilRunning; this.blockUntilRunning = blockUntilRunning;
if (!blockUntilRunning) if (!blockUntilRunning)

View File

@ -44,7 +44,7 @@ import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
@ -133,7 +133,7 @@ public class BaseCloudStackClientLiveTest {
"invalid account type: %s, please specify an apiKey of a USER, for example: %s", currentUser "invalid account type: %s, please specify an apiKey of a USER, for example: %s", currentUser
.getAccountType(), Iterables.filter(users, UserPredicates.isUserAccount()))); .getAccountType(), Iterables.filter(users, UserPredicates.isUserAccount())));
injector = Guice.createInjector(new JschSshClientModule(), new Log4JLoggingModule()); injector = Guice.createInjector(new SshjSshClientModule(), new Log4JLoggingModule());
sshFactory = injector.getInstance(SshClient.Factory.class); sshFactory = injector.getInstance(SshClient.Factory.class);
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, 1, TimeUnit.SECONDS); socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, 1, TimeUnit.SECONDS);
injector.injectMembers(socketTester); injector.injectMembers(socketTester);