Example usage for com.amazonaws.util AwsHostNameUtils localHostName

List of usage examples for com.amazonaws.util AwsHostNameUtils localHostName

Introduction

In this page you can find the example usage for com.amazonaws.util AwsHostNameUtils localHostName.

Prototype

public static String localHostName() 

Source Link

Document

Returns the host name for the local host.

Usage

From source file:com.github.lpezet.antiope.metrics.aws.BlockingRequestBuilder.java

License:Open Source License

private List<PutMetricDataRequest> newPutMetricDataRequests(Collection<MetricDatum> pData) {
    List<PutMetricDataRequest> oList = new ArrayList<PutMetricDataRequest>();
    final String ns = mMetricsConfig.getMetricNameSpace();
    PutMetricDataRequest oReq = newPutMetricDataRequest(pData, ns);
    oList.add(oReq);//from   ww  w  . j a  va 2s.  co m
    final boolean oPerHost = mMetricsConfig.isPerHostMetricEnabled();
    String oPerHostNameSpace = null;
    String oHostName = null;
    Dimension oHostDim = null;
    final boolean oSingleNamespace = mMetricsConfig.isSingleMetricNamespace();
    if (oPerHost) {
        oHostName = mMetricsConfig.getHostMetricName();
        oHostName = oHostName == null ? "" : oHostName.trim();
        if (oHostName.length() == 0)
            oHostName = AwsHostNameUtils.localHostName();
        oHostDim = dimension(Dimensions.Host, oHostName);
        if (oSingleNamespace) {
            oReq = newPutMetricDataRequest(pData, ns, oHostDim);
        } else {
            oPerHostNameSpace = ns + NAMESPACE_DELIMITER + oHostName;
            oReq = newPutMetricDataRequest(pData, oPerHostNameSpace);
        }
        oList.add(oReq);
    }
    String oJvmMetricName = mMetricsConfig.getJvmMetricName();
    if (oJvmMetricName != null) {
        oJvmMetricName = oJvmMetricName.trim();
        if (oJvmMetricName.length() > 0) {
            if (oSingleNamespace) {
                Dimension oJvmDim = dimension(Dimensions.JVM, oJvmMetricName);
                if (oPerHost) {
                    // If OS metrics are already included at the per host level,
                    // there is little reason, if any, to include them at the
                    // JVM level.  Hence the filtering.
                    oReq = newPutMetricDataRequest(filterOSMetrics(pData), ns, oHostDim, oJvmDim);
                } else {
                    oReq = newPutMetricDataRequest(pData, ns, oJvmDim);
                }

            } else {
                String oPerJvmNameSpace = oPerHostNameSpace == null ? ns + NAMESPACE_DELIMITER + oJvmMetricName
                        : oPerHostNameSpace + NAMESPACE_DELIMITER + oJvmMetricName;
                // If OS metrics are already included at the per host level,
                // there is little reason, if any, to include them at the
                // JVM level.  Hence the filtering.
                oReq = newPutMetricDataRequest(oPerHost ? filterOSMetrics(pData) : pData, oPerJvmNameSpace);
            }
            oList.add(oReq);
        }
    }
    return oList;
}