From: <ju...@us...> - 2007-08-07 00:20:31
|
Revision: 4919 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=4919&view=rev Author: julgui Date: 2007-08-06 17:19:43 -0700 (Mon, 06 Aug 2007) Log Message: ----------- New -t option to terminate successful deployments when using multiple deployment and one of them fails. Not finished yet. SFOS-382 Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java 2007-08-06 20:23:43 UTC (rev 4918) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java 2007-08-07 00:19:43 UTC (rev 4919) @@ -25,6 +25,8 @@ import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.TerminationRecord; + import java.util.Hashtable; import java.rmi.RemoteException; import java.io.IOException; @@ -161,6 +163,20 @@ public Object resultObject = null; /** + * A result can be terminated if during a set of deployments one of them + * fails, this is related to -t (terminate) option and it can only be applied + * to DEPLOY actions. + */ + public boolean isResultTerminated = false; + /** + * Indicates if the termination of a result object was succesful. + */ + public boolean isResultTerminatedSuccessfully=true; + + /** possible result termination error message */ + public String resultTerminationMessage=null; + + /** * Result message for action */ private String resultMessage = null; @@ -405,7 +421,7 @@ result= messageError.toString(); } if ((Logger.logStackTrace)|| - (((resultMessage != null) || (resultException != null)) && (resultType != Result.SUCCESSFUL))) { + (((resultMessage != null) || (resultException != null)) && ((resultType != Result.SUCCESSFUL)|| isResultTerminated))) { messageError = new StringBuffer(); messageError.append(lineSeparator); messageError.append("Result:"); @@ -428,6 +444,13 @@ messageError.append("'"); } } + if (isResultTerminated) { + messageError.append(lineSeparator); + messageError.append("* Result termination "); + if (isResultTerminatedSuccessfully) messageError.append(" succeeded"); + else messageError.append(" failed"); + if (resultTerminationMessage!=null) messageError.append("; Message: "+resultTerminationMessage); + } if (originalSFACT!=null && Logger.logStackTrace) { messageError.append(lineSeparator); messageError.append("* Command line SFACT: '"); @@ -938,6 +961,27 @@ return resultObject; } + /** Terminates result object ONLY a result exists and it was deployed by this configuration descriptor using + * a DEPLOY action. The success of the termination intent will be stored in {@link #isResultTerminatedSuccessfully} + * @return true if it tried to terminate result, false it it did not try + */ + public boolean terminateDeployedResult (){ + if ((resultObject!=null)&& (resultObject instanceof Prim) && + (getActionType() == Action.DEPLOY) && !isResultTerminated){ + try { + this.isResultTerminated=true; + ((Prim)resultObject).sfTerminate(new TerminationRecord(TerminationRecord. + NORMAL, + "Multiple deployment failed", null)); + } catch (RemoteException ex) { + this.resultTerminationMessage = ex.toString(); + } + return true; + } + + return false; + } + /** * get the name of this component * @return String component name Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java 2007-08-06 20:23:43 UTC (rev 4918) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java 2007-08-07 00:19:43 UTC (rev 4919) @@ -48,7 +48,7 @@ /** Usage string for SFSystem. */ private static final String USAGE = "\n" + - " Usage: SFSystem [-a SFACT] [-f SFREF] [-e] [-d] [-headless]\n" + + " Usage: SFSystem [-a SFACT] [-f SFREF] [-t] [-e] [-d] [-headless]\n" + " or: SFSystem -?\n"; /** Help string for SFSystem. */ @@ -94,8 +94,8 @@ " ex4: Get diagnostics report for \"sfDefault\" component running in remote daemon\n" + " 'rootProcess:sfDefault':DIAGNOSTICS:::remoteHostName:\n" + "\n" + - " -f SFREF: file with a set of SmartFrog Action Descriptors (SFACT)" + - "\n" + + " -f SFREF: file with a set of SmartFrog Action Descriptors (SFACT)" +"\n" + + " -t (terminate): Terminate successfull deployments if one of the listed (with -a or -f) deployments failed." + "\n" + " -e (exit): The daemon will terminate after finishing the deployment." + "\n" + " -d or -diagnostics: print information that might be helpful to diagnose or report problems." + "\n" + " " + OPTION_HEADLESS + ": the process will run in headless mode\n" + @@ -119,6 +119,9 @@ /** Vector for configurationDescriptors to be deployed. */ public Vector cfgDescriptors = new Vector(); + /** Terminate sucessful deployments in case of a deployment failure. */ + public boolean terminateOnDeploymentFailure = false; + /** Flag indicating the exit status of the application. */ public boolean exit = false; @@ -170,6 +173,8 @@ } else if ("-d".equals(currentArg) || "-diagnostics".equals(currentArg)) { //diagnostics diagnostics = true; + } else if ("-t".equals(currentArg)) { + this.terminateOnDeploymentFailure = true; } else if ("-e".equals(currentArg)) { //exit after the operation(s) exit = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |