Search in sources :

Example 1 with Task

use of org.opennms.core.tasks.Task in project opennms by OpenNMS.

the class NodeScan method schedule.

ScheduledFuture<?> schedule(ScheduledExecutorService executor, NodeScanSchedule schedule) {
    final Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                final Task t = createTask();
                t.schedule();
                // NMS-5593 shows 10 provisioning threads all waiting on these
                // latches which is probably exhausting the thread pool
                t.waitFor();
                LOG.info("Finished scanning node {}/{}/{}", getNodeId(), getForeignSource(), getForeignId());
            } catch (final InterruptedException e) {
                LOG.warn("The node scan for node {}/{}/{} was interrupted", getNodeId(), getForeignSource(), getForeignId(), e);
                Thread.currentThread().interrupt();
            } catch (final ExecutionException e) {
                LOG.warn("An error occurred while scanning node {}/{}/{}", getNodeId(), getForeignSource(), getForeignId(), e);
            }
        }
    };
    return executor.scheduleWithFixedDelay(r, schedule.getInitialDelay().getMillis(), schedule.getScanInterval().getMillis(), TimeUnit.MILLISECONDS);
}
Also used : BatchTask(org.opennms.core.tasks.BatchTask) Task(org.opennms.core.tasks.Task) ContainerTask(org.opennms.core.tasks.ContainerTask) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with Task

use of org.opennms.core.tasks.Task in project opennms by OpenNMS.

the class DragonWaveNodeSwitchingIT method runScan.

public void runScan(final NodeScan scan) throws InterruptedException, ExecutionException {
    final Task t = scan.createTask();
    t.schedule();
    t.waitFor();
    waitForEverything();
}
Also used : Task(org.opennms.core.tasks.Task)

Example 3 with Task

use of org.opennms.core.tasks.Task in project opennms by OpenNMS.

the class IfIndexNullIT method runScan.

public void runScan(final NodeScan scan) throws InterruptedException, ExecutionException {
    final Task t = scan.createTask();
    t.schedule();
    t.waitFor();
    waitForEverything();
}
Also used : Task(org.opennms.core.tasks.Task)

Example 4 with Task

use of org.opennms.core.tasks.Task in project opennms by OpenNMS.

the class NewSuspectScanIT method runScan.

public void runScan(final Scan scan) throws InterruptedException, ExecutionException {
    final Task t = scan.createTask();
    t.schedule();
    t.waitFor();
    waitForEverything();
}
Also used : Task(org.opennms.core.tasks.Task)

Example 5 with Task

use of org.opennms.core.tasks.Task in project opennms by OpenNMS.

the class ProvisionerIT method runScan.

private void runScan(final Scan scan) throws InterruptedException, ExecutionException {
    final boolean paused = getScheduledExecutor().isPaused();
    if (paused)
        getScheduledExecutor().resume();
    final Task t = scan.createTask();
    t.schedule();
    t.waitFor();
    waitForEverything();
    if (paused)
        getScheduledExecutor().pause();
}
Also used : Task(org.opennms.core.tasks.Task)

Aggregations

Task (org.opennms.core.tasks.Task)9 ExecutionException (java.util.concurrent.ExecutionException)3 EventHandler (org.opennms.netmgt.events.api.annotations.EventHandler)2 InetAddress (java.net.InetAddress)1 BatchTask (org.opennms.core.tasks.BatchTask)1 ContainerTask (org.opennms.core.tasks.ContainerTask)1 Event (org.opennms.netmgt.xml.event.Event)1