int durationMinutes,
Print print)
throws ExecutionProblem {
if (members.isEmpty()) {
throw new ExecutionProblem("this CloudDeployment has no members," +
" it cannot be launched");
}
final File dir = new File(dirPath);
if (!(dir.exists() && dir.isDirectory() && dir.canWrite())) {
throw new IllegalArgumentException("Provided directory must" +
" exist and be writeable");
}
final String eprIdIpDirPath = ExecuteUtil.makeDirectory(dirPath,
"id-ip-dir", print);
final String ensembleEprPath = new File(dir,
HistoryUtil.ENSEMBLE_EPR_FILE_NAME)
.getAbsolutePath();
RunTask[] tasks = new RunTask[members.size()];
for (int i = 0; i < members.size(); i++) {
MemberDeployment member = members.get(i);
boolean needsUserdata = (broker != null &&
member.getMember().getClusterForUserData() != null);
String memberName = HistoryUtil.getMemberName(i+1);
String printName = member.getMember().getPrintName();
if (printName == null) {
printName = memberName;
}
String eprPath = new File(dir, memberName +"-epr").getAbsolutePath();
if (member.getInstanceCount() == 1) {
eprPath += ".xml";
}
String metadataPath;
String deployPath;
String userdataPath = null;
try {
metadataPath = HistoryUtil.writeMetadata(dir,
memberName+"-metadata.xml",
cloud.generateMetadata(member));
deployPath = HistoryUtil.writeDeployment(dir,
memberName+"-deploy.xml",
cloud.generateDeployment(member, durationMinutes));
if (needsUserdata) {
userdataPath = HistoryUtil.writeUserData(dir,
memberName+"-userdata.xml",
broker,
member.getMember().getClusterForUserData());
}
} catch (Exception e) {
throw new ExecutionProblem("Problem writing data files for "+
printName,e);
}
tasks[i] = new RunTask(
eprPath,