use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class RedirectingStoreTest method makeSuperClock.
private VectorClock makeSuperClock(long time) {
List<ClockEntry> clockEntries = new ArrayList<ClockEntry>();
clockEntries.add(new ClockEntry((short) 0, time));
clockEntries.add(new ClockEntry((short) 1, time));
clockEntries.add(new ClockEntry((short) 2, time));
return new VectorClock(clockEntries, time);
}
use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class FileBackedCachingStorageEngineTest method testConcurrentWriteFailure.
@Test
public void testConcurrentWriteFailure() {
ByteArray key = getKey();
Store<ByteArray, byte[], byte[]> store = getStore();
VectorClock c1 = getClock(1, 1);
VectorClock c2 = getClock(1, 2);
byte[] value = getValue();
// put two conflicting versions, then delete one
Versioned<byte[]> v1 = new Versioned<byte[]>(value, c1);
Versioned<byte[]> v2 = new Versioned<byte[]>(value, c2);
store.put(key, v1, null);
try {
store.put(key, v2, null);
fail("Concurrent write succeeded in FileBackedCachingStorageEngine. Should not be allowed.");
} catch (VoldemortException ve) {
// This is OK
}
}
use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class ServerSideRoutingTest method checkServerSideRouting.
private void checkServerSideRouting(VoldemortServer server0, VoldemortServer server1) {
// create bunch of key-value pairs
HashMap<ByteArray, byte[]> entryMap = ServerTestUtils.createRandomKeyValuePairs(TEST_VALUES_SIZE);
// populate all entries in server1
Store<ByteArray, byte[], byte[]> store = server1.getStoreRepository().getRoutedStore(testStoreName);
for (Entry<ByteArray, byte[]> entry : entryMap.entrySet()) {
store.put(entry.getKey(), Versioned.value(entry.getValue(), new VectorClock().incremented(0, System.currentTimeMillis())), null);
}
// try fetching them from server0
store = server0.getStoreRepository().getLocalStore(testStoreName);
RoutingStrategy routing = server0.getMetadataStore().getRoutingStrategy(testStoreName);
for (Entry<ByteArray, byte[]> entry : entryMap.entrySet()) {
List<Node> nodes = routing.routeRequest(entry.getKey().get());
if (hasNode(nodes, 0)) {
assertTrue("ServerSideRouting should return keys from other nodes.", ByteUtils.compare(entry.getValue(), store.get(entry.getKey(), null).get(0).getValue()) == 0);
}
}
}
use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class RedirectingStoreTest method testProxyGetDuringPut.
@Test
public void testProxyGetDuringPut() {
final RedirectingStore storeNode2 = getRedirectingStore(2, servers[2].getMetadataStore(), "test");
final RedirectingStore storeNode0 = getRedirectingStore(0, servers[0].getMetadataStore(), "test");
// Check primary
for (final Entry<ByteArray, byte[]> entry : primaryEntriesMoved.entrySet()) {
try {
// should see obsoleteVersionException for same vectorClock
storeNode2.put(entry.getKey(), Versioned.value(entry.getValue(), new VectorClock().incremented(0, System.currentTimeMillis())), null);
fail("Should see obsoleteVersionException here.");
} catch (ObsoleteVersionException e) {
// ignore
}
try {
// should see obsoleteVersionException for same vectorClock
storeNode0.put(entry.getKey(), Versioned.value(entry.getValue(), new VectorClock().incremented(0, System.currentTimeMillis())), null);
fail("Should see obsoleteVersionException here.");
} catch (ObsoleteVersionException e) {
// ignore
} catch (InvalidMetadataException e) {
}
}
}
use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class AbstractZoneAffinityTest method setup.
@Before
public void setup() throws IOException {
byte[] v1_bytes = { (byte) 'V', (byte) '1' };
byte[] v2_bytes = { (byte) 'V', (byte) '2' };
byte[] k1_bytes = { (byte) 'K', (byte) '1' };
byte[] k2_bytes = { (byte) 'K', (byte) '2' };
byte[] k3_bytes = { (byte) 'K', (byte) '3' };
clientConfig = new ClientConfig();
clientConfig.setBootstrapUrls(cluster.getNodes().iterator().next().getSocketUrl().toString());
clientConfig.setClientZoneId(clientZoneId);
setupZoneAffinitySettings();
SocketStoreClientFactory socketStoreClientFactory = new SocketStoreClientFactory(clientConfig);
for (Integer nodeId : cluster.getNodeIds()) {
SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties());
VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster);
vservers.put(nodeId, vs);
socketStoreFactories.put(nodeId, socketStoreFactory);
Store<ByteArray, byte[], byte[]> store = vs.getStoreRepository().getLocalStore(storeDef.getName());
Node node = cluster.getNodeById(nodeId);
VectorClock version1 = new VectorClock();
version1.incrementVersion(0, System.currentTimeMillis());
VectorClock version2 = version1.incremented(0, System.currentTimeMillis());
if (node.getZoneId() == clientZoneId) {
// local zone
store.put(new ByteArray(k1_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
store.put(new ByteArray(k2_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
} else {
// remote zone
store.put(new ByteArray(k1_bytes), new Versioned<byte[]>(v2_bytes, version2), null);
store.put(new ByteArray(k2_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
store.put(new ByteArray(k3_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
}
}
client = socketStoreClientFactory.getRawStore(storeDef.getName(), null);
}
Aggregations