int duration = this.args.getDurationMinutes();
int pollMs = this.args.getPollMs();
if (clusterPath == null) {
throw new ParameterProblem("You must specify a cluster " +
"document with --" + Opts.CLUSTER_OPT_STRING);
}
this.cluster = ClusterUtil.getCluster(clusterPath, this.print);
Cloudworkspace_Type[] workspaces = this.cluster.getWorkspace();
if (workspaces == null || workspaces.length == 0) {
throw new ParameterProblem("The cluster document must contain "+
"at least one workspace");
}
for (Cloudworkspace_Type ws : workspaces) {
final Clouddeploy_Type[] deploys = ws.getDeploy();
if (deploys != null && deploys.length > 0) {
// we may want to enable this functionality in the future
// but let's keep things simple for now
throw new ParameterProblem("Your cluster document includes <deploy> " +
"elements, which are not allowed at this time.");
}
String name = ws.getName();
if (name == null || name.trim().length() == 0) {
throw new ParameterProblem("Every workspace must have a unique "+
"name");
}
name = name.trim();
for (Cloudworkspace_Type existingWs : this.workspaceList) {
String existingWsName = existingWs.getName().trim();
if (existingWsName.equals(name)) {
throw new ParameterProblem("Every workspace must have a " +
"unique name");
}
}
this.workspaceList.add(ws);
}
if (deployPath == null) {
throw new ParameterProblem("You must specify a deployment document " +
"using the --"+Opts.DEPLOY_OPT_STRING+" option");
}
final Map<String, Clouddeploy_Type[]> deployMap;
try {
final Clouddeployment_Type deployDoc =
ClusterUtil.parseDeployDocument(deployPath);
deployMap = ClusterUtil.parseDeployment(deployDoc);
} catch (DeserializationException de) {
throw new ParameterProblem("Failed to parse deployment " +
"document: " + de.getMessage());
} catch (IOException ie) {
throw new ParameterProblem("Failed to read deployment "+
"document: "+ ie.getMessage());
}
handleDeploymentMap(deployMap);
if (this.needsBroker) {
if (brokerUrl == null || brokerId == null) {
throw new ParameterProblem("You must specify a valid Context " +
"Broker URL and identity string in your properties file ("+
this.args.getPropertiesPath()+") keys: "+
Props.KEY_BROKER_URL+" and " + Props.KEY_BROKER_IDENTITY
);
}
}
if (sshFile == null) {
this.print.info("\nWarning: a SSH public key was not specified. " +
"It will not be installed into cluster.");
}
if (duration <= 0) {
throw new ParameterProblem("Please specify a valid duration (--"+
Opts.HOURS_OPT_STRING+")");
}
if (pollMs <= 0) {
throw new ParameterProblem("Please specify a valid polling " +
"frequency in the properties file ("+
this.args.getPropertiesPath()+")");
}
}