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());
}
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);
}
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;
}
Aggregations