private Map<String, Object> buildStreamEvent(GenericMetricEntity entity) { Map<String, Object> map = new HashMap<>(); map.put("site", entity.getTags().get("site")); map.put("user", entity.getTags().get("user")); map.put("timestamp", entity.getTimestamp()); map.put("metric", entity.getPrefix()); map.put("value", entity.getValue()[0]); return map; }
private void updateEntityAggValue(GenericMetricEntity entity, HadoopClusterConstants.AggregateFunc aggFunc, double value, double count) { double lastValue = entity.getValue()[0]; switch (aggFunc) { case MAX: entity.setValue(new double[] {Math.max(lastValue, value)}); return; case AVG: long avgValue = (long) ((lastValue * count + value) / (count + 1)); entity.setValue(new double[] {avgValue}); return; default: throw new IllegalArgumentException("Illegal aggregation function: " + aggFunc); } }
private void createMetric(String metricName, Map<String, String> tags, long timestamp, int value) { String key = metricName + tags.toString() + " " + timestamp; GenericMetricEntity entity = appMetricEntities.get(key); if (entity == null) { entity = new GenericMetricEntity(); entity.setTags(tags); entity.setTimestamp(timestamp); entity.setPrefix(metricName); entity.setValue(new double[] {0.0}); appMetricEntities.put(key, entity); } double lastValue = entity.getValue()[0]; entity.setValue(new double[] {lastValue + value}); }
private void createMetric(Map<String, GenericMetricEntity> appMetricEntities, long timestamp, Map<String, String> tags, String metricName, int value) { String key = metricName + tags.toString() + " " + timestamp; GenericMetricEntity entity = appMetricEntities.get(key); if (entity == null) { entity = new GenericMetricEntity(); entity.setTags(tags); entity.setTimestamp(timestamp); entity.setPrefix(metricName); entity.setValue(new double[] {0.0}); appMetricEntities.put(key, entity); } double lastValue = entity.getValue()[0]; entity.setValue(new double[] {lastValue + value}); }
this.aggregateValues.get(aggregatorColumns).put(entity.getTimestamp(), previous + (long)entity.getValue()[0]);
if(singleMetricEntity == null) singleMetricEntity = new GenericMetricShadowEntity(); GenericMetricEntity e = (GenericMetricEntity)logAPIEntity; if(e.getValue()!=null) { int count = e.getValue().length; @SuppressWarnings("unused") Class<?> cls = ed.getMetricDefinition().getSingleTimestampEntityClass(); singleMetricEntity.setValue(e.getValue()[i]);
@Override public void entityCreated(TaggedLogAPIEntity entity) throws Exception { GenericMetricEntity e = (GenericMetricEntity)entity; double[] value = e.getValue(); if (value != null) { int count = value.length; @SuppressWarnings("unused") Class<?> cls = ed.getMetricDefinition().getSingleTimestampEntityClass(); for (int i = 0; i < count; i++) { long ts = entity.getTimestamp() + i * ed.getMetricDefinition().getInterval(); // exclude those entity which is not within the time range in search condition. [start, end) if (ts < start || ts >= end) { continue; } single.setTimestamp(ts); single.setTags(entity.getTags()); single.setValue(e.getValue()[i]); for (EntityCreationListener l : listeners) { l.entityCreated(single); } } } }
@Override public void entityCreated(TaggedLogAPIEntity entity) throws Exception{ GenericMetricEntity e = (GenericMetricEntity)entity; double[] value = e.getValue(); if(value != null) { int count =value.length; @SuppressWarnings("unused") Class<?> cls = ed.getMetricDefinition().getSingleTimestampEntityClass(); for (int i = 0; i < count; i++) { long ts = entity.getTimestamp() + i * ed.getMetricDefinition().getInterval(); // exclude those entity which is not within the time range in search condition. [start, end) if (ts < start || ts >= end) { continue; } single.setTimestamp(ts); single.setTags(entity.getTags()); single.setValue(e.getValue()[i]); for (EntityCreationListener l : _listeners) { l.entityCreated(single); } } } }