public RunnerInstance( Instance instance ) { this.instance = instance; this.hostname = instance.getPublicDnsName(); this.ipv4Address = instance.getPublicIpAddress(); this.url = "https://" + instance.getPublicDnsName() + ":" + Runner.DEFAULT_SERVER_PORT + "/"; }
@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 + "/"; }
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(",");
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());
/** * 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; }
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)
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() + ",");
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());
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;
private String getPreferredHostName(final Instance instance) { if (this.preferPrivateIpHostnames) { return instance.getPrivateIpAddress(); } return instance.getPublicDnsName(); } }
public String getInstanceDns(String instanceId) { return getInstanceDescription(instanceId).getPublicDnsName(); }
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; }
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; } }
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."); }
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); } }
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); } }
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; } }
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; } }
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); }
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); }