本文整理匯總了Java中com.amazonaws.services.ec2.model.Instance.getPrivateDnsName方法的典型用法代碼示例。如果您正苦於以下問題:Java Instance.getPrivateDnsName方法的具體用法?Java Instance.getPrivateDnsName怎麽用?Java Instance.getPrivateDnsName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amazonaws.services.ec2.model.Instance
的用法示例。
在下文中一共展示了Instance.getPrivateDnsName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getEC2HostAddress
import com.amazonaws.services.ec2.model.Instance; //導入方法依賴的package包/類
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;
}
}
示例2: getPropertyValue
import com.amazonaws.services.ec2.model.Instance; //導入方法依賴的package包/類
@Override
protected String getPropertyValue(Instance instance) {
return instance.getPrivateDnsName();
}
示例3: connectToWinRM
import com.amazonaws.services.ec2.model.Instance; //導入方法依賴的package包/類
private WinConnection connectToWinRM(EC2Computer computer, PrintStream logger) throws AmazonClientException,
InterruptedException {
final long timeout = computer.getNode().getLaunchTimeoutInMillis();
final long startTime = System.currentTimeMillis();
logger.println(computer.getNode().getDisplayName() + " booted at " + computer.getNode().getCreatedTime());
boolean alreadyBooted = (startTime - computer.getNode().getCreatedTime()) > TimeUnit.MINUTES.toMillis(3);
while (true) {
try {
long waitTime = System.currentTimeMillis() - startTime;
if (waitTime > timeout) {
throw new AmazonClientException("Timed out after " + (waitTime / 1000)
+ " seconds of waiting for winrm to be connected");
}
Instance instance = computer.updateInstanceDescription();
String vpc_id = instance.getVpcId();
String ip, host;
if (computer.getNode().usePrivateDnsName) {
host = instance.getPrivateDnsName();
ip = instance.getPrivateIpAddress(); // SmbFile doesn't quite work with hostnames
} else {
host = instance.getPublicDnsName();
if (host == null || host.equals("")) {
host = instance.getPrivateDnsName();
ip = instance.getPrivateIpAddress(); // SmbFile doesn't quite work with hostnames
}
else {
host = instance.getPublicDnsName();
ip = instance.getPublicIpAddress(); // SmbFile doesn't quite work with hostnames
}
}
if ("0.0.0.0".equals(host)) {
logger.println("Invalid host 0.0.0.0, your host is most likely waiting for an ip address.");
throw new IOException("goto sleep");
}
logger.println("Connecting to " + host + "(" + ip + ") with WinRM as " + computer.getNode().remoteAdmin);
WinConnection connection = new WinConnection(ip, computer.getNode().remoteAdmin, computer.getNode().getAdminPassword());
connection.setUseHTTPS(computer.getNode().isUseHTTPS());
if (!connection.ping()) {
logger.println("Waiting for WinRM to come up. Sleeping 10s.");
Thread.sleep(sleepBetweenAttemps);
continue;
}
if (!alreadyBooted || computer.getNode().stopOnTerminate) {
logger.println("WinRM service responded. Waiting for WinRM service to stabilize on " + computer.getNode().getDisplayName());
Thread.sleep(computer.getNode().getBootDelay());
alreadyBooted = true;
logger.println("WinRM should now be ok on " + computer.getNode().getDisplayName());
if (!connection.ping()) {
logger.println("WinRM not yet up. Sleeping 10s.");
Thread.sleep(sleepBetweenAttemps);
continue;
}
}
logger.println("Connected with WinRM.");
return connection; // successfully connected
} catch (IOException e) {
logger.println("Waiting for WinRM to come up. Sleeping 10s.");
Thread.sleep(sleepBetweenAttemps);
}
}
}
示例4: hostName
import com.amazonaws.services.ec2.model.Instance; //導入方法依賴的package包/類
private String hostName(Instance remoteInstance) {
String publicDNS = remoteInstance.getPublicDnsName();
return publicDNS != null ? publicDNS : remoteInstance.getPrivateDnsName();
}