Search code examples
cachingjbossinfinispanjcache

distributed cache infinispan and varibale properties in infinispan.xml


so I m using infinispan 11.0 in embedded mode and I have two questions :


First question :


I am building an app for a client and I am going to have multiple caches ( local and distributed ). the thing is when I have one node alive is there a possibility to force the distributed caches to work as a local cache ( i mean stop sending messages to sync with the non-existing nodes something like initial_cluster_size but when the node are below the required number the cache will act as a local cache) to increase performance.


Second question


is there a possibility to pass variables in infinispan.xml because the node names are located in another file so is the possibility to reference the value in infinispan ( using spring for example )?

ps: for this question, I have to deal with infinispan.xml file I know that the request can be treated programmatically


Solution

  • First question

    What do you mean by stop sending messages to sync with the non-existing nodes? Infinispan does not send messages to "nobody" and, if you have a single node, the distributed cache does not send any messages to the network. See code here.

    Second question

    Yes, if you load your properties in a Properties object, you can do something like this:

    Properties props = ... //my properties
    ParserRegistry reg = new ParserRegistry(Thread.current.getContextClassLoader(), false, props);
    ConfigurationBuilderHolder holder = reg.parse(/*infinispan.xml path or File*/); //check other parse methods
    DefaultCacheManager manager = new DefaultCacheManager(holder, true);
    

    Reference the key in your infinispan.xml using ${key}.