List of usage examples for com.amazonaws.util EC2MetadataUtils getInstanceType
public static String getInstanceType()
From source file:com.boundlessgeo.suite.geoserver.cloudwatch.aws.MetricDatumEncoder.java
License:Open Source License
private void setUp() { try {// w ww .java 2 s . c om if (enablePerInstanceMetrics) { amiId = EC2MetadataUtils.getAmiId(); logger.info("Detected AMI ID of {}", amiId); instanceType = EC2MetadataUtils.getInstanceType(); logger.info("Detected Instance Type = {}", instanceType); if (StringUtils.isBlank(instanceId)) { instanceId = EC2MetadataUtils.getInstanceId(); logger.info("Detected Instance Id of {}", instanceId); } else logger.info("Instance Id overridden with {}", instanceId); } setup = true; } catch (Exception ex) { logger.error("Unable to determine AMI ID or Instance type...are we on AWS?"); logger.error(ex.getMessage()); //only try this once....the strings can just be empty if it fails. //the sender will catch it anyways setup = true; } }