Created
May 21, 2012 22:15
-
-
Save karanmalhi/2765027 to your computer and use it in GitHub Desktop.
deploymentStatus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private DeploymentStatus getDeploymentStatus(DeploymentAction latest) { | |
DeploymentStatus status; | |
if (Action.DELETE.equals(latest.getAction())) { | |
status = DeploymentStatus.DELETING; | |
} else { | |
boolean inProcess = false; | |
int failCount = 0; | |
// if size is 0, that means we do not have any status yes, a typical indication that the deployment on servers has not started yet. | |
if (latest.getStatuses().size() == 0) { | |
// the deployment is still in progress, i.e. about to start | |
status = DeploymentStatus.IN_PROGRESS; | |
return status; | |
} | |
for (ServerDeploy s : latest.getStatuses()) { | |
switch (s.getState()) { | |
case IN_PROCESS: | |
inProcess = true; | |
break; | |
case FAILED: | |
failCount++; | |
break; | |
} | |
} | |
// the order of check is critical here. Even if we get a failure, we still need to make sure that deployments on other servers complete | |
// i.e. you want to let the deployment finish on as many servers as possible , hence we want to keep it in progress till then | |
if (inProcess) { | |
status = DeploymentStatus.IN_PROGRESS; | |
} else if (failCount == 0) { | |
status = DeploymentStatus.SUCCESSFUL; | |
} else { | |
status = DeploymentStatus.FAILED; | |
} | |
} | |
return status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment