本文整理了Java中com.amazonaws.services.ec2.model.Instance.getPublicDnsName()
方法的一些代码示例,展示了Instance.getPublicDnsName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getPublicDnsName()
方法的具体详情如下:
包路径:com.amazonaws.services.ec2.model.Instance
类名称:Instance
方法名:getPublicDnsName
[英](IPv4 only) The public DNS name assigned to the instance. This name is not available until the instance enters the running
state. For EC2-VPC, this name is only available if you've enabled DNS hostnames for your VPC.
[中](仅限IPv4)分配给实例的公共DNS名称。在实例进入running
状态之前,此名称不可用。对于EC2-VPC,此名称仅在为VPC启用DNS主机名时可用。
代码示例来源: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 (getProductCodes() != null)
sb.append("ProductCodes: ").append(getProductCodes()).append(",");
if (getPublicDnsName() != null)
sb.append("PublicDnsName: ").append(getPublicDnsName()).append(",");
if (getPublicIpAddress() != null)
sb.append("PublicIpAddress: ").append(getPublicIpAddress()).append(",");
代码示例来源:origin: aws/aws-sdk-java
hashCode = prime * hashCode + ((getPrivateIpAddress() == null) ? 0 : getPrivateIpAddress().hashCode());
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());
代码示例来源: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.getProductCodes() != null && other.getProductCodes().equals(this.getProductCodes()) == false)
return false;
if (other.getPublicDnsName() == null ^ this.getPublicDnsName() == null)
return false;
if (other.getPublicDnsName() != null && other.getPublicDnsName().equals(this.getPublicDnsName()) == false)
return false;
if (other.getPublicIpAddress() == null ^ this.getPublicIpAddress() == null)
代码示例来源:origin: aws-amplify/aws-sdk-android
if (getState() != null) sb.append("State: " + getState() + ",");
if (getPrivateDnsName() != null) sb.append("PrivateDnsName: " + getPrivateDnsName() + ",");
if (getPublicDnsName() != null) sb.append("PublicDnsName: " + getPublicDnsName() + ",");
if (getStateTransitionReason() != null) sb.append("StateTransitionReason: " + getStateTransitionReason() + ",");
if (getKeyName() != null) sb.append("KeyName: " + getKeyName() + ",");
代码示例来源:origin: aws-amplify/aws-sdk-android
hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode());
hashCode = prime * hashCode + ((getPrivateDnsName() == null) ? 0 : getPrivateDnsName().hashCode());
hashCode = prime * hashCode + ((getPublicDnsName() == null) ? 0 : getPublicDnsName().hashCode());
hashCode = prime * hashCode + ((getStateTransitionReason() == null) ? 0 : getStateTransitionReason().hashCode());
hashCode = prime * hashCode + ((getKeyName() == null) ? 0 : getKeyName().hashCode());
代码示例来源:origin: aws-amplify/aws-sdk-android
if (other.getPrivateDnsName() == null ^ this.getPrivateDnsName() == null) return false;
if (other.getPrivateDnsName() != null && other.getPrivateDnsName().equals(this.getPrivateDnsName()) == false) return false;
if (other.getPublicDnsName() == null ^ this.getPublicDnsName() == null) return false;
if (other.getPublicDnsName() != null && other.getPublicDnsName().equals(this.getPublicDnsName()) == false) return false;
if (other.getStateTransitionReason() == null ^ this.getStateTransitionReason() == null) return false;
if (other.getStateTransitionReason() != null && other.getStateTransitionReason().equals(this.getStateTransitionReason()) == 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: com.github.vatbub/awsec2wakelauncher.common
public String getInstanceDns(String instanceId) {
return getInstanceDescription(instanceId).getPublicDnsName();
}
代码示例来源:origin: stackoverflow.com
String getInstancePublicDnsName(String instanceId) {
DescribeInstancesResult describeInstancesRequest = ec2.describeInstances();
List<Reservation> reservations = describeInstancesRequest.getReservations();
Set<Instance> allInstances = new HashSet<Instance>();
for (Reservation reservation : reservations) {
for (Instance instance : reservation.getInstances()) {
if (instance.getInstanceId().equals(instanceId))
return instance.getPublicDnsName();
}
}
return null;
}
代码示例来源: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: com.xebialabs.cloud/overcast
public String waitUntilRunningAndGetPublicDnsName() {
// Give Amazon some time to settle before we ask it for information
sleep(5);
for (; ; ) {
DescribeInstancesRequest describe = new DescribeInstancesRequest().withInstanceIds(asList(instanceId));
Instance instance = ec2.describeInstances(describe).getReservations().get(0).getInstances().get(0);
if (instance.getState().getName().equals("running")) {
return instance.getPublicDnsName();
}
logger.info("Instance {} is still {}. Waiting...", instanceId, instance.getState().getName());
sleep(1);
}
}
代码示例来源:origin: com.xebialabs.overthere/itest-support
public String waitUntilRunningAndGetPublicDnsName() {
// Give Amazon some time to settle before we ask it for information
sleep(5);
for (;;) {
DescribeInstancesRequest describe = new DescribeInstancesRequest().withInstanceIds(newArrayList(instanceId));
Instance instance = ec2.describeInstances(describe).getReservations().get(0).getInstances().get(0);
if (instance.getState().getName().equals("running")) {
return instance.getPublicDnsName();
}
logger.info("Instance {} is still {}. Waiting...", instanceId, instance.getState().getName());
sleep(1);
}
}
代码示例来源:origin: com.proofpoint.galaxy/galaxy-cli
private static boolean allInstancesStarted(DescribeInstancesResult describeInstancesResult, int port)
{
for (Reservation reservation : describeInstancesResult.getReservations()) {
for (com.amazonaws.services.ec2.model.Instance instance : reservation.getInstances()) {
if (instance.getState() == null || instance.getState().getCode() == null) {
return false;
}
// is it running?
int state = instance.getState().getCode();
if (state == STATE_PENDING || instance.getPublicDnsName() == null) {
return false;
}
// can we talk to it yet?
try {
Resources.toByteArray(new URL(format("http://%s:%s/v1/slot", instance.getPublicDnsName(), port)));
}
catch (Exception e) {
return false;
}
}
}
return true;
}
}
代码示例来源:origin: jenkinsci/ec2-plugin
private String getEC2HostAddress(EC2Computer computer) throws InterruptedException {
Instance instance = computer.updateInstanceDescription();
if (computer.getNode().usePrivateDnsName) {
return instance.getPrivateDnsName();
} else {
String host = instance.getPublicDnsName();
// If we fail to get a public DNS name, try to get the public IP
// (but only if the plugin config let us use the public IP to
// connect to the slave).
if (StringUtils.isEmpty(host)) {
SlaveTemplate slaveTemplate = computer.getSlaveTemplate();
if (instance.getPublicIpAddress() != null && slaveTemplate.isConnectUsingPublicIp()) {
host = instance.getPublicIpAddress();
}
}
// If we fail to get a public DNS name or public IP, use the private
// IP.
if (StringUtils.isEmpty(host)) {
host = instance.getPrivateIpAddress();
}
return host;
}
}
代码示例来源:origin: jenkinsci/ec2-plugin
protected EC2OndemandSlave newOndemandSlave(Instance inst) throws FormException, IOException {
return new EC2OndemandSlave(inst.getInstanceId(), description, remoteFS, getNumExecutors(), labels, mode, initScript,
tmpDir, remoteAdmin, jvmopts, stopOnTerminate, idleTerminationMinutes, inst.getPublicDnsName(),
inst.getPrivateDnsName(), EC2Tag.fromAmazonTags(inst.getTags()), parent.name, usePrivateDnsName,
useDedicatedTenancy, getLaunchTimeout(), amiType, maxTotalUses);
}
代码示例来源:origin: org.jenkins-ci.plugins/ec2
protected EC2OndemandSlave newOndemandSlave(Instance inst) throws FormException, IOException {
return new EC2OndemandSlave(inst.getInstanceId(), description, remoteFS, getNumExecutors(), labels, mode, initScript, tmpDir, remoteAdmin, jvmopts, stopOnTerminate, idleTerminationMinutes, inst.getPublicDnsName(), inst.getPrivateDnsName(), EC2Tag.fromAmazonTags(inst.getTags()), parent.name, usePrivateDnsName, useDedicatedTenancy, getLaunchTimeout(), amiType);
}
内容来源于网络,如有侵权,请联系作者删除!