Search in sources :

Example 41 with StoreDefinitionsMapper

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

the class RebalancePlanCLI method main.

public static void main(String[] args) throws Exception {
    setupParser();
    OptionSet options = getValidOptions(args);
    // Required args
    String currentClusterXML = (String) options.valueOf("current-cluster");
    String currentStoresXML = (String) options.valueOf("current-stores");
    String finalClusterXML = (String) options.valueOf("final-cluster");
    // Required args for some use cases
    String finalStoresXML = new String(currentStoresXML);
    if (options.has("final-stores")) {
        finalStoresXML = (String) options.valueOf("final-stores");
    }
    Cluster currentCluster = new ClusterMapper().readCluster(new File(currentClusterXML));
    List<StoreDefinition> currentStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(currentStoresXML));
    Cluster finalCluster = new ClusterMapper().readCluster(new File(finalClusterXML));
    List<StoreDefinition> finalStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(finalStoresXML));
    // Optional args
    int batchSize = CmdUtils.valueOf(options, "batch-size", RebalancePlan.BATCH_SIZE);
    String outputDir = null;
    if (options.has("output-dir")) {
        outputDir = (String) options.valueOf("output-dir");
    }
    new RebalancePlan(currentCluster, currentStoreDefs, finalCluster, finalStoreDefs, batchSize, outputDir);
}
Also used : RebalancePlan(voldemort.client.rebalance.RebalancePlan) StoreDefinition(voldemort.store.StoreDefinition) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Cluster(voldemort.cluster.Cluster) ClusterMapper(voldemort.xml.ClusterMapper) OptionSet(joptsimple.OptionSet) File(java.io.File)

Example 42 with StoreDefinitionsMapper

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

the class ReplaceNodeCLI method init.

private void init() {
    this.adminClient = new AdminClient(this.url);
    this.newAdminClient = new AdminClient(this.newUrl);
    this.cluster = adminClient.getAdminClientCluster();
    // Validate node exists in the old cluster
    this.cluster.getNodeById(nodeId);
    this.newCluster = newAdminClient.getAdminClientCluster();
    if (newCluster.getNumberOfNodes() > 1) {
        newNodeId = nodeId;
    } else {
        newNodeId = newCluster.getNodeIds().iterator().next().intValue();
    }
    this.clusterXml = getClusterXML();
    // Update your cluster XML based on the consensus
    this.cluster = new ClusterMapper().readCluster(new StringReader(clusterXml));
    this.storesXml = getStoresXML();
    this.storeDefinitions = new StoreDefinitionsMapper().readStoreList(new StringReader(storesXml), false);
}
Also used : StringReader(java.io.StringReader) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ClusterMapper(voldemort.xml.ClusterMapper) AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 43 with StoreDefinitionsMapper

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

the class StreamingSlopPusherTest method replaceOneNode.

private void replaceOneNode(int nodeId) throws IOException {
    Cluster oldCluster = cluster;
    cluster = ServerTestUtils.getLocalClusterWithOneNodeReplaced(cluster, nodeId);
    metadataStore = ServerTestUtils.createMetadataStore(cluster, new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile)));
    String newClusterXml = new ClusterMapper().writeCluster(cluster);
    AdminClient adminClient = ServerTestUtils.getAdminClient(oldCluster);
    for (Integer remoteNodeId : oldCluster.getNodeIds()) {
        try {
            adminClient.metadataMgmtOps.updateRemoteMetadata(remoteNodeId, MetadataStore.CLUSTER_KEY, newClusterXml);
        } catch (UnreachableStoreException e) {
        }
    }
}
Also used : StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Cluster(voldemort.cluster.Cluster) ClusterMapper(voldemort.xml.ClusterMapper) UnreachableStoreException(voldemort.store.UnreachableStoreException) File(java.io.File) AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 44 with StoreDefinitionsMapper

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

the class StreamingSlopPusherTest method setUp.

@Before
public void setUp() throws Exception {
    cluster = ServerTestUtils.getLocalCluster(NUM_SERVERS);
    servers = new VoldemortServer[NUM_SERVERS];
    props = new Properties();
    metadataStore = ServerTestUtils.createMetadataStore(cluster, new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile)));
    props.put("pusher.type", "streaming");
    props.put("slop.frequency.ms", "1000000");
    configs = new VoldemortConfig[NUM_SERVERS];
    for (int i = 0; i < NUM_SERVERS; i++) {
        configs[i] = ServerTestUtils.createServerConfig(true, i, TestUtils.createTempDir().getAbsolutePath(), null, storesXmlfile, props);
    }
}
Also used : StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Properties(java.util.Properties) File(java.io.File) Before(org.junit.Before)

Example 45 with StoreDefinitionsMapper

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

the class DataCleanupJobTest method updateStoreDef.

private void updateStoreDef(int retentionDays) {
    StoreDefinition storeDef = getStoreDef(retentionDays);
    StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
    String storeStr = mapper.writeStoreList(Arrays.asList(storeDef));
    VectorClock clock = new VectorClock(System.currentTimeMillis());
    clock.incrementVersion(0, System.currentTimeMillis());
    Versioned<byte[]> storeSerialized = new Versioned<byte[]>(ByteUtils.getBytes(storeStr, "UTF-8"), clock);
    metadataStore.updateStoreDefinitions(storeSerialized);
}
Also used : Versioned(voldemort.versioning.Versioned) StoreDefinition(voldemort.store.StoreDefinition) VectorClock(voldemort.versioning.VectorClock) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper)

Aggregations

StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)82 StoreDefinition (voldemort.store.StoreDefinition)50 File (java.io.File)44 StringReader (java.io.StringReader)29 ClusterMapper (voldemort.xml.ClusterMapper)26 Before (org.junit.Before)19 Cluster (voldemort.cluster.Cluster)18 Properties (java.util.Properties)16 VoldemortException (voldemort.VoldemortException)15 Test (org.junit.Test)14 Node (voldemort.cluster.Node)14 AdminClient (voldemort.client.protocol.admin.AdminClient)13 ArrayList (java.util.ArrayList)12 StoreDefinitionBuilder (voldemort.store.StoreDefinitionBuilder)12 IOException (java.io.IOException)10 OptionSet (joptsimple.OptionSet)9 VoldemortServer (voldemort.server.VoldemortServer)9 ByteArray (voldemort.utils.ByteArray)9 HashMap (java.util.HashMap)8 SerializerDefinition (voldemort.serialization.SerializerDefinition)8