@Override public String toString() { return "AddPoint[key=" + getResourceMetricKey() + ", point=" + getPoint() + "]"; } }
@Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (getClass() != obj.getClass()) return false; AddPointCommand other=(AddPointCommand) obj; return isEquivalent(other) && ObjectUtil.typedEquals(getPoint(), other.getPoint()) ; }
@Override public int hashCode() { return super.hashCode() + ObjectUtil.hashCode(getPoint()) ; }
@Override @InsightEndPoint public void executeCommand(AddPointCommand command) { ResourceMetricKey key = command.getResourceMetricKey(); GaugeMetricDataAdapter mData = (GaugeMetricDataAdapter) dataRepo.createOrGetMetricData(key); DataPoint point = command.getPoint(); Time rangeStart = point.getTimeStamp(); Time rangeEnd = rangeStart.plus(Time.inMillis((int)point.getValue())); if (rangeEnd.equals(rangeStart)) { // In case of something executing in no time, our range is still 1 ns rangeEnd = rangeEnd.plus(Time.inNanos(1)); } TimeRange pointRange = TimeRange.between(rangeStart, rangeEnd); GaugeMetricValue value = new GaugeMetricValueBuilder(pointRange).addPoint(point.getValue()).build(); mData.addValues(singletonList(value)); } }