Search in sources :

Example 6 with CompressionStrategyFactory

use of voldemort.store.compress.CompressionStrategyFactory in project voldemort by voldemort.

the class BuildAndPushMapper method configure.

@Override
@SuppressWarnings("unchecked")
public void configure(JobConf conf) {
    super.configure(conf);
    md5er = ByteUtils.getDigest("md5");
    keySerializerDefinition = getStoreDef().getKeySerializer();
    valueSerializerDefinition = getStoreDef().getValueSerializer();
    keyCompressor = new CompressionStrategyFactory().get(keySerializerDefinition.getCompression());
    valueCompressor = new CompressionStrategyFactory().get(valueSerializerDefinition.getCompression());
    routingStrategy = new ConsistentRoutingStrategy(getCluster(), getStoreDef().getReplicationFactor());
}
Also used : ConsistentRoutingStrategy(voldemort.routing.ConsistentRoutingStrategy) CompressionStrategyFactory(voldemort.store.compress.CompressionStrategyFactory)

Example 7 with CompressionStrategyFactory

use of voldemort.store.compress.CompressionStrategyFactory in project voldemort by voldemort.

the class ViewStorageConfiguration method getStore.

public StorageEngine<ByteArray, byte[], byte[]> getStore(StoreDefinition storeDef, RoutingStrategy strategy) {
    String name = storeDef.getName();
    StoreDefinition def = StoreUtils.getStoreDef(storeDefs, name);
    String targetName = def.getViewTargetStoreName();
    StoreDefinition targetDef = StoreUtils.getStoreDef(storeDefs, targetName);
    StorageEngine<ByteArray, byte[], byte[]> target = storeRepo.getStorageEngine(targetName);
    if (target == null)
        throw new VoldemortException("View \"" + name + "\" has a target store \"" + targetName + "\" which does not exist.");
    String factoryName = def.getSerializerFactory();
    SerializerFactory factory;
    if (factoryName == null)
        factory = new DefaultSerializerFactory();
    else
        factory = loadSerializerFactory(factoryName);
    CompressionStrategy valueCompressionStrategy = null;
    if (targetDef.getValueSerializer().hasCompression()) {
        valueCompressionStrategy = new CompressionStrategyFactory().get(targetDef.getValueSerializer().getCompression());
    }
    View<?, ?, ?, ?> view = loadTransformation(def.getValueTransformation());
    return new ViewStorageEngine(name, target, factory.getSerializer(def.getValueSerializer()), def.getTransformsSerializer() != null ? factory.getSerializer(def.getTransformsSerializer()) : null, factory.getSerializer(targetDef.getKeySerializer()), factory.getSerializer(targetDef.getValueSerializer()), valueCompressionStrategy, view);
}
Also used : DefaultSerializerFactory(voldemort.serialization.DefaultSerializerFactory) DefaultSerializerFactory(voldemort.serialization.DefaultSerializerFactory) SerializerFactory(voldemort.serialization.SerializerFactory) StoreDefinition(voldemort.store.StoreDefinition) ByteArray(voldemort.utils.ByteArray) CompressionStrategy(voldemort.store.compress.CompressionStrategy) CompressionStrategyFactory(voldemort.store.compress.CompressionStrategyFactory) VoldemortException(voldemort.VoldemortException)

Example 8 with CompressionStrategyFactory

use of voldemort.store.compress.CompressionStrategyFactory in project voldemort by voldemort.

the class StreamingClientTest method verifyKeysExist.

/*
     * Checks if each node has the keys it is reponsible for returns false
     * otherwise
     */
public boolean verifyKeysExist(int nodeIdToVerifyOn) {
    RoutingStrategyFactory factory = new RoutingStrategyFactory();
    RoutingStrategy storeRoutingStrategy = factory.updateRoutingStrategy(storeDef, adminClient.getAdminClientCluster());
    HashMap<Integer, ArrayList<String>> expectedNodeIdToKeys;
    expectedNodeIdToKeys = new HashMap();
    Collection<Node> nodesInCluster = adminClient.getAdminClientCluster().getNodes();
    for (Node node : nodesInCluster) {
        ArrayList<String> keysForNode = new ArrayList();
        expectedNodeIdToKeys.put(node.getId(), keysForNode);
    }
    for (int i = 0; i < NUM_KEYS_1; i++) {
        String key = i + "";
        String value = key;
        List<Node> nodeList = storeRoutingStrategy.routeRequest(key.getBytes());
        for (Node node : nodeList) {
            ArrayList<String> keysForNode = expectedNodeIdToKeys.get(node.getId());
            keysForNode.add(key);
        }
    }
    ArrayList<String> fetchedKeysForNode = new ArrayList();
    for (Node node : nodesInCluster) {
        List<Integer> partitionIdList = Lists.newArrayList();
        partitionIdList.addAll(node.getPartitionIds());
        Iterator<ByteArray> keyIteratorRef = null;
        keyIteratorRef = adminClient.bulkFetchOps.fetchKeys(node.getId(), TEST_STORE_NAME, partitionIdList, null, false);
        final SerializerDefinition serializerDef = storeDef.getKeySerializer();
        final SerializerFactory serializerFactory = new DefaultSerializerFactory();
        @SuppressWarnings("unchecked") final Serializer<Object> serializer = (Serializer<Object>) serializerFactory.getSerializer(serializerDef);
        final CompressionStrategy keysCompressionStrategy;
        if (serializerDef != null && serializerDef.hasCompression()) {
            keysCompressionStrategy = new CompressionStrategyFactory().get(serializerDef.getCompression());
        } else {
            keysCompressionStrategy = null;
        }
        final Iterator<ByteArray> keyIterator = keyIteratorRef;
        while (keyIterator.hasNext()) {
            byte[] keyBytes = keyIterator.next().get();
            try {
                Object keyObject = serializer.toObject((null == keysCompressionStrategy) ? keyBytes : keysCompressionStrategy.inflate(keyBytes));
                fetchedKeysForNode.add((String) keyObject);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    ArrayList<String> keysForNode = expectedNodeIdToKeys.get(nodeIdToVerifyOn);
    if (!fetchedKeysForNode.containsAll(keysForNode))
        return false;
    else
        return true;
}
Also used : HashMap(java.util.HashMap) RoutingStrategyFactory(voldemort.routing.RoutingStrategyFactory) Node(voldemort.cluster.Node) ArrayList(java.util.ArrayList) CompressionStrategy(voldemort.store.compress.CompressionStrategy) CompressionStrategyFactory(voldemort.store.compress.CompressionStrategyFactory) RoutingStrategy(voldemort.routing.RoutingStrategy) ByteArray(voldemort.utils.ByteArray) Serializer(voldemort.serialization.Serializer) DefaultSerializerFactory(voldemort.serialization.DefaultSerializerFactory) SerializerFactory(voldemort.serialization.SerializerFactory) IOException(java.io.IOException) DefaultSerializerFactory(voldemort.serialization.DefaultSerializerFactory) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Aggregations

CompressionStrategyFactory (voldemort.store.compress.CompressionStrategyFactory)8 DefaultSerializerFactory (voldemort.serialization.DefaultSerializerFactory)6 Serializer (voldemort.serialization.Serializer)6 CompressionStrategy (voldemort.store.compress.CompressionStrategy)6 ByteArray (voldemort.utils.ByteArray)6 Node (voldemort.cluster.Node)5 SerializerDefinition (voldemort.serialization.SerializerDefinition)5 SerializerFactory (voldemort.serialization.SerializerFactory)5 StoreDefinition (voldemort.store.StoreDefinition)5 IOException (java.io.IOException)4 StringSerializer (voldemort.serialization.StringSerializer)4 BufferedWriter (java.io.BufferedWriter)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DataOutputStream (java.io.DataOutputStream)2 GenericRecord (org.apache.avro.generic.GenericRecord)2 JsonFactory (org.codehaus.jackson.JsonFactory)2 JsonGenerator (org.codehaus.jackson.JsonGenerator)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2