com.amazonaws.services.ec2.model.Instance.getLaunchTime()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中com.amazonaws.services.ec2.model.Instance.getLaunchTime()方法的一些代码示例,展示了Instance.getLaunchTime()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getLaunchTime()方法的具体详情如下:
包路径:com.amazonaws.services.ec2.model.Instance
类名称:Instance
方法名:getLaunchTime

Instance.getLaunchTime介绍

[英]The time the instance was launched.
[中]实例启动的时间。

代码示例

代码示例来源:origin: aws/aws-sdk-java

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(",");

代码示例来源:origin: aws/aws-sdk-java

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());

代码示例来源:origin: aws/aws-sdk-java

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)

代码示例来源:origin: aws-amplify/aws-sdk-android

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() + ",");

代码示例来源:origin: aws-amplify/aws-sdk-android

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());

代码示例来源:origin: jenkinsci/ec2-plugin

/**
 * Number of milli-secs since the instance was started.
 */
public long getUptime() throws AmazonClientException, InterruptedException {
  return System.currentTimeMillis() - describeInstance().getLaunchTime().getTime();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

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;

代码示例来源:origin: org.jenkins-ci.plugins/ec2

/**
 * Number of milli-secs since the instance was started.
 */
public long getUptime() throws AmazonClientException, InterruptedException {
  return System.currentTimeMillis()-describeInstance().getLaunchTime().getTime();
}

代码示例来源:origin: com.netflix.spinnaker.clouddriver/clouddriver-aws

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);
}

代码示例来源:origin: com.atlassian.buildeng/ecs-scheduler

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;

代码示例来源:origin: jenkinsci/ec2-plugin

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});

代码示例来源:origin: RetailMeNot/SeleniumGridScaler

@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);
      }
    }
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/ec2

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()));
  }
}

代码示例来源:origin: pinterest/soundwave

cmdbRunningInstances.remove(ec2Instance.getInstanceId());
if (fiveMinutesBeforeNow.isBefore(new DateTime(ec2Instance.getLaunchTime()))) {
 logger.info("Ignore recently launched instance {} in recouncile",
   ec2Instance.getInstanceId());

代码示例来源:origin: jenkinsci/ec2-plugin

createdTime = i.getLaunchTime().getTime();
instanceType = i.getInstanceType();

代码示例来源:origin: pinterest/soundwave

@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;
 }
}

代码示例来源:origin: com.elastisys.scale/cloudpool.aws.commons

DateTime launchtime = new DateTime(instance.getLaunchTime(), DateTimeZone.UTC);
List<String> publicIps = new ArrayList<>();
List<String> privateIps = new ArrayList<>();

代码示例来源:origin: com.atlassian.buildeng/ecs-scheduler

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();
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-ec2

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());

代码示例来源:origin: airbnb/billow

this.virtualizationType = instance.getVirtualizationType();
this.sourceDestCheck = instance.getSourceDestCheck();
this.launchTime = new DateTime(instance.getLaunchTime());

相关文章

Instance类方法