use of com.ms.silverking.cloud.zookeeper.ZooKeeperConfig in project SilverKing by Morgan-Stanley.
the class StaticRingCreator method main.
public static void main(String[] args) {
if (args.length != 4) {
System.out.println("args: <ringName> <zkConfig> <servers> <replication>");
} else {
try {
String ringName;
ZooKeeperConfig zkConfig;
Set<String> servers;
int replication;
ringName = args[0];
zkConfig = new ZooKeeperConfig(args[1]);
servers = ImmutableSet.copyOf(StringUtil.splitAndTrim(args[2], ","));
replication = Integer.parseInt(args[3]);
createStaticRing(ringName, zkConfig, servers, replication);
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperConfig in project SilverKing by Morgan-Stanley.
the class NamedRingConfigurationUtil method fromGridConfiguration.
public static NamedRingConfiguration fromGridConfiguration(SKGridConfiguration gc) throws IOException, KeeperException {
MetaClient _mc;
long version;
String ringName;
ZooKeeperConfig zkConfig;
com.ms.silverking.cloud.dht.meta.MetaClient dhtMC;
dhtMC = new com.ms.silverking.cloud.dht.meta.MetaClient(gc);
ringName = dhtMC.getDHTConfiguration().getRingName();
zkConfig = dhtMC.getZooKeeper().getZKConfig();
_mc = new MetaClient(new NamedRingConfiguration(ringName, RingConfiguration.emptyTemplate), zkConfig);
// FIXME - version never changes
version = _mc.getZooKeeper().getLatestVersion(MetaPaths.getRingConfigPath(ringName));
return new NamedRingConfiguration(ringName, new RingConfigurationZK(_mc).readFromZK(version, null));
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperConfig in project SilverKing by Morgan-Stanley.
the class MetaTool method doWork.
@Override
protected void doWork(MetaToolOptions options) throws IOException, KeeperException {
MetaClient mc;
Tool tool;
ZooKeeperConfig zkConfig;
tool = Tool.valueOf(options.tool);
zkConfig = new ZooKeeperConfig(options.zkConfig);
mc = new MetaClient(namedDHTConfigurationFor(tool, options.name), zkConfig);
doWork(options, new MetaToolWorker(getModule(tool, mc)));
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperConfig in project SilverKing by Morgan-Stanley.
the class DHTNode method main.
/**
* @param args
*/
public static void main(String[] args) {
try {
DHTNode dhtNode;
String dhtName;
ZooKeeperConfig zkConfig;
DHTNodeOptions options;
CmdLineParser parser;
LWTPoolProvider.createDefaultWorkPools();
options = new DHTNodeOptions();
parser = new CmdLineParser(options);
try {
parser.parseArgument(args);
dhtName = options.dhtName;
zkConfig = new ZooKeeperConfig(options.zkConfig);
dhtNode = new DHTNode(dhtName, zkConfig, options.inactiveNodeTimeoutSeconds, options.disableReap, options.leaveTrash);
// Log.setLevelAll();
Log.initAsyncLogging();
dhtNode.run();
Log.warning("DHTNode run() returned cleanly");
} catch (CmdLineException cle) {
Log.logErrorWarning(cle);
System.err.println(cle.getMessage());
parser.printUsage(System.err);
return;
} catch (Exception e) {
Log.logErrorWarning(e);
e.printStackTrace();
} finally {
Log.warning("DHTNode leaving main()");
}
} catch (Exception e) {
Log.logErrorWarning(e);
}
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperConfig in project SilverKing by Morgan-Stanley.
the class DevTest method test.
public void test(int numKeys, int reps, String namespace, Compression compression, ChecksumType checksumType, EnumSet<Test> tests) throws Exception {
DHTClient client;
ClientDHTConfiguration dhtConfig;
DHTSession session;
AsynchronousNamespacePerspective<String, String> asyncNSP;
AsyncRetrieval<String, String> asyncRetrieval;
AsyncPut<String> asyncPut;
Stopwatch sw;
PutOptions putOptions;
asyncPut = null;
client = new DHTClient();
dhtConfig = new ClientDHTConfiguration(dhtName, new ZooKeeperConfig(zkLocs));
session = client.openSession(dhtConfig);
putOptions = session.getDefaultNamespaceOptions().getDefaultPutOptions().compression(compression).checksumType(checksumType);
asyncNSP = session.openAsyncNamespacePerspective(namespace, String.class, String.class);
sw = new SimpleStopwatch();
if (tests.contains(Test.Put)) {
System.out.println("\n\n\t\tPUT");
for (int i = 0; i < reps; i++) {
// asyncPut = asyncNSP.put("Hello"+ i, "world!");
asyncPut = asyncNSP.put(createMap(i, numKeys), putOptions);
asyncPut.waitForCompletion();
}
sw.stop();
displayTimes(sw, reps, numKeys, valueSize);
}
if (tests.contains(Test.Get)) {
System.out.println("\n\n\t\tGET");
GetOptions getOptions;
sw.reset();
getOptions = OptionsHelper.newGetOptions(RetrievalType.VALUE_AND_META_DATA, session.getDefaultNamespaceOptions().getDefaultGetOptions().getVersionConstraint());
for (int i = 0; i < reps; i++) {
Set<String> keys;
Map<String, ? extends StoredValue<String>> values;
keys = createSet(i, numKeys);
asyncRetrieval = asyncNSP.get(keys, getOptions);
asyncRetrieval.waitForCompletion();
if (displayValues) {
System.out.printf("keys: %s\n", CollectionUtil.toString(keys));
values = asyncRetrieval.getStoredValues();
System.out.printf("values: %s\n", CollectionUtil.toString(values.entrySet()));
for (Entry<String, ? extends StoredValue<String>> entry : values.entrySet()) {
System.out.println(entry.getKey() + " -> " + entry.getValue().getValue() + "\t" + entry.getValue().getMetaData().toString(true));
}
}
}
sw.stop();
displayTimes(sw, reps, numKeys, valueSize);
}
}
Aggregations