17.2. DistributedCallable API
The
DistributedCallable
interface is a subtype of the existing Callable
from java.util.concurrent.package, and can be executed in a remote JVM and receive input from JBoss Data Grid. The DistributedCallable
interface is used to facilitate tasks that require access to JBoss Data Grid cache data.
When using the
DistributedCallable
API to execute a task, the task's main algorithm remains unchanged, however the input source is changed.
Users who have already implemented
Callable
interface to describe task units must extend DistributedCallable
and use keys from JBoss Data Grid execution environment as input for the task. For example:
public interface DistributedCallable<K, V, T> extends Callable<T> { /** * Invoked by execution environment after DistributedCallable * has been migrated for execution to a specific Infinispan node. * * @param cache * cache whose keys are used as input data for this * DistributedCallable task * @param inputKeys * keys used as input for this DistributedCallable task */ public void setEnvironment(Cache<K, V> cache, Set<K> inputKeys); }