use of org.graylog2.periodical.Periodicals in project graylog2-server by Graylog2.
the class SchedulerBindings method configure.
@Override
protected void configure() {
// TODO Add instrumentation to ExecutorService and ThreadFactory
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(SCHEDULED_THREADS_POOL_SIZE, new ThreadFactoryBuilder().setNameFormat("scheduled-%d").setDaemon(false).setUncaughtExceptionHandler(new Tools.LogUncaughtExceptionHandler(LOG)).build());
bind(ScheduledExecutorService.class).annotatedWith(Names.named("scheduler")).toInstance(scheduler);
// TODO Add instrumentation to ExecutorService and ThreadFactory
final ScheduledExecutorService daemonScheduler = Executors.newScheduledThreadPool(SCHEDULED_THREADS_POOL_SIZE, new ThreadFactoryBuilder().setNameFormat("scheduled-daemon-%d").setDaemon(true).setUncaughtExceptionHandler(new Tools.LogUncaughtExceptionHandler(LOG)).build());
bind(ScheduledExecutorService.class).annotatedWith(Names.named("daemonScheduler")).toInstance(daemonScheduler);
bind(Periodicals.class).toInstance(new Periodicals(scheduler, daemonScheduler));
}
use of org.graylog2.periodical.Periodicals in project graylog2-server by Graylog2.
the class PeriodicalsService method startUp.
@Override
protected void startUp() throws Exception {
LOG.info("Starting {} periodicals ...", periodicalSet.size());
for (Periodical periodical : periodicalSet) {
try {
periodical.initialize();
if (periodical.masterOnly() && !serverStatus.hasCapability(ServerStatus.Capability.MASTER)) {
LOG.info("Not starting [{}] periodical. Only started on Graylog master nodes.", periodical.getClass().getCanonicalName());
continue;
}
if (!periodical.startOnThisNode()) {
LOG.info("Not starting [{}] periodical. Not configured to run on this node.", periodical.getClass().getCanonicalName());
continue;
}
// Register and start.
periodicals.registerAndStart(periodical);
} catch (Exception e) {
LOG.error("Could not initialize periodical.", e);
}
}
}
use of org.graylog2.periodical.Periodicals in project graylog2-server by Graylog2.
the class PeriodicalsTest method testGetAllStoppedOnGracefulShutdown.
@Test
public void testGetAllStoppedOnGracefulShutdown() throws Exception {
final Periodical periodical2 = mock(Periodical.class);
when(periodical2.stopOnGracefulShutdown()).thenReturn(true);
periodicals.registerAndStart(periodical);
periodicals.registerAndStart(periodical2);
List<Periodical> allStoppedOnGracefulShutdown = periodicals.getAllStoppedOnGracefulShutdown();
assertFalse("periodical without graceful shutdown is in the list", allStoppedOnGracefulShutdown.contains(periodical));
assertTrue("graceful shutdown periodical is not in the list", allStoppedOnGracefulShutdown.contains(periodical2));
assertEquals("more graceful shutdown periodicals in the list", allStoppedOnGracefulShutdown.size(), 1);
}
Aggregations