// proxy getting from Node 0 and issue a write based off that,
// incrementing the clock for Node 2 and make sure there is no
// ObsoleteVersionException at both Node 0 and
// Node 2.
ByteArray secondaryKey = testSecondaryKeys.get(0);
VectorClock clock1 = ((VectorClock)
redirectingStoreNode2.getVersions(secondaryKey).get(0)).incremented(2,
System.currentTimeMillis());
try {
redirectingStoreNode2.put(secondaryKey,
Versioned.value("write-through".getBytes("UTF-8"), clock1),
null);
} catch(Exception e) {
fail("Unexpected error in testing write through proxy put");
e.printStackTrace();
}
waitForProxyPutsToDrain(redirectingStoreNode2);
assertTrue("Unexpected failures in proxy put",
redirectingStoreNode2.getProxyPutStats().getNumProxyPutFailures() == 0);
assertEquals("Unexpected value in Node 2",
"write-through",
new String(socketStoreNode2.get(secondaryKey, null).get(0).getValue()));
assertTrue("Proxy write not seen on proxy node 0",
"write-through".equals(new String(socketStoreNode0.get(secondaryKey, null)
.get(0)
.getValue())));
// Also test that if put fails locally, proxy put is not attempted.
try {
redirectingStoreNode2.put(secondaryKey,
Versioned.value("write-through-updated".getBytes("UTF-8"),
clock1),
null);
fail("Should have thrown OVE");
} catch(ObsoleteVersionException ove) {
// Expected
} catch(Exception e) {
fail("Unexpected error in testing write through proxy put");
e.printStackTrace();
}
waitForProxyPutsToDrain(redirectingStoreNode2);
assertFalse("Proxy write not seen on proxy node 0",
"write-through-updated".equals(new String(socketStoreNode0.get(secondaryKey,
null)
.get(0)
.getValue())));
// 2. Make sure if the proxy node is still a replica, we don't issue
// proxy puts. Node 2 -> Node 0 on partition 0, for which Node 0 is
// still a replica
ByteArray primaryKey = testPrimaryKeys.get(0);
VectorClock clock2 = ((VectorClock)
redirectingStoreNode2.getVersions(primaryKey).get(0)).incremented(2,
System.currentTimeMillis());
try {
redirectingStoreNode2.put(primaryKey,
Versioned.value("write-through".getBytes("UTF-8"), clock2),