Search in sources :

Example 1 with ZooKeeperConfig

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();
        }
    }
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException)

Example 2 with ZooKeeperConfig

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));
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig)

Example 3 with ZooKeeperConfig

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)));
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig) MetaClient(com.ms.silverking.cloud.dht.meta.MetaClient)

Example 4 with ZooKeeperConfig

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);
    }
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig) CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 5 with ZooKeeperConfig

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);
    }
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig) ClientDHTConfiguration(com.ms.silverking.cloud.dht.client.ClientDHTConfiguration) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) DHTSession(com.ms.silverking.cloud.dht.client.DHTSession) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) GetOptions(com.ms.silverking.cloud.dht.GetOptions) PutOptions(com.ms.silverking.cloud.dht.PutOptions) DHTClient(com.ms.silverking.cloud.dht.client.DHTClient)

Aggregations

ZooKeeperConfig (com.ms.silverking.cloud.zookeeper.ZooKeeperConfig)14 IOException (java.io.IOException)7 KeeperException (org.apache.zookeeper.KeeperException)6 MetaClient (com.ms.silverking.cloud.dht.meta.MetaClient)2 ZooKeeperExtended (com.ms.silverking.cloud.zookeeper.ZooKeeperExtended)2 CmdLineException (org.kohsuke.args4j.CmdLineException)2 CmdLineParser (org.kohsuke.args4j.CmdLineParser)2 GetOptions (com.ms.silverking.cloud.dht.GetOptions)1 NamespaceCreationOptions (com.ms.silverking.cloud.dht.NamespaceCreationOptions)1 PutOptions (com.ms.silverking.cloud.dht.PutOptions)1 ClientDHTConfiguration (com.ms.silverking.cloud.dht.client.ClientDHTConfiguration)1 DHTClient (com.ms.silverking.cloud.dht.client.DHTClient)1 DHTSession (com.ms.silverking.cloud.dht.client.DHTSession)1 DHTNode (com.ms.silverking.cloud.dht.daemon.DHTNode)1 DHTConfiguration (com.ms.silverking.cloud.dht.meta.DHTConfiguration)1 DHTConfigurationZK (com.ms.silverking.cloud.dht.meta.DHTConfigurationZK)1 DHTRingCurTargetZK (com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK)1 MetaClient (com.ms.silverking.cloud.meta.MetaClient)1 MetaClient (com.ms.silverking.cloud.toporing.meta.MetaClient)1 UUIDBase (com.ms.silverking.id.UUIDBase)1