Example usage for com.amazonaws.services.codedeploy.model GetDeploymentRequest GetDeploymentRequest

List of usage examples for com.amazonaws.services.codedeploy.model GetDeploymentRequest GetDeploymentRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.codedeploy.model GetDeploymentRequest GetDeploymentRequest.

Prototype

GetDeploymentRequest

Source Link

Usage

From source file:jetbrains.buildServer.runner.codedeploy.AWSClient.java

License:Apache License

private void waitForDeployment(@NotNull String deploymentId, int waitTimeoutSec, int waitIntervalSec) {
    myListener.deploymentWaitStarted(deploymentId);

    final GetDeploymentRequest dRequest = new GetDeploymentRequest().withDeploymentId(deploymentId);

    DeploymentInfo dInfo = myCodeDeployClient.getDeployment(dRequest).getDeploymentInfo();

    long startTime = (dInfo == null || dInfo.getStartTime() == null) ? System.currentTimeMillis()
            : dInfo.getStartTime().getTime();

    while (dInfo == null || dInfo.getCompleteTime() == null) {
        myListener.deploymentInProgress(deploymentId, getInstancesStatus(dInfo));

        if (System.currentTimeMillis() - startTime > waitTimeoutSec * 1000) {
            myListener.deploymentFailed(deploymentId, waitTimeoutSec, getErrorInfo(dInfo),
                    getInstancesStatus(dInfo));
            return;
        }/*  w  w w  .  j a  v a  2  s. c  o m*/

        try {
            Thread.sleep(waitIntervalSec * 1000);
        } catch (InterruptedException e) {
            processFailure(e);
            return;
        }

        dInfo = myCodeDeployClient.getDeployment(dRequest).getDeploymentInfo();
    }

    if (isSuccess(dInfo)) {
        myListener.deploymentSucceeded(deploymentId, getInstancesStatus(dInfo));
    } else {
        myListener.deploymentFailed(deploymentId, null, getErrorInfo(dInfo), getInstancesStatus(dInfo));
    }
}