final CountDownLatch latch = new CountDownLatch(2);
// start get operation.
executors.execute(new Runnable() {
@Override
public void run() {
SocketStoreClientFactory factory = null;
try {
// wait for the rebalancing to begin
List<VoldemortServer> serverList = Lists.newArrayList(serverMap.get(3), serverMap.get(5),
serverMap.get(9), serverMap.get(11));
while(!rebalancingComplete.get()) {
Iterator<VoldemortServer> serverIterator = serverList.iterator();
while(serverIterator.hasNext()) {
VoldemortServer server = serverIterator.next();
if(ByteUtils.getString(server.getMetadataStore()
.get(MetadataStore.SERVER_STATE_KEY, null)
.get(0)
.getValue(),
"UTF-8")
.compareTo(VoldemortState.REBALANCING_MASTER_SERVER.toString()) == 0) {
logger.info("Server " + server.getIdentityNode().getId()
+ " transitioned into REBALANCING MODE");
serverIterator.remove();
}
}
if(serverList.size() == 0) {
rebalancingStarted.set(true);
break;
}
}
if(rebalancingStarted.get()) {
factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls
(getBootstrapUrl(updatedCurrentCluster, 3))
.setEnableLazy(false)
.setSocketTimeout(120, TimeUnit.SECONDS)
.setClientZoneId(3));
final StoreClient<String, String> storeClientRW = new DefaultStoreClient
<String, String>(testStoreNameRW,
null,
factory,
3);
// Now perform some writes and determine the end state of the changed keys.
// Initially, all data now with zero vector clock
for(ByteArray movingKey: movingKeysList) {
try {
String keyStr = ByteUtils.getString(movingKey.get(), "UTF-8");
String valStr = "proxy_write";
storeClientRW.put(keyStr, valStr);
baselineTuples.put(keyStr, valStr);
baselineVersions.get(keyStr)
.incrementVersion(11, System.currentTimeMillis());
proxyWritesDone.set(true);
if(rebalancingComplete.get()) {
break;
}
} catch(InvalidMetadataException e) {
logger.error("Encountered an invalid metadata exception.. ", e);
}
}
}
} catch(Exception e) {
logger.error("Exception in proxy write thread..", e);
exceptions.add(e);
} finally {
if(factory != null)
factory.close();
latch.countDown();
}
}
});