Example usage for com.amazonaws.services.codedeploy.model DeploymentInfo getStartTime

List of usage examples for com.amazonaws.services.codedeploy.model DeploymentInfo getStartTime

Introduction

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

Prototype


public java.util.Date getStartTime() 

Source Link

Document

A timestamp that indicates when the deployment was deployed to the deployment group.

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;
        }//from  w  ww  .  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));
    }
}