public AWSEBEnvironmentUpdaterThread(AWSElasticBeanstalk awseb, EnvironmentDescription envd, BuildListener listener, String versionLabel) { this.awseb = awseb; this.envd = envd; this.listener = listener; this.versionLabel = versionLabel; this.lastEvent = new EventDescription(); lastEvent.setEventDate(new Date()); // We can make our requests and, hopefully, safely assume the environmentId won't change under us. envRequest = new DescribeEnvironmentsRequest().withEnvironmentIds(envd.getEnvironmentId()); eventRequest = new DescribeEventsRequest().withEnvironmentId(envd.getEnvironmentId()); // Hack to acknowledge that the time of the Jenkins box may not match AWS. try { DescribeEventsResult lastEntry = awseb.describeEvents(new DescribeEventsRequest() .withEnvironmentId(envd.getEnvironmentId()) .withMaxRecords(1)); lastEvent = lastEntry.getEvents().get(0); } catch (Exception e) { log("'%s': Unable to get last event, using system current timestamp for event logs", envd.getEnvironmentName()); } eventRequest.withStartTime(lastEvent.getEventDate()); // Initialize to the right start time. this.environmentId = envd.getEnvironmentId(); nAttempt = 0; }
private boolean compareEventDescriptions(EventDescription first, EventDescription second) { boolean isEqual = first.getApplicationName().equals(second.getApplicationName()); isEqual &= first.getEnvironmentName().equals(second.getEnvironmentName()); isEqual &= first.getMessage().equals(second.getMessage()); isEqual &= first.getSeverity().equals(second.getSeverity()); isEqual &= first.getEventDate().getTime() == second.getEventDate().getTime(); return isEqual; }