本文整理了Java中com.amazonaws.services.ec2.model.Instance.getPublicIpAddress()
方法的一些代码示例,展示了Instance.getPublicIpAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getPublicIpAddress()
方法的具体详情如下:
包路径:com.amazonaws.services.ec2.model.Instance
类名称:Instance
方法名:getPublicIpAddress
[英]The public IPv4 address assigned to the instance, if applicable.
[中]分配给实例的公共IPv4地址(如果适用)。
代码示例来源:origin: h2oai/h2o-2
private static boolean canConnect(List<Instance> instances) {
for( Instance instance : instances ) {
try {
String ssh = "ssh -q" + Host.SSH_OPTS + " " + instance.getPublicIpAddress();
Process p = Runtime.getRuntime().exec(ssh + " exit");
if( p.waitFor() != 0 )
return false;
} catch( Exception e ) {
return false;
} finally {
}
}
return true;
}
}
代码示例来源:origin: h2oai/h2o-2
private static String ip(Instance instance) {
String ip = instance.getPublicIpAddress();
if( ip != null && ip.length() != 0 )
if( instance.getState().getName().equals("running") )
return ip;
return null;
}
代码示例来源:origin: apache/incubator-gobblin
private String getMasterPublicIp() {
final long startTime = System.currentTimeMillis();
final long launchTimeout = TimeUnit.MINUTES.toMillis(10);
boolean isMasterLaunched = false;
List<Instance> instanceIds = Collections.emptyList();
while (!isMasterLaunched && (System.currentTimeMillis() - startTime) < launchTimeout) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted while waiting for cluster master to boot up", e);
}
instanceIds = this.awsSdkClient.getInstancesForGroup(this.masterAutoScalingGroupName, "running");
isMasterLaunched = instanceIds.size() > 0;
}
if (!isMasterLaunched) {
throw new RuntimeException("Timed out while waiting for cluster master. "
+ "Check for issue manually for ASG: " + this.masterAutoScalingGroupName);
}
// This will change if cluster master restarts, but that will be handled by Helix events
// TODO: Add listener to Helix / Zookeeper for master restart and update master public ip
// .. although we do not use master public ip for anything
return instanceIds.get(0).getPublicIpAddress();
}
代码示例来源:origin: apache/usergrid
public RunnerInstance( Instance instance ) {
this.instance = instance;
this.hostname = instance.getPublicDnsName();
this.ipv4Address = instance.getPublicIpAddress();
this.url = "https://" + instance.getPublicDnsName() + ":" + Runner.DEFAULT_SERVER_PORT + "/";
}
代码示例来源:origin: apache/usergrid
@SuppressWarnings( "UnusedDeclaration" )
public RunnerInstance( Instance instance, int port ) {
this.instance = instance;
this.port = port;
this.hostname = instance.getPublicDnsName();
this.ipv4Address = instance.getPublicIpAddress();
this.url = "https://" + instance.getPublicDnsName() + ":" + port + "/";
}
代码示例来源:origin: aws/aws-sdk-java
if (getPublicDnsName() != null)
sb.append("PublicDnsName: ").append(getPublicDnsName()).append(",");
if (getPublicIpAddress() != null)
sb.append("PublicIpAddress: ").append(getPublicIpAddress()).append(",");
if (getRamdiskId() != null)
sb.append("RamdiskId: ").append(getRamdiskId()).append(",");
代码示例来源:origin: h2oai/h2o-2
String[] prv = new String[boxes];
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 + ((getProductCodes() == null) ? 0 : getProductCodes().hashCode());
hashCode = prime * hashCode + ((getPublicDnsName() == null) ? 0 : getPublicDnsName().hashCode());
hashCode = prime * hashCode + ((getPublicIpAddress() == null) ? 0 : getPublicIpAddress().hashCode());
hashCode = prime * hashCode + ((getRamdiskId() == null) ? 0 : getRamdiskId().hashCode());
hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().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.getPublicDnsName() != null && other.getPublicDnsName().equals(this.getPublicDnsName()) == false)
return false;
if (other.getPublicIpAddress() == null ^ this.getPublicIpAddress() == null)
return false;
if (other.getPublicIpAddress() != null && other.getPublicIpAddress().equals(this.getPublicIpAddress()) == false)
return false;
if (other.getRamdiskId() == null ^ this.getRamdiskId() == null)
代码示例来源:origin: aws-amplify/aws-sdk-android
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() + ",");
if (getArchitecture() != null) sb.append("Architecture: " + getArchitecture() + ",");
代码示例来源:origin: aws-amplify/aws-sdk-android
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());
hashCode = prime * hashCode + ((getArchitecture() == null) ? 0 : getArchitecture().hashCode());
代码示例来源:origin: aws-amplify/aws-sdk-android
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;
if (other.getStateReason() == null ^ this.getStateReason() == null) return false;
if (other.getStateReason() != null && other.getStateReason().equals(this.getStateReason()) == false) return false;
代码示例来源:origin: com.github.vatbub/awsec2wakelauncher.common
public String getInstanceIp(String instanceId) {
return getInstanceDescription(instanceId).getPublicIpAddress();
}
代码示例来源:origin: stackoverflow.com
DescribeInstancesResult result= ec2.describeInstances(request);
List <Reservation> list = result.getReservations();
for (Reservation res:list) {
List <Instance> instanceList= res.getInstances();
for (Instance instance:instanceList){
System.out.println("Instance Public IP :" + instance.getPublicIpAddress());
}
}
代码示例来源:origin: paulhoule/infovore
private String lookupIpOfInstance(String instanceId) throws Exception {
DescribeInstancesResult r=ec2Client.describeInstances(
new DescribeInstancesRequest().withInstanceIds(instanceId)
);
List<Reservation> instances=r.getReservations();
if(instances.size() != 1)
throw new Exception("Could not find instance ["+instanceId+"]");
return instances.get(0).getInstances().get(0).getPublicIpAddress();
}
代码示例来源: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: paulhoule/infovore
private String findIpAddress(String instanceId) {
DescribeInstancesResult result=ec2Client.describeInstances(new DescribeInstancesRequest().withInstanceIds(instanceId));
return result.getReservations().get(0).getInstances().get(0).getPublicIpAddress();
};
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!