use of voldemort.store.slop.SlopStorageEngine in project voldemort by voldemort.
the class DataCleanupJobTest method setUp.
@Before
public void setUp() throws Exception {
time = new MockTime();
storeDir = TestUtils.createTempDir();
FileDeleteStrategy.FORCE.delete(storeDir);
// lets use all the default values.
Props props = new Props();
props.put("node.id", 1);
props.put("voldemort.home", "test/common/voldemort/config");
VoldemortConfig voldemortConfig = new VoldemortConfig(props);
voldemortConfig.setBdbCacheSize(1024 * 1024);
voldemortConfig.setBdbOneEnvPerStore(true);
voldemortConfig.setBdbDataDirectory(storeDir.toURI().getPath());
voldemortConfig.setBdbPrefixKeysWithPartitionId(prefixPartitionId);
bdbStorage = new BdbStorageConfiguration(voldemortConfig);
StoreDefinition storeDef = getStoreDef(START_RETENTION);
engine = bdbStorage.getStore(storeDef, TestUtils.makeSingleNodeRoutingStrategy());
List<Node> nodes = Lists.newArrayList();
nodes.add(new Node(0, "test-host", 1234, 1235, 1236, Arrays.asList(0)));
Cluster cluster = new Cluster("cluster", nodes);
StoreRepository repo = new StoreRepository();
repo.setSlopStore(new SlopStorageEngine(new InMemoryStorageEngine<ByteArray, byte[], byte[]>("slop"), cluster));
repo.addNodeStore(0, engine);
metadataStore = ServerTestUtils.createMetadataStore(cluster, Arrays.asList(storeDef));
}
use of voldemort.store.slop.SlopStorageEngine in project voldemort by voldemort.
the class StreamingSlopPusherTest method testNormalPush.
@Test
public void testNormalPush() throws InterruptedException, IOException {
startServers(0, 1);
// Put into slop store 0
StorageEngine<ByteArray, Slop, byte[]> slopStoreNode0 = getVoldemortServer(0).getStoreRepository().getSlopStore().asSlopStore();
// Generate slops for 1
final List<Versioned<Slop>> entrySet = ServerTestUtils.createRandomSlops(1, 100, "test-replication-memory", "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
populateSlops(0, slopStoreNode0, entrySet);
StreamingSlopPusherJob pusher = new StreamingSlopPusherJob(getVoldemortServer(0).getStoreRepository(), getVoldemortServer(0).getMetadataStore(), new BannagePeriodFailureDetector(new FailureDetectorConfig().setCluster(cluster).setConnectionVerifier(new ServerStoreConnectionVerifier(socketStoreFactory, metadataStore, configs[0]))), configs[0], new ScanPermitWrapper(1));
pusher.run();
// Give some time for the slops to go over
Thread.sleep(2000);
// 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();
assertEquals(slopEngine.getOutstandingTotal(), 0);
assertEquals(slopEngine.getOutstandingByNode().get(1), new Long(0));
assertEquals(slopEngine.getOutstandingByNode().get(2), new Long(0));
stopServers(0, 1);
}
use of voldemort.store.slop.SlopStorageEngine in project voldemort by voldemort.
the class StreamingSlopPusherTest method testFailedServer.
@Test
public void testFailedServer() throws IOException, InterruptedException {
startServers(0, 2);
// Put into slop store 0
StorageEngine<ByteArray, Slop, byte[]> slopStoreNode0 = getVoldemortServer(0).getStoreRepository().getSlopStore().asSlopStore();
// Generate slops for 1
final List<Versioned<Slop>> entrySet1 = ServerTestUtils.createRandomSlops(1, 50, "test-replication-memory", "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
// Generate slops for 2
final List<Versioned<Slop>> entrySet2 = ServerTestUtils.createRandomSlops(2, 50, "test-replication-memory", "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
populateSlops(0, slopStoreNode0, entrySet1, entrySet2);
StreamingSlopPusherJob pusher = new StreamingSlopPusherJob(getVoldemortServer(0).getStoreRepository(), getVoldemortServer(0).getMetadataStore(), new BannagePeriodFailureDetector(new FailureDetectorConfig().setCluster(cluster).setConnectionVerifier(new ServerStoreConnectionVerifier(socketStoreFactory, metadataStore, configs[0]))), configs[0], new ScanPermitWrapper(1));
pusher.run();
// Give some time for the slops to go over
Thread.sleep(2000);
// 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();
assertEquals(slopEngine.getOutstandingTotal(), 50);
assertEquals(slopEngine.getOutstandingByNode().get(1), new Long(50));
assertEquals(slopEngine.getOutstandingByNode().get(2), new Long(0));
stopServers(0, 2);
}
Aggregations