use of org.openstreetmap.atlas.utilities.scalars.Duration in project atlas-checks by osmlab.
the class RunnableCheck method run.
/**
* Runs the {@link Check} over {@link AtlasObject}s, posting resulting {@link CheckFlag}s to
* {@link RunnableCheckBase#eventService} and {@link MapRouletteClient}
*/
@Override
public void run() {
try {
final Time timer = Time.now();
this.getObjects().forEach(object -> {
final Optional<CheckFlag> flag = this.getCheck().check(object);
if (flag.isPresent()) {
this.addTask(flag.get());
this.getEventService().post(new CheckFlagEvent(this.getName(), flag.get()));
}
});
this.getCheck().clear();
final Duration checkRunTime = timer.elapsedSince();
logger.info("{} completed in {}.", this.getName(), checkRunTime);
this.getEventService().post(new MetricEvent(this.getName(), checkRunTime));
this.uploadTasks();
} catch (final Exception e) {
logger.error(String.format("%s failed to complete.", this.getName()), e);
}
}
Aggregations