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);
}
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();
}
}
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);
}
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;
}
}
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;
}
}
Aggregations