ShutdownMechanism_Type shutdownMechanism = null;
if (this.args.trashAtShutdown) {
shutdownMechanism = ShutdownMechanism_Type.Trash;
}
URI newPropagationTargetURI = null;
try {
if (this.args.saveTarget != null) {
newPropagationTargetURI = new URI(this.args.saveTarget);
}
} catch (Exception e) {
throw new ParameterProblem("Problem with save-target '" +
this.args.saveTarget + "': " + e.getMessage(), e);
}
if (this.dep == null) {
boolean end = false;
String err = name() + " requires a deployment request. This " +
"can be specified by file or by a number of arguments." +
" Problem encountered is that a file request is not " +
"configured and expected commandline arguments are " +
"missing: ";
if (deployDuration < 1 && memoryRequest < 1) {
end = true;
err += "duration and memory request.";
} else if (memoryRequest < 1) {
end = true;
err += "memory request.";
} else if (deployDuration < 1) {
end = true;
err += "duration.";
}
if (end) {
throw new ParameterProblem(err);
}
// default is 1
if (numNodes < 1) {
numNodes = 1;
}
// default is Running
if (requestState == null) {
requestState = InitialState_Type.Running;
}
// shutdownMechanism has no default except 'not set' which
// triggers 'normal'
this.dep = WSUtils.constructDeploymentType(deployDuration,
memoryRequest,
numNodes,
requestState,
shutdownMechanism,
newPropagationTargetURI);
if (this.pr.enabled()) {
final String msg =
"Created deployment request soley from arguments.";
if (this.pr.useThis()) {
this.pr.infoln(
PrCodes.DEPREQ__USING_ARGS, msg);
} else if (this.pr.useLogging()) {
logger.info(msg);
}
}
} else {
if (deployDuration > 0) {
if (this.pr.enabled()) {
final String msg =
"Duration argument provided: overriding duration " +
"found in deployment request file, it is now: " +
deployDuration + " minutes";
final String dbg;
try {
final int oldMins = CommonUtil.durationToMinutes(
this.dep.getDeploymentTime().getMinDuration());
dbg = "Old duration: " + oldMins + " minutes";
} catch (InvalidDurationException e) {
throw new ParameterProblem(e.getMessage(), e);
}
if (this.pr.useThis()) {
this.pr.infoln(
PrCodes.DEPREQ__FILE_OVERRIDE, msg);
this.pr.dbg(dbg);
} else if (this.pr.useLogging()) {
logger.info(msg);
logger.debug(dbg);
}
}
this.dep.setDeploymentTime(
WSUtils.constructDeploymentTime_Type(deployDuration));
}
if (memoryRequest > 0) {
if (this.pr.enabled()) {
final String msg =
"Memory argument provided: overriding memory " +
"found in deployment request file, it is now: " +
memoryRequest + " MB";
if (this.pr.useThis()) {
this.pr.infoln(
PrCodes.DEPREQ__FILE_OVERRIDE, msg);
} else if (this.pr.useLogging()) {
logger.info(msg);
}
}
WSUtils.setMemory(memoryRequest,
this.dep.getResourceAllocation());
}
if (numNodes > 0) {
if (this.pr.enabled()) {
final String msg =
"Num-nodes argument provided: overriding number " +
"found in deployment request file, it is now: " +
numNodes + " nodes";
final String dbg = "Old num-nodes: " +
this.dep.getNodeNumber();
if (this.pr.useThis()) {
this.pr.infoln(
PrCodes.DEPREQ__FILE_OVERRIDE, msg);
this.pr.dbg(dbg);
} else if (this.pr.useLogging()) {
logger.info(msg);
logger.debug(dbg);
}
}
this.dep.setNodeNumber(numNodes);
}
if (requestState != null) {
if (this.pr.enabled()) {
final String msg =
"Initial state argument provided: overriding " +
"initial state setting found in deployment request " +
"file, it is now: " + requestState.getValue();
final String dbg = "Old state: " +
this.dep.getInitialState().getValue();
if (this.pr.useThis()) {
this.pr.infoln(
PrCodes.DEPREQ__FILE_OVERRIDE, msg);
this.pr.dbg(dbg);
} else if (this.pr.useLogging()) {
logger.info(msg);
logger.debug(dbg);
}
}
this.dep.setInitialState(requestState);
}
if (shutdownMechanism != null) {
if (this.pr.enabled()) {
boolean presentInFile = false;
String dbg = "No setting in file for shutdown mechanism";
if (this.dep.getShutdownMechanism() != null) {
presentInFile = true;
dbg = "Old shutdown mechanism: " +
this.dep.getShutdownMechanism().getValue();
}
final String msg;
if (presentInFile) {
msg = "Shutdown mechanism argument provided: " +
"overriding shutdown mechanism setting found " +
"in deployment request file, it is now: " +
requestState.getValue();
} else {
msg = "Setting shutdown mechanism to: " +
requestState.getValue();
}
if (this.pr.useThis()) {
this.pr.infoln(
PrCodes.DEPREQ__FILE_OVERRIDE, msg);
this.pr.dbg(dbg);
} else if (this.pr.useLogging()) {
logger.info(msg);
logger.debug(dbg);
}
}
this.dep.setShutdownMechanism(shutdownMechanism);
}
if (newPropagationTargetURI != null) {
if (this.pr.enabled()) {
boolean presentInFile = false;
String dbg = "No setting in file for alternate " +
"propagation target";
if (this.dep.getPostShutdown() != null) {
if (this.dep.getPostShutdown().
getRootPartitionUnpropagationTarget() != null) {
presentInFile = true;
dbg = "Old alternate propagation target: " +
this.dep.getPostShutdown().
getRootPartitionUnpropagationTarget().toString();
}
}
final String msg;
if (presentInFile) {
msg = "Alternate propagation target argument provided: " +
"overriding the setting found " +
"in deployment request file, it is now '" +
newPropagationTargetURI.toString() + "'";
} else {
msg = "Setting alternate propagation target to '" +
newPropagationTargetURI.toString() + "'";
}
if (this.pr.useThis()) {
this.pr.infoln(
PrCodes.DEPREQ__FILE_OVERRIDE, msg);