Example usage for org.apache.zookeeper.server.quorum QuorumPeerMain main

List of usage examples for org.apache.zookeeper.server.quorum QuorumPeerMain main

Introduction

In this page you can find the example usage for org.apache.zookeeper.server.quorum QuorumPeerMain main.

Prototype

public static void main(String[] args) 

Source Link

Document

To start the replicated server specify the configuration file name on the command line.

Usage

From source file:com.iveely.computing.coordinate.ZookeeperServer.java

License:Apache License

/**
 * Start zookeeper server./*from   www .  j  av a2  s. c o m*/
 */
@Override
public void run() {
    Thread.currentThread().setName("zookeeper server thread");
    QuorumPeerMain.main(new String[] { "zoo.cfg" });
}

From source file:com.nearinfinity.blur.zookeeper.ZkUtilsTest.java

License:Apache License

@BeforeClass
public static void setupZookeeper() {
    _serverThread = new Thread(new Runnable() {
        @Override/*from  w w  w. ja v  a 2 s .  c o m*/
        public void run() {
            QuorumPeerMain.main(new String[] { "./src/test/resources/zoo.cfg" });
        }
    });
    _serverThread.setDaemon(true);
    _serverThread.start();
}

From source file:com.taobao.adfs.distributed.DistributedFunctionTest.java

License:Apache License

@BeforeClass
static public void setup() throws Exception {
    final String dataPath = "target/" + simpleClassName + "/zookeeperServerData";
    Utilities.mkdirs(dataPath, true);
    new Thread() {
        public void run() {
            QuorumPeerMain.main(new String[] { "21810", dataPath });
        }//w  w w .  j av a2s.  co  m
    }.start();
    Thread.sleep(3000);
}

From source file:ml.shifu.guagua.coordinator.zk.ZooKeeperUtils.java

License:Apache License

/**
 * Start embed zookeeper server in a daemon thread.
 *///from   w w  w.  ja va2 s. co  m
public static int startEmbedZooKeeper() throws IOException {
    final String zooKeeperWorkingDir = getZooKeeperWorkingDir();
    createFolder(zooKeeperWorkingDir);

    final String confName = zooKeeperWorkingDir + File.separator + "zoo.cfg";
    int validZkPort = getValidZooKeeperPort();

    prepZooKeeperConf(confName, validZkPort + "");

    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            QuorumPeerMain.main(new String[] { confName });
        }
    }, "Embed ZooKeeper");

    thread.setDaemon(true);
    thread.start();

    // used local data should be cleaned.
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                FileUtils.deleteDirectory(new File(zooKeeperWorkingDir));
            } catch (IOException ignore) {
            }
        }
    }));

    return validZkPort;
}

From source file:org.apache.pulsar.zookeeper.ZooKeeperStarter.java

License:Apache License

public static void main(String[] args) throws Exception {
    // Register basic JVM metrics
    DefaultExports.initialize();/*from   w ww . j  a v a2 s . com*/

    // Start Jetty to serve stats
    int port = Integer.parseInt(System.getProperties().getProperty("stats_server_port", "8080"));

    log.info("Starting ZK stats HTTP server at port {}", port);
    InetSocketAddress httpEndpoint = InetSocketAddress.createUnresolved("0.0.0.0", port);

    Server server = new Server(httpEndpoint);
    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
    try {
        server.start();
    } catch (Exception e) {
        log.error(
                "Failed to start HTTP server at port {}. Use \"-Dstats_server_port=1234\" to change port number",
                port, e);
        throw e;
    }

    // Start the regular ZooKeeper server
    QuorumPeerMain.main(args);
}