infinispan/infinispan — pull request #1369 by vblagoje (2012-10-09 21:53:41+00:00)
Title: ISPN-1042 - Enable distributed and Map/Reduce task interruption/cancellation

Master only. https://issues.jboss.org/browse/ISPN-1042

There are three separate commits in this PR.

1) convert DistributedExecuteCommand

This commit converts DistributedExecuteCommand to CacheRpcCommand as we do not need DistributedExecuteCommand to be VisitableCommand to begin with and we need it to be CacheRpcCommand to be able to cancel it's execution in remote VM

2) split and update MapReduceFuture

We simplify MapReduceTask by encapsulating each task/command sent to a remote VM into TaskPart abstraction. MapTaskPart captures logic of map function execution and ReduceTaskPart of reduce. Such an abstraction is easier to cancel in 3) and overall code is greatly simplified as well.

3) Actual command cancelation

This commit is debatable (and I welcome it); it is a matter of style how to introduce UUID to commands. I chose to have CacheRpcCommand extend CancellableCommand. Therefore each CacheRpcCommand is cancellable - although we never need to do actual cancelation of some commands. We could have only specific commands implement CancellableCommand, however we can only cancel CacheRpcCommand as other non CacheRpcCommand are actually wrapped into CacheRpcCommand for wire transport so it becomes rather messy to deal with cancellation that way. We could rename CancellableCommand to UniqueIdentifiableCommand because UUID of command might be used for something else as well. Anyways, lets discuss this one further.