public Map<String, List<ScheduledTask<?>>> getActiveTasks() { Map<String, List<ScheduledTask<?>>> result = getAllTasks(); List<ScheduledTask<?>> tasks = null; // filter for activeOrSubmitted for (Iterator<String> c = result.keySet().iterator(); c.hasNext(); ) { String cls = c.next(); tasks = result.get(cls); for (Iterator<ScheduledTask<?>> i = tasks.iterator(); i.hasNext(); ) { ScheduledTask<?> task = i.next(); if (!task.getTaskState().isActiveOrSubmitted()) { i.remove(); } } if (tasks.isEmpty()) { c.remove(); } } return result; }
public Map<String, List<ScheduledTask<?>>> getRunningTasks() { Map<String, List<ScheduledTask<?>>> result = getAllTasks(); List<ScheduledTask<?>> tasks = null; // filter for RUNNING for (Iterator<String> c = result.keySet().iterator(); c.hasNext(); ) { String cls = c.next(); tasks = result.get(cls); for (Iterator<ScheduledTask<?>> i = tasks.iterator(); i.hasNext(); ) { ScheduledTask<?> task = i.next(); if (!TaskState.RUNNING.equals(task.getTaskState())) { i.remove(); } } if (tasks.isEmpty()) { c.remove(); } } return result; } }
public Map<String, List<ScheduledTask<?>>> getActiveTasks() { Map<String, List<ScheduledTask<?>>> result = getAllTasks(); List<ScheduledTask<?>> tasks = null; // filter for activeOrSubmitted for ( Iterator<String> c = result.keySet().iterator(); c.hasNext(); ) { String cls = c.next(); tasks = result.get( cls ); for ( Iterator<ScheduledTask<?>> i = tasks.iterator(); i.hasNext(); ) { ScheduledTask<?> task = i.next(); if ( !task.getTaskState().isActiveOrSubmitted() ) { i.remove(); } } if ( tasks.isEmpty() ) { c.remove(); } } return result; }
public Map<String, List<ScheduledTask<?>>> getRunningTasks() { Map<String, List<ScheduledTask<?>>> result = getAllTasks(); List<ScheduledTask<?>> tasks = null; // filter for RUNNING for ( Iterator<String> c = result.keySet().iterator(); c.hasNext(); ) { String cls = c.next(); tasks = result.get( cls ); for ( Iterator<ScheduledTask<?>> i = tasks.iterator(); i.hasNext(); ) { ScheduledTask<?> task = i.next(); if ( !TaskState.RUNNING.equals( task.getTaskState() ) ) { i.remove(); } } if ( tasks.isEmpty() ) { c.remove(); } } return result; } }
public ScheduledTask<?> getTaskById(String id) throws NoSuchTaskException { if (StringUtils_isEmpty(id)) { throw new IllegalArgumentException("The Tasks cannot have null IDs!"); } final Collection<List<ScheduledTask<?>>> activeTasks = getAllTasks().values(); for (List<ScheduledTask<?>> tasks : activeTasks) { for (ScheduledTask<?> task : tasks) { if (task.getId().equals(id)) { return task; } } } throw new NoSuchTaskException(id); }
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); }
public ScheduledTask<?> getTaskById( String id ) throws NoSuchTaskException { if ( StringUtils_isEmpty(id) ) { throw new IllegalArgumentException( "The Tasks cannot have null IDs!" ); } final Collection<List<ScheduledTask<?>>> activeTasks = getAllTasks().values(); for ( List<ScheduledTask<?>> tasks : activeTasks ) { for ( ScheduledTask<?> task : tasks ) { if ( task.getId().equals( id ) ) { return task; } } } throw new NoSuchTaskException( id ); }