List of usage examples for org.apache.commons.configuration SubsetConfiguration getString
public String getString(String key, String defaultValue)
From source file:com.chocolatefactory.newrelic.plugins.hadoop.NewRelicSink.java
@Override public void init(SubsetConfiguration conf) { debugEnabled = false;/* ww w . j a v a 2 s . c o m*/ getGroupings = false; div = NewRelicMetrics.kMetricTreeDivider; categoryName = NewRelicMetrics.kCategoryMetricName; deltaName = NewRelicMetrics.kDeltaMetricName; overviewName = NewRelicMetrics.kOverviewMetricName; hadoopProcType = conf.getString("proctype", NewRelicMetrics.kDefaultAgentName); nrLicenseKey = conf.getString("nrlicensekey", ""); logger = Logger.getLogger(NewRelicSink.class); if (hadoopProcType.equals(NewRelicMetrics.kDefaultAgentName) && !conf.containsKey("enabled")) { logger.info("Monitoring disabled for this procees."); logger.info("Shutting down New Relic sink."); return; } else if ("".equals(nrLicenseKey) || (nrLicenseKey == null)) { logger.info("No New Relic License Key given."); logger.info("Shutting down New Relic sink."); return; } else { context = buildContext(nrLicenseKey, conf.getString("hostname", ""), hadoopProcType); component = context.getComponents().next(); } // Debug stuff if (conf.getString("debug", "false").equals("true")) { debugEnabled = true; logger.info("New Relic Sink: DEBUG enabled."); } if (conf.getString("nrgroupings", "false").equals("true")) { getGroupings = true; metricGroupings = new HashMap<String, Integer>(); logger.info("New Relic Sink: Getting Metric Groupings"); } // For Insights nrInsightsKey = conf.getString("nrinsightskey", ""); nrAccountId = conf.getString("nraccountid", ""); if ("".equals(nrInsightsKey) || (nrInsightsKey == null) || "".equals(nrAccountId) || (nrAccountId == null)) { logger.info("No New Relic (Insights Insert Key || Account ID) given."); logger.info("Metrics will not be fed to insights."); useInsights = false; } else { logger.info("Insights metric recording is enabled!"); useInsights = true; insightsService = InsightsService.withAccountId(nrAccountId).withApiKey(nrInsightsKey).withSsl(true); } // Initializing hashmaps to hold metrics metricNames = new HashMap<String, String[]>(); oldMetricValues = new HashMap<String, Float>(); insightsMetrics = new HashMap<String, Object>(); }
From source file:org.apache.hadoop.metrics2.ovis.OvisSink.java
@Override public void init(SubsetConfiguration conf) { ldmsSamplerPort = conf.getInt("port", DEFAULT_PORT); hostname = conf.getString("host", DEFAULT_HOST); daemonName = conf.getString("daemon", "unknown"); try {/*from w w w . ja va 2s .c o m*/ ldmsSamplerAddr = InetAddress.getByName(hostname); socket = new DatagramSocket(); } catch (Exception e) { throw new MetricsException("OvisSink: Failed to new " + "DatagramSocket: " + e.getMessage()); } }
From source file:org.apache.hadoop.metrics2.sink.timeline.HadoopTimelineMetricsSink.java
/** * Return configured serviceName with or without prefix. * Default without serviceName or configured prefix : first config prefix * With prefix : configured prefix + first config prefix * Configured serviceName : Return serviceName as is. *//*from www .j a v a 2 s .c o m*/ private String getServiceName(SubsetConfiguration conf) { String serviceNamePrefix = conf.getString(SERVICE_NAME_PREFIX, ""); String serviceName = conf.getString(SERVICE_NAME, ""); return StringUtils.isEmpty(serviceName) ? StringUtils.isEmpty(serviceNamePrefix) ? getFirstConfigPrefix(conf) : serviceNamePrefix + "-" + getFirstConfigPrefix(conf) : serviceName; }