2 Replies Latest reply on Mar 7, 2014 1:39 AM by mvpratap

    TimerTasks are not Cancelling in distribution mode

    mvpratap

      I am using Infinispan in distribution mode with two nodes and numOwners=1.. I am creating  10 TimerTasks(JAVA) on node1 and added to some cache .So 6 keys are stored in node1 and 4 keys are stored on node2. And I am scheduling those timertasks on node1 and immediately i am cancelling all those timertasks on node1. Timertasks available on node1 (6) got successfully cancelled..But timerTasks on node2 are not cancelled..

      cluster formed successfully...

       

      I am attaching the sample programs and output..

      I am running TimerTestMain in node1 and TimerTest in node2..I started node2 first and then node 1..

      Node1Output and Node2Output also i attached here..

       

      when i added keys to node1 it is added once to the cache,,but when i am removing keys on node1  why it is removing twice...in the cache ??? Is there any problem with logger or it will be like that only ??

       

      Does any body provide help on this.....

        • 1. Re: TimerTasks are not Cancelling in distribution mode
          william.burns

          While you have made your TimerTask serializable that doesn't mean that it can be used in a distributed fashion.  The TimerTask only works when confined in a single JVM to individual instances.  By serializing this on node1 and then deserializing on node2 you have created a different instance on a different JVM, the cancel can't work in that case.  The reason it works on node1 is because we are storing the same reference you provided to us in the cache, so you are actually cancelling it.  There would be a requirement to send a message to node1 from node2 to start/stop the task somehow.  Are you specifically looking for a reoccurring cancellable clustered task ?  We have the distributed execution framework http://infinispan.org/docs/6.0.x/user_guide/user_guide.html#_distributed_execution_framework which doesn't have the reoccurring portion, but does allow for executing tasks on various nodes of the cluster.

           

          when i added keys to node1 it is added once to the cache,,but when i am removing keys on node1  why it is removing twice...in the cache ??? Is there any problem with logger or it will be like that only ??

           

          This is how our local listeners work.  We raise the event up to twice, the first time before the modification occurs and then after it is completed.  This is especially important for transaction caches as the second notification can come quite a bit later during the commit.  Event (Infinispan Distribution 6.0.0.Final API)

          • 2. Re: TimerTasks are not Cancelling in distribution mode
            mvpratap

            Dear William Burns ,

            Thanks for giving Response,

            How it is working(timertasks are cancelling successfully) with two nodes and numOwners=2 ???

             

            I am using 30 Timers in my application And I want to serialize those TimerTasks ..I don't want to use Distributed Execution Framework ,,it is not suitable to my application..Because i cannot acheive TimerTask functionality(schedule at fixed rate ,, to cancel the scheduled task) through DistributedCallable .

             

            1.Is there any function to make scheduledWithFixedDelay means ScheduledExecutorService??

            2.With Future we can cancel the tasks but that Future is not serialized..??

             

            So,Is there any alternative solution for this.???? Is Infinispan is  Suitable to this type of applications???

             

            Kindly respond to this..