private HistogramFactory(GaugeMetricValue gaugeValue) { metricValue = gaugeValue; binsCount = 1; definition = InsightGaugeHistogramDefinition.getInstance(); lowOutliers = false; highOutliers = false; start = Double.NEGATIVE_INFINITY; end = Double.POSITIVE_INFINITY; }
public SparseHistogram() { // for serialization this(InsightGaugeHistogramDefinition.getInstance()); }
SparseHistogram(List<IndexedBin> indexedBins) { this(InsightGaugeHistogramDefinition.getInstance(), indexedBins); }
public GaugeMetricValue(TimeRange timeRange) { this.range = timeRange; this.min = NaN; this.max = NaN; this.n = 0; this.sum = 0.0; this.sumOfSquares = 0.0; this.histo = new SparseHistogram(InsightGaugeHistogramDefinition.getInstance(), new ArrayList<IndexedBin>()); }
public MutableGaugeMetricValue(TimeRange timeRange) { this.range = timeRange; this.histo = new HistogramAccumulator(InsightGaugeHistogramDefinition.getInstance()); }
static private HistogramAccumulator makeHistoAccumulator() { return new HistogramAccumulator(InsightGaugeHistogramDefinition.getInstance()); } }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { long version = in.readLong(); if (version != serialVersionUID) { throw new StreamCorruptedException("Mismatched serialVersionUID - expected" + serialVersionUID + ", actual=" + version); } int size = in.readInt(), maxNumber=(-1); bins = (size > 0) ? new ArrayList<IndexedBin>(size) : null; boolean readHistogramDefinition=false; for (size-- ; size >= 0; size--) { IndexedBin bin=new IndexedBin(in.readInt(), in.readLong()); int binNumber=bin.getBinNumber(); if (binNumber > maxNumber) { maxNumber = binNumber; } if ((size == 0) && (maxNumber == binNumber) && (bin.getCount() == withHistogramDefinitionUID)) { readHistogramDefinition = true; } else { bins.add(bin); } } bins = (bins == null) ? Collections.<IndexedBin>emptyList() : Collections.unmodifiableList(bins); if (readHistogramDefinition) { histogramDefinition = (HistogramDefinition) in.readObject(); } else { histogramDefinition = InsightGaugeHistogramDefinition.getInstance(); } }
public GaugeMetricValueBuilder(TimeRange timeRange){ this(timeRange, new HistogramAccumulator(InsightGaugeHistogramDefinition.getInstance()), new SummaryStatistics()); }
public void fromData(DataInput dataInput) throws IOException { super.fromData(serialVersionUID, dataInput); int numSlots = dataInput.readInt(); GaugeMetricValue[] slots = new GaugeMetricValue[numSlots]; int usedSlots = dataInput.readInt(); for (int i=0; i<usedSlots; i++) { int slotIdx = dataInput.readInt(); double min = dataInput.readDouble(); double max = dataInput.readDouble(); long n = dataInput.readLong(); double sum = dataInput.readDouble(); double sumOfSquares = dataInput.readDouble(); long rangeStart = dataInput.readLong(); long rangeEnd = rangeStart + getEntryGranularity().getNanos(); int numBins = dataInput.readInt(); List<IndexedBin> bins = new ArrayList<IndexedBin>(numBins); for (int b=0; b<numBins; b++) { bins.add(new IndexedBin(dataInput.readInt(), dataInput.readLong())); } slots[slotIdx] = new GaugeMetricValue(TimeRange.nanoTimeRange(rangeStart, rangeEnd), min, max, n, sum, sumOfSquares, new SparseHistogram(InsightGaugeHistogramDefinition.getInstance(), bins)); } this.slots = Arrays.asList(slots); }
@Override public SparseHistogram deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { HistogramDefinition histo=null; Collection<IndexedBin> bins=null; while (jp.nextToken() != JsonToken.END_OBJECT) { String fieldName = jp.getCurrentName(); jp.nextToken(); if ("bins".equals(fieldName)) { bins = readObjectsList(jp, fieldName, IndexedBin.class, bins); } else if ("histogramDefinition".equals(fieldName)) { if (histo != null) { throw new StreamCorruptedException("Multiple histogram definitions"); } histo = jp.readValueAs(HistogramDefinition.class); } else { throw new StreamCorruptedException("Unknown field: " + fieldName); } } if (histo == null) { histo = InsightGaugeHistogramDefinition.getInstance(); } if (bins == null) { return new SparseHistogram(histo); } List<IndexedBin> binsList=new ArrayList<IndexedBin>(bins); Collections.sort(binsList); return new SparseHistogram(histo, binsList); }
public static UpdateMetricDistributionCommand getUpdateGauge() { ResourceMetricKey key = ResourceMetricKey.valueOf(getServerResourceCommand("butter", "butter-label").getResource().getKey(), Metrics.ENDPOINT_RESPONSE_TIME); IndexedBin bin1 = new IndexedBin(1, 4); IndexedBin bin2 = new IndexedBin(2, 6); SparseHistogram histo = new SparseHistogram(InsightGaugeHistogramDefinition.getInstance(), Arrays.asList(bin1, bin2)); GaugeMetricValue gauge = new GaugeMetricValue(TimeRange.range(0, 56), 34, 80, 40, 400, 600,histo); return new UpdateMetricDistributionCommand(key, gauge); }