Search in sources :

Example 61 with SerializerDefinition

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

the class ServerTestUtils method getStoreDef.

public static StoreDefinition getStoreDef(String storeName, int preads, int rreads, int pwrites, int rwrites, int zonereads, int zonewrites, HashMap<Integer, Integer> zoneReplicationFactor, HintedHandoffStrategyType hhType, String strategyType) {
    SerializerDefinition serDef = new SerializerDefinition("string");
    int replicationFactor = 0;
    for (Integer repFac : zoneReplicationFactor.values()) {
        replicationFactor += repFac;
    }
    return new StoreDefinitionBuilder().setName(storeName).setType(InMemoryStorageConfiguration.TYPE_NAME).setKeySerializer(serDef).setValueSerializer(serDef).setRoutingPolicy(RoutingTier.SERVER).setRoutingStrategyType(strategyType).setPreferredReads(preads).setRequiredReads(rreads).setHintedHandoffStrategy(hhType).setZoneCountReads(zonereads).setZoneCountWrites(zonewrites).setReplicationFactor(replicationFactor).setZoneReplicationFactor(zoneReplicationFactor).setPreferredWrites(pwrites).setRequiredWrites(rwrites).build();
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Example 62 with SerializerDefinition

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

the class StoreDefinitionUtils method validateSchemaAsNeeded.

/**
 * Validate store schema -- backward compatibility if it is AVRO generic
 * versioned -- sanity checks for avro in general
 *
 * @param storeDefinition the store definition to check on
 */
public static void validateSchemaAsNeeded(StoreDefinition storeDefinition) {
    logger.info("Validating schema for store: " + storeDefinition.getName());
    SerializerDefinition keySerDef = storeDefinition.getKeySerializer();
    // validate the key schemas
    try {
        validateIfAvroSchema(keySerDef);
    } catch (Exception e) {
        logger.error("Validating key schema failed for store:  " + storeDefinition.getName());
        throw new VoldemortException("Error validating key schema for store:  " + storeDefinition.getName() + " " + e.getMessage(), e);
    }
    // validate the value schemas
    SerializerDefinition valueSerDef = storeDefinition.getValueSerializer();
    try {
        validateIfAvroSchema(valueSerDef);
    } catch (Exception e) {
        logger.error("Validating value schema failed for store:  " + storeDefinition.getName());
        throw new VoldemortException("Error validating value schema for store:  " + storeDefinition.getName() + " " + e.getMessage(), e);
    }
}
Also used : VoldemortException(voldemort.VoldemortException) SerializerDefinition(voldemort.serialization.SerializerDefinition) VoldemortException(voldemort.VoldemortException)

Example 63 with SerializerDefinition

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

the class RoutedStoreTest method testOperationSpecificTimeouts.

@Test
public void testOperationSpecificTimeouts() throws Exception {
    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>();
    for (int i = 0; i < 3; i++) {
        Store<ByteArray, byte[], byte[]> store = new SleepyStore<ByteArray, byte[], byte[]>(200, 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);
    // with a 500ms general timeout and a 100ms get timeout, only get should
    // fail
    TimeoutConfig timeoutConfig = new TimeoutConfig(1500, false);
    timeoutConfig.setOperationTimeout(VoldemortOpCode.GET_OP_CODE, 100);
    RoutedStoreFactory routedStoreFactory = createFactory();
    RoutedStore routedStore = routedStoreFactory.create(new Cluster("test", nodes), definition, stores, failureDetector, createConfig(timeoutConfig));
    try {
        routedStore.put(new ByteArray("test".getBytes()), new Versioned<byte[]>(new byte[] { 1 }), null);
    } catch (InsufficientOperationalNodesException e) {
        fail("Should not have failed");
    }
    try {
        routedStore.get(new ByteArray("test".getBytes()), null);
        fail("Should have thrown");
    } catch (InsufficientOperationalNodesException e) {
    }
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) TimeoutConfig(voldemort.client.TimeoutConfig) HashMap(java.util.HashMap) Node(voldemort.cluster.Node) ArrayList(java.util.ArrayList) Store(voldemort.store.Store) SleepyStore(voldemort.store.SleepyStore) StatTrackingStore(voldemort.store.stats.StatTrackingStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) FailingStore(voldemort.store.FailingStore) FailingReadsStore(voldemort.store.FailingReadsStore) VoldemortTestConstants.getNineNodeCluster(voldemort.VoldemortTestConstants.getNineNodeCluster) Cluster(voldemort.cluster.Cluster) SleepyStore(voldemort.store.SleepyStore) StoreDefinition(voldemort.store.StoreDefinition) InsufficientOperationalNodesException(voldemort.store.InsufficientOperationalNodesException) ByteArray(voldemort.utils.ByteArray) SerializerDefinition(voldemort.serialization.SerializerDefinition) AbstractByteArrayStoreTest(voldemort.store.AbstractByteArrayStoreTest) Test(org.junit.Test)

Example 64 with SerializerDefinition

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

the class ClusterForkLiftTool method checkStoresOnBothSides.

private HashMap<String, StoreDefinition> checkStoresOnBothSides(boolean ignoreSchemaMismatch) {
    List<StoreDefinition> srcStoreDefs = getStoreDefinitions(srcAdminClient);
    HashMap<String, StoreDefinition> srcStoreDefMap = StoreUtils.getStoreDefsAsMap(srcStoreDefs);
    List<StoreDefinition> dstStoreDefs = getStoreDefinitions(dstStreamingClient.getAdminClient());
    HashMap<String, StoreDefinition> dstStoreDefMap = StoreUtils.getStoreDefsAsMap(dstStoreDefs);
    Set<String> storesToSkip = new HashSet<String>();
    for (String store : storesList) {
        if (!srcStoreDefMap.containsKey(store)) {
            String message = "Store " + store + " does not exist in source cluster ";
            logger.warn(message);
            throw new VoldemortApplicationException(message);
        }
        StoreDefinition srcStoreDef = srcStoreDefMap.get(store);
        if (!dstStoreDefMap.containsKey(store)) {
            String message = "Store " + store + " does not exist in destination cluster ";
            logger.warn(message);
            throw new VoldemortApplicationException(message);
        }
        StoreDefinition dstStoreDef = dstStoreDefMap.get(store);
        if (!ignoreSchemaMismatch) {
            SerializerDefinition srcKeySerializer = srcStoreDef.getKeySerializer();
            SerializerDefinition dstKeySerializer = dstStoreDef.getKeySerializer();
            if (srcKeySerializer.semanticEquals(dstKeySerializer) == false) {
                String message = "Store " + store + " Key schema does not match between Source and destination \n";
                message += "Source : " + srcKeySerializer.getFormattedString() + "\n";
                message += "Destination : " + dstKeySerializer.getFormattedString() + "\n";
                logger.warn(message);
                throw new VoldemortApplicationException(message);
            }
            SerializerDefinition srcValueSerializer = srcStoreDef.getValueSerializer();
            SerializerDefinition dstValueSerializer = dstStoreDef.getValueSerializer();
            if (srcValueSerializer.semanticEquals(dstValueSerializer) == false) {
                String message = "Store " + store + " Value schema does not match between Source and destination \n";
                message += "Source : " + srcValueSerializer.getFormattedString() + "\n";
                message += "Destination : " + dstValueSerializer.getFormattedString() + "\n";
                logger.warn(message);
                throw new VoldemortApplicationException(message);
            }
        }
    }
    return srcStoreDefMap;
}
Also used : VoldemortApplicationException(voldemort.VoldemortApplicationException) StoreDefinition(voldemort.store.StoreDefinition) SerializerDefinition(voldemort.serialization.SerializerDefinition) HashSet(java.util.HashSet)

Example 65 with SerializerDefinition

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

the class E2ENonblockingCheckoutTest method getStoreDef.

public static List<StoreDefinition> getStoreDef(int nodeId) {
    List<StoreDefinition> defs = new ArrayList<StoreDefinition>();
    SerializerDefinition serDef = new SerializerDefinition("string");
    String storageConfiguration = InMemoryStorageConfiguration.TYPE_NAME;
    if (nodeId == 2) {
        storageConfiguration = SlowStorageConfiguration.TYPE_NAME;
    }
    defs.add(new StoreDefinitionBuilder().setName(STORE_NAME).setType(storageConfiguration).setKeySerializer(serDef).setValueSerializer(serDef).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_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)

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