You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geode.apache.org by "evaristo.camarero@yahoo.es" <ev...@yahoo.es> on 2022/04/28 11:16:21 UTC

Re: SCHEDULE CODE EXECUTION IN GEODE SERVERS

 Hi there,
Thanks a lot for the response. I am really sorry I missed this mail and that is the reason I did not answer back.
If I understand right, the init and remove callbacks could be used for instance to schedule whatever logic is needed. In our case, we would like to periodically call a function, so we could use initialize method to create a scheduledExecutorService and program the periodic calls, right?
Thanks again,
/Evaristo




    En martes, 15 de marzo de 2022, 22:43:50 CET, Nabarun Nag <nn...@vmware.com> escribió:  
 
 #yiv6531636535 P {margin-top:0;margin-bottom:0;}Hi Evaristo,
We had a discussion with the devs, and they came up with a couple of suggestions like using Functions or CacheListeners/CacheWriters   
   - You can create a CacheListener/CacheWriter to a region, so that when the region is created the initialize method is called in the Listener   
Eg: In the cache.xml   
   <initializer>
  <class-name>TestInitializer</class-name> 
</initializer>Create an empty CacheListener/CacheWriter to the region that implements a Declarable with an initialize method (TestInitializer )   
   public class TestInitializer implements Declarable {

  public void init(Properties properties) {
    System.out.println("TestInitializer.init invoked");
  }
}This CacheListener can be removed at a later point in time with the region's AttributedMutator removeCacheListener method call.

Please do let us know if you want any more details, or can share with us what you want that scheduled code to do, perhaps more resources can be saved using event listeners.

RegardsNabarun NagFrom: evaristo.camarero@yahoo.es <ev...@yahoo.es>
Sent: Wednesday, March 9, 2022 11:39 PM
To: user@geode.apache.org <us...@geode.apache.org>
Subject: SCHEDULE CODE EXECUTION IN GEODE SERVERS Hi there,
Is it possible to run in Geode periodically scheduled code (e.g. server function) without the need to perform a remote call from a Geode client.
I am looking for something like scheduledFunction.
Currently I only the change to start a thread (or executor that periodically executes my code), BUT I see things that are not convenient:- How to stop that thread? It can be a daemon thread, BUT for instance when running testing then that thread keeps going...- It is a resource waste because ideally this scheduled execution could be using regular thread pools
Thanks in advance,
/Evaristo