use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class AdminStoreSwapper method main.
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
parser.accepts("help", "print usage information");
parser.accepts("cluster", "[REQUIRED] the voldemort cluster.xml file ").withRequiredArg().describedAs("cluster.xml");
parser.accepts("name", "[REQUIRED] the name of the store to swap").withRequiredArg().describedAs("store-name");
parser.accepts("file", "[REQUIRED] uri of a directory containing the new store files").withRequiredArg().describedAs("uri");
parser.accepts("timeout", "http timeout for the fetch in ms").withRequiredArg().describedAs("timeout ms").ofType(Integer.class);
parser.accepts("rollback", "Rollback store to older version");
parser.accepts("push-version", "[REQUIRED] Version of push to fetch / rollback-to").withRequiredArg().ofType(Long.class);
OptionSet options = parser.parse(args);
if (options.has("help")) {
parser.printHelpOn(System.out);
System.exit(0);
}
Set<String> missing = CmdUtils.missing(options, "cluster", "name", "file", "push-version");
if (missing.size() > 0) {
if (!(missing.equals(ImmutableSet.of("file")) && (options.has("rollback")))) {
System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing));
parser.printHelpOn(System.err);
System.exit(1);
}
}
String clusterXml = (String) options.valueOf("cluster");
String storeName = (String) options.valueOf("name");
String filePath = (String) options.valueOf("file");
int timeoutMs = CmdUtils.valueOf(options, "timeout", (int) (3 * Time.SECONDS_PER_HOUR * Time.MS_PER_SECOND));
boolean rollbackStore = options.has("rollback");
Long pushVersion = (Long) options.valueOf("push-version");
String clusterStr = FileUtils.readFileToString(new File(clusterXml));
Cluster cluster = new ClusterMapper().readCluster(new StringReader(clusterStr));
ExecutorService executor = Executors.newFixedThreadPool(cluster.getNumberOfNodes());
AdminClient adminClient = new AdminClient(cluster);
AdminStoreSwapper swapper = new AdminStoreSwapper(executor, adminClient, timeoutMs);
try {
long start = System.currentTimeMillis();
if (rollbackStore) {
swapper.invokeRollback(storeName, pushVersion.longValue());
} else {
swapper.fetchAndSwapStoreData(storeName, filePath, pushVersion.longValue());
}
long end = System.currentTimeMillis();
swapper.logger.info("Succeeded on all nodes in " + ((end - start) / Time.MS_PER_SECOND) + " seconds.");
} finally {
if (adminClient != null)
adminClient.close();
executor.shutdownNow();
executor.awaitTermination(1, TimeUnit.SECONDS);
}
System.exit(0);
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class ZoneShrinkageClientTest method setup.
@Before
public void setup() throws IOException {
ClusterTestUtils.reset();
sourceCluster = ClusterTestUtils.getZZZCluster();
targetCluster = RebalanceUtils.vacateZone(sourceCluster, DROP_ZONE_ID);
sourceStoreDefs = ClusterTestUtils.getZZZStoreDefsBDB();
targetStoreDefs = RebalanceUtils.dropZone(sourceStoreDefs, DROP_ZONE_ID);
File sourceStoreDefsXml = ServerTestUtils.createTempFile("zzz-stores-", ".xml");
FileUtils.writeStringToFile(sourceStoreDefsXml, new StoreDefinitionsMapper().writeStoreList(sourceStoreDefs));
servers = new VoldemortServer[sourceCluster.getNumberOfNodes()];
ServerTestUtils.startVoldemortCluster(servers, null, null, sourceStoreDefsXml.getAbsolutePath(), new Properties(), sourceCluster);
Properties adminProperties = new Properties();
adminProperties.setProperty("max_connections", "2");
adminClient = new AdminClient(servers[0].getMetadataStore().getCluster(), new AdminClientConfig(adminProperties));
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class VoldemortServerTest method testInvalidNodeIdUpdateFails.
@Test
public void testInvalidNodeIdUpdateFails() throws IOException {
Cluster localCluster = ServerTestUtils.getLocalCluster(1);
VoldemortConfig config = getVoldemortConfig(new Properties());
server = new VoldemortServer(config, localCluster);
server.start();
final int UPDATED_NODE_ID = 3;
Node oldNode = localCluster.getNodes().iterator().next();
// For single local node, host matcher is not used.
config.setNodeIdImplementation(new NodeIdHostMatcher(UPDATED_NODE_ID));
oldAdminClient = new AdminClient(localCluster);
try {
oldAdminClient.metadataMgmtOps.updateRemoteMetadata(oldNode.getId(), MetadataStore.NODE_ID_KEY, Integer.toString(UPDATED_NODE_ID));
Assert.fail("Invalid node id should have failed");
} catch (VoldemortException ex) {
// Expected, ignore
}
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class QuotaLimitingStoreTest method setup.
@Before
public void setup() throws IOException {
Properties props = new Properties();
props.put("enable.quota.limiting", "true");
server = ServerTestUtils.startStandAloneVoldemortServer(props, "test/common/voldemort/config/single-store.xml");
adminClient = new AdminClient(server.getMetadataStore().getCluster());
String bootStrapUrl = "tcp://" + server.getIdentityNode().getHost() + ":" + server.getIdentityNode().getSocketPort();
factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootStrapUrl));
storeClient = factory.getStoreClient("test");
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class VoldemortBuildAndPushJob method allClustersEqual.
/**
* Check if all cluster objects in the list are congruent.
*
* @param clusterUrls of cluster objects
* @return
*/
private void allClustersEqual(final List<String> clusterUrls) {
Validate.notEmpty(clusterUrls, "clusterUrls cannot be null");
// If only one clusterUrl return immediately
if (clusterUrls.size() == 1)
return;
AdminClient adminClientLhs = adminClientPerCluster.get(clusterUrls.get(0));
Cluster clusterLhs = adminClientLhs.getAdminClientCluster();
for (int index = 1; index < clusterUrls.size(); index++) {
AdminClient adminClientRhs = adminClientPerCluster.get(clusterUrls.get(index));
Cluster clusterRhs = adminClientRhs.getAdminClientCluster();
if (!areTwoClustersEqual(clusterLhs, clusterRhs))
throw new VoldemortException("Cluster " + clusterLhs.getName() + " is not the same as " + clusterRhs.getName());
}
}
Aggregations