List of usage examples for com.amazonaws.services.ec2 AmazonEC2Client shutdown
@Override public void shutdown()
From source file:com.netflix.ice.basic.BasicReservationService.java
License:Apache License
private void pollAPI() throws Exception { long currentTime = new DateMidnight().getMillis(); DescribeReservedInstancesOfferingsRequest req = new DescribeReservedInstancesOfferingsRequest().withFilters( new com.amazonaws.services.ec2.model.Filter().withName("marketplace").withValues("false")); String token = null;//ww w. j a v a2s . com boolean hasNewPrice = false; AmazonEC2Client ec2Client = new AmazonEC2Client(AwsUtils.awsCredentialsProvider, AwsUtils.clientConfig); for (Region region : Region.getAllRegions()) { ec2Client.setEndpoint("ec2." + region.name + ".amazonaws.com"); do { if (!StringUtils.isEmpty(token)) req.setNextToken(token); DescribeReservedInstancesOfferingsResult offers = ec2Client.describeReservedInstancesOfferings(req); token = offers.getNextToken(); for (ReservedInstancesOffering offer : offers.getReservedInstancesOfferings()) { if (offer.getProductDescription().indexOf("Amazon VPC") >= 0) continue; ReservationUtilization utilization = ReservationUtilization.get(offer.getOfferingType()); Ec2InstanceReservationPrice.ReservationPeriod term = offer.getDuration() / 24 / 3600 > 366 ? Ec2InstanceReservationPrice.ReservationPeriod.threeyear : Ec2InstanceReservationPrice.ReservationPeriod.oneyear; if (term != this.term) continue; double hourly = offer.getUsagePrice(); if (hourly <= 0) { for (RecurringCharge recurringCharge : offer.getRecurringCharges()) { if (recurringCharge.getFrequency().equals("Hourly")) { hourly = recurringCharge.getAmount(); break; } } } UsageType usageType = getUsageType(offer.getInstanceType(), offer.getProductDescription()); hasNewPrice = setPrice(utilization, currentTime, Zone.getZone(offer.getAvailabilityZone()).region, usageType, offer.getFixedPrice(), hourly) || hasNewPrice; logger.info("Setting RI price for " + Zone.getZone(offer.getAvailabilityZone()).region + " " + utilization + " " + usageType + " " + offer.getFixedPrice() + " " + hourly); } } while (!StringUtils.isEmpty(token)); } ec2Client.shutdown(); if (hasNewPrice) { for (ReservationUtilization utilization : files.keySet()) { File file = files.get(utilization); DataOutputStream out = new DataOutputStream(new FileOutputStream(file)); try { Serializer.serialize(out, this.ec2InstanceReservationPrices.get(utilization)); AwsUtils.upload(config.workS3BucketName, config.workS3BucketPrefix, file); } finally { out.close(); } } } }
From source file:com.netflix.ice.processor.ReservationCapacityPoller.java
License:Apache License
@Override protected void poll() throws Exception { ProcessorConfig config = ProcessorConfig.getInstance(); // read from s3 if not exists File file = new File(config.localDir, "reservation_capacity.txt"); if (!file.exists()) { logger.info("downloading " + file + "..."); AwsUtils.downloadFileIfNotExist(config.workS3BucketName, config.workS3BucketPrefix, file); logger.info("downloaded " + file); }/* ww w . ja v a2 s. c o m*/ // read from file Map<String, ReservedInstances> reservations = Maps.newTreeMap(); if (file.exists()) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String line; while ((line = reader.readLine()) != null) { String[] tokens = line.split(","); String accountId = tokens[0]; String region = tokens[1]; String reservationId = tokens[2]; String zone = tokens[3]; Long start = Long.parseLong(tokens[4]); long duration = Long.parseLong(tokens[5]); String instanceType = tokens[6]; String productDescription = tokens[7]; int instanceCount = Integer.parseInt(tokens[8]); String offeringType = tokens[9]; String state = tokens[10]; Long end = tokens.length > 11 ? Long.parseLong(tokens[11]) : null; float fixedPrice = tokens.length > 12 ? Float.parseFloat(tokens[12]) : 0; float usagePrice = tokens.length > 13 ? Float.parseFloat(tokens[13]) : 0; ReservedInstances reservation = new ReservedInstances().withAvailabilityZone(zone) .withStart(new Date(start)).withDuration(duration).withInstanceType(instanceType) .withProductDescription(productDescription).withInstanceCount(instanceCount) .withOfferingType(offeringType).withState(state).withFixedPrice(fixedPrice) .withUsagePrice(usagePrice); if (end != null) reservation.setEnd(new Date(end)); else reservation.setEnd(new Date(start + duration * 1000)); reservations.put(accountId + "," + region + "," + reservationId, reservation); } } catch (Exception e) { logger.error("error in reading " + file, e); } finally { if (reader != null) try { reader.close(); } catch (Exception e) { } } } logger.info("read " + reservations.size() + " reservations."); for (Account account : config.accountService.getReservationAccounts().keySet()) { try { AmazonEC2Client ec2Client; String assumeRole = config.accountService.getReservationAccessRoles().get(account); if (assumeRole != null) { String externalId = config.accountService.getReservationAccessExternalIds().get(account); final Credentials credentials = AwsUtils.getAssumedCredentials(account.id, assumeRole, externalId); ec2Client = new AmazonEC2Client(new AWSSessionCredentials() { public String getAWSAccessKeyId() { return credentials.getAccessKeyId(); } public String getAWSSecretKey() { return credentials.getSecretAccessKey(); } public String getSessionToken() { return credentials.getSessionToken(); } }); } else ec2Client = new AmazonEC2Client(AwsUtils.awsCredentialsProvider.getCredentials(), AwsUtils.clientConfig); for (Region region : Region.getAllRegions()) { ec2Client.setEndpoint("ec2." + region.name + ".amazonaws.com"); try { DescribeReservedInstancesResult result = ec2Client.describeReservedInstances(); for (ReservedInstances reservation : result.getReservedInstances()) { String key = account.id + "," + region.name + "," + reservation.getReservedInstancesId(); reservations.put(key, reservation); if (reservation.getEnd() == null) reservation.setEnd(new Date( reservation.getStart().getTime() + reservation.getDuration() * 1000L)); if (reservation.getFixedPrice() == null) reservation.setFixedPrice(0f); if (reservation.getUsagePrice() == null) reservation.setUsagePrice(0f); } } catch (Exception e) { logger.error("error in describeReservedInstances for " + region.name + " " + account.name, e); } } ec2Client.shutdown(); } catch (Exception e) { logger.error("Error in describeReservedInstances for " + account.name, e); } } config.reservationService.updateEc2Reservations(reservations); updatedConfig = true; // archive to disk BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(file)); for (String key : reservations.keySet()) { ReservedInstances reservation = reservations.get(key); String[] line = new String[] { key, reservation.getAvailabilityZone(), reservation.getStart().getTime() + "", reservation.getDuration().toString(), reservation.getInstanceType(), reservation.getProductDescription(), reservation.getInstanceCount().toString(), reservation.getOfferingType(), reservation.getState(), reservation.getEnd().getTime() + "", reservation.getFixedPrice() + "", reservation.getUsagePrice() + "", }; writer.write(StringUtils.join(line, ",")); writer.newLine(); } } catch (Exception e) { logger.error("", e); } finally { if (writer != null) try { writer.close(); } catch (Exception e) { } } logger.info("archived " + reservations.size() + " reservations."); // archive to s3 logger.info("uploading " + file + "..."); AwsUtils.upload(config.workS3BucketName, config.workS3BucketPrefix, config.localDir, file.getName()); logger.info("uploaded " + file); }
From source file:com.pearson.eidetic.driver.threads.RefreshAwsAccountVolumes.java
@Override public void run() { ConcurrentHashMap<Region, ArrayList<Volume>> localVolumeNoTime; localVolumeNoTime = awsAccount_.getVolumeNoTime_Copy(); ConcurrentHashMap<Region, ArrayList<Volume>> localVolumeTime; localVolumeTime = awsAccount_.getVolumeTime_Copy(); ConcurrentHashMap<Region, ArrayList<Volume>> localCopyVolumeSnapshots; localCopyVolumeSnapshots = awsAccount_.getCopyVolumeSnapshots_Copy(); JSONParser parser = new JSONParser(); for (Map.Entry<com.amazonaws.regions.Region, ArrayList<Volume>> entry : localVolumeNoTime.entrySet()) { com.amazonaws.regions.Region region = entry.getKey(); AmazonEC2Client ec2Client = connect(region, awsAccount_.getAwsAccessKeyId(), awsAccount_.getAwsSecretKey()); List<Volume> volumes = initialization(ec2Client, localVolumeNoTime, localVolumeTime, localCopyVolumeSnapshots, region); for (Volume volume : volumes) { JSONObject eideticParameters; eideticParameters = getEideticParameters(volume, parser); if (eideticParameters == null) { continue; }/*from w ww .j av a 2 s. c o m*/ JSONObject createSnapshot; createSnapshot = getCreateSnapshot(volume, eideticParameters); if (createSnapshot == null) { continue; } HashMap<Integer, ConcurrentHashMap<Region, ArrayList<Volume>>> resultSet; resultSet = refreshCreateSnapshotVolumes(volume, createSnapshot, localVolumeTime, localVolumeNoTime, region); if (resultSet == null) { continue; } if (resultSet.isEmpty()) { continue; } try { localVolumeTime = resultSet.get(0); localVolumeNoTime = resultSet.get(1); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error getting from resultSet\", Volume_id=\"" + volume.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } //Time for CopyVolumeSnapshots //If this volume does not have copysnapshot localCopyVolumeSnapshots = refreshCopyVolumeSnapshots(volume, eideticParameters, localCopyVolumeSnapshots, region); } localVolumeTime = processLocalVolumeTime(localVolumeTime, region); localVolumeNoTime = processLocalVolumeNoTime(localVolumeNoTime, region); localCopyVolumeSnapshots = processLocalCopyVolumeSnapshots(localCopyVolumeSnapshots, region); ec2Client.shutdown(); } awsAccount_.replaceVolumeNoTime(localVolumeNoTime); awsAccount_.replaceVolumeTime(localVolumeTime); awsAccount_.replaceCopyVolumeSnapshots(localCopyVolumeSnapshots); }
From source file:com.pearson.eidetic.driver.threads.subthreads.ErrorChecker.java
@Override public void run() { isFinished_ = false;/* w w w.j a v a 2s .co m*/ for (Map.Entry<com.amazonaws.regions.Region, ArrayList<Volume>> entry : awsAccount_.getVolumeNoTime_Copy() .entrySet()) { try { //Get all pending! com.amazonaws.regions.Region region = entry.getKey(); AmazonEC2Client ec2Client = connect(region, awsAccount_.getAwsAccessKeyId(), awsAccount_.getAwsSecretKey()); List<Snapshot> error_snapshots = getAllErrorSnapshots(ec2Client); if (error_snapshots.isEmpty()) { continue; } loggerOuputSnapshotErrors(error_snapshots, region); deleteSnapshotErrors(ec2Client, error_snapshots); ec2Client.shutdown(); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in ErrorChecker workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } isFinished_ = true; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotChecker.java
@Override public void run() { isFinished_ = false;//from w w w .j av a 2s. co m //kill thread if wrong creds \/ \/ \/ \/ AmazonEC2Client ec2Client = connect(region_, awsAccessKeyId_, awsSecretKey_); for (Volume vol : VolumeNoTime_) { try { Date date = new java.util.Date(); JSONParser parser = new JSONParser(); String inttagvalue = getIntTagValue(vol); if (inttagvalue == null) { continue; } JSONObject eideticParameters; try { Object obj = parser.parse(inttagvalue); eideticParameters = (JSONObject) obj; } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } String period = getPeriod(eideticParameters, vol); if (period == null) { continue; } Integer keep = getKeep(eideticParameters, vol); if (keep == null) { continue; } Boolean success; success = snapshotDecision(ec2Client, vol, period); if (!success) { continue; } success = snapshotCreation(ec2Client, vol, period, date); if (!success) { continue; } snapshotDeletion(ec2Client, vol, period, keep); logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"normal eidetic process did not create a snapshot for volume in alloted time.\", Volume_id=\"" + vol.getVolumeId() + "\""); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotChecker workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } for (Volume vol : VolumeTime_) { try { Date date = new java.util.Date(); JSONParser parser = new JSONParser(); String inttagvalue = getIntTagValue(vol); if (inttagvalue == null) { continue; } JSONObject eideticParameters; try { Object obj = parser.parse(inttagvalue); eideticParameters = (JSONObject) obj; } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } String period = getPeriod(eideticParameters, vol); if (period == null) { continue; } Integer keep = getKeep(eideticParameters, vol); if (keep == null) { continue; } Boolean success; success = snapshotDecision(ec2Client, vol, period); if (!success) { continue; } success = snapshotCreation(ec2Client, vol, period, date); if (!success) { continue; } snapshotDeletion(ec2Client, vol, period, keep); logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"normal eidetic process did not create a snapshot for volume in alloted time.\", Volume_id=\"" + vol.getVolumeId() + "\""); } catch (Exception e) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in EideticChcker workflow', Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } ec2Client.shutdown(); isFinished_ = true; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotCleaner.java
@Override public void run() { isFinished_ = false;//from ww w .j a va 2 s . c om for (Map.Entry<com.amazonaws.regions.Region, ArrayList<Volume>> entry : awsAccount_.getVolumeNoTime_Copy() .entrySet()) { try { com.amazonaws.regions.Region region = entry.getKey(); //kill thread if wrong creds \/ \/ \/ \/ AmazonEC2Client ec2Client = connect(region, awsAccount_.getAwsAccessKeyId(), awsAccount_.getAwsSecretKey()); Boolean success; allSnapshotsClean(ec2Client); success = eideticClean(ec2Client); if (!success) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotCleaner workflow\""); } ec2Client.shutdown(); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotCleaner workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } isFinished_ = true; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotCreationTime.java
@Override public void run() { isFinished_ = false;/*ww w . j av a2 s. co m*/ for (Map.Entry<com.amazonaws.regions.Region, ArrayList<Volume>> entry : awsAccount_ .getCopyVolumeSnapshots_Copy().entrySet()) { try { //Get all pending! com.amazonaws.regions.Region region = entry.getKey(); AmazonEC2Client ec2Client = connect(region, awsAccount_.getAwsAccessKeyId(), awsAccount_.getAwsSecretKey()); //Add CreationPendings addCreationPending(ec2Client); //Get all snapshots with creation pending updateCreationPending(ec2Client); //Get all snapshots with creation pending addCreationComplete(ec2Client); ec2Client.shutdown(); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotCreationTime workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } isFinished_ = true; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeNoTime.java
@Override public void run() { isFinished_ = false;// ww w . j a v a 2 s .co m //kill thread if wrong creds \/ \/ \/ \/ AmazonEC2Client ec2Client = connect(region_, awsAccessKeyId_, awsSecretKey_); for (Volume vol : VolumeNoTime_) { try { Date date = new java.util.Date(); JSONParser parser = new JSONParser(); String inttagvalue = getIntTagValue(vol); if (inttagvalue == null) { continue; } JSONObject eideticParameters; try { Object obj = parser.parse(inttagvalue); eideticParameters = (JSONObject) obj; } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } String period = getPeriod(eideticParameters, vol); if (period == null) { continue; } Integer keep = getKeep(eideticParameters, vol); if (keep == null) { continue; } Boolean success; success = snapshotDecision(ec2Client, vol, period); if (!success) { continue; } success = snapshotCreation(ec2Client, vol, period, date); if (!success) { continue; } snapshotDeletion(ec2Client, vol, period, keep); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotVolumeNoTime workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } ec2Client.shutdown(); isFinished_ = true; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeSync.java
@Override public void run() { isFinished_ = false;/* ww w . j av a2 s . c o m*/ AmazonEC2Client ec2Client = connect(region_, awsAccessKeyId_, awsSecretKey_); for (Volume vol : VolumeSync_) { try { Date date = new java.util.Date(); JSONParser parser = new JSONParser(); String inttagvalue = getIntTagValue(vol); if (inttagvalue == null) { continue; } JSONObject eideticParameters; try { Object obj = parser.parse(inttagvalue); eideticParameters = (JSONObject) obj; } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } //Same Integer keep = getKeep(eideticParameters, vol); if (keep == null) { continue; } Boolean success; success = snapshotCreation(ec2Client, vol, date); if (!success) { continue; } snapshotDeletion(ec2Client, vol, keep); } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotVolumeSync workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } ec2Client.shutdown(); isFinished_ = true; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeSyncValidator.java
@Override public void run() { isFinished_ = false;/*from w w w .j a v a 2s .c o m*/ AmazonEC2Client ec2Client = connect(region_, awsAccessKeyId_, awsSecretKey_); for (Volume vol : VolumeSyncValidate_) { try { JSONParser parser = new JSONParser(); String inttagvalue = getIntTagValue(vol); if (inttagvalue == null) { continue; } JSONObject eideticParameters; try { Object obj = parser.parse(inttagvalue); eideticParameters = (JSONObject) obj; } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } if (eideticParameters == null) { continue; } //Same Integer keep = getKeep(eideticParameters, vol); if (keep == null) { continue; } JSONObject syncSnapshot = null; if (eideticParameters.containsKey("SyncSnapshot")) { syncSnapshot = (JSONObject) eideticParameters.get("SyncSnapshot"); } if (syncSnapshot == null) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\""); continue; } JSONObject validateParameters; try { validateParameters = (JSONObject) syncSnapshot.get("Validate"); } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } Integer createAfter = getCreateAfter(validateParameters, vol); String cluster = getCluster(validateParameters, vol); if (validateCluster_.containsKey(cluster)) { validateCluster_.get(cluster).add(new MutableTriple(vol, createAfter, keep)); } else { validateCluster_.put(cluster, new ArrayList<MutableTriple<Volume, Integer, Integer>>()); validateCluster_.get(cluster).add(new MutableTriple(vol, createAfter, keep)); } } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotVolumeSync workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } for (String cluster : validateCluster_.keySet()) { try { ArrayList<MutableTriple<Volume, Integer, Integer>> myList = validateCluster_.get(cluster); Boolean snapshotCluster = false; Integer min = Integer.MAX_VALUE; for (MutableTriple trip : myList) { if (((Integer) trip.getMiddle()) < min) { min = (Integer) trip.getMiddle(); } } for (MutableTriple trip : myList) { if (snapshotDecision(ec2Client, (Volume) trip.getLeft(), min)) { snapshotCluster = true; } } if (snapshotCluster) { ArrayList<Volume> vols = new ArrayList<>(); for (MutableTriple trip : myList) { vols.add((Volume) trip.getLeft()); } SnapshotVolumeSync thread = new SnapshotVolumeSync(awsAccessKeyId_, awsSecretKey_, uniqueAwsAccountIdentifier_, maxApiRequestsPerSecond_, ApplicationConfiguration.getAwsCallRetryAttempts(), region_, vols, true); try { thread.run(); } catch (Exception e) { String responseMessage = "Error running cluster validator thread for cluster " + cluster; logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Error=\"" + responseMessage + "\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } Integer wait = 0; while (!(thread.isFinished()) && (wait <= 200)) { Threads.sleepMilliseconds(250); //break after 50 seconds wait = wait + 1; } } } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotVolumeSync workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } ec2Client.shutdown(); isFinished_ = true; }