logger.tracef("Add of deployment %s", deploymentName);
String runtimeName = dai.getNewContentFileName();
byte[] hash = dai.getNewContentHash();
if (runtimeName == null) {
// This is a request to add already existing content to this set's server groups
DeploymentUnitElement de = model.getDeployment(deploymentName);
if (de == null) {
throw new InvalidDeploymentPlanException("Unknown deployment unit " + deploymentName);
}
runtimeName = de.getRuntimeName();
hash = de.getSha1Hash();
}
else if (model.getDeployment(deploymentName) == null) {
// Deployment is new to the domain; add it
DomainDeploymentAdd dda = new DomainDeploymentAdd(deploymentName, runtimeName, hash, false);
au.domainUpdates.add(new DomainUpdate(dda, model, true));
}
// Now add to serve groups
ServerGroupDeploymentAdd sgda = new ServerGroupDeploymentAdd(deploymentName, runtimeName, hash, false);
addServerGroupUpdates(plan, au, sgda, model);
break;
}
case DEPLOY: {
logger.tracef("Deploy of deployment %s", dai.getDeploymentUnitUniqueName());
ServerGroupDeploymentStartStopUpdate sgdssu = new ServerGroupDeploymentStartStopUpdate(dai.getDeploymentUnitUniqueName(), true);
addServerGroupUpdates(plan, au, sgdssu, model);
break;
}
case FULL_REPLACE: {
logger.tracef("Full replace of deployment %s", dai.getDeploymentUnitUniqueName());
// Validate all relevant server groups are touched
String deploymentName = dai.getDeploymentUnitUniqueName();
Set<String> names = new LinkedHashSet<String>(model.getServerGroupNames());
for (Set<ServerGroupDeploymentPlan> ssgp : plan.getServerGroupDeploymentPlans()) {
for (ServerGroupDeploymentPlan sgdp : ssgp) {
names.remove(sgdp.getServerGroupName());
}
}
for (Iterator<String> it = names.iterator(); it.hasNext();) {
String name = it.next();
ServerGroupElement sge = model.getServerGroup(name);
if (sge.getDeployment(dai.getDeploymentUnitUniqueName()) == null) {
it.remove();
}
}
if (names.size() > 0) {
throw new IncompleteDeploymentReplaceException(deploymentName, names.toArray(new String[names.size()]));
}
DeploymentUnitElement deployment = model.getDeployment(dai.getDeploymentUnitUniqueName());
boolean start = deployment != null && deployment.isStart();
DomainDeploymentFullReplaceUpdate ddfru = new DomainDeploymentFullReplaceUpdate(deploymentName, dai.getNewContentFileName(), dai.getNewContentHash(), start);
au.domainUpdates.add(new DomainUpdate(ddfru, model, true));
break;
}
case REDEPLOY: {