Package voldemort.utils

Examples of voldemort.utils.ByteArray


        OpInvoker(CountDownLatch signal, byte opCode, ConcurrentLinkedQueue<Long> runTimes) {
            this.signal = signal;
            this.opCode = opCode;
            this.runTimes = runTimes;
            this.key = new ByteArray(ByteUtils.getBytes("key", "UTF-8"));
            this.value = ByteUtils.getBytes("value", "UTF-8");
            logger.debug("OpInvoker created for operation " + getOpName(this.opCode) + "(Thread: "
                         + Thread.currentThread().getName() + ")");
        }
View Full Code Here


    @Override
    public List<ByteArray> getKeys(int numKeys) {
        List<ByteArray> keys = new ArrayList<ByteArray>(numKeys);
        for(int i = 0; i < numKeys; i++)
            keys.add(new ByteArray(TestUtils.randomBytes(10)));
        return keys;
    }
View Full Code Here

        while(true) {
            if(System.currentTimeMillis() > endMs) {
                break;
            }
            // generate key
            ByteArray key = new ByteArray(TestUtils.randomBytes(KEY_LENGTH));
            byte[] value = TestUtils.randomBytes(VALUE_LENGTH);
            // put to nodes
            try {
                client.put(key.get(), value);
                // if put does not throw exception
                List<Node> routes = testEnv.routeRequest(key.get());
                for(Node node: routes) {
                    numAssertPuts++;
                    nodeIds.add(node.getId());
                    Store<ByteArray, byte[], byte[]> realStore = testEnv.getRealStore(node.getId());
                    if(realStore instanceof InMemoryPutAssertionStorageEngine) {
View Full Code Here

                          new byte[][] {},
                          null,
                          new VectorClock[] {},
                          new boolean[] {});

        testGetAllRequest(new ByteArray[] { new ByteArray() },
                          new byte[][] { new byte[] {} },
                          null,
                          new VectorClock[] { new VectorClock() },
                          new boolean[] { true });
View Full Code Here

            this.store.deleteAll();
        }
    }

    public void testPutRequests() throws Exception {
        testPutRequest(new ByteArray(), new byte[0], null, new VectorClock(), null);
        testPutRequest(TestUtils.toByteArray("hello"),
                       "world".getBytes(),
                       null,
                       new VectorClock(),
                       null);
View Full Code Here

        }
    }

    public void testDeleteRequests() throws Exception {
        // test pre-existing are deleted
        testDeleteRequest(new ByteArray(),
                          new VectorClock(),
                          new Versioned<byte[]>("hello".getBytes()),
                          true);
        testDeleteRequest(TestUtils.toByteArray("hello"),
                          new VectorClock(),
View Full Code Here

        while(true) {
            if(System.currentTimeMillis() > endMs) {
                break;
            }
            // generate key
            ByteArray key = new ByteArray(TestUtils.randomBytes(KEY_LENGTH));
            byte[] value = TestUtils.randomBytes(VALUE_LENGTH);
            Versioned<byte[]> outputValue = Versioned.value(value);
            // put to nodes
            try {
                // if put does not throw exception
                List<Node> routes = testEnv.routeRequest(key.get());
                for(Node node: routes) {
                    numAssertPuts++;
                    nodeIds.add(node.getId());
                    Store<ByteArray, byte[], byte[]> realStore = testEnv.getRealStore(node.getId());
                    if(realStore instanceof InMemoryPutAssertionStorageEngine) {
View Full Code Here

public class QueryKeyResultTest {

    @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);
View Full Code Here

        assertEquals(null, queryKeyResult.getException());
    }

    @Test
    public void testExceptionCtor() {
        ByteArray key = new ByteArray("key".getBytes());

        Exception e = new Exception();
        QueryKeyResult queryKeyResult = new QueryKeyResult(key, e);

        assertFalse(queryKeyResult.hasValues());
View Full Code Here

     * read-repair
     */

    @Test
    public void testMissingKeysAreAddedToNodeWhenDoingReadRepair() throws Exception {
        ByteArray key = TestUtils.toByteArray("key");
        byte[] value = "foo".getBytes();

        Cluster cluster = VoldemortTestConstants.getThreeNodeCluster();
        StoreDefinition storeDef = ServerTestUtils.getStoreDef("test",
                                                               3,
                                                               3,
                                                               3,
                                                               2,
                                                               2,
                                                               RoutingStrategyType.CONSISTENT_STRATEGY);
        Map<Integer, Store<ByteArray, byte[], byte[]>> subStores = Maps.newHashMap();

        for(int a = 0; a < 3; a++) {
            int id = Iterables.get(cluster.getNodes(), a).getId();
            InMemoryStorageEngine<ByteArray, byte[], byte[]> subStore = new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test");
            subStores.put(id, subStore);
        }

        FailureDetectorConfig failureDetectorConfig = new FailureDetectorConfig().setImplementationClassName(failureDetectorClass.getName())
                                                                                 .setBannagePeriod(1000)
                                                                                 .setCluster(cluster)
                                                                                 .setStoreVerifier(create(subStores))
                                                                                 .setTime(time);

        failureDetector = create(failureDetectorConfig, false);

        routedStoreThreadPool = Executors.newFixedThreadPool(1);

        RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(routedStoreThreadPool);

        RoutedStore store = routedStoreFactory.create(cluster,
                                                      storeDef,
                                                      subStores,
                                                      failureDetector,
                                                      new RoutedStoreConfig().setTimeoutConfig(new TimeoutConfig(1000L,
                                                                                                                 false)));

        recordException(failureDetector, Iterables.get(cluster.getNodes(), 0));
        store.put(key, new Versioned<byte[]>(value), null);
        recordSuccess(failureDetector, Iterables.get(cluster.getNodes(), 0));
        time.sleep(2000);

        assertEquals(2, store.get(key, null).size());
        // Last get should have repaired the missing key from node 0 so all
        // stores should now return a value
        assertEquals(3, store.get(key, null).size());

        ByteArray anotherKey = TestUtils.toByteArray("anotherKey");
        // Try again, now use getAll to read repair
        recordException(failureDetector, Iterables.get(cluster.getNodes(), 0));
        store.put(anotherKey, new Versioned<byte[]>(value), null);
        recordSuccess(failureDetector, Iterables.get(cluster.getNodes(), 0));
        assertEquals(2, store.getAll(Arrays.asList(anotherKey), null).get(anotherKey).size());
View Full Code Here

TOP

Related Classes of voldemort.utils.ByteArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.