Search in sources :

Example 61 with StoreDefinition

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;
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) HashMap(java.util.HashMap) StoreDefinition(voldemort.store.StoreDefinition) LinkedList(java.util.LinkedList) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Example 62 with StoreDefinition

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;
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) StoreDefinition(voldemort.store.StoreDefinition) ArrayList(java.util.ArrayList) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Example 63 with StoreDefinition

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);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Element(org.jdom.Element) StoreDefinition(voldemort.store.StoreDefinition)

Example 64 with StoreDefinition

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();
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) RoutingTier(voldemort.client.RoutingTier) StoreDefinition(voldemort.store.StoreDefinition) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Example 65 with StoreDefinition

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);
    }
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) Pair(voldemort.utils.Pair)

Aggregations

StoreDefinition (voldemort.store.StoreDefinition)215 Cluster (voldemort.cluster.Cluster)74 Test (org.junit.Test)67 ArrayList (java.util.ArrayList)56 HashMap (java.util.HashMap)50 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)50 VoldemortException (voldemort.VoldemortException)49 ByteArray (voldemort.utils.ByteArray)49 Node (voldemort.cluster.Node)43 StoreDefinitionBuilder (voldemort.store.StoreDefinitionBuilder)42 SerializerDefinition (voldemort.serialization.SerializerDefinition)38 File (java.io.File)34 StringReader (java.io.StringReader)34 Versioned (voldemort.versioning.Versioned)29 IOException (java.io.IOException)24 List (java.util.List)23 Store (voldemort.store.Store)21 AdminClient (voldemort.client.protocol.admin.AdminClient)19 RoutingStrategyFactory (voldemort.routing.RoutingStrategyFactory)19 ClusterMapper (voldemort.xml.ClusterMapper)18