public <T> ScheduledTask<T> updateSchedule(ScheduledTask<T> task) throws RejectedExecutionException, NullPointerException { // Simply add the task to config, will find existing by id, remove, then store new taskConfig.addTask(task); return task; }
public <T> T createTaskInstance( Class<T> taskType ) throws IllegalArgumentException { return taskConfig.createTaskInstance( taskType ); }
protected <T> void removeFromTasksMap(ScheduledTask<T> task) { final List<ScheduledTask<?>> tasks = tasksMap.get(task.getType()); if (tasks != null) { tasks.remove(task); // this is potentially problematic, might _remove_ concurrently added new task // but, this is only here to keep map keys small, but the keys (task types) are actually // rather small, so I see no point of pruning map for keys // if ( tasks.size() == 0 ) // { // tasksMap.remove( task.getType() ); // } } taskConfig.removeTask(task); }
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); }
protected <T> void removeFromTasksMap( ScheduledTask<T> task ) { final List<ScheduledTask<?>> tasks = tasksMap.get( task.getType() ); if ( tasks != null ) { tasks.remove( task ); // this is potentially problematic, might _remove_ concurrently added new task // but, this is only here to keep map keys small, but the keys (task types) are actually // rather small, so I see no point of pruning map for keys // if ( tasks.size() == 0 ) // { // tasksMap.remove( task.getType() ); // } } taskConfig.removeTask( task ); }
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 <T> ScheduledTask<T> updateSchedule( ScheduledTask<T> task ) throws RejectedExecutionException, NullPointerException { // Simply add the task to config, will find existing by id, remove, then store new taskConfig.addTask( task ); return task; }
public <T> T createTaskInstance(Class<T> taskType) throws IllegalArgumentException { return taskConfig.createTaskInstance(taskType); }
protected void taskRescheduled( ScheduledTask<?> task ) { taskConfig.addTask( task ); }
@Deprecated public SchedulerTask<?> createTaskInstance(String taskType) throws IllegalArgumentException { return taskConfig.createTaskInstance(taskType); }
protected void taskRescheduled(ScheduledTask<?> task) { taskConfig.addTask(task); }
@Deprecated public SchedulerTask<?> createTaskInstance( String taskType ) throws IllegalArgumentException { return taskConfig.createTaskInstance( taskType ); }
protected <T> void addToTasksMap(ScheduledTask<T> task, boolean store) { tasksMap.putIfAbsent(task.getType(), new CopyOnWriteArrayList<ScheduledTask<?>>()); tasksMap.get(task.getType()).add(task); if (store) { taskConfig.addTask(task); } }
protected <T> void addToTasksMap( ScheduledTask<T> task, boolean store ) { tasksMap.putIfAbsent( task.getType(), new CopyOnWriteArrayList<ScheduledTask<?>>() ); tasksMap.get( task.getType() ).add( task ); if ( store ) { taskConfig.addTask( task ); } }