Package voldemort.store.slop

Examples of voldemort.store.slop.Slop


            nodes.add(new Node(i, Integer.toString(i), 1234, 1235, 1236, Arrays.asList(i)));
        return new Cluster("cluster", nodes);
    }

    private Versioned<Slop> randomSlop(String name, int nodeId) {
        return Versioned.value(new Slop(name,
                                        Operation.PUT,
                                        TestUtils.randomBytes(10),
                                        TestUtils.randomBytes(10),
                                        nodeId,
                                        new Date()));
View Full Code Here


        // those items
        for(Versioned<Slop> vs: delivered) {
            // check that all the slops are in the stores
            // and no new slops have appeared
            // and the SloppyStore is now empty
            Slop slop = vs.getValue();
            assertEquals("Slop remains.", 0, repo.getSlopStore().get(slop.makeKey(), null).size());
            assertTrue(bytesEqual(slop.getValue(), repo.getNodeStore(STORE_NAME, slop.getNodeId())
                                                       .get(slop.getKey(), null)
                                                       .get(0)
                                                       .getValue()));
        }
        // check that all undelivered slop is undelivered
        for(Versioned<Slop> vs: undelivered) {
            Slop slop = vs.getValue();
            assertEquals("Slop is gone!", 1, repo.getSlopStore().get(slop.makeKey(), null).size());
        }
    }
View Full Code Here

    public Set<Slop> getAllSlops(Iterable<ByteArray> slopKeys) {
        Set<Slop> registeredSlops = Sets.newHashSet();
        for(Store<ByteArray, Slop, byte[]> slopStore: slopStores.values()) {
            Map<ByteArray, List<Versioned<Slop>>> res = slopStore.getAll(slopKeys, null);
            for(Map.Entry<ByteArray, List<Versioned<Slop>>> entry: res.entrySet()) {
                Slop slop = entry.getValue().get(0).getValue();
                registeredSlops.add(slop);
                logger.info(slop);
            }
        }
        return registeredSlops;
View Full Code Here

        // 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;
    }
View Full Code Here

        // Now check if the slops went through and also got deleted
        Iterator<Versioned<Slop>> entryIterator = entrySet2.listIterator();
        while(entryIterator.hasNext()) {
            Versioned<Slop> versionedSlop = entryIterator.next();
            Slop nextSlop = versionedSlop.getValue();
            StorageEngine<ByteArray, byte[], byte[]> store = getVoldemortServer(2).getStoreRepository()
                                                                                  .getStorageEngine(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());
            }

            // did it get deleted correctly
            assertEquals("slop should have gone", 0, slopStoreNode0.get(nextSlop.makeKey(), null)
                                                                   .size());
        }

        entryIterator = entrySet1.listIterator();
        while(entryIterator.hasNext()) {
            Versioned<Slop> versionedSlop = entryIterator.next();
            Slop nextSlop = versionedSlop.getValue();
            // did it get deleted correctly
            assertNotSame("slop should be there", 0, slopStoreNode0.get(nextSlop.makeKey(), null)
                                                                   .size());
        }

        // Check counts
        SlopStorageEngine slopEngine = getVoldemortServer(0).getStoreRepository().getSlopStore();
View Full Code Here

        List<Versioned<Slop>> entrySet = Lists.newArrayList();
        for(String storeName: Lists.newArrayList("test-replication-memory",
                                                 "users",
                                                 "test-replication-persistent")) {
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.PUT,
                                                  key1,
                                                  value1,
                                                  null,
                                                  1,
                                                  new Date()), vectorClock1));
            vectorClock1 = vectorClock1.incremented(0, System.currentTimeMillis());
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.DELETE,
                                                  key1,
                                                  null,
                                                  null,
                                                  1,
                                                  new Date()), vectorClock1));
            vectorClock1 = vectorClock1.incremented(0, System.currentTimeMillis());
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.PUT,
                                                  key1,
                                                  value2,
                                                  null,
                                                  1,
                                                  new Date()), vectorClock1));

            vectorClock2 = vectorClock2.incremented(0, System.currentTimeMillis());
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.PUT,
                                                  key2,
                                                  value2,
                                                  null,
                                                  1,
                                                  new Date()), vectorClock2));
            vectorClock2 = vectorClock2.incremented(0, System.currentTimeMillis());
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.DELETE,
                                                  key2,
                                                  null,
                                                  null,
                                                  1,
View Full Code Here

        // Now check if the slops went through and also got deleted
        Iterator<Versioned<Slop>> entryIterator = entrySet.listIterator();
        while(entryIterator.hasNext()) {
            Versioned<Slop> versionedSlop = entryIterator.next();
            Slop nextSlop = versionedSlop.getValue();
            StorageEngine<ByteArray, byte[], byte[]> store = getVoldemortServer(1).getStoreRepository()
                                                                                  .getStorageEngine(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());
            }

            // did it get deleted correctly
            assertEquals("slop should have gone", 0, slopStoreNode0.get(nextSlop.makeKey(), null)
                                                                   .size());
        }

        // Check counts
        SlopStorageEngine slopEngine = getVoldemortServer(0).getStoreRepository().getSlopStore();
View Full Code Here

    private void assertSerializes(Slop slop) {
        assertEquals(slop, this.serializer.toObject(this.serializer.toBytes(slop)));
    }

    public void testSerialization() {
        assertSerializes(new Slop("test",
                                  Slop.Operation.DELETE,
                                  "hello".getBytes(),
                                  new byte[] { 1 },
                                  1,
                                  new Date()));
        assertSerializes(new Slop("test",
                                  Slop.Operation.PUT,
                                  "".getBytes(),
                                  new byte[] {},
                                  1,
                                  new Date()));
        assertSerializes(new Slop("test",
                                  Slop.Operation.PUT,
                                  "hello".getBytes(),
                                  null,
                                  1,
                                  new Date()));
View Full Code Here

        Map<Integer, Map<ByteArray, byte[]>> nodeToSlopData = new HashMap<Integer, Map<ByteArray, byte[]>>();
        Set<ByteArray> slopKeys = makeSlopKeys(nodeToFailedKeysMap, Slop.Operation.PUT);
        for(Store<ByteArray, Slop, byte[]> slopStore: slopStores.values()) {
            Map<ByteArray, List<Versioned<Slop>>> getAllResult = slopStore.getAll(slopKeys, null);
            for(Map.Entry<ByteArray, List<Versioned<Slop>>> entry: getAllResult.entrySet()) {
                Slop slop = entry.getValue().get(0).getValue();
                Integer nodeId = slop.getNodeId();
                // get data
                if(!nodeToSlopData.containsKey(nodeId)) {
                    nodeToSlopData.put(nodeId, new HashMap<ByteArray, byte[]>());
                }
                Map<ByteArray, byte[]> perNodeSlopMap = nodeToSlopData.get(nodeId);
                perNodeSlopMap.put(slop.getKey(), slop.getValue());

                if(logger.isTraceEnabled())
                    logger.trace(slop);
            }
        }
View Full Code Here

        // Now check if the slops worked
        Iterator<Versioned<Slop>> entryIterator0 = entrySetNode0.listIterator();
        while(entryIterator0.hasNext()) {
            Versioned<Slop> versionedSlop = entryIterator0.next();
            Slop nextSlop = versionedSlop.getValue();
            StorageEngine<ByteArray, byte[], byte[]> store = getVoldemortServer(1).getStoreRepository()
                                                                                  .getStorageEngine(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());
            }
            // did it get deleted correctly
            assertEquals("slop should have gone", 0, slopStoreNode0.get(nextSlop.makeKey(), null)
                                                                   .size());
        }

        Iterator<Versioned<Slop>> entryIterator1 = entrySetNode1.listIterator();
        while(entryIterator1.hasNext()) {
            Versioned<Slop> versionedSlop = entryIterator1.next();
            Slop nextSlop = versionedSlop.getValue();
            StorageEngine<ByteArray, byte[], byte[]> store = getVoldemortServer(0).getStoreRepository()
                                                                                  .getStorageEngine(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());
            }
            // did it get deleted correctly
            assertEquals("slop should have gone", 0, slopStoreNode1.get(nextSlop.makeKey(), null)
                                                                   .size());
        }

        // Check counts
        SlopStorageEngine slopEngine = getVoldemortServer(0).getStoreRepository().getSlopStore();
View Full Code Here

TOP

Related Classes of voldemort.store.slop.Slop

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.