Search in sources :

Example 31 with SerializerDefinition

use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.

the class AdminServiceBasicTest method testUpdateMultipleStores.

@Test
public void testUpdateMultipleStores() {
    doClientOperation();
    AdminClient client = getAdminClient();
    List<StoreDefinition> originalStoreDefinitions = client.metadataMgmtOps.getRemoteStoreDefList(0).getValue();
    StoreDefinition oldTestReplicationStore = getStoreDefinitionFromList(originalStoreDefinitions, "test-replication-memory");
    StoreDefinition oldTestRecoveryStore = getStoreDefinitionFromList(originalStoreDefinitions, "test-recovery-data");
    StoreDefinition oldTestBasicStore = getStoreDefinitionFromList(originalStoreDefinitions, "test-basic-replication-memory");
    // Create store definitions for existing stores with different 'safe' changes
    List<StoreDefinition> storesToBeUpdatedList = new ArrayList<StoreDefinition>();
    StoreDefinition definition1 = new StoreDefinitionBuilder().setName("test-replication-memory").setType(InMemoryStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition(oldTestReplicationStore.getKeySerializer().getName())).setValueSerializer(oldTestReplicationStore.getValueSerializer()).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(1).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).setOwners(Collections.singletonList("alice")).build();
    StoreDefinition definition2 = new StoreDefinitionBuilder().setName("test-recovery-data").setType(InMemoryStorageConfiguration.TYPE_NAME).setKeySerializer(oldTestRecoveryStore.getKeySerializer()).setValueSerializer(oldTestRecoveryStore.getValueSerializer()).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(2).setRequiredWrites(1).build();
    StoreDefinition definition3 = new StoreDefinitionBuilder().setName("test-basic-replication-memory").setType(InMemoryStorageConfiguration.TYPE_NAME).setKeySerializer(oldTestBasicStore.getKeySerializer()).setValueSerializer(oldTestBasicStore.getValueSerializer()).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(2).setRequiredReads(1).setPreferredWrites(2).setRequiredWrites(2).build();
    storesToBeUpdatedList.add(definition1);
    storesToBeUpdatedList.add(definition2);
    storesToBeUpdatedList.add(definition3);
    updateAndResetStoreDefinitions(storesToBeUpdatedList);
    doClientOperation();
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) StoreDefinition(voldemort.store.StoreDefinition) ArrayList(java.util.ArrayList) SerializerDefinition(voldemort.serialization.SerializerDefinition) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 32 with SerializerDefinition

use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.

the class AdminServiceBasicTest method testDeleteStore.

@Test
public void testDeleteStore() throws Exception {
    AdminClient adminClient = getAdminClient();
    doClientOperation();
    StoreDefinition definition = new StoreDefinitionBuilder().setName("deleteTest").setType(InMemoryStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(1).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
    adminClient.storeMgmtOps.addStore(definition);
    // now test the store
    StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setCacheStoreClients(false).setBootstrapUrls(cluster.getNodeById(0).getSocketUrl().toString()));
    StoreClient<Object, Object> client = factory.getStoreClient("deleteTest");
    int numStores = adminClient.metadataMgmtOps.getRemoteStoreDefList(0).getValue().size();
    // delete the store
    assertEquals(adminClient.metadataMgmtOps.getRemoteStoreDefList(0).getValue().contains(definition), true);
    adminClient.storeMgmtOps.deleteStore("deleteTest");
    assertEquals(adminClient.metadataMgmtOps.getRemoteStoreDefList(0).getValue().size(), numStores - 1);
    assertEquals(adminClient.metadataMgmtOps.getRemoteStoreDefList(0).getValue().contains(definition), false);
    // will attempt to bootstrap)
    try {
        client = factory.getStoreClient("deleteTest");
        client.put("abc", "123");
        String s = (String) client.get("abc").getValue();
        assertEquals(s, "123");
        fail("Should have received bootstrap failure exception");
    } catch (Exception e) {
        if (!(e instanceof BootstrapFailureException))
            throw e;
    }
    doClientOperation();
    // try adding the store again
    adminClient.storeMgmtOps.addStore(definition);
    client = factory.getStoreClient("deleteTest");
    client.put("abc", "123");
    String s = (String) client.get("abc").getValue();
    assertEquals(s, "123");
    doClientOperation();
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) VoldemortException(voldemort.VoldemortException) VoldemortApplicationException(voldemort.VoldemortApplicationException) IOException(java.io.IOException) InvalidMetadataException(voldemort.store.InvalidMetadataException) StoreDefinition(voldemort.store.StoreDefinition) AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) SerializerDefinition(voldemort.serialization.SerializerDefinition) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 33 with SerializerDefinition

use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.

the class AdminServiceBasicTest method testUpdateSerializerFails.

@Test(expected = VoldemortException.class)
public void testUpdateSerializerFails() {
    doClientOperation();
    AdminClient client = getAdminClient();
    List<StoreDefinition> originalStoreDefinitions = client.metadataMgmtOps.getRemoteStoreDefList(0).getValue();
    StoreDefinition oldStore = getStoreDefinitionFromList(originalStoreDefinitions, "test-replication-memory");
    // Create a store definition for an existing store with a different
    // replication factor
    List<StoreDefinition> storesToBeUpdatedList = new ArrayList<StoreDefinition>();
    String storeName = "test-replication-memory";
    StoreDefinition definitionNew = new StoreDefinitionBuilder().setName(storeName).setType(InMemoryStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("changing-the-serializer")).setValueSerializer(oldStore.getValueSerializer()).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
    storesToBeUpdatedList.add(definitionNew);
    updateAndResetStoreDefinitions(storesToBeUpdatedList);
    doClientOperation();
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) StoreDefinition(voldemort.store.StoreDefinition) ArrayList(java.util.ArrayList) SerializerDefinition(voldemort.serialization.SerializerDefinition) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 34 with SerializerDefinition

use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.

the class E2EClientRequestExecutorPoolAndFailureDetectorTest method getStoreDef.

public static List<StoreDefinition> getStoreDef() {
    List<StoreDefinition> defs = new ArrayList<StoreDefinition>();
    SerializerDefinition serDef = new SerializerDefinition("string");
    String storageConfiguration = SlowStorageConfiguration.TYPE_NAME;
    defs.add(new StoreDefinitionBuilder().setName(STORE_NAME).setType(storageConfiguration).setKeySerializer(serDef).setValueSerializer(serDef).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setHintedHandoffStrategy(HintedHandoffStrategyType.PROXIMITY_STRATEGY).setReplicationFactor(3).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build());
    return defs;
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) StoreDefinition(voldemort.store.StoreDefinition) ArrayList(java.util.ArrayList) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Example 35 with SerializerDefinition

use of voldemort.serialization.SerializerDefinition in project voldemort by voldemort.

the class StreamingClientTest method configs.

@Parameterized.Parameters
public static Collection<Object[]> configs() {
    StoreDefinition storeDefConsistentStrategy = new StoreDefinitionBuilder().setName(TEST_STORE_NAME).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(2).setRequiredWrites(2).build();
    HashMap<Integer, Integer> zoneReplicationFactor = new HashMap<Integer, Integer>();
    zoneReplicationFactor.put(1, 2);
    zoneReplicationFactor.put(3, 2);
    StoreDefinition storeDefZoneStrategy = new StoreDefinitionBuilder().setName(TEST_STORE_NAME).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(zoneReplicationFactor).setHintedHandoffStrategy(HintedHandoffStrategyType.PROXIMITY_STRATEGY).build();
    return Arrays.asList(new Object[][] { { 2, ServerTestUtils.getLocalCluster(2, new int[][] { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } }), 0, storeDefConsistentStrategy }, { 2, ServerTestUtils.getLocalNonContiguousNodesCluster(new int[] { 1, 3 }, new int[][] { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } }), 1, storeDefConsistentStrategy }, { 6, ClusterTestUtils.getZ1Z3ClusterWithNonContiguousNodeIds(), 3, storeDefZoneStrategy } });
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) HashMap(java.util.HashMap) StoreDefinition(voldemort.store.StoreDefinition) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Aggregations

SerializerDefinition (voldemort.serialization.SerializerDefinition)65 StoreDefinitionBuilder (voldemort.store.StoreDefinitionBuilder)46 StoreDefinition (voldemort.store.StoreDefinition)38 HashMap (java.util.HashMap)31 ArrayList (java.util.ArrayList)22 ByteArray (voldemort.utils.ByteArray)19 Test (org.junit.Test)18 DefaultSerializerFactory (voldemort.serialization.DefaultSerializerFactory)15 File (java.io.File)14 Cluster (voldemort.cluster.Cluster)12 Node (voldemort.cluster.Node)11 LinkedList (java.util.LinkedList)10 IOException (java.io.IOException)9 Serializer (voldemort.serialization.Serializer)9 List (java.util.List)8 VoldemortException (voldemort.VoldemortException)8 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)8 StatTrackingStore (voldemort.store.stats.StatTrackingStore)7 Before (org.junit.Before)6 Store (voldemort.store.Store)6