use of voldemort.versioning.Version in project voldemort by voldemort.
the class DefaultStoreClient method put.
public Version put(K key, V value, Object transforms) {
Version version = getVersionForPut(key);
Versioned<V> versioned = Versioned.value(value, version);
return put(key, versioned, transforms);
}
use of voldemort.versioning.Version in project voldemort by voldemort.
the class SystemStoreClient method putSysStore.
public Version putSysStore(K key, Versioned<V> value) {
Version version = null;
try {
if (logger.isDebugEnabled()) {
logger.debug("Invoking Put for key : " + key + " on store name : " + this.storeName);
}
this.sysStore.put(key, value, null);
version = value.getVersion();
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Exception caught during putSysStore: " + e);
}
logger.info("Exception during put", e);
}
return version;
}
use of voldemort.versioning.Version in project voldemort by voldemort.
the class GossiperTest method testGossiper.
// Protect against this test running forever until the root cause of running
// forever is found.
@Test(timeout = 1800)
public void testGossiper() throws Exception {
Cluster newCluster = null;
boolean startedAdditionalServer = false;
while (!startedAdditionalServer) {
try {
newCluster = attemptStartAdditionalServer();
startedAdditionalServer = true;
} catch (IOException ioe) {
logger.warn("Caught an IOException when attempting to start additional server. Will print stacktrace and then attempt to start additional server again.");
ioe.printStackTrace();
}
}
// Get the new cluster.xml
AdminClient localAdminClient = getAdminClient(newCluster);
Versioned<String> versionedClusterXML = localAdminClient.metadataMgmtOps.getRemoteMetadata(3, MetadataStore.CLUSTER_KEY);
// Increment the version, let what would be the "donor node" know about
// it to seed the Gossip.
Version version = versionedClusterXML.getVersion();
((VectorClock) version).incrementVersion(3, ((VectorClock) version).getTimestamp() + 1);
((VectorClock) version).incrementVersion(0, ((VectorClock) version).getTimestamp() + 1);
localAdminClient.metadataMgmtOps.updateRemoteMetadata(0, MetadataStore.CLUSTER_KEY, versionedClusterXML);
localAdminClient.metadataMgmtOps.updateRemoteMetadata(3, MetadataStore.CLUSTER_KEY, versionedClusterXML);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
// Wait up to five seconds for Gossip to spread
final Cluster newFinalCluster = newCluster;
try {
TestUtils.assertWithBackoff(5000, new Attempt() {
public void checkCondition() {
int serversSeen = 0;
// Now verify that we have gossiped correctly
for (VoldemortServer server : servers) {
Cluster clusterAtServer = server.getMetadataStore().getCluster();
int nodeId = server.getMetadataStore().getNodeId();
assertEquals("server " + nodeId + " has heard " + " the gossip about number of nodes", clusterAtServer.getNumberOfNodes(), newFinalCluster.getNumberOfNodes());
assertEquals("server " + nodeId + " has heard " + " the gossip about partitions", clusterAtServer.getNodeById(nodeId).getPartitionIds(), newFinalCluster.getNodeById(nodeId).getPartitionIds());
serversSeen++;
}
assertEquals("saw all servers", serversSeen, servers.size());
}
});
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
use of voldemort.versioning.Version in project voldemort by voldemort.
the class AbstractRequestFormatTest method testGetVersionRequest.
public void testGetVersionRequest(ByteArray key, byte[] value, VectorClock version, boolean isPresent) throws Exception {
try {
if (isPresent) {
testPutRequest(key, value, null, version, null, false);
}
ByteArrayOutputStream getVersionRequest = new ByteArrayOutputStream();
this.clientWireFormat.writeGetVersionRequest(new DataOutputStream(getVersionRequest), storeName, key, RequestRoutingType.NORMAL);
ByteArrayOutputStream getVersionResponse = handleRequest(getVersionRequest);
testIsCompleteGetVersionResponse(getVersionResponse);
List<Version> values = this.clientWireFormat.readGetVersionResponse(inputStream(getVersionResponse));
if (isPresent) {
assertEquals(1, values.size());
VectorClock returnValue = (VectorClock) values.get(0);
assertEquals(version, returnValue);
assertEquals(version.getTimestamp(), returnValue.getTimestamp());
} else {
assertEquals(0, values.size());
}
} finally {
this.store.deleteAll();
}
}
use of voldemort.versioning.Version in project voldemort by voldemort.
the class RoutedStoreTest method testGetVersions2.
@Test
public void testGetVersions2() throws Exception {
List<ByteArray> keys = getKeys(2);
ByteArray key = keys.get(0);
byte[] value = getValue();
Store<ByteArray, byte[], byte[]> store = getStore();
store.put(key, Versioned.value(value), null);
List<Versioned<byte[]>> versioneds = store.get(key, null);
List<Version> versions = store.getVersions(key);
assertEquals(1, versioneds.size());
assertEquals(9, versions.size());
for (int i = 0; i < versions.size(); i++) assertEquals(versioneds.get(0).getVersion(), versions.get(i));
assertEquals(0, store.getVersions(keys.get(1)).size());
}
Aggregations