JavaBr
JavaBr

Reputation: 21

Configuration change between two Hazelcast Nodes Behavior?

I am using Hazelcast (ver3.2) in order to have a distributedQueue between two running instance of an App (two differnet JVM, the nodes are connecting via tcp).Each of my instances is a Node and each of my instances has Asynchronous CLients.

For some reason I have to change the max size of my distributedQueue and the backup process (from async to sync). I need to have at least one of my instance running everytime, i will change the hazelcast configuration for each instance and restart the instances one after the other (tomcat).

My Question is : Will the configuration diff be an issue ?

My distributed queue is configured in the hazelcast-config-file of each of my instances (nodes).

Other question : Does my Distributed Queue need to be only in only one of the Nodes Hazelcast Configuration Files ? If two Nodes are part of a Cluster, the DistributedQueue has to be declared each side or only one ?

Thanks

UPDATE

I performed a quick test using two nodes starting at localhost and two different configiration : one with a distributed queue called "testQueue" with max size = 90 and the other one with the same queue name but with max size = 70.

    @Test
    public void twoNodesWithDifferentQueueConfiguration() throws Exception {


    Config config1 = new ClasspathXmlConfig("hazelcast-node-1-config.xml");
    HazelcastInstance hz1 = Hazelcast.newHazelcastInstance(config1);

    Config config2 = new ClasspathXmlConfig("hazelcast-node-2-config.xml");
    HazelcastInstance hz2 = Hazelcast.newHazelcastInstance(config2);


    System.out.println("Local Queue of Hz1 remaining capacity : "+hz1.getQueue("testQueue").remainingCapacity());
    System.out.println("Local Queue of Hz2 remaining capacity : "+hz2.getQueue("testQueue").remainingCapacity());
    HazelcastInstance hazelcastClient = HazelcastClient.newHazelcastClient(getClientConfig());

    hazelcastClient.getQueue("testQueue").add(UUID.randomUUID().toString());

    System.out.println("Local Queue of Hz1 remaining capacity : "+hz1.getQueue("testQueue").remainingCapacity());
    System.out.println("Local Queue of Hz2 remaining capacity : "+hz2.getQueue("testQueue").remainingCapacity());

}

The two nodes connect to each other and form a cluster. If a use a simple java client and add an item to the queue called "testQueue" the max remainig size of the queue seems different for each node.

Local Queue of Hz1 remaining capacity : 90
Local Queue of Hz2 remaining capacity : 70
mai 18, 2016 3:54:30 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test2] is STARTING
mai 18, 2016 3:54:30 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test2] is STARTED
mai 18, 2016 3:54:30 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test2] is CLIENT_CONNECTED
mai 18, 2016 3:54:30 PM com.hazelcast.client.spi.ClientClusterService
INFOS: 

Members [2] {
  Member [127.0.0.1]:5701
  Member [127.0.0.1]:5702
}

Local Queue of Hz1 remaining capacity : 89
Local Queue of Hz2 remaining capacity : 69

But it is the same distributed object right ?

Upvotes: 1

Views: 605

Answers (1)

A.K.Desai
A.K.Desai

Reputation: 1294

Will the configuration diff be an issue ?

Yes. Configurations should be same across all the nodes and should be defined at the start. I believe, on the fly configurations are not supported yet.

Does my Distributed Queue need to be only in only one of the Nodes Hazelcast Configuration Files ? If two Nodes are part of a Cluster, the DistributedQueue has to be declared each side or only one ?

If you are using XML way of configuring Hazelcast then you can define the queue configuration in that itself. If you are starting programmatically then defining in one place is enough. Note that its a Distributed data structure, so once you define it in one node, it gets shared & distributed across the cluster.

Upvotes: 1

Related Questions