/** * Returns a metric key which corresponds to the invocation * count of the given tag. */ public MetricKey getMetricKey() { if (key == null) { key = MetricKey.valueOf("tag." + getTag() + ":type=counter"); } return key; } }
public Object readResolve() throws ObjectStreamException { if (StringUtil.isEmpty(key)) { throw new StreamCorruptedException("No current key"); } return valueOf(key); }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { long version = in.readLong(); if (version != serialVersionUID) { throw new IllegalStateException("Unable to deserialize GaugeMetricCommand; unexpected serialVersionUID: " + version); } resource = ResourceKey.valueOf((String) in.readObject()); metric = MetricKey.valueOf((String) in.readObject()); value = (GaugeMetricValue)in.readObject(); }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { long version = in.readLong(); if (version != serialVersionUID) { throw new IllegalStateException("Unable to deserialize ScalarMetricCommand; unexpected serialVersionUID: " + version); } resource = ResourceKey.valueOf((String) in.readObject()); metric = MetricKey.valueOf((String) in.readObject()); range = (TimeRange) in.readObject(); value = in.readDouble(); }
static Command createMetricCommand (ResourceKey resKey, TimeRange range, String key, PointType pt, Collection<? extends IDataPoint> points) { if (ListUtil.size(points) <= 0) { return null; } ResourceMetricKey metricKey = ResourceMetricKey.valueOf(resKey, MetricKey.valueOf(key)); switch (pt) { case COUNTER: { CounterMetricValueBuilder valueBuilder = new CounterMetricValueBuilder(range); CounterMetricValue mValue = (CounterMetricValue)aggregateValue(points, valueBuilder); return new UpdateMetricCommand(metricKey, mValue); } case GAUGE: { GaugeMetricValueBuilder valueBuilder=new GaugeMetricValueBuilder(range); GaugeMetricValue gValue = (GaugeMetricValue)aggregateValue(points, valueBuilder); return new UpdateMetricDistributionCommand(metricKey, gValue); } default: throw new IllegalStateException("createMetricCommand(" + metricKey + ")[" + range + "] unhandled point type: " + pt); } }