/** * Gets the next task to execute. * * @return the task to execute, or null if the batch is complete. */ public Object next() { int partitionId = nextPartitionId(); return partitionId == -1 ? null : taskFactory.create(partitionId); }
private void process(TaskBatch batch) { Object task = batch.next(); if (task == null) { completedOperationBatchCount.inc(); return; } try { if (task instanceof Operation) { process((Operation) task); } else if (task instanceof Runnable) { process((Runnable) task); } else { throw new IllegalStateException("Unhandled task: " + task + " from " + batch.taskFactory()); } } finally { queue.add(batch, false); } }
@Override public void executeOnPartitions(PartitionTaskFactory taskFactory, BitSet partitions) { checkNotNull(taskFactory, "taskFactory can't be null"); checkNotNull(partitions, "partitions can't be null"); for (PartitionOperationThread partitionThread : partitionThreads) { TaskBatch batch = new TaskBatch(taskFactory, partitions, partitionThread.threadId, partitionThreads.length); partitionThread.queue.add(batch, false); } }
private void process(TaskBatch batch) { Object task = batch.next(); if (task == null) { completedOperationBatchCount.inc(); return; } try { if (task instanceof Operation) { process((Operation) task); } else if (task instanceof Runnable) { process((Runnable) task); } else { throw new IllegalStateException("Unhandled task: " + task + " from " + batch.taskFactory()); } } finally { queue.add(batch, false); } }
@Override public void executeOnPartitions(PartitionTaskFactory taskFactory, BitSet partitions) { checkNotNull(taskFactory, "taskFactory can't be null"); checkNotNull(partitions, "partitions can't be null"); for (PartitionOperationThread partitionThread : partitionThreads) { TaskBatch batch = new TaskBatch(taskFactory, partitions, partitionThread.threadId, partitionThreads.length); partitionThread.queue.add(batch, false); } }
/** * Gets the next task to execute. * * @return the task to execute, or null if the batch is complete. */ public Object next() { int partitionId = nextPartitionId(); return partitionId == -1 ? null : taskFactory.create(partitionId); }