Created
May 21, 2012 22:15
Revisions
-
kmalhi created this gist
May 21, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ 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; }