public void shutdown() { getLogger().info("Shutting down Scheduler..."); try { scheduledExecutorService.shutdown(); boolean stopped = scheduledExecutorService.awaitTermination(3L, TimeUnit.SECONDS); if (!stopped) { final Map<String, List<ScheduledTask<?>>> runningTasks = getRunningTasks(); if (!runningTasks.isEmpty()) { scheduledExecutorService.shutdownNow(); getLogger().warn("Scheduler shut down forcibly with tasks running."); } else { getLogger().info("Scheduler shut down cleanly with tasks scheduled."); } } } catch (InterruptedException e) { getLogger().info("Termination interrupted", e); } }
public void shutdown() { getLogger().info( "Shutting down Scheduler..." ); getScheduledExecutorService().shutdown(); try { boolean stopped = getScheduledExecutorService().awaitTermination( 1, TimeUnit.SECONDS ); if ( !stopped ) { final Map<String, List<ScheduledTask<?>>> runningTasks = getRunningTasks(); if ( !runningTasks.isEmpty() ) { getScheduledExecutorService().shutdownNow(); getLogger().warn( "Scheduler shut down forcibly with tasks running." ); } else { getLogger().info( "Scheduler shut down cleanly with tasks scheduled." ); } } } catch ( InterruptedException e ) { getLogger().info( "Termination interrupted", e ); } }
public void initializeTasks() { getLogger().info("Initializing Scheduler..."); // this call delegates to task config manager that loads up the persisted tasks (if any) // and performs a series of callbacks to this to make them "alive" taskConfig.initializeTasks(this); // wind up the "idGen" source, to the max ID we got loaded up from config (the generated IDs are persisted) int maxId = 0; for (Map.Entry<String, List<ScheduledTask<?>>> entry : getAllTasks().entrySet()) { for (ScheduledTask<?> task : entry.getValue()) { try { maxId = Math.max(maxId, Integer.parseInt(task.getId())); } catch (NumberFormatException e) { // be forgiving about non number IDs // hint1: sadly, some Nexus ITs does have them // hint2: they will not clash with numbers anyway } } } idGen.set(maxId); }
public void initializeTasks() { getLogger().info( "Initializing Scheduler..." ); // this call delegates to task config manager that loads up the persisted tasks (if any) // and performs a series of callbacks to this to make them "alive" taskConfig.initializeTasks( this ); // wind up the "idGen" source, to the max ID we got loaded up from config (the generated IDs are persisted) int maxId = 0; for ( Map.Entry<String, List<ScheduledTask<?>>> entry : getAllTasks().entrySet() ) { for ( ScheduledTask<?> task : entry.getValue() ) { try { maxId = Math.max( maxId, Integer.parseInt( task.getId() ) ); } catch ( NumberFormatException e ) { // be forgiving about non number IDs // hint1: sadly, some Nexus ITs does have them // hint2: they will not clash with numbers anyway } } } idGen.set( maxId ); }