Fasih Ur Rehman
Fasih Ur Rehman

Reputation: 21

Restrict Infinispan Cache to add multiple Nodes in a Cluster

I am using Infinispan cache in Jboss for my java project. I have two nodes of Jboss running on different machines. I have successfully configure my infinispan cache which replicate their data between two nodes. Below is my infinispan cache configuration:

GlobalConfigurationBuilder global = new GlobalConfigurationBuilder();
JChannel jchannel = new JChannel();
JGroupsTransport transport = new JGroupsTransport(jchannel);
global.transport().transport(transport);
manager = new DefaultCacheManager(global.build());
ConfigurationBuilder c = new ConfigurationBuilder();
c.clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(numOwners).numSegments(numSegments).capacityFactor(capacityFactor).build();
c.invocationBatching().enable();
c.transaction().transactionMode(TransactionMode.TRANSACTIONAL).lockingMode(LockingMode.PESSIMISTIC);
manager.defineConfiguration(DIST, c.build());

but the problem is whenever i used above configuration its automatically detect all nodes and add it to the cluster which is i don't want. How can i restrict this; not to add all nodes in a cluster.

TIA.

Upvotes: 0

Views: 800

Answers (1)

pruivo
pruivo

Reputation: 1334

offtopic: Infinispan creates the JChannel for you if you don't want to create and manage it yourself. Use GlobalConfigurationBuilder.defaultClusteredBuilder(). You can find the Infinispan's configuration here: https://infinispan.org/docs/stable/titles/configuring/configuring.html#cluster_transport

To solve your issue, you need to change the JGroups configuration. If you are using UDP+PING combination (most likely), to create separated clusters just change the UDP mcast_addr and/or mcast_port attributes.

Check the JGroups' documentation for more info: http://www.jgroups.org/manual4/index.html#DiscoveryProtocols

Upvotes: 1

Related Questions