Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2013-08-26 20:34:34 +0000
committerRoberto E. Escobar2013-09-06 23:34:17 +0000
commit7bb9a26096b6c7ccab52b2e923ae270283f2a3d2 (patch)
tree92054314ad9256c23e7ea27628150523e47b2514 /plugins/org.eclipse.osee.executor.admin
parent0c4767ab9244dc576618791d3f852506932e3d10 (diff)
downloadorg.eclipse.osee-7bb9a26096b6c7ccab52b2e923ae270283f2a3d2.tar.gz
org.eclipse.osee-7bb9a26096b6c7ccab52b2e923ae270283f2a3d2.tar.xz
org.eclipse.osee-7bb9a26096b6c7ccab52b2e923ae270283f2a3d2.zip
refinement: Improve result set API
Remove getList method. Remove getIterable method. Since resultSet is already an Iterable object, these methods are not needed. Add size and isEmpty methods for convenience. Change-Id: I34160b3acaad391949ff9da0e81afa95f4532677
Diffstat (limited to 'plugins/org.eclipse.osee.executor.admin')
-rw-r--r--plugins/org.eclipse.osee.executor.admin/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.osee.executor.admin/src/org/eclipse/osee/executor/admin/WorkUtility.java17
2 files changed, 11 insertions, 11 deletions
diff --git a/plugins/org.eclipse.osee.executor.admin/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.executor.admin/META-INF/MANIFEST.MF
index 3d76d2f4b6..27a7fd1b6b 100644
--- a/plugins/org.eclipse.osee.executor.admin/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.executor.admin/META-INF/MANIFEST.MF
@@ -6,9 +6,8 @@ Bundle-Version: 0.14.0.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.osee.executor.admin
-Import-Package: com.google.common.collect,
- com.google.common.util.concurrent,
- org.eclipse.osee.event,
+Import-Package: org.eclipse.osee.event,
org.eclipse.osee.logger
Service-Component: OSGI-INF/*.xml
Bundle-ActivationPolicy: lazy
+Require-Bundle: com.google.guava;bundle-version="[11.0.0,15.0.0)"
diff --git a/plugins/org.eclipse.osee.executor.admin/src/org/eclipse/osee/executor/admin/WorkUtility.java b/plugins/org.eclipse.osee.executor.admin/src/org/eclipse/osee/executor/admin/WorkUtility.java
index e6ec8886dd..42f2e1933b 100644
--- a/plugins/org.eclipse.osee.executor.admin/src/org/eclipse/osee/executor/admin/WorkUtility.java
+++ b/plugins/org.eclipse.osee.executor.admin/src/org/eclipse/osee/executor/admin/WorkUtility.java
@@ -17,6 +17,7 @@ import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import org.eclipse.osee.executor.admin.internal.ExecutorAdminImpl;
+import com.google.common.collect.Iterables;
/**
* @author Roberto E. Escobar
@@ -35,11 +36,11 @@ public final class WorkUtility {
}
- public static <INPUT, OUTPUT> List<Callable<Collection<OUTPUT>>> partitionWork(Collection<INPUT> work, PartitionFactory<INPUT, OUTPUT> factory) throws Exception {
+ public static <INPUT, OUTPUT> List<Callable<Collection<OUTPUT>>> partitionWork(Iterable<INPUT> work, PartitionFactory<INPUT, OUTPUT> factory) throws Exception {
List<Callable<Collection<OUTPUT>>> callables = new LinkedList<Callable<Collection<OUTPUT>>>();
-
- if (!work.isEmpty()) {
- int partitionSize = Math.max(1, work.size() / NUM_PARTITIONS);
+ int size = Iterables.size(work);
+ if (size > 0) {
+ int partitionSize = Math.max(1, size / NUM_PARTITIONS);
List<INPUT> subList = new LinkedList<INPUT>();
@@ -65,19 +66,19 @@ public final class WorkUtility {
return callables;
}
- public static <INPUT, OUTPUT> List<Future<Collection<OUTPUT>>> partitionAndScheduleWork(ExecutorAdmin executorAdmin, PartitionFactory<INPUT, OUTPUT> factory, Collection<INPUT> items) throws Exception {
+ public static <INPUT, OUTPUT> List<Future<Collection<OUTPUT>>> partitionAndScheduleWork(ExecutorAdmin executorAdmin, PartitionFactory<INPUT, OUTPUT> factory, Iterable<INPUT> items) throws Exception {
return partitionAndScheduleWork(executorAdmin, ExecutorAdminImpl.DEFAULT_EXECUTOR, factory, items, null);
}
- public static <INPUT, OUTPUT> List<Future<Collection<OUTPUT>>> partitionAndScheduleWork(ExecutorAdmin executorAdmin, PartitionFactory<INPUT, OUTPUT> factory, Collection<INPUT> items, ExecutionCallback<Collection<OUTPUT>> callback) throws Exception {
+ public static <INPUT, OUTPUT> List<Future<Collection<OUTPUT>>> partitionAndScheduleWork(ExecutorAdmin executorAdmin, PartitionFactory<INPUT, OUTPUT> factory, Iterable<INPUT> items, ExecutionCallback<Collection<OUTPUT>> callback) throws Exception {
return partitionAndScheduleWork(executorAdmin, ExecutorAdminImpl.DEFAULT_EXECUTOR, factory, items, callback);
}
- public static <INPUT, OUTPUT> List<Future<Collection<OUTPUT>>> partitionAndScheduleWork(ExecutorAdmin executorAdmin, String executorId, PartitionFactory<INPUT, OUTPUT> factory, Collection<INPUT> items) throws Exception {
+ public static <INPUT, OUTPUT> List<Future<Collection<OUTPUT>>> partitionAndScheduleWork(ExecutorAdmin executorAdmin, String executorId, PartitionFactory<INPUT, OUTPUT> factory, Iterable<INPUT> items) throws Exception {
return partitionAndScheduleWork(executorAdmin, executorId, factory, items, null);
}
- public static <INPUT, OUTPUT> List<Future<Collection<OUTPUT>>> partitionAndScheduleWork(ExecutorAdmin executorAdmin, String executorId, PartitionFactory<INPUT, OUTPUT> factory, Collection<INPUT> items, ExecutionCallback<Collection<OUTPUT>> callback) throws Exception {
+ public static <INPUT, OUTPUT> List<Future<Collection<OUTPUT>>> partitionAndScheduleWork(ExecutorAdmin executorAdmin, String executorId, PartitionFactory<INPUT, OUTPUT> factory, Iterable<INPUT> items, ExecutionCallback<Collection<OUTPUT>> callback) throws Exception {
List<Future<Collection<OUTPUT>>> futures = new LinkedList<Future<Collection<OUTPUT>>>();
List<Callable<Collection<OUTPUT>>> callables = partitionWork(items, factory);
if (!callables.isEmpty()) {

Back to the top