DESCRIPTION

JVMCBC-231: fix race condition in remove all case on reconfigure

Motivation:
-----------
In certain cases during reconfiguration events (as processed by the
RequestHandler's reconfigure method), a race condition can happen and
cause two subsequent reconfigurations to fail.

This is when the configuration's list of nodes is empty, resulting in
all nodes being disconnected. The second incoming empty configuration
could be received at a point where the node set in memory is not emptied
yet, but immediately after that the Observable of nodes to disconnect
from is created empty. This in turn throws a NoSuchElementException when
the last() operator is called.

Modifications:
--------------
The set of nodes (which could be concurrently mutated in the race
condition) is now "snapshotted" in a synchronized manner, preventing
the race condition to happen in the first place.

A new test that simulates the race condition (by always making the set
of nodes's isEmpty() method to return true) has been added.

Results:
--------
All tests pass and the surface for a race condition to happen during a
reconfiguration where the node list is empty has been reduced.

Change-Id: Ida55e548d45cdc2b096282698ce9ca9b629948eb


COMMENTS

author: Estrella Humphrey
date: 2015-08-17 14:58:08.235000000

Uploaded patch set 1.

-------------------------------------
author: Gerrit Code Review
date: 2015-08-17 15:09:45.755000000

Change has been successfully cherry-picked as e718140440e2655b204c52aaac5501553ff83348

-------------------------------------
