use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.
the class RebalanceMetadataConsistencyTest method setUp.
@Before
public void setUp() {
currentCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0 }, { 1, 3 }, { 2 } });
finalCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0 }, { 1 }, { 2 }, { 3 } });
rwStoreDefWithReplication = new StoreDefinitionBuilder().setName(testStoreNameRW).setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
Store<String, String, String> innerStore = new InMemoryStorageEngine<String, String, String>("inner-store");
innerStore.put(MetadataStore.CLUSTER_KEY, new Versioned<String>(new ClusterMapper().writeCluster(currentCluster)), null);
innerStore.put(MetadataStore.STORES_KEY, new Versioned<String>(new StoreDefinitionsMapper().writeStoreList(Lists.newArrayList(rwStoreDefWithReplication))), null);
rwStoreDefWithReplication2 = new StoreDefinitionBuilder().setName(testStoreNameRW2).setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
metadataStore = MetadataStore.createInMemoryMetadataStore(innerStore, 0);
rebalancer = new Rebalancer(null, metadataStore, null, null);
}
use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.
the class StoreRoutingPlanTest method setupNonContiguous.
@Before
public void setupNonContiguous() {
Cluster z1z3Current = ClusterTestUtils.getZ1Z3ClusterWithNonContiguousNodeIds();
HashMap<Integer, Integer> zoneRep211 = new HashMap<Integer, Integer>();
zoneRep211.put(1, 2);
zoneRep211.put(3, 2);
StoreDefinition z1z3211StoreDef = new StoreDefinitionBuilder().setName("z1z3211").setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.ZONE_STRATEGY).setReplicationFactor(4).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).setZoneCountReads(0).setZoneCountWrites(0).setZoneReplicationFactor(zoneRep211).setHintedHandoffStrategy(HintedHandoffStrategyType.PROXIMITY_STRATEGY).build();
z1z3BaseRoutingPlan = new BaseStoreRoutingPlan(z1z3Current, z1z3211StoreDef);
z1z3StoreRoutingPlan = new StoreRoutingPlan(z1z3Current, z1z3211StoreDef);
// 3 zones
Cluster z1z3z5Current = ClusterTestUtils.getZ1Z3Z5ClusterWithNonContiguousNodeIds();
HashMap<Integer, Integer> zoneRep3zones211 = new HashMap<Integer, Integer>();
zoneRep3zones211.put(1, 2);
zoneRep3zones211.put(3, 2);
zoneRep3zones211.put(5, 2);
StoreDefinition z1z3z5211StoreDef = new StoreDefinitionBuilder().setName("z1z3z5211").setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.ZONE_STRATEGY).setReplicationFactor(6).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).setZoneCountReads(0).setZoneCountWrites(0).setZoneReplicationFactor(zoneRep3zones211).setHintedHandoffStrategy(HintedHandoffStrategyType.PROXIMITY_STRATEGY).build();
z1z3z5BaseRoutingPlan = new BaseStoreRoutingPlan(z1z3z5Current, z1z3z5211StoreDef);
z1z3z5StoreRoutingPlan = new StoreRoutingPlan(z1z3z5Current, z1z3z5211StoreDef);
}
use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.
the class GetallNodeReachTest method testGetall_322.
@Test
public void testGetall_322() throws Exception {
cluster = getEightNodeClusterWithZones();
HashMap<Integer, Integer> zoneReplicationFactor = new HashMap<Integer, Integer>();
zoneReplicationFactor.put(0, 3);
zoneReplicationFactor.put(1, 3);
storeDef = new StoreDefinitionBuilder().setName("test").setType(InMemoryStorageConfiguration.TYPE_NAME).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.ZONE_STRATEGY).setReplicationFactor(6).setZoneReplicationFactor(zoneReplicationFactor).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setPreferredReads(2).setRequiredReads(2).setPreferredWrites(2).setRequiredWrites(2).setZoneCountReads(0).setZoneCountWrites(0).build();
makeStore();
Versioned<byte[]> v = Versioned.value("v".getBytes());
subStores.get(0).put(TestUtils.toByteArray("k1111_1111"), v, null);
subStores.get(0).put(TestUtils.toByteArray("k0000_1111"), v, null);
subStores.get(1).put(TestUtils.toByteArray("k1111_1111"), v, null);
subStores.get(1).put(TestUtils.toByteArray("k0000_1111"), v, null);
subStores.get(2).put(TestUtils.toByteArray("k1111_1111"), v, null);
subStores.get(2).put(TestUtils.toByteArray("k0000_1111"), v, null);
subStores.get(3).put(TestUtils.toByteArray("k0000_1111"), v, null);
subStores.get(3).put(TestUtils.toByteArray("k1111_1111"), v, null);
subStores.get(4).put(TestUtils.toByteArray("k1111_1111"), v, null);
subStores.get(4).put(TestUtils.toByteArray("k1111_0000"), v, null);
subStores.get(5).put(TestUtils.toByteArray("k1111_1111"), v, null);
subStores.get(5).put(TestUtils.toByteArray("k1111_0000"), v, null);
subStores.get(6).put(TestUtils.toByteArray("k1111_1111"), v, null);
subStores.get(6).put(TestUtils.toByteArray("k1111_0000"), v, null);
subStores.get(7).put(TestUtils.toByteArray("k1111_1111"), v, null);
subStores.get(7).put(TestUtils.toByteArray("k1111_0000"), v, null);
/* test multiple keys getall */
List<ByteArray> keys = new ArrayList<ByteArray>();
keys.add(TestUtils.toByteArray("k0000_0000"));
keys.add(TestUtils.toByteArray("k0000_1111"));
keys.add(TestUtils.toByteArray("k1111_0000"));
keys.add(TestUtils.toByteArray("k1111_1111"));
Map<ByteArray, List<Versioned<byte[]>>> result = store.getAll(keys, null);
assertFalse(result.containsKey(TestUtils.toByteArray("not_included")));
assertFalse(result.containsKey(TestUtils.toByteArray("k0000_0000")));
assertEquals(2, result.get(TestUtils.toByteArray("k0000_1111")).size());
assertFalse(result.containsKey(TestUtils.toByteArray("k1111_0000")));
assertEquals(2, result.get(TestUtils.toByteArray("k1111_1111")).size());
}
use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.
the class RoutedStoreTest method testPutTimeout.
@Test
public void testPutTimeout() throws Exception {
int timeout = 50;
StoreDefinition definition = new StoreDefinitionBuilder().setName("test").setType("foo").setKeySerializer(new SerializerDefinition("test")).setValueSerializer(new SerializerDefinition("test")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(3).setPreferredReads(3).setRequiredReads(3).setPreferredWrites(3).setRequiredWrites(3).build();
Map<Integer, Store<ByteArray, byte[], byte[]>> stores = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
List<Node> nodes = new ArrayList<Node>();
int totalDelay = 0;
for (int i = 0; i < 3; i++) {
int delay = 4 + i * timeout;
totalDelay += delay;
Store<ByteArray, byte[], byte[]> store = new SleepyStore<ByteArray, byte[], byte[]>(delay, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
stores.put(i, store);
List<Integer> partitions = Arrays.asList(i);
nodes.add(new Node(i, "none", 0, 0, 0, partitions));
}
setFailureDetector(stores);
routedStoreThreadPool = Executors.newFixedThreadPool(3);
RoutedStoreFactory routedStoreFactory = createFactory();
RoutedStore routedStore = routedStoreFactory.create(new Cluster("test", nodes), definition, stores, failureDetector, createConfig(timeout));
long start = System.nanoTime();
try {
routedStore.put(new ByteArray("test".getBytes()), new Versioned<byte[]>(new byte[] { 1 }), null);
fail("Should have thrown");
} catch (InsufficientOperationalNodesException e) {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + totalDelay, elapsed < totalDelay);
}
}
use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.
the class RoutedStoreTest method testGetTimeout.
@Test
public void testGetTimeout() throws Exception {
int timeout = 50;
StoreDefinition definition = new StoreDefinitionBuilder().setName("test").setType("foo").setKeySerializer(new SerializerDefinition("test")).setValueSerializer(new SerializerDefinition("test")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(3).setPreferredReads(3).setRequiredReads(3).setPreferredWrites(3).setRequiredWrites(3).build();
Map<Integer, Store<ByteArray, byte[], byte[]>> stores = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
List<Node> nodes = new ArrayList<Node>();
int totalDelay = 0;
for (int i = 0; i < 3; i++) {
int delay = 4 + i * timeout;
totalDelay += delay;
Store<ByteArray, byte[], byte[]> store = new SleepyStore<ByteArray, byte[], byte[]>(delay, new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
stores.put(i, store);
List<Integer> partitions = Arrays.asList(i);
nodes.add(new Node(i, "none", 0, 0, 0, partitions));
}
setFailureDetector(stores);
routedStoreThreadPool = Executors.newFixedThreadPool(3);
RoutedStoreFactory routedStoreFactory = createFactory();
RoutedStore routedStore = routedStoreFactory.create(new Cluster("test", nodes), definition, stores, failureDetector, createConfig(timeout));
long start = System.nanoTime();
try {
routedStore.get(new ByteArray("test".getBytes()), null);
fail("Should have thrown");
} catch (InsufficientOperationalNodesException e) {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + totalDelay, elapsed < totalDelay);
}
}
Aggregations