Search in sources :

Example 1 with NamespaceCreationOptions

use of com.ms.silverking.cloud.dht.NamespaceCreationOptions in project SilverKing by Morgan-Stanley.

the class StaticDHTCreator method main.

public static void main(String[] args) {
    try {
        StaticDHTCreator sdc;
        StaticDHTCreatorOptions options;
        CmdLineParser parser;
        Set<String> servers;
        String dhtName;
        String gcName;
        int port;
        NamespaceCreationOptions nsCreationOptions;
        UUIDBase uuid;
        options = new StaticDHTCreatorOptions();
        parser = new CmdLineParser(options);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException cle) {
            System.err.println(cle.getMessage());
            parser.printUsage(System.err);
            System.exit(-1);
        }
        if ((options.serverFile == null && options.servers == null) || (options.serverFile != null && options.servers != null)) {
            System.err.println("Exactly one of serverFile and servers should be provided");
            parser.printUsage(System.err);
            System.exit(-1);
        }
        if (options.serverFile != null) {
            servers = ImmutableSet.copyOf(StreamParser.parseFileLines(options.serverFile));
        } else {
            servers = CollectionUtil.parseSet(options.servers, serverDelimiter);
        }
        uuid = new UUIDBase(true);
        if (options.gridConfig != null) {
            gcName = options.gridConfig;
        } else {
            gcName = gcNameBase + uuid.toString();
        }
        if (options.dhtName != null) {
            dhtName = options.dhtName;
        } else {
            dhtName = dhtNameBase + uuid.toString();
        }
        if (options.port == StaticDHTCreatorOptions.defaultPort) {
            port = Util.getFreePort();
        } else {
            port = options.port;
        }
        if (options.nsCreationOptions != null) {
            nsCreationOptions = NamespaceCreationOptions.parse(options.nsCreationOptions);
        } else {
            nsCreationOptions = NamespaceCreationOptions.defaultOptions;
        }
        sdc = new StaticDHTCreator(new ZooKeeperConfig(options.zkEnsemble), servers, options.replication, dhtName, gcName, port, nsCreationOptions, options.gridConfigDir);
        sdc.createStaticDHT(uuid, options.initialHeapSize, options.maxHeapSize, options.skInstanceLogBaseVar, options.dataBaseVar, options.skfsConfigurationFile);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig) CmdLineParser(org.kohsuke.args4j.CmdLineParser) UUIDBase(com.ms.silverking.id.UUIDBase) NamespaceCreationOptions(com.ms.silverking.cloud.dht.NamespaceCreationOptions) CmdLineException(org.kohsuke.args4j.CmdLineException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Aggregations

NamespaceCreationOptions (com.ms.silverking.cloud.dht.NamespaceCreationOptions)1 ZooKeeperConfig (com.ms.silverking.cloud.zookeeper.ZooKeeperConfig)1 UUIDBase (com.ms.silverking.id.UUIDBase)1 IOException (java.io.IOException)1 KeeperException (org.apache.zookeeper.KeeperException)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1 CmdLineParser (org.kohsuke.args4j.CmdLineParser)1