Search in sources :

Example 1 with ZooKeeperServerMain

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain in project lucene-solr by apache.

the class SolrZkServerProps method start.

public void start() {
    if (zkRun == null)
        return;
    zkThread = new Thread() {

        @Override
        public void run() {
            try {
                if (zkProps.getServers().size() > 1) {
                    QuorumPeerMain zkServer = new QuorumPeerMain();
                    zkServer.runFromConfig(zkProps);
                } else {
                    ServerConfig sc = new ServerConfig();
                    sc.readFrom(zkProps);
                    ZooKeeperServerMain zkServer = new ZooKeeperServerMain();
                    zkServer.runFromConfig(sc);
                }
                log.info("ZooKeeper Server exited.");
            } catch (Exception e) {
                log.error("ZooKeeper Server ERROR", e);
                throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
            }
        }
    };
    if (zkProps.getServers().size() > 1) {
        log.info("STARTING EMBEDDED ENSEMBLE ZOOKEEPER SERVER at port " + zkProps.getClientPortAddress().getPort());
    } else {
        log.info("STARTING EMBEDDED STANDALONE ZOOKEEPER SERVER at port " + zkProps.getClientPortAddress().getPort());
    }
    zkThread.setDaemon(true);
    zkThread.start();
    try {
        // pause for ZooKeeper to start
        Thread.sleep(500);
    } catch (Exception e) {
        log.error("STARTING ZOOKEEPER", e);
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerMain(org.apache.zookeeper.server.quorum.QuorumPeerMain) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) SolrException(org.apache.solr.common.SolrException) SolrException(org.apache.solr.common.SolrException)

Example 2 with ZooKeeperServerMain

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain in project carbondata by apache.

the class ZooKeeperLockingTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    Properties startupProperties = new Properties();
    startupProperties.setProperty("dataDir", (new File("./target").getAbsolutePath()));
    startupProperties.setProperty("dataLogDir", (new File("./target").getAbsolutePath()));
    freePort = findFreePort();
    startupProperties.setProperty("clientPort", "" + freePort);
    QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
    try {
        quorumConfiguration.parseProperties(startupProperties);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final ZooKeeperServerMain zooKeeperServer = new ZooKeeperServerMain();
    final ServerConfig configuration = new ServerConfig();
    configuration.readFrom(quorumConfiguration);
    new Thread() {

        public void run() {
            try {
                zooKeeperServer.runFromConfig(configuration);
            } catch (IOException e) {
                System.out.println("ZooKeeper failure");
            }
        }
    }.start();
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) IOException(java.io.IOException) Properties(java.util.Properties) CarbonProperties(org.apache.carbondata.core.util.CarbonProperties) File(java.io.File) IOException(java.io.IOException) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain) Before(org.junit.Before)

Example 3 with ZooKeeperServerMain

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain in project herddb by diennea.

the class ZooKeeperMainWrapper method run.

public void run() throws Exception {
    pidFileLocker.lock();
    server = new ZooKeeperServerMain();
    QuorumPeerConfig qp = new QuorumPeerConfig();
    qp.parseProperties(configuration);
    ServerConfig sc = new ServerConfig();
    sc.readFrom(qp);
    server.runFromConfig(sc);
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain)

Example 4 with ZooKeeperServerMain

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain in project thingsboard by thingsboard.

the class KafkaDemoClient method startZkLocal.

private static void startZkLocal() throws Exception {
    final File zkTmpDir = File.createTempFile("zookeeper", "test");
    if (zkTmpDir.delete() && zkTmpDir.mkdir()) {
        Properties zkProperties = new Properties();
        zkProperties.setProperty("dataDir", zkTmpDir.getAbsolutePath());
        zkProperties.setProperty("clientPort", String.valueOf(ZK_PORT));
        ServerConfig configuration = new ServerConfig();
        QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
        quorumConfiguration.parseProperties(zkProperties);
        configuration.readFrom(quorumConfiguration);
        new Thread() {

            public void run() {
                try {
                    new ZooKeeperServerMain().runFromConfig(configuration);
                } catch (IOException e) {
                    System.out.println("Start of Local ZooKeeper Failed");
                    e.printStackTrace(System.err);
                }
            }
        }.start();
    } else {
        System.out.println("Failed to delete or create data dir for Zookeeper");
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain)

Example 5 with ZooKeeperServerMain

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain in project zookeeper by apache.

the class EnforceAuthenticationTest method testServerCannotStart.

private void testServerCannotStart(Map<String, String> prop) throws Exception {
    File confFile = getConfFile(prop);
    ServerConfig config = new ServerConfig();
    config.parse(confFile.toString());
    ZooKeeperServerMain serverMain = new ZooKeeperServerMain();
    try {
        serverMain.runFromConfig(config);
        fail("IllegalArgumentException is expected.");
    } catch (IllegalArgumentException e) {
    // do nothing
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) File(java.io.File) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain)

Aggregations

ServerConfig (org.apache.zookeeper.server.ServerConfig)10 ZooKeeperServerMain (org.apache.zookeeper.server.ZooKeeperServerMain)10 IOException (java.io.IOException)6 Properties (java.util.Properties)5 QuorumPeerConfig (org.apache.zookeeper.server.quorum.QuorumPeerConfig)5 File (java.io.File)4 InputStream (java.io.InputStream)3 QuorumPeerMain (org.apache.zookeeper.server.quorum.QuorumPeerMain)3 DatadirCleanupManager (org.apache.zookeeper.server.DatadirCleanupManager)2 FileInputStream (java.io.FileInputStream)1 UnknownHostException (java.net.UnknownHostException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 TimeoutException (java.util.concurrent.TimeoutException)1 SaslException (javax.security.sasl.SaslException)1 CarbonProperties (org.apache.carbondata.core.util.CarbonProperties)1 ServerConfig (org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig)1 ZooKeeperServerMain (org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain)1 QuorumPeerConfig (org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig)1 QuorumPeerMain (org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerMain)1 SolrException (org.apache.solr.common.SolrException)1