Search in sources :

Example 6 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class GenerateScriptCLI method main.

public static void main(String[] args) throws IOException {
    OptionParser parser = null;
    OptionSet options = null;
    try {
        parser = setupParser();
        options = parser.parse(args);
    } catch (OptionException oe) {
        parser.printHelpOn(System.out);
        printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
        return;
    }
    /* validate options */
    if (options.has("help")) {
        printUsage();
        return;
    }
    if (!options.hasArgument("url") || !options.hasArgument("script") || !options.hasArgument("output")) {
        printUsageAndDie("Missing a required argument.");
        return;
    }
    String url = (String) options.valueOf("url");
    String inputScriptPath = getFilePath(options, "script");
    String outputScriptPath = getFilePath(options, "output");
    String scpFilePath = getFilePath(options, "scp");
    AdminClient client = AdminToolUtils.getAdminClient(url);
    PrintWriter writer = new PrintWriter(outputScriptPath, "UTF-8");
    for (Node node : client.getAdminClientCluster().getNodes()) {
        FileInputStream fis = new FileInputStream(inputScriptPath);
        BufferedReader br = new BufferedReader(new InputStreamReader(fis));
        if (scpFilePath != null && scpFilePath.length() > 0) {
            writer.println("scp " + scpFilePath + "  " + node.getHost() + ":~");
        }
        int randomNumber = 1000 + new Random().nextInt(100000);
        String hereDocumentTag = "NODE_" + node.getId() + "_" + randomNumber;
        // Use SSH here script
        writer.println("ssh -T " + node.getHost() + "  << " + hereDocumentTag);
        String line = null;
        while ((line = br.readLine()) != null) {
            line = line.replace("@@ID@@", Integer.toString(node.getId()));
            line = line.replace("@@HOST@@", node.getHost());
            line = line.replace("@@URL@@", node.getSocketUrl().toString());
            writer.println(line);
        }
        writer.println(hereDocumentTag);
        writer.println("\n\n\n");
        br.close();
    }
    writer.close();
    System.out.println("Output script generated at " + outputScriptPath);
}
Also used : InputStreamReader(java.io.InputStreamReader) Random(java.util.Random) Node(voldemort.cluster.Node) BufferedReader(java.io.BufferedReader) OptionException(joptsimple.OptionException) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) FileInputStream(java.io.FileInputStream) AdminClient(voldemort.client.protocol.admin.AdminClient) PrintWriter(java.io.PrintWriter)

Example 7 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class ReadOnlyReplicationHelperCLI method main.

public static void main(String[] args) throws Exception {
    setupParser();
    OptionSet options = getValidOptions(args);
    // Required args
    String url = (String) options.valueOf(OPT_URL);
    Integer nodeId = (Integer) options.valueOf(OPT_NODE);
    PrintStream outputStream;
    if (options.has(OPT_OUTPUT)) {
        String output = (String) options.valueOf(OPT_OUTPUT);
        outputStream = new PrintStream(output);
    } else {
        outputStream = System.out;
    }
    Boolean local = options.has(OPT_LOCAL);
    AdminClient adminClient = new AdminClient(url);
    outputStream.println("src_host_name,src_node_id,src_rel_path,dest_rel_path");
    List<String> infoList = getReadOnlyReplicationInfo(adminClient, nodeId, local);
    for (String info : infoList) {
        outputStream.println(info);
    }
    if (outputStream != System.out) {
        outputStream.close();
    }
}
Also used : PrintStream(java.io.PrintStream) OptionSet(joptsimple.OptionSet) AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 8 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class VoldemortBuildAndPushJob method createAdminClient.

private AdminClient createAdminClient(String url, boolean fetchAllStoresXml, int connectionTimeoutSec, int socketTimeoutSec) {
    ClientConfig config = new ClientConfig().setBootstrapUrls(url).setConnectionTimeout(connectionTimeoutSec, TimeUnit.SECONDS).setFetchAllStoresXmlInBootstrap(fetchAllStoresXml);
    AdminClientConfig adminConfig = new AdminClientConfig().setAdminSocketTimeoutSec(socketTimeoutSec);
    return new AdminClient(adminConfig, config);
}
Also used : AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) ClientConfig(voldemort.client.ClientConfig) AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 9 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class AbstractNonZonedRebalanceTest method testRebalanceCleanPrimary.

@Test(timeout = 600000)
public void testRebalanceCleanPrimary() throws Exception {
    logger.info("Starting testRebalanceCleanPrimary");
    try {
        Cluster currentCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0 }, { 1, 3 }, { 2 } });
        Cluster finalCluster = UpdateClusterUtils.createUpdatedCluster(currentCluster, 2, Lists.newArrayList(3));
        // start servers 0 , 1, 2
        Map<String, String> configProps = new HashMap<String, String>();
        configProps.put("enable.repair", "true");
        List<Integer> serverList = Arrays.asList(0, 1, 2);
        currentCluster = startServers(currentCluster, rwStoreDefFileWithReplication, serverList, configProps);
        String bootstrapUrl = getBootstrapUrl(currentCluster, 0);
        final ClusterTestUtils.RebalanceKit rebalanceKit = ClusterTestUtils.getRebalanceKit(bootstrapUrl, finalCluster);
        try {
            AdminClient adminClient = rebalanceKit.controller.getAdminClient();
            populateData(currentCluster, rwStoreDefWithReplication, adminClient, false);
            // Figure out the positive keys to check
            List<ByteArray> positiveTestKeyList = sampleKeysFromPartition(adminClient, 1, rwStoreDefWithReplication.getName(), Arrays.asList(1), 20);
            rebalanceAndCheck(rebalanceKit.plan, rebalanceKit.controller, Arrays.asList(0, 1, 2));
            checkConsistentMetadata(finalCluster, serverList);
            // Do the cleanup operation
            for (int i = 0; i < 3; i++) {
                adminClient.storeMntOps.repairJob(i);
            }
            // wait for the repairs to complete
            for (int i = 0; i < 3; i++) {
                ServerTestUtils.waitForAsyncOperationOnServer(serverMap.get(i), "Repair", 5000);
            }
            // do the positive tests
            checkForKeyExistence(adminClient, 1, rwStoreDefWithReplication.getName(), positiveTestKeyList);
            logger.info("[Primary] Successful clean after Rebalancing");
        } finally {
            // stop servers
            stopServer(serverList);
        }
    } catch (AssertionError ae) {
        logger.error("Assertion broken in testRebalanceCleanPrimary ", ae);
        throw ae;
    }
}
Also used : HashMap(java.util.HashMap) Cluster(voldemort.cluster.Cluster) ClusterTestUtils(voldemort.ClusterTestUtils) ByteArray(voldemort.utils.ByteArray) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 10 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class AbstractNonZonedRebalanceTest method testRebalanceCleanSecondary.

@Test(timeout = 600000)
public void testRebalanceCleanSecondary() throws Exception {
    logger.info("Starting testRebalanceCleanSecondary");
    try {
        Cluster currentCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0, 3 }, { 1 }, { 2 } });
        Cluster finalCluster = UpdateClusterUtils.createUpdatedCluster(currentCluster, 2, Lists.newArrayList(3));
        // start servers 0 , 1, 2
        Map<String, String> configProps = new HashMap<String, String>();
        configProps.put("enable.repair", "true");
        List<Integer> serverList = Arrays.asList(0, 1, 2);
        currentCluster = startServers(currentCluster, rwStoreDefFileWithReplication, serverList, configProps);
        String bootstrapUrl = getBootstrapUrl(currentCluster, 0);
        final ClusterTestUtils.RebalanceKit rebalanceKit = ClusterTestUtils.getRebalanceKit(bootstrapUrl, finalCluster);
        try {
            AdminClient adminClient = rebalanceKit.controller.getAdminClient();
            populateData(currentCluster, rwStoreDefWithReplication, adminClient, false);
            // Figure out the positive and negative keys to check
            List<ByteArray> positiveTestKeyList = sampleKeysFromPartition(adminClient, 0, rwStoreDefWithReplication.getName(), Arrays.asList(3), 20);
            rebalanceAndCheck(rebalanceKit.plan, rebalanceKit.controller, Arrays.asList(0, 1, 2));
            checkConsistentMetadata(finalCluster, serverList);
            // Do the cleanup operation
            for (int i = 0; i < 3; i++) {
                adminClient.storeMntOps.repairJob(i);
            }
            // wait for the repairs to complete
            for (int i = 0; i < 3; i++) {
                ServerTestUtils.waitForAsyncOperationOnServer(serverMap.get(i), "Repair", 5000);
            }
            // do the positive tests
            checkForKeyExistence(adminClient, 0, rwStoreDefWithReplication.getName(), positiveTestKeyList);
            logger.info("[Secondary] Successful clean after Rebalancing");
        } finally {
            // stop servers
            stopServer(serverList);
        }
    } catch (AssertionError ae) {
        logger.error("Assertion broken in testRWRebalanceCleanSecondary ", ae);
        throw ae;
    }
}
Also used : HashMap(java.util.HashMap) Cluster(voldemort.cluster.Cluster) ClusterTestUtils(voldemort.ClusterTestUtils) ByteArray(voldemort.utils.ByteArray) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Aggregations

AdminClient (voldemort.client.protocol.admin.AdminClient)80 Test (org.junit.Test)35 Cluster (voldemort.cluster.Cluster)26 Node (voldemort.cluster.Node)26 Properties (java.util.Properties)19 StoreDefinition (voldemort.store.StoreDefinition)19 ArrayList (java.util.ArrayList)18 AdminClientConfig (voldemort.client.protocol.admin.AdminClientConfig)18 VoldemortException (voldemort.VoldemortException)17 IOException (java.io.IOException)14 Before (org.junit.Before)14 ByteArray (voldemort.utils.ByteArray)14 HashMap (java.util.HashMap)13 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)13 File (java.io.File)11 VoldemortServer (voldemort.server.VoldemortServer)11 ClientConfig (voldemort.client.ClientConfig)10 VectorClock (voldemort.versioning.VectorClock)10 Versioned (voldemort.versioning.Versioned)9 ClusterMapper (voldemort.xml.ClusterMapper)9