/** * serialize all the MetricsTimeVaryingLong */ public void write(DataOutput out) throws IOException { out.writeByte(SCANMETRICS_VERSION); Collection<MetricsBase> mbs = registry.getMetricsList(); // we only handle MetricsTimeVaryingLong for now. int metricsCount = 0; for (MetricsBase mb : mbs) { if ( mb instanceof MetricsTimeVaryingLong) { metricsCount++; } else { throw new IOException("unsupported metrics type. metrics name: " + mb.getName() + ", metrics description: " + mb.getDescription()); } } out.writeInt(metricsCount); for (MetricsBase mb : mbs) { out.writeUTF(mb.getName()); out.writeLong(((MetricsTimeVaryingLong) mb).getCurrentIntervalValue()); } }
/** * Since this object is a registered updater, this method will be called * periodically, e.g. every 5 seconds. */ public void doUpdates(MetricsContext unused) { synchronized (this) { for (MetricsBase m : registry.getMetricsList()) { m.pushMetric(metricsRecord); } } metricsRecord.update(); }
private static MetricsRegistry copyMinusHBaseMetrics(final MetricsRegistry mr) { MetricsRegistry copy = new MetricsRegistry(); for (MetricsBase metric : mr.getMetricsList()) { if (metric instanceof MetricsRate || metric instanceof MetricsString || metric instanceof MetricsHistogram || metric instanceof ExactCounterMetric) { continue; } copy.add(metric.getName(), metric); } return copy; }
attributesInfo.add(new MBeanAttributeInfo(o.getName() + NUM_OPS, "java.lang.Integer", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + AVG_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MIN_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MAX_TIME, "java.lang.Long", o.getDescription(), true, false, false)); needsMinMaxResetOperation = true; // the min and max can be reset. metricsRateAttributeMod.put(o.getName() + NUM_OPS, o); metricsRateAttributeMod.put(o.getName() + AVG_TIME, o); metricsRateAttributeMod.put(o.getName() + MIN_TIME, o); metricsRateAttributeMod.put(o.getName() + MAX_TIME, o); attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Integer", o.getDescription(), true, false, false)); } else if ( MetricsLongValue.class.isInstance(o) || MetricsTimeVaryingLong.class.isInstance(o) ) { attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Long", o.getDescription(), true, false, false)); } else { MetricsUtil.LOG.error("unknown metrics type: " + o.getClass().getName());
@Override public void doUpdates(MetricsContext unused) { synchronized (this) { for (MetricsBase m : registry.getMetricsList()) { m.pushMetric(metricsRecord); } } metricsRecord.update(); }
public void readFields(DataInput in) throws IOException { int version = in.readByte(); if (version > (int)SCANMETRICS_VERSION) { throw new IOException("version " + version + " not supported"); } int metricsCount = in.readInt(); for (int i=0; i<metricsCount; i++) { String metricsName = in.readUTF(); long v = in.readLong(); MetricsBase mb = registry.get(metricsName); if ( mb instanceof MetricsTimeVaryingLong) { ((MetricsTimeVaryingLong) mb).inc(v); } else { LOG.warn("unsupported metrics type. metrics name: " + mb.getName() + ", metrics description: " + mb.getDescription()); } } }
/** * Since this object is a registered updater, this method will be called * periodically, e.g. every 5 seconds. */ public void doUpdates(MetricsContext unused) { synchronized (this) { for (MetricsBase m : registry.getMetricsList()) { m.pushMetric(metricsRecord); } } metricsRecord.update(); }
attributesInfo.add(new MBeanAttributeInfo(o.getName() + NUM_OPS, "java.lang.Integer", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + AVG_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MIN_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MAX_TIME, "java.lang.Long", o.getDescription(), true, false, false)); needsMinMaxResetOperation = true; // the min and max can be reset. metricsRateAttributeMod.put(o.getName() + NUM_OPS, o); metricsRateAttributeMod.put(o.getName() + AVG_TIME, o); metricsRateAttributeMod.put(o.getName() + MIN_TIME, o); metricsRateAttributeMod.put(o.getName() + MAX_TIME, o); attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Integer", o.getDescription(), true, false, false)); } else if ( MetricsLongValue.class.isInstance(o) || MetricsTimeVaryingLong.class.isInstance(o) ) { attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Long", o.getDescription(), true, false, false)); } else { MetricsUtil.LOG.error("unknown metrics type: " + o.getClass().getName());
/** * Since this object is a registered updater, this method will be called * periodically, e.g. every 5 seconds. */ public void doUpdates(MetricsContext unused) { synchronized (this) { for (MetricsBase m : registry.getMetricsList()) { m.pushMetric(metricsRecord); } } metricsRecord.update(); }
attributesInfo.add(new MBeanAttributeInfo(o.getName() + NUM_OPS, "java.lang.Integer", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + AVG_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MIN_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MAX_TIME, "java.lang.Long", o.getDescription(), true, false, false)); needsMinMaxResetOperation = true; // the min and max can be reset. metricsRateAttributeMod.put(o.getName() + NUM_OPS, o); metricsRateAttributeMod.put(o.getName() + AVG_TIME, o); metricsRateAttributeMod.put(o.getName() + MIN_TIME, o); metricsRateAttributeMod.put(o.getName() + MAX_TIME, o); attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Integer", o.getDescription(), true, false, false)); } else if ( MetricsLongValue.class.isInstance(o) || MetricsTimeVaryingLong.class.isInstance(o) ) { attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Long", o.getDescription(), true, false, false)); } else if ( MetricsNonTimeRate.class.isInstance(o)) { attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Float", o.getDescription(), true, false, false)); } else if ( MetricsRate.class.isInstance(o)) { attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Float", o.getDescription(), true, false, false)); } else {
@Override public void doUpdates(MetricsContext unused) { synchronized (this) { for (MetricsBase m : metricsRegistry.getMetricsList()) { m.pushMetric(metricsRecord); } } metricsRecord.update(); }
attributesInfo.add(new MBeanAttributeInfo(o.getName() + NUM_OPS, "java.lang.Integer", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + AVG_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MIN_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MAX_TIME, "java.lang.Long", o.getDescription(), true, false, false)); needsMinMaxResetOperation = true; // the min and max can be reset. metricsRateAttributeMod.put(o.getName() + NUM_OPS, o); metricsRateAttributeMod.put(o.getName() + AVG_TIME, o); metricsRateAttributeMod.put(o.getName() + MIN_TIME, o); metricsRateAttributeMod.put(o.getName() + MAX_TIME, o); attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Integer", o.getDescription(), true, false, false)); } else if ( MetricsLongValue.class.isInstance(o) || MetricsTimeVaryingLong.class.isInstance(o) ) { attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Long", o.getDescription(), true, false, false)); } else { MetricsUtil.LOG.error("unknown metrics type: " + o.getClass().getName());
@Override public void doUpdates(MetricsContext unused) { synchronized (this) { for (MetricsBase m : metricsRegistry.getMetricsList()) { m.pushMetric(metricsRecord); } } metricsRecord.update(); }
attributesInfo.add(new MBeanAttributeInfo(o.getName() + NUM_OPS, "java.lang.Integer", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + AVG_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MIN_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MAX_TIME, "java.lang.Long", o.getDescription(), true, false, false)); needsMinMaxResetOperation = true; // the min and max can be reset. metricsRateAttributeMod.put(o.getName() + NUM_OPS, o); metricsRateAttributeMod.put(o.getName() + AVG_TIME, o); metricsRateAttributeMod.put(o.getName() + MIN_TIME, o); metricsRateAttributeMod.put(o.getName() + MAX_TIME, o); attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Integer", o.getDescription(), true, false, false)); } else if ( MetricsLongValue.class.isInstance(o) || MetricsTimeVaryingLong.class.isInstance(o) ) { attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Long", o.getDescription(), true, false, false)); } else { MetricsUtil.LOG.error("unknown metrics type: " + o.getClass().getName());
@Override public void doUpdates(MetricsContext metricsContext) { synchronized (this) { for (MetricsBase m : registry.getMetricsList()) { m.pushMetric(metricsRecord); } } metricsRecord.update(); }
attributesInfo.add(new MBeanAttributeInfo(o.getName() + NUM_OPS, "java.lang.Integer", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + AVG_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MIN_TIME, "java.lang.Long", o.getDescription(), true, false, false)); attributesInfo.add(new MBeanAttributeInfo(o.getName() + MAX_TIME, "java.lang.Long", o.getDescription(), true, false, false)); needsMinMaxResetOperation = true; // the min and max can be reset. metricsRateAttributeMod.put(o.getName() + NUM_OPS, o); metricsRateAttributeMod.put(o.getName() + AVG_TIME, o); metricsRateAttributeMod.put(o.getName() + MIN_TIME, o); metricsRateAttributeMod.put(o.getName() + MAX_TIME, o); attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Integer", o.getDescription(), true, false, false)); } else if ( MetricsLongValue.class.isInstance(o) || MetricsTimeVaryingLong.class.isInstance(o) ) { attributesInfo.add(new MBeanAttributeInfo(o.getName(), "java.lang.Long", o.getDescription(), true, false, false)); } else { MetricsUtil.LOG.error("unknown metrics type: " + o.getClass().getName());
@Override public void doUpdates(MetricsContext context) { synchronized (this) { for (MetricsBase m : registry.getMetricsList()) { m.pushMetric(metricsRecord); } } metricsRecord.update(); }
if (metric.getName() == null || parentAttributes.contains(metric.getName())) continue; attributes.add( new MBeanAttributeInfo(metric.getName(), "java.lang.Float", metric.getDescription(), true, false, false) ); extendedAttributes.put(metric.getName(), metric); } else if (metric instanceof MetricsString) { attributes.add( new MBeanAttributeInfo(metric.getName(), "java.lang.String", metric.getDescription(), true, false, false) ); extendedAttributes.put(metric.getName(), metric); LOG.info("MetricsString added: " + metric.getName()); } else if (metric instanceof MetricsHistogram) { String metricName = metric.getName() + MetricsHistogram.NUM_OPS_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.MIN_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.MAX_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.MEAN_METRIC_NAME;
/** * Push the metrics to the monitoring subsystem on doUpdate() call. */ public void doUpdates(final MetricsContext context) { // Both getMetricsList() and pushMetric() are thread-safe for (MetricsBase m : registry.getMetricsList()) { m.pushMetric(metricsRecord); } metricsRecord.update(); }
/** * Push the metrics to the monitoring subsystem on doUpdate() call. */ public void doUpdates(final MetricsContext context) { // getMetricsList() and pushMetric() are thread safe methods for (MetricsBase m : registry.getMetricsList()) { m.pushMetric(metricsRecord); } metricsRecord.update(); } }