use of voldemort.store.StoreDefinition in project voldemort by voldemort.
the class ClusterTestUtils method getZZZ111StoreDefs.
public static List<StoreDefinition> getZZZ111StoreDefs(String storageType) {
List<StoreDefinition> storeDefs = new LinkedList<StoreDefinition>();
HashMap<Integer, Integer> zoneRep111 = new HashMap<Integer, Integer>();
zoneRep111.put(0, 1);
zoneRep111.put(1, 1);
zoneRep111.put(2, 1);
StoreDefinition storeDef111 = new StoreDefinitionBuilder().setName("ZZ111").setType(storageType).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.ZONE_STRATEGY).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setReplicationFactor(3).setZoneReplicationFactor(zoneRep111).setRequiredReads(1).setRequiredWrites(1).setZoneCountReads(0).setZoneCountWrites(0).build();
storeDefs.add(storeDef111);
return storeDefs;
}
use of voldemort.store.StoreDefinition in project voldemort by voldemort.
the class ServerTestUtils method getStoreDefs.
public static List<StoreDefinition> getStoreDefs(int numStores) {
List<StoreDefinition> defs = new ArrayList<StoreDefinition>();
SerializerDefinition serDef = new SerializerDefinition("string");
for (int i = 0; i < numStores; i++) defs.add(new StoreDefinitionBuilder().setName("test" + i).setType(InMemoryStorageConfiguration.TYPE_NAME).setKeySerializer(serDef).setValueSerializer(serDef).setRoutingPolicy(RoutingTier.SERVER).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build());
return defs;
}
use of voldemort.store.StoreDefinition in project voldemort by voldemort.
the class StoreDefinitionsMapper method writeStoreList.
public String writeStoreList(List<StoreDefinition> stores) {
Element root = new Element(STORES_ELMT);
for (StoreDefinition def : stores) {
if (def.isView())
root.addContent(viewToElement(def));
else
root.addContent(storeToElement(def));
}
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(root);
}
use of voldemort.store.StoreDefinition in project voldemort by voldemort.
the class StoreDefinitionsMapper method readView.
private StoreDefinition readView(Element store, List<StoreDefinition> stores) {
String name = store.getChildText(STORE_NAME_ELMT);
String targetName = store.getChildText(VIEW_TARGET_ELMT);
String description = store.getChildText(STORE_DESCRIPTION_ELMT);
String ownerText = store.getChildText(STORE_OWNERS_ELMT);
List<String> owners = Lists.newArrayList();
if (ownerText != null) {
for (String owner : Utils.COMMA_SEP.split(ownerText.trim())) if (owner.trim().length() > 0)
owners.add(owner);
}
StoreDefinition target = StoreUtils.getStoreDef(stores, targetName);
if (target == null)
throw new MappingException("View \"" + name + "\" has target store \"" + targetName + "\" but no such store exists");
int requiredReads = getChildWithDefault(store, STORE_REQUIRED_READS_ELMT, target.getRequiredReads());
int preferredReads = getChildWithDefault(store, STORE_PREFERRED_READS_ELMT, target.getRequiredReads());
int requiredWrites = getChildWithDefault(store, STORE_REQUIRED_WRITES_ELMT, target.getRequiredReads());
int preferredWrites = getChildWithDefault(store, STORE_PREFERRED_WRITES_ELMT, target.getRequiredReads());
Integer zoneCountReads = getChildWithDefault(store, STORE_ZONE_COUNT_READS, target.getZoneCountReads());
Integer zoneCountWrites = getChildWithDefault(store, STORE_ZONE_COUNT_WRITES, target.getZoneCountWrites());
String viewSerializerFactoryName = null;
if (store.getChildText(VIEW_SERIALIZER_FACTORY_ELMT) != null) {
viewSerializerFactoryName = store.getChild(VIEW_SERIALIZER_FACTORY_ELMT).getText();
}
SerializerDefinition keySerializer = target.getKeySerializer();
SerializerDefinition valueSerializer = target.getValueSerializer();
if (store.getChild(STORE_VALUE_SERIALIZER_ELMT) != null)
valueSerializer = readSerializer(store.getChild(STORE_VALUE_SERIALIZER_ELMT));
SerializerDefinition transformSerializer = target.getTransformsSerializer();
if (store.getChild(STORE_TRANSFORM_SERIALIZER_ELMT) != null)
transformSerializer = readSerializer(store.getChild(STORE_TRANSFORM_SERIALIZER_ELMT));
RoutingTier routingTier = null;
if (store.getChildText(STORE_ROUTING_TIER_ELMT) != null) {
routingTier = RoutingTier.fromDisplay(store.getChildText(STORE_ROUTING_TIER_ELMT));
} else {
routingTier = target.getRoutingPolicy();
}
String viewClass = store.getChildText(VIEW_TRANS_ELMT);
return new StoreDefinitionBuilder().setName(name).setViewOf(targetName).setType(ViewStorageConfiguration.TYPE_NAME).setDescription(description).setOwners(owners).setRoutingPolicy(routingTier).setRoutingStrategyType(target.getRoutingStrategyType()).setKeySerializer(keySerializer).setValueSerializer(valueSerializer).setTransformsSerializer(transformSerializer).setReplicationFactor(target.getReplicationFactor()).setZoneReplicationFactor(target.getZoneReplicationFactor()).setPreferredReads(preferredReads).setRequiredReads(requiredReads).setPreferredWrites(preferredWrites).setRequiredWrites(requiredWrites).setZoneCountReads(zoneCountReads).setZoneCountWrites(zoneCountWrites).setView(viewClass).setSerializerFactory(viewSerializerFactoryName).build();
}
use of voldemort.store.StoreDefinition in project voldemort by voldemort.
the class VoldemortAdminTool method executeUpdateEntries.
private static void executeUpdateEntries(Integer nodeId, AdminClient adminClient, List<String> storeNames, String inputDirPath) throws IOException {
List<StoreDefinition> storeDefinitionList = getStoreDefinitions(adminClient, nodeId);
Map<String, StoreDefinition> storeDefinitionMap = Maps.newHashMap();
for (StoreDefinition storeDefinition : storeDefinitionList) {
storeDefinitionMap.put(storeDefinition.getName(), storeDefinition);
}
File inputDir = new File(inputDirPath);
if (!inputDir.exists()) {
throw new FileNotFoundException("input directory " + inputDirPath + " doesn't exist");
}
if (storeNames == null) {
storeNames = Lists.newArrayList();
for (File storeFile : inputDir.listFiles()) {
String fileName = storeFile.getName();
if (fileName.endsWith(".entries")) {
int extPosition = fileName.lastIndexOf(".entries");
storeNames.add(fileName.substring(0, extPosition));
}
}
}
for (String storeName : storeNames) {
Iterator<Pair<ByteArray, Versioned<byte[]>>> iterator = readEntriesBinary(inputDir, storeName);
adminClient.streamingOps.updateEntries(nodeId, storeName, iterator, null);
}
}
Aggregations