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()); } } }
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. 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());
/** * 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()); } }
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. 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());
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. 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());
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. 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());
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. 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());
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. 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 {
"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()); "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric);