Search in sources :

Example 71 with ByteArray

use of voldemort.utils.ByteArray in project voldemort by voldemort.

the class AbstractRequestFormatTest method testPutRequests.

@Test
public void testPutRequests() throws Exception {
    testPutRequest(new ByteArray(), new byte[0], null, new VectorClock(), null, true);
    testPutRequest(TestUtils.toByteArray("hello"), "world".getBytes(), null, new VectorClock(), null, false);
    testPutRequest(TestUtils.toByteArray("hello"), "world".getBytes(), null, new VectorClock(), ObsoleteVersionException.class, true);
}
Also used : VectorClock(voldemort.versioning.VectorClock) ByteArray(voldemort.utils.ByteArray) Test(org.junit.Test)

Example 72 with ByteArray

use of voldemort.utils.ByteArray in project voldemort by voldemort.

the class QueryKeyResultTest method testStandardCtor.

@Test
public void testStandardCtor() {
    ByteArray key = new ByteArray("key".getBytes());
    List<Versioned<byte[]>> values = new ArrayList<Versioned<byte[]>>(0);
    Versioned<byte[]> value1 = TestUtils.getVersioned(TestUtils.randomBytes(10), 1, 1, 1);
    values.add(value1);
    Versioned<byte[]> value2 = TestUtils.getVersioned(TestUtils.randomBytes(10), 1, 1, 2);
    values.add(value2);
    QueryKeyResult queryKeyResult = new QueryKeyResult(key, values);
    assertTrue(queryKeyResult.hasValues());
    assertEquals(values, queryKeyResult.getValues());
    assertFalse(queryKeyResult.hasException());
    assertEquals(null, queryKeyResult.getException());
}
Also used : Versioned(voldemort.versioning.Versioned) ArrayList(java.util.ArrayList) ByteArray(voldemort.utils.ByteArray) Test(org.junit.Test)

Example 73 with ByteArray

use of voldemort.utils.ByteArray in project voldemort by voldemort.

the class StreamingClientTest method testStreaming.

@Test
public void testStreaming() {
    Props property = new Props();
    property.put("streaming.platform.bootstrapURL", SERVER_LOCAL_URL + serverPorts[0]);
    StreamingClientConfig config = new StreamingClientConfig(property);
    BaseStreamingClient streamer = new BaseStreamingClient(config);
    streamer.initStreamingSession(TEST_STORE_NAME, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            return null;
        }
    }, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            return null;
        }
    }, true);
    for (int i = 0; i < NUM_KEYS_1; i++) {
        String key = i + "";
        String value = key;
        Versioned<byte[]> outputValue = Versioned.value(value.getBytes());
        // adminClient.streamingPut(new ByteArray(key.getBytes()),
        // outputValue);
        streamer.streamingPut(new ByteArray(key.getBytes()), outputValue);
    }
    streamer.commitToVoldemort();
    streamer.closeStreamingSession();
    assertEquals(verifyKeysExist(nodeIdOnWhichToVerifyKey), true);
}
Also used : ByteArray(voldemort.utils.ByteArray) Props(voldemort.utils.Props) IOException(java.io.IOException) Test(org.junit.Test)

Example 74 with ByteArray

use of voldemort.utils.ByteArray in project voldemort by voldemort.

the class AbstractZonedRebalanceTest method populateData.

private void populateData(Cluster cluster, StoreDefinition storeDef) throws Exception {
    // Create SocketStores for each Node first
    Map<Integer, Store<ByteArray, byte[], byte[]>> storeMap = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
    for (Node node : cluster.getNodes()) {
        storeMap.put(node.getId(), getSocketStore(storeDef.getName(), node.getHost(), node.getSocketPort()));
    }
    BaseStoreRoutingPlan storeInstance = new BaseStoreRoutingPlan(cluster, storeDef);
    for (Entry<String, String> entry : testEntries.entrySet()) {
        ByteArray keyBytes = new ByteArray(ByteUtils.getBytes(entry.getKey(), "UTF-8"));
        List<Integer> preferenceNodes = storeInstance.getReplicationNodeList(keyBytes.get());
        // Go over every node
        for (int nodeId : preferenceNodes) {
            try {
                storeMap.get(nodeId).put(keyBytes, new Versioned<byte[]>(ByteUtils.getBytes(entry.getValue(), "UTF-8")), null);
            } catch (ObsoleteVersionException e) {
                logger.info("Why are we seeing this at all here ?? ");
                e.printStackTrace();
            }
        }
    }
    // close all socket stores
    for (Store<ByteArray, byte[], byte[]> store : storeMap.values()) {
        store.close();
    }
}
Also used : HashMap(java.util.HashMap) Node(voldemort.cluster.Node) Store(voldemort.store.Store) MetadataStore(voldemort.store.metadata.MetadataStore) ObsoleteVersionException(voldemort.versioning.ObsoleteVersionException) ByteArray(voldemort.utils.ByteArray) BaseStoreRoutingPlan(voldemort.routing.BaseStoreRoutingPlan)

Example 75 with ByteArray

use of voldemort.utils.ByteArray in project voldemort by voldemort.

the class OfflineStateTest method testSlopStreaming.

private boolean testSlopStreaming() {
    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();
    try {
        getAdminClient().streamingOps.updateSlopEntries(0, slopIterator);
    } catch (VoldemortException e) {
        return false;
    }
    // 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)) {
            return store.get(nextSlop.getKey(), null).size() != 0;
        } else if (nextSlop.getOperation().equals(Slop.Operation.DELETE)) {
            return store.get(nextSlop.getKey(), null).size() == 0;
        }
    }
    return false;
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) VoldemortException(voldemort.VoldemortException) Slop(voldemort.store.slop.Slop)

Aggregations

ByteArray (voldemort.utils.ByteArray)309 Versioned (voldemort.versioning.Versioned)130 Test (org.junit.Test)125 VoldemortException (voldemort.VoldemortException)67 VectorClock (voldemort.versioning.VectorClock)65 ArrayList (java.util.ArrayList)61 Node (voldemort.cluster.Node)61 List (java.util.List)58 HashMap (java.util.HashMap)53 StoreDefinition (voldemort.store.StoreDefinition)49 Cluster (voldemort.cluster.Cluster)33 AbstractByteArrayStoreTest (voldemort.store.AbstractByteArrayStoreTest)31 Store (voldemort.store.Store)31 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)31 IOException (java.io.IOException)30 Slop (voldemort.store.slop.Slop)29 Map (java.util.Map)28 Pair (voldemort.utils.Pair)28 UnreachableStoreException (voldemort.store.UnreachableStoreException)26 StatTrackingStore (voldemort.store.stats.StatTrackingStore)25