use of org.opennms.nrtg.api.model.CollectionTask in project opennms by OpenNMS.
the class CollectionCommanderStarter method start.
public void start() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(4);
taskExecutor.initialize();
taskExecutor.setMaxPoolSize(4);
taskExecutor.setQueueCapacity(8);
taskExecutor.initialize();
Long startTime = System.currentTimeMillis();
Integer i = 0;
while (i < 100) {
CollectionTask ct = new CollectionTask(1200, "SNMP_All_Metrics");
PooledJobPublisher jobPublisher = new PooledJobPublisher(ct);
taskExecutor.execute(jobPublisher);
i++;
}
logger.info("All started '{}'ms", System.currentTimeMillis() - startTime);
Boolean done = false;
while (!done) {
if (taskExecutor.getActiveCount() == 0) {
logger.info("Tasks active '{}'", taskExecutor.getActiveCount());
logger.info("All done '{}'ms", System.currentTimeMillis() - startTime);
taskExecutor.shutdown();
done = true;
} else {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.error("'{}'", e.getMessage());
}
}
}
}
Aggregations