Question

I am trying to setup a replicated cache set up on 2 different servers using Infinispan cache.

Node1 and Node2 are 2 physical servers on which hotrod server is running.

My intention is to create some cache(with custom Configuration) on node1/node2 from a remote client (Node3).

On Node3, I am trying to do the following..

RemoteCacheManager rm = new RemoteCacheManager ("node1ip4address", portNumber); rm.getCache("namedcache1"); ----> this method's javadoc says,

/** * Retrieves a named cache from the remote server if the cache has been * defined, otherwise if the cache name is underfined, it will return null. */

I checked the Source code of RemoteCacheManager. This class does not have defineConfiguration() method such as the one exists in EmbeddedCacheManager.

Is there a way i can create cache on remote node?

Thanks, -Venkat

Was it helpful?

Solution

No, there is no way to create a cache through the HotRod protocol. Even in embedded mode, Infinispan doesn't have a way to say "create this cache on all the cluster nodes", which you would need with HotRod because you don't know which server you're accessing.

The CacheManager JMX bean has a startCache method, but you still can't define new configurations (they'll use the default cache's configuration). And you need to call it on every node of the cluster.

Obviously, it would be best if you could configure the caches statically in the server's configuration.

OTHER TIPS

We can use the rest call to the management running on 9990 and create the cache,

curl --digest -s -i -u "usr:pwd" -X POST -H 'Content-type: application/json' -d @cacheTemplate.json http://serverurl:9990/management

where the cacheTemplate.json to create a cache with name cart in the container named clustered

{
    "address":[
        "subsystem",
        "datagrid-infinispan",
        "cache-container",
        "clustered",
        "configurations",
        "CONFIGURATIONS",
        "distributed-cache-configuration",
        "cart"
    ],
    "operation":"add",
    "mode":"SYNC",
    "store-type":"None",
    "store-original-type":"None",
    "template":false
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top