Refine search
/** Creates a new instance of JvmMetrics */ private JvmMetrics(String processName, String sessionId, String recordName) { MetricsContext context = MetricsUtil.getContext("jvm"); metrics = MetricsUtil.createRecord(context, recordName); metrics.setTag("processName", processName); metrics.setTag("sessionId", sessionId); context.registerUpdater(this); }
/** * Utility method to create and return new metrics record instance within the * given context. This record is tagged with the host name. * * @param context the context * @param recordName name of the record * @return newly created metrics record */ public static MetricsRecord createRecord(MetricsContext context, String recordName) { MetricsRecord metricsRecord = context.createRecord(recordName); metricsRecord.setTag("hostName", getHostName()); return metricsRecord; }
@Override public void unregisterUpdater(Updater updater) { for (MetricsContext ctxt : subctxt) { ctxt.unregisterUpdater(updater); } }
@Override public void startMonitoring() throws IOException { for (MetricsContext ctxt : subctxt) { try { ctxt.startMonitoring(); } catch (IOException e) { LOG.warn("startMonitoring failed: " + ctxt.getContextName(), e); } } }
/** * Initializes, for testing, two NoEmitMetricsContext's, and adds one value * to the first of them. */ public void setUp() throws IOException { nc1 = new NoEmitMetricsContext(); nc1.init("test1", ContextFactory.getFactory()); nc2 = new NoEmitMetricsContext(); nc2.init("test2", ContextFactory.getFactory()); contexts = new ArrayList<MetricsContext>(); contexts.add(nc1); contexts.add(nc2); MetricsRecord r = nc1.createRecord("testRecord"); r.setTag("testTag1", "testTagValue1"); r.setTag("testTag2", "testTagValue2"); r.setMetric("testMetric1", 1); r.setMetric("testMetric2", 33); r.update(); Map<String, Collection<OutputRecord>> m = nc1.getAllRecords(); assertEquals(1, m.size()); assertEquals(1, m.values().size()); Collection<OutputRecord> outputRecords = m.values().iterator().next(); assertEquals(1, outputRecords.size()); outputRecord = outputRecords.iterator().next(); }
public ThemisCpStatistics() { context = MetricsUtil.getContext("themis"); metricsRecord = MetricsUtil.createRecord(context, "coprocessor"); context.registerUpdater(this); }
} finally { RPC.stopProxy(umbilical); MetricsContext metricsContext = MetricsUtil.getContext("mapred"); metricsContext.close();
/** * Utility method to return the named context. * If the desired context cannot be created for any reason, the exception * is logged, and a null context is returned. */ public static MetricsContext getContext(String contextName) { MetricsContext metricsContext; try { metricsContext = ContextFactory.getFactory().getContext(contextName); if (!metricsContext.isMonitoring()) { metricsContext.startMonitoring(); } } catch (Exception ex) { LOG.error("Unable to create metrics context " + contextName, ex); metricsContext = ContextFactory.getNullContext(contextName); } return metricsContext; }
/** * Collects all metric data, and returns a map: * contextName -> recordName -> [ (tag->tagValue), (metric->metricValue) ]. * The values are either String or Number. The final value is implemented * as a list of TagsMetricsPair. */ Map<String, Map<String, List<TagsMetricsPair>>> makeMap( Collection<MetricsContext> contexts) throws IOException { Map<String, Map<String, List<TagsMetricsPair>>> map = new TreeMap<String, Map<String, List<TagsMetricsPair>>>(); for (MetricsContext context : contexts) { Map<String, List<TagsMetricsPair>> records = new TreeMap<String, List<TagsMetricsPair>>(); map.put(context.getContextName(), records); for (Map.Entry<String, Collection<OutputRecord>> r : context.getAllRecords().entrySet()) { List<TagsMetricsPair> metricsAndTags = new ArrayList<TagsMetricsPair>(); records.put(r.getKey(), metricsAndTags); for (OutputRecord outputRecord : r.getValue()) { TagMap tagMap = outputRecord.getTagsCopy(); MetricMap metricMap = outputRecord.getMetricsCopy(); metricsAndTags.add(new TagsMetricsPair(tagMap, metricMap)); } } } return map; }
MetricsRecordDelegator(String recordName, ArrayList<MetricsContext> ctxts) { this.recordName = recordName; this.subrecs = new ArrayList<MetricsRecord>(ctxts.size()); for (MetricsContext ctxt : ctxts) { subrecs.add(ctxt.createRecord(recordName)); } }
metricsContext.init(contextName, this); contextMap.put(contextName, metricsContext);
@Override public void close() { for (MetricsContext ctxt : subctxt) { ctxt.close(); } }
/** * Return true if all subcontexts are monitoring. */ @Override public boolean isMonitoring() { boolean ret = true; for (MetricsContext ctxt : subctxt) { ret &= ctxt.isMonitoring(); } return ret; }
/** * Initializes, for testing, two NoEmitMetricsContext's, and adds one value * to the first of them. */ @Override public void setUp() throws IOException { nc1 = new NoEmitMetricsContext(); nc1.init("test1", ContextFactory.getFactory()); nc2 = new NoEmitMetricsContext(); nc2.init("test2", ContextFactory.getFactory()); contexts = new ArrayList<MetricsContext>(); contexts.add(nc1); contexts.add(nc2); MetricsRecord r = nc1.createRecord("testRecord"); r.setTag("testTag1", "testTagValue1"); r.setTag("testTag2", "testTagValue2"); r.setMetric("testMetric1", 1); r.setMetric("testMetric2", 33); r.update(); Map<String, Collection<OutputRecord>> m = nc1.getAllRecords(); assertEquals(1, m.size()); assertEquals(1, m.values().size()); Collection<OutputRecord> outputRecords = m.values().iterator().next(); assertEquals(1, outputRecords.size()); outputRecord = outputRecords.iterator().next(); }
public LookasideMetrics() { // Create a record for LookasideCache metrics MetricsContext metricsContext = MetricsUtil.getContext("lookasideCache"); metricsRecord = MetricsUtil.createRecord(metricsContext, "LookasideFileSystem"); metricsContext.registerUpdater(this); }
RPC.stopProxy(proxy); MetricsContext metricsContext = MetricsUtil.getContext("mapred"); metricsContext.close();
/** * Utility method to return the named context. * If the desired context cannot be created for any reason, the exception * is logged, and a null context is returned. */ public static MetricsContext getContext(String refName, String contextName) { MetricsContext metricsContext; try { metricsContext = ContextFactory.getFactory().getContext(refName, contextName); if (!metricsContext.isMonitoring()) { metricsContext.startMonitoring(); } } catch (Exception ex) { LOG.error("Unable to create metrics context " + contextName, ex); metricsContext = ContextFactory.getNullContext(contextName); } return metricsContext; }
/** * Collects all metric data, and returns a map: * contextName -> recordName -> [ (tag->tagValue), (metric->metricValue) ]. * The values are either String or Number. The final value is implemented * as a list of TagsMetricsPair. */ Map<String, Map<String, List<TagsMetricsPair>>> makeMap( Collection<MetricsContext> contexts) throws IOException { Map<String, Map<String, List<TagsMetricsPair>>> map = new TreeMap<String, Map<String, List<TagsMetricsPair>>>(); for (MetricsContext context : contexts) { Map<String, List<TagsMetricsPair>> records = new TreeMap<String, List<TagsMetricsPair>>(); map.put(context.getContextName(), records); for (Map.Entry<String, Collection<OutputRecord>> r : context.getAllRecords().entrySet()) { List<TagsMetricsPair> metricsAndTags = new ArrayList<TagsMetricsPair>(); records.put(r.getKey(), metricsAndTags); for (OutputRecord outputRecord : r.getValue()) { TagMap tagMap = outputRecord.getTagsCopy(); MetricMap metricMap = outputRecord.getMetricsCopy(); metricsAndTags.add(new TagsMetricsPair(tagMap, metricMap)); } } } return map; }
@InterfaceAudience.Private @Override public void startMonitoring() throws IOException { for (MetricsContext ctxt : subctxt) { try { ctxt.startMonitoring(); } catch (IOException e) { LOG.warn("startMonitoring failed: " + ctxt.getContextName(), e); } } }
MetricsRecordDelegator(String recordName, ArrayList<MetricsContext> ctxts) { this.recordName = recordName; this.subrecs = new ArrayList<MetricsRecord>(ctxts.size()); for (MetricsContext ctxt : ctxts) { subrecs.add(ctxt.createRecord(recordName)); } }