[infinispan-dev] Command cancellation

Vladimir Blagojevic vblagoje at redhat.com
Fri Sep 21 06:42:18 EDT 2012


Hi,

I wanted to run by you guys design of command cancellation Manik and I 
talked about recently. For more background regarding this task read 
https://issues.jboss.org/browse/ISPN-1042

At originating node I would have each Cancellable command create its 
UUID as part of constructor. After that command gets sent away to remote 
VMs but just before it gets executed there we associated thread with 
UUID by calling CancellationService.registerThread (as a first line of 
code in Command#perform). After registration has been setup Cancellable 
command goes into potentially lengthy (in seconds) execution. If needed 
we would be able to send CancelCommand which would call 
CancellationService#cancelTask with UUID. CancelTask would interrupt the 
associated thread.

WDYT?

Regards,
Vladimir

Cancellation of tasks:

class CancellationService {
  UUID registerThread(Thread t, UUID uuid) {
     // put thread in map, associate with newly give UUID
    }
  void cancelTask(UUID uuid) {
//     look up thread, interrupt if exists.
   }
}

interface CancellableCommand {
   UUID getCommandUUID();
}

command CancelCommand {
   Object perform() {
//      Calls CancellationService.cancelTask with UUID.  The UUID is a 
parameter of this command.
  }
}


More information about the infinispan-dev mailing list