use of voldemort.versioning.Versioned in project voldemort by voldemort.
the class AdminServiceBasicTest method testUpdateSlops.
@Test
public void testUpdateSlops() {
final List<Versioned<Slop>> entrySet = ServerTestUtils.createRandomSlops(0, 10000, testStoreName, "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
Iterator<Versioned<Slop>> slopIterator = entrySet.iterator();
getAdminClient().streamingOps.updateSlopEntries(0, slopIterator);
// check updated values
Iterator<Versioned<Slop>> entrysetItr = entrySet.iterator();
while (entrysetItr.hasNext()) {
Versioned<Slop> versioned = entrysetItr.next();
Slop nextSlop = versioned.getValue();
Store<ByteArray, byte[], byte[]> store = getStore(0, nextSlop.getStoreName());
if (nextSlop.getOperation().equals(Slop.Operation.PUT)) {
assertNotSame("entry should be present at store", 0, store.get(nextSlop.getKey(), null).size());
assertEquals("entry value should match", new String(nextSlop.getValue()), new String(store.get(nextSlop.getKey(), null).get(0).getValue()));
} else if (nextSlop.getOperation().equals(Slop.Operation.DELETE)) {
assertEquals("entry value should match", 0, store.get(nextSlop.getKey(), null).size());
}
}
}
use of voldemort.versioning.Versioned in project voldemort by voldemort.
the class AbstractAdminServiceFilterTest method testDeleteStreamWithFilter.
@Test
public void testDeleteStreamWithFilter() {
// user store should be present
Store<ByteArray, byte[], byte[]> store = getStore(0, testStoreName);
assertNotSame("Store '" + testStoreName + "' should not be null", null, store);
Set<Pair<ByteArray, Versioned<byte[]>>> entrySet = createEntries();
VoldemortFilter filter = new VoldemortFilterImpl();
RoutingStrategy strategy = new RoutingStrategyFactory().updateRoutingStrategy(getStoreDef(), getCluster());
for (Pair<ByteArray, Versioned<byte[]>> pair : entrySet) {
if (Utils.nodeListToNodeIdList(strategy.routeRequest(pair.getFirst().get())).contains(0))
store.put(pair.getFirst(), pair.getSecond(), null);
}
// make delete stream call with filter
getAdminClient().storeMntOps.deletePartitions(0, testStoreName, Lists.newArrayList(0, 1), filter);
// assert none of the filtered entries are returned.
for (Pair<ByteArray, Versioned<byte[]>> entry : entrySet) {
if (Utils.nodeListToNodeIdList(strategy.routeRequest(entry.getFirst().get())).contains(0)) {
if (filter.accept(entry.getFirst(), entry.getSecond())) {
assertEquals("All entries should be deleted except the filtered ones.", 0, store.get(entry.getFirst(), null).size());
} else {
assertNotSame("filtered entry should be still present.", 0, store.get(entry.getFirst(), null).size());
assertEquals("values should match", new String(entry.getSecond().getValue()), new String(store.get(entry.getFirst(), null).get(0).getValue()));
}
}
}
}
use of voldemort.versioning.Versioned in project voldemort by voldemort.
the class AbstractAdminServiceFilterTest method testUpdateAsStreamWithFilter.
@Test
public void testUpdateAsStreamWithFilter() {
VoldemortFilter filter = new VoldemortFilterImpl();
Set<Pair<ByteArray, Versioned<byte[]>>> entrySet = createEntries();
// make update stream call with filter
getAdminClient().streamingOps.updateEntries(0, testStoreName, entrySet.iterator(), filter);
// assert none of the filtered entries are updated.
// user store should be present
Store<ByteArray, byte[], byte[]> store = getStore(0, testStoreName);
assertNotSame("Store '" + testStoreName + "' should not be null", null, store);
for (Pair<ByteArray, Versioned<byte[]>> entry : entrySet) {
if (filter.accept(entry.getFirst(), entry.getSecond())) {
assertEquals("Store should have this key/value pair", 1, store.get(entry.getFirst(), null).size());
assertEquals("Store should have this key/value pair", entry.getSecond(), store.get(entry.getFirst(), null).get(0));
} else {
assertEquals("Store should Not have this key/value pair", 0, store.get(entry.getFirst(), null).size());
}
}
}
use of voldemort.versioning.Versioned in project voldemort by voldemort.
the class AbstractAdminServiceFilterTest method testFetchAsStreamWithFilter.
@Test
public void testFetchAsStreamWithFilter() {
// user store should be present
Store<ByteArray, byte[], byte[]> store = getStore(0, testStoreName);
assertNotSame("Store '" + testStoreName + "' should not be null", null, store);
VoldemortFilter filter = new VoldemortFilterImpl();
int shouldFilterCount = 0;
RoutingStrategy strategy = new RoutingStrategyFactory().updateRoutingStrategy(getStoreDef(), getCluster());
for (Pair<ByteArray, Versioned<byte[]>> pair : createEntries()) {
if (Utils.nodeListToNodeIdList(strategy.routeRequest(pair.getFirst().get())).contains(0)) {
store.put(pair.getFirst(), pair.getSecond(), null);
if (!filter.accept(pair.getFirst(), pair.getSecond())) {
shouldFilterCount++;
}
}
}
// make fetch stream call with filter
Iterator<Pair<ByteArray, Versioned<byte[]>>> entryIterator = getAdminClient().bulkFetchOps.fetchEntries(0, testStoreName, getCluster().getNodeById(0).getPartitionIds(), filter, false);
// assert none of the filtered entries are returned.
while (entryIterator.hasNext()) {
Pair<ByteArray, Versioned<byte[]>> entry = entryIterator.next();
if (!filter.accept(entry.getFirst(), entry.getSecond())) {
fail();
}
}
}
use of voldemort.versioning.Versioned in project voldemort by voldemort.
the class CatBdbStore method main.
public static void main(String[] args) throws Exception {
if (args.length != 2)
Utils.croak("USAGE: java " + CatBdbStore.class.getName() + " bdb_dir" + " storeName" + " server.properties.path");
String bdbDir = args[0];
String storeName = args[1];
String serverProperties = args[2];
VoldemortConfig config = new VoldemortConfig(new Props(new File(serverProperties)));
EnvironmentConfig environmentConfig = new EnvironmentConfig();
environmentConfig.setDurability(Durability.COMMIT_NO_SYNC);
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(config.isBdbWriteTransactionsEnabled());
Environment environment = new Environment(new File(bdbDir), environmentConfig);
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(config.isBdbWriteTransactionsEnabled());
databaseConfig.setSortedDuplicates(false);
Database database = environment.openDatabase(null, storeName, databaseConfig);
StorageEngine<ByteArray, byte[], byte[]> store = null;
if (config.getBdbPrefixKeysWithPartitionId()) {
store = new PartitionPrefixedBdbStorageEngine(storeName, environment, database, new BdbRuntimeConfig(), TestUtils.makeSingleNodeRoutingStrategy());
} else {
store = new BdbStorageEngine(storeName, environment, database, new BdbRuntimeConfig());
}
StorageEngine<String, String, String> stringStore = SerializingStorageEngine.wrap(store, new StringSerializer(), new StringSerializer(), new StringSerializer());
Iterator<Pair<String, Versioned<String>>> iter = stringStore.entries();
while (iter.hasNext()) {
Pair<String, Versioned<String>> entry = iter.next();
System.out.println(entry.getFirst() + " => " + entry.getSecond().getValue());
}
}
Aggregations