Class GridExecutorService
- java.lang.Object
-
- org.apache.ignite.internal.executor.GridExecutorService
-
- All Implemented Interfaces:
Externalizable,Serializable,Executor,ExecutorService
public class GridExecutorService extends Object implements ExecutorService, Externalizable
AnExecutorServicethat executes each submitted task in grid throughIgniteinstance, normally configured usingIgnite.executorService()method.GridExecutorServicedelegates commands execution to already startedIgniteinstance. Every submitted task will be serialized and transferred to any node in grid.All submitted tasks must implement
Serializableinterface.Note, that GridExecutorService implements ExecutorService from JDK 1.5. If you have problems with compilation for JDK 1.6 and above you need to apply some changes (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833)
Change signature for methods
invokeAll(Collection),invokeAll(Collection, long, TimeUnit),invokeAny(Collection),invokeAny(Collection, long, TimeUnit)topublic class GridExecutorService implements ExecutorService { ... public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { ... } public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { ... } public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException { ... } public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { } ... }- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GridExecutorService()No-arg constructor is required by externalization.GridExecutorService(ClusterGroupAdapter prj, GridKernalContext ctx)Creates executor service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitTermination(long timeout, TimeUnit unit)voidexecute(Runnable cmd)<T> List<Future<T>>invokeAll(Collection<? extends Callable<T>> tasks)<T> List<Future<T>>invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)<T> TinvokeAny(Collection<? extends Callable<T>> tasks)<T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)booleanisShutdown()booleanisTerminated()voidreadExternal(ObjectInput in)protected ObjectreadResolve()Reconstructs object on unmarshalling.voidshutdown()List<Runnable>shutdownNow()Future<?>submit(Runnable task)<T> Future<T>submit(Runnable task, T res)<T> Future<T>submit(Callable<T> task)voidwriteExternal(ObjectOutput out)
-
-
-
Constructor Detail
-
GridExecutorService
public GridExecutorService()
No-arg constructor is required by externalization.
-
GridExecutorService
public GridExecutorService(ClusterGroupAdapter prj, GridKernalContext ctx)
Creates executor service.- Parameters:
prj- Projection.ctx- Grid logger.
-
-
Method Detail
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
readResolve
protected Object readResolve() throws ObjectStreamException
Reconstructs object on unmarshalling.- Returns:
- Reconstructed object.
- Throws:
ObjectStreamException- Thrown in case of unmarshalling error.
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
public List<Runnable> shutdownNow()
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
submit
public <T> Future<T> submit(Callable<T> task)
- Specified by:
submitin interfaceExecutorService
-
submit
public <T> Future<T> submit(Runnable task, T res)
- Specified by:
submitin interfaceExecutorService
-
submit
public Future<?> submit(Runnable task)
- Specified by:
submitin interfaceExecutorService
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
Note, for compilation with JDK 1.6 necessary to change method signature (note the
<? extends T>clause).... public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { // Method body. } ...- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
Note, for compilation with JDK 1.6 necessary to change method signature (note the
<? extends T>clause).public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { ... }- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
Note, for compilation with JDK 1.6 necessary to change method signature (note the
<? extends T>clause).... public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException { // Method body. } ...- Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Note, for compilation with JDK 1.6 necessary to change method signature (note the
<? extends T>clause).... public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { } ...- Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
-