/** * Set a new interval, cancels the existing schedule, re-establishes the new schedule if the * interval is a positive number. * * @param newInterval to set */ public void setInterval(long newInterval) { interval = newInterval; metricScheduleService.remove(this); if (interval > 0) { metricScheduleService.add(interval, this); } }
public void execute(MetricExecutionContext context) { long timestamp = metricScheduleService.getCurrentTime(); StatementMetric[] metrics = context.getStatementMetricRepository().reportGroup(statementGroup); if (metrics != null) { for (int i = 0; i < metrics.length; i++) { StatementMetric metric = metrics[i]; if (metric != null) { metric.setTimestamp(timestamp); metricEventRouter.route(metrics[i]); } } } if (interval != -1) { metricScheduleService.add(interval, this); } }