Search in sources :

Example 11 with ClusterMapper

use of voldemort.xml.ClusterMapper in project voldemort by voldemort.

the class VoldemortServer method getTestMetadataStore.

private static MetadataStore getTestMetadataStore(VoldemortConfig voldemortConfig, Cluster cluster) {
    ConfigurationStorageEngine metadataInnerEngine = new ConfigurationStorageEngine("metadata-config-store", voldemortConfig.getMetadataDirectory());
    List<Versioned<String>> clusterXmlValue = metadataInnerEngine.get(MetadataStore.CLUSTER_KEY, null);
    VectorClock version = null;
    if (clusterXmlValue.size() <= 0) {
        version = new VectorClock();
    } else {
        version = (VectorClock) clusterXmlValue.get(0).getVersion();
    }
    int nodeId = getNodeId(voldemortConfig, cluster);
    version.incrementVersion(nodeId, System.currentTimeMillis());
    metadataInnerEngine.put(MetadataStore.CLUSTER_KEY, new Versioned<String>(new ClusterMapper().writeCluster(cluster), version), null);
    return MetadataStore.createInMemoryMetadataStore(metadataInnerEngine, nodeId);
}
Also used : Versioned(voldemort.versioning.Versioned) VectorClock(voldemort.versioning.VectorClock) ConfigurationStorageEngine(voldemort.store.configuration.ConfigurationStorageEngine) ClusterMapper(voldemort.xml.ClusterMapper)

Example 12 with ClusterMapper

use of voldemort.xml.ClusterMapper in project voldemort by voldemort.

the class ServerTestUtils method getStores.

public static StoreRepository getStores(String storeName, String clusterXml, String storesXml) {
    StoreRepository repository = new StoreRepository();
    Store<ByteArray, byte[], byte[]> store = new InMemoryStorageEngine<ByteArray, byte[], byte[]>(storeName);
    repository.addLocalStore(store);
    repository.addRoutedStore(store);
    // create new metadata store.
    MetadataStore metadata = createMetadataStore(new ClusterMapper().readCluster(new StringReader(clusterXml)), new StoreDefinitionsMapper().readStoreList(new StringReader(storesXml)));
    repository.addLocalStore(metadata);
    return repository;
}
Also used : MetadataStore(voldemort.store.metadata.MetadataStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StringReader(java.io.StringReader) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ByteArray(voldemort.utils.ByteArray) StoreRepository(voldemort.server.StoreRepository) ClusterMapper(voldemort.xml.ClusterMapper)

Example 13 with ClusterMapper

use of voldemort.xml.ClusterMapper in project voldemort by voldemort.

the class ServerTestUtils method createMetadataStore.

public static MetadataStore createMetadataStore(Cluster cluster, List<StoreDefinition> storeDefs) {
    Store<String, String, String> innerStore = new InMemoryStorageEngine<String, String, String>("inner-store");
    innerStore.put(MetadataStore.CLUSTER_KEY, new Versioned<String>(new ClusterMapper().writeCluster(cluster)), null);
    innerStore.put(MetadataStore.STORES_KEY, new Versioned<String>(new StoreDefinitionsMapper().writeStoreList(storeDefs)), null);
    return MetadataStore.createInMemoryMetadataStore(innerStore, 0);
}
Also used : InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ClusterMapper(voldemort.xml.ClusterMapper)

Example 14 with ClusterMapper

use of voldemort.xml.ClusterMapper in project voldemort by voldemort.

the class ServerTestUtils method createMetadataStore.

public static MetadataStore createMetadataStore(Cluster cluster, List<StoreDefinition> storeDefs, int nodeId) {
    Store<String, String, String> innerStore = new InMemoryStorageEngine<String, String, String>("inner-store");
    innerStore.put(MetadataStore.CLUSTER_KEY, new Versioned<String>(new ClusterMapper().writeCluster(cluster)), null);
    innerStore.put(MetadataStore.STORES_KEY, new Versioned<String>(new StoreDefinitionsMapper().writeStoreList(storeDefs)), null);
    return MetadataStore.createInMemoryMetadataStore(innerStore, nodeId);
}
Also used : InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ClusterMapper(voldemort.xml.ClusterMapper)

Example 15 with ClusterMapper

use of voldemort.xml.ClusterMapper in project voldemort by voldemort.

the class ZoneShrinkageCLI method shrinkClusterXml.

protected static String shrinkClusterXml(String clusterXml, int droppingZoneId) {
    Cluster initialCluster = new ClusterMapper().readCluster(new StringReader(clusterXml));
    Cluster intermediateCluster = RebalanceUtils.vacateZone(initialCluster, droppingZoneId);
    Cluster finalCluster = RebalanceUtils.dropZone(intermediateCluster, droppingZoneId);
    String newClusterXml = new ClusterMapper().writeCluster(finalCluster);
    return newClusterXml;
}
Also used : StringReader(java.io.StringReader) Cluster(voldemort.cluster.Cluster) ClusterMapper(voldemort.xml.ClusterMapper)

Aggregations

ClusterMapper (voldemort.xml.ClusterMapper)41 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)26 Cluster (voldemort.cluster.Cluster)23 File (java.io.File)18 StoreDefinition (voldemort.store.StoreDefinition)18 StringReader (java.io.StringReader)13 OptionSet (joptsimple.OptionSet)10 Node (voldemort.cluster.Node)10 AdminClient (voldemort.client.protocol.admin.AdminClient)9 VoldemortException (voldemort.VoldemortException)8 Test (org.junit.Test)6 ByteArray (voldemort.utils.ByteArray)6 Versioned (voldemort.versioning.Versioned)6 OptionParser (joptsimple.OptionParser)5 IOException (java.io.IOException)4 InMemoryStorageEngine (voldemort.store.memory.InMemoryStorageEngine)4 FileNotFoundException (java.io.FileNotFoundException)3 ClientConfig (voldemort.client.ClientConfig)3 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)3 BufferedReader (java.io.BufferedReader)2