In my setup I have two instances of an application that are both up and processing requests at the same time, using Hazelcast to share state and locking. The setup is default in that all the data is on both nodes with 50% being live, 50% being a backup for the other node.
I wish to add blue/green deployment to my setup such that, I can deploy a new version with no interruptions in processing requests and without loosing any data/processing requests erroneously.
During a deploy, I would bring down one instance of the application, meaning the remaining instance will now have 100% of the live data and process requests with that. If anything were to go wrong with that instance, I'd loose all my data (I have no backup setup) - I'm happy accepting this risk.
Once I bring up the new version instance of the application, Hazelcast should start to rebalance the cache, such that its 50% live and 50% backup on each instance again. It is at this point I want to block and wait until the rebalance is fully complete before I advertise the new instance as live. When complete, the new instance has 50% of the live data and 50% as backup.
When rebalancing is complete, I can then bring down the second version, bring up the new version, Hazelcast would initialize a rebalance, I'd block, wait for the rebalance to complete, then advertise the second instance as live.
My blue/green deployment would now be complete.
The question: how do I block the new instance until the rebalance in complete (it's received all the data)?