Search in sources :

Example 31 with Versioned

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());
        }
    }
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) Slop(voldemort.store.slop.Slop) Test(org.junit.Test)

Example 32 with Versioned

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()));
            }
        }
    }
}
Also used : Versioned(voldemort.versioning.Versioned) RoutingStrategyFactory(voldemort.routing.RoutingStrategyFactory) RoutingStrategy(voldemort.routing.RoutingStrategy) ByteArray(voldemort.utils.ByteArray) VoldemortFilter(voldemort.client.protocol.VoldemortFilter) Pair(voldemort.utils.Pair) Test(org.junit.Test)

Example 33 with Versioned

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());
        }
    }
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) VoldemortFilter(voldemort.client.protocol.VoldemortFilter) Pair(voldemort.utils.Pair) Test(org.junit.Test)

Example 34 with Versioned

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();
        }
    }
}
Also used : Versioned(voldemort.versioning.Versioned) RoutingStrategyFactory(voldemort.routing.RoutingStrategyFactory) RoutingStrategy(voldemort.routing.RoutingStrategy) ByteArray(voldemort.utils.ByteArray) VoldemortFilter(voldemort.client.protocol.VoldemortFilter) Pair(voldemort.utils.Pair) Test(org.junit.Test)

Example 35 with Versioned

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());
    }
}
Also used : BdbRuntimeConfig(voldemort.store.bdb.BdbRuntimeConfig) Versioned(voldemort.versioning.Versioned) EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Props(voldemort.utils.Props) VoldemortConfig(voldemort.server.VoldemortConfig) PartitionPrefixedBdbStorageEngine(voldemort.store.bdb.PartitionPrefixedBdbStorageEngine) BdbStorageEngine(voldemort.store.bdb.BdbStorageEngine) PartitionPrefixedBdbStorageEngine(voldemort.store.bdb.PartitionPrefixedBdbStorageEngine) Database(com.sleepycat.je.Database) Environment(com.sleepycat.je.Environment) ByteArray(voldemort.utils.ByteArray) File(java.io.File) StringSerializer(voldemort.serialization.StringSerializer) DatabaseConfig(com.sleepycat.je.DatabaseConfig) Pair(voldemort.utils.Pair)

Aggregations

Versioned (voldemort.versioning.Versioned)214 ByteArray (voldemort.utils.ByteArray)130 Test (org.junit.Test)88 VectorClock (voldemort.versioning.VectorClock)73 ArrayList (java.util.ArrayList)56 VoldemortException (voldemort.VoldemortException)48 List (java.util.List)36 StoreDefinition (voldemort.store.StoreDefinition)29 HashMap (java.util.HashMap)28 IOException (java.io.IOException)27 Node (voldemort.cluster.Node)27 Pair (voldemort.utils.Pair)25 Slop (voldemort.store.slop.Slop)22 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)22 Map (java.util.Map)21 Cluster (voldemort.cluster.Cluster)17 AbstractByteArrayStoreTest (voldemort.store.AbstractByteArrayStoreTest)15 InvalidMetadataException (voldemort.store.InvalidMetadataException)13 PersistenceFailureException (voldemort.store.PersistenceFailureException)13 Version (voldemort.versioning.Version)13