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

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

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

Instance.getPrivateIpAddress介绍

[英]The private IPv4 address assigned to the instance.
[中]分配给实例的专用IPv4地址。

代码示例

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

if (getPrivateDnsName() != null)
  sb.append("PrivateDnsName: ").append(getPrivateDnsName()).append(",");
if (getPrivateIpAddress() != null)
  sb.append("PrivateIpAddress: ").append(getPrivateIpAddress()).append(",");
if (getProductCodes() != null)
  sb.append("ProductCodes: ").append(getProductCodes()).append(",");

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException {
  initClients();
  List<String> instanceIds = new ArrayList<>();
  DescribeLoadBalancersRequest req = new DescribeLoadBalancersRequest().withLoadBalancerNames(loadBalancerName);
  List<LoadBalancerDescription> descs = amazonELBClient.describeLoadBalancers(req).getLoadBalancerDescriptions();
  for (LoadBalancerDescription desc : descs) {
    for (Instance instance : desc.getInstances())
      instanceIds.add(instance.getInstanceId());
  }
  DescribeInstancesRequest instReq = new DescribeInstancesRequest().withInstanceIds(instanceIds);
  List<Reservation> reservations = amazonEC2Client.describeInstances(instReq).getReservations();
  List<InetSocketAddress> addrs = new ArrayList<>();
  for (Reservation reservation : reservations) {
    List<com.amazonaws.services.ec2.model.Instance> instances = reservation.getInstances();
    for (com.amazonaws.services.ec2.model.Instance instance : instances)
      addrs.add(new InetSocketAddress(instance.getPrivateIpAddress(), 0));
  }
  return addrs;
}

代码示例来源:origin: h2oai/h2o-2

for( int i = 0; i < boxes; i++ ) {
 pub[i] = instances.get(i).getPublicIpAddress();
 prv[i] = instances.get(i).getPrivateIpAddress();

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

hashCode = prime * hashCode + ((getPlatform() == null) ? 0 : getPlatform().hashCode());
hashCode = prime * hashCode + ((getPrivateDnsName() == null) ? 0 : getPrivateDnsName().hashCode());
hashCode = prime * hashCode + ((getPrivateIpAddress() == null) ? 0 : getPrivateIpAddress().hashCode());
hashCode = prime * hashCode + ((getProductCodes() == null) ? 0 : getProductCodes().hashCode());
hashCode = prime * hashCode + ((getPublicDnsName() == null) ? 0 : getPublicDnsName().hashCode());

代码示例来源:origin: apache/usergrid

/**
 * Constructs and returns an BasicInstance object, using information from <code>ec2</code>
 *
 * @param ec2
 * @return
 */
protected static Instance toInstance( com.amazonaws.services.ec2.model.Instance ec2 ) {
  Instance instance;
  BasicInstanceSpec spec;
  spec = new BasicInstanceSpec();
  spec.setImageId( ec2.getImageId() );
  spec.setKeyName( ec2.getKeyName() );
  spec.setType( ec2.getInstanceType() );
  instance = new BasicInstance(
          ec2.getInstanceId(),
          spec,
          InstanceState.fromValue( ec2.getState().getName() ),
          ec2.getPrivateDnsName(),
          ec2.getPublicDnsName(),
          ec2.getPrivateIpAddress(),
          ec2.getPublicIpAddress()
      );
  return instance;
}

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

if (other.getPrivateDnsName() != null && other.getPrivateDnsName().equals(this.getPrivateDnsName()) == false)
  return false;
if (other.getPrivateIpAddress() == null ^ this.getPrivateIpAddress() == null)
  return false;
if (other.getPrivateIpAddress() != null && other.getPrivateIpAddress().equals(this.getPrivateIpAddress()) == false)
  return false;
if (other.getProductCodes() == null ^ this.getProductCodes() == null)

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

if (getSubnetId() != null) sb.append("SubnetId: " + getSubnetId() + ",");
if (getVpcId() != null) sb.append("VpcId: " + getVpcId() + ",");
if (getPrivateIpAddress() != null) sb.append("PrivateIpAddress: " + getPrivateIpAddress() + ",");
if (getPublicIpAddress() != null) sb.append("PublicIpAddress: " + getPublicIpAddress() + ",");
if (getStateReason() != null) sb.append("StateReason: " + getStateReason() + ",");

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

hashCode = prime * hashCode + ((getSubnetId() == null) ? 0 : getSubnetId().hashCode()); 
hashCode = prime * hashCode + ((getVpcId() == null) ? 0 : getVpcId().hashCode()); 
hashCode = prime * hashCode + ((getPrivateIpAddress() == null) ? 0 : getPrivateIpAddress().hashCode()); 
hashCode = prime * hashCode + ((getPublicIpAddress() == null) ? 0 : getPublicIpAddress().hashCode()); 
hashCode = prime * hashCode + ((getStateReason() == null) ? 0 : getStateReason().hashCode());

代码示例来源:origin: com.n3twork.druid/druid-indexing-service

@Override
 public String apply(Instance input)
 {
  return input.getPrivateIpAddress();
 }
}

代码示例来源:origin: gofore/aws-training

private Predicate<Instance> accessible(boolean requirePrivateAccessible) {
  if (requirePrivateAccessible) {
    return i -> !Strings.isNullOrEmpty(i.getPrivateIpAddress());
  } else {
    return i -> true;
  }
}

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

if (other.getVpcId() == null ^ this.getVpcId() == null) return false;
if (other.getVpcId() != null && other.getVpcId().equals(this.getVpcId()) == false) return false; 
if (other.getPrivateIpAddress() == null ^ this.getPrivateIpAddress() == null) return false;
if (other.getPrivateIpAddress() != null && other.getPrivateIpAddress().equals(this.getPrivateIpAddress()) == false) return false; 
if (other.getPublicIpAddress() == null ^ this.getPublicIpAddress() == null) return false;
if (other.getPublicIpAddress() != null && other.getPublicIpAddress().equals(this.getPublicIpAddress()) == false) return false;

代码示例来源:origin: electronicarts/gatling-aws-maven-plugin

private String getPreferredHostName(final Instance instance) {
    if (this.preferPrivateIpHostnames) {
      return instance.getPrivateIpAddress();
    }

    return instance.getPublicDnsName();
  }
}

代码示例来源:origin: gofore/aws-training

private OverloadResource.OverloadStatus loadOverloadStatus(com.amazonaws.services.ec2.model.Instance instance) {
  try {
    HttpURLConnection connection = (HttpURLConnection) getOverloadUrl(instance.getPrivateIpAddress()).openConnection();
    connection.setRequestProperty("Content-Type", "application/json");
    connection.setRequestMethod("GET");
    return om.readValue(connection.getInputStream(), OverloadResource.OverloadStatus.class);
  } catch (IOException ex) {
    throw new RuntimeException(ex);
  }
}

代码示例来源:origin: bitsofinfo/s3-bucket-loader

/**
 * Returns map of instanceId:privateIp
 * 
 * @param ec2Instances
 * @return
 */
public Map<String,String> getPrivateIPs(List<Instance> ec2Instances) {
  TreeMap<String,String> names = new TreeMap<String,String>(String.CASE_INSENSITIVE_ORDER);
  for (Instance i : ec2Instances) {
    names.put(i.getInstanceId(),i.getPrivateIpAddress());
  }
  return names;
}

代码示例来源:origin: UrbanCode/terraform

/**
 *
 * @param instanceId
 * @param ec2Client
 * @return
 */
public String getPrivateIp(String instanceId, AmazonEC2 ec2Client) {
  String privateIp = null;
  Instance instance = this.getInstanceById(instanceId, ec2Client);
  if (instance != null) {
    privateIp = instance.getPrivateIpAddress();
  }
  return privateIp;
}

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

private String getEC2HostAddress(EC2Computer computer, Instance inst) {
  if (computer.getNode().usePrivateDnsName) {
    return inst.getPrivateDnsName();
  } else {
    String host = inst.getPublicDnsName();
    // If we fail to get a public DNS name, use the private IP.
    if (host == null || host.equals("")) {
      host = inst.getPrivateIpAddress();
    }
    return host;
  }
}

代码示例来源:origin: stackoverflow.com

public String getMasterNodeIp(AmazonElasticMapReduceClient emr, String emrId) throws Exception {
  Cluster cluster = emr.describeCluster(new DescribeClusterRequest().withClusterId(emrId));
  ListInstancesResult instances = emr.listInstances(new ListInstancesRequest().withClusterId(emrId));
  String masterDnsName = cluster.getMasterPublicDnsName();
  for (Instance instance : instances.getInstances()) {
    if (instance.getPublicDnsName().equals(masterDnsName)) {
      return instance.getPrivateIpAddress();
    }
  }
  throw new Exception("Failed to find master node private ip.");
}

代码示例来源:origin: stackoverflow.com

DescribeInstancesRequest describeRequest = new DescribeInstancesRequest().withInstanceIds(instanceId);
DescribeInstancesResult describeResult = ec2.describeInstances(describeRequest);
Instance instance = describeResult.getReservations().get(0).getInstances().get(0);
String publicIp = instance.getPublicIpAddress();
String privateIp = instance.getPrivateIpAddress();

代码示例来源:origin: com.hazelcast.simulator/simulator

private void addInstanceToAgentsFile(Instance instance) {
  String instanceId = instance.getInstanceId();
  DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest().withInstanceIds(instanceId);
  DescribeInstancesResult result = ec2.describeInstances(describeInstancesRequest);
  for (Reservation reservation : result.getReservations()) {
    for (Instance reserved : reservation.getInstances()) {
      appendText(reserved.getPublicIpAddress() + ',' + reserved.getPrivateIpAddress() + NEW_LINE, agentsFile);
      componentRegistry.addAgent(reserved.getPublicIpAddress(), reserved.getPrivateIpAddress());
    }
  }
}

代码示例来源:origin: msoute/vertx-deploy-tools

private Ec2Instance toEc2Instance(com.amazonaws.services.ec2.model.Instance instance) {
  return new Ec2Instance.Builder().withInstanceId(instance.getInstanceId()).withPrivateIp(instance.getPrivateIpAddress()).withPublicIp(instance.getPublicIpAddress()).build();
}

相关文章

Instance类方法