Search in sources :

Example 1 with CheckFlagEvent

use of org.openstreetmap.atlas.checks.event.CheckFlagEvent 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);
    }
}
Also used : MetricEvent(org.openstreetmap.atlas.checks.event.MetricEvent) CheckFlag(org.openstreetmap.atlas.checks.flag.CheckFlag) Time(org.openstreetmap.atlas.utilities.time.Time) Duration(org.openstreetmap.atlas.utilities.scalars.Duration) CheckFlagEvent(org.openstreetmap.atlas.checks.event.CheckFlagEvent)

Aggregations

CheckFlagEvent (org.openstreetmap.atlas.checks.event.CheckFlagEvent)1 MetricEvent (org.openstreetmap.atlas.checks.event.MetricEvent)1 CheckFlag (org.openstreetmap.atlas.checks.flag.CheckFlag)1 Duration (org.openstreetmap.atlas.utilities.scalars.Duration)1 Time (org.openstreetmap.atlas.utilities.time.Time)1