if (getKeyName() != null) sb.append("KeyName: ").append(getKeyName()).append(","); if (getLaunchTime() != null) sb.append("LaunchTime: ").append(getLaunchTime()).append(","); if (getMonitoring() != null) sb.append("Monitoring: ").append(getMonitoring()).append(",");
hashCode = prime * hashCode + ((getKernelId() == null) ? 0 : getKernelId().hashCode()); hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode()); hashCode = prime * hashCode + ((getLaunchTime() == null) ? 0 : getLaunchTime().hashCode()); hashCode = prime * hashCode + ((getMonitoring() == null) ? 0 : getMonitoring().hashCode()); hashCode = prime * hashCode + ((getPlacement() == null) ? 0 : getPlacement().hashCode());
if (other.getKeyName() != null && other.getKeyName().equals(this.getKeyName()) == false) return false; if (other.getLaunchTime() == null ^ this.getLaunchTime() == null) return false; if (other.getLaunchTime() != null && other.getLaunchTime().equals(this.getLaunchTime()) == false) return false; if (other.getMonitoring() == null ^ this.getMonitoring() == null)
if (getProductCodes() != null) sb.append("ProductCodes: " + getProductCodes() + ","); if (getInstanceType() != null) sb.append("InstanceType: " + getInstanceType() + ","); if (getLaunchTime() != null) sb.append("LaunchTime: " + getLaunchTime() + ","); if (getPlacement() != null) sb.append("Placement: " + getPlacement() + ","); if (getKernelId() != null) sb.append("KernelId: " + getKernelId() + ",");
hashCode = prime * hashCode + ((getProductCodes() == null) ? 0 : getProductCodes().hashCode()); hashCode = prime * hashCode + ((getInstanceType() == null) ? 0 : getInstanceType().hashCode()); hashCode = prime * hashCode + ((getLaunchTime() == null) ? 0 : getLaunchTime().hashCode()); hashCode = prime * hashCode + ((getPlacement() == null) ? 0 : getPlacement().hashCode()); hashCode = prime * hashCode + ((getKernelId() == null) ? 0 : getKernelId().hashCode());
/** * Number of milli-secs since the instance was started. */ public long getUptime() throws AmazonClientException, InterruptedException { return System.currentTimeMillis() - describeInstance().getLaunchTime().getTime(); }
if (other.getInstanceType() == null ^ this.getInstanceType() == null) return false; if (other.getInstanceType() != null && other.getInstanceType().equals(this.getInstanceType()) == false) return false; if (other.getLaunchTime() == null ^ this.getLaunchTime() == null) return false; if (other.getLaunchTime() != null && other.getLaunchTime().equals(this.getLaunchTime()) == false) return false; if (other.getPlacement() == null ^ this.getPlacement() == null) return false; if (other.getPlacement() != null && other.getPlacement().equals(this.getPlacement()) == false) return false;
/** * Number of milli-secs since the instance was started. */ public long getUptime() throws AmazonClientException, InterruptedException { return System.currentTimeMillis()-describeInstance().getLaunchTime().getTime(); }
boolean isInstanceOldEnough(Instance instance) { return Optional.ofNullable(instance.getLaunchTime()) .map(Date::getTime) .map(Instant::ofEpochMilli) .map(i -> i.plusMillis(requiredInstanceLifetime)) .map(i -> clock.instant().isAfter(i)) .orElse(false); }
Instance ec2 = instances.get(t); if (ec2 != null) { final long lifespan = new Date().getTime() - ec2.getLaunchTime().getTime(); return Duration.ofMinutes(ASG_MISSING_IN_CLUSTER_GRACE_PERIOD).toMillis() < lifespan && Duration.ofMinutes(60 - Constants.MINUTES_BEFORE_BILLING_CYCLE).toMillis() > lifespan;
long startTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - instance.getLaunchTime().getTime()); LOGGER.log(Level.INFO, "{0} Node {1} moved to RUNNING state in {2} seconds and is ready to be connected by Jenkins", new Object[]{t, slave.getNodeName(), startTime});
@Override public void doWork() { log.info("Running " + AutomationReaperTask.NAME); DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest(); Filter filter = new Filter("tag:LaunchSource"); filter.withValues("SeleniumGridScalerPlugin"); describeInstancesRequest.withFilters(filter); List<Reservation> reservations = ec2.describeInstances(describeInstancesRequest); for(Reservation reservation : reservations) { for(Instance instance : reservation.getInstances()) { // Look for orphaned nodes Date threshold = AutomationUtils.modifyDate(new Date(),-30, Calendar.MINUTE); String instanceId = instance.getInstanceId(); // If we found a node old enough AND we're not internally tracking it, this means this is an orphaned node and we should terminate it if(threshold.after(instance.getLaunchTime()) && !AutomationContext.getContext().nodeExists(instanceId)) { log.info("Terminating orphaned node: " + instanceId); ec2.terminateInstance(instanceId); } } } }
protected void fetchLiveInstanceData( boolean force ) throws AmazonClientException { /* If we've grabbed the data recently, don't bother getting it again unless we are forced */ long now = System.currentTimeMillis(); if ((lastFetchTime > 0) && (now - lastFetchTime < MIN_FETCH_TIME) && !force) { return; } if (getInstanceId() == null || getInstanceId() == ""){ /* The getInstanceId() implementation on EC2SpotSlave can return null if the spot request doesn't * yet know the instance id that it is starting. What happens is that null is passed to getInstanceId() * which searches AWS but without an instanceID the search returns some random box. We then fetch * its metadata, including tags, and then later, when the spot request eventually gets the * instanceID correctly we push the saved tags from that random box up to the new spot resulting in * confusion and delay. */ return; } Instance i = getInstance(getInstanceId(), getCloud()); lastFetchTime = now; lastFetchInstance = i; if (i == null) return; publicDNS = i.getPublicDnsName(); privateDNS = i.getPrivateIpAddress(); createdTime = i.getLaunchTime().getTime(); tags = new LinkedList<EC2Tag>(); for (Tag t : i.getTags()) { tags.add(new EC2Tag(t.getKey(), t.getValue())); } }
cmdbRunningInstances.remove(ec2Instance.getInstanceId()); if (fiveMinutesBeforeNow.isBefore(new DateTime(ec2Instance.getLaunchTime()))) { logger.info("Ignore recently launched instance {} in recouncile", ec2Instance.getInstanceId());
createdTime = i.getLaunchTime().getTime(); instanceType = i.getInstanceType();
@Override public EsInstance createFromEC2(Instance awsInstance) throws Exception { Preconditions.checkNotNull(awsInstance); EsInstance esInstance = new EsInstance(); esInstance.setId(awsInstance.getInstanceId()); esInstance.setState(awsInstance.getState().getName()); esInstance.setLocation(awsInstance.getPlacement().getAvailabilityZone()); //Region=location-last char. This is what CMDBV1 and people on internet do. //There should be a better way. Right now, keep as what it is esInstance.setRegion( esInstance.getLocation().substring(0, esInstance.getLocation().length() - 1)); esInstance.setAwsLaunchTime(awsInstance.getLaunchTime()); esInstance.setSubnetId(awsInstance.getSubnetId()); esInstance.setVpcId(awsInstance.getVpcId()); //Convert AWS instance to a map of property bags and save it. esInstance.getCloud() .put("aws", getAwsInstanceProperties(awsInstance)); Date utcNow = DateTime.now(DateTimeZone.UTC).toDate(); esInstance.setCreatedTime(utcNow); esInstance.setUpdatedTime(utcNow); return esInstance; } }
DateTime launchtime = new DateTime(instance.getLaunchTime(), DateTimeZone.UTC); List<String> publicIps = new ArrayList<>(); List<String> privateIps = new ArrayList<>();
public DockerHost(ContainerInstance containerInstance, Instance instance, boolean inASG) throws ECSException { remainingMemory = getIntegralResource(containerInstance, true, "MEMORY"); remainingCpu = getIntegralResource(containerInstance, true, "CPU"); registeredMemory = getIntegralResource(containerInstance, false, "MEMORY"); registeredCpu = getIntegralResource(containerInstance, false, "CPU"); containerInstanceArn = containerInstance.getContainerInstanceArn(); instanceId = containerInstance.getEc2InstanceId(); status = containerInstance.getStatus(); launchTime = instance.getLaunchTime(); agentConnected = containerInstance.isAgentConnected(); presentInASG = inASG; attributes = containerInstance.getAttributes(); }
hashCode = prime * hashCode + ((getKernelId() == null) ? 0 : getKernelId().hashCode()); hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode()); hashCode = prime * hashCode + ((getLaunchTime() == null) ? 0 : getLaunchTime().hashCode()); hashCode = prime * hashCode + ((getMonitoring() == null) ? 0 : getMonitoring().hashCode()); hashCode = prime * hashCode + ((getPlacement() == null) ? 0 : getPlacement().hashCode());
this.virtualizationType = instance.getVirtualizationType(); this.sourceDestCheck = instance.getSourceDestCheck(); this.launchTime = new DateTime(instance.getLaunchTime());