Search in sources :

Example 1 with QuorumPeerMain

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerMain 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 QuorumPeerMain

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

the class QuorumDigestAuthTest method testEnableQuorumServerRequireSaslWithoutQuorumLearnerRequireSasl.

/**
 * If quorumpeer learner is not auth enabled then self won't be able to join
 * quorum. So this test is ensuring that the quorumpeer learner is also auth
 * enabled while enabling quorum server require sasl.
 */
@Test(timeout = 10000)
public void testEnableQuorumServerRequireSaslWithoutQuorumLearnerRequireSasl() throws Exception {
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_LOGIN_CONTEXT, "QuorumLearner");
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "false");
    MainThread mthread = new MainThread(1, PortAssignment.unique(), "", authConfigs);
    String[] args = new String[1];
    args[0] = mthread.getConfFile().toString();
    try {
        new QuorumPeerMain() {

            @Override
            protected void initializeAndRun(String[] args) throws ConfigException, IOException, AdminServer.AdminServerException {
                super.initializeAndRun(args);
            }
        }.initializeAndRun(args);
        Assert.fail("Must throw exception as quorumpeer learner is not enabled!");
    } catch (ConfigException e) {
    // expected
    }
}
Also used : MainThread(org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread) QuorumPeerMain(org.apache.zookeeper.server.quorum.QuorumPeerMain) HashMap(java.util.HashMap) ConfigException(org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with QuorumPeerMain

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

the class QuorumDigestAuthTest method testEnableQuorumAuthenticationConfigurations.

/**
 * If quorumpeer learner is not auth enabled then self won't be able to join
 * quorum. So this test is ensuring that the quorumpeer learner is also auth
 * enabled while enabling quorum server require sasl.
 */
@Test(timeout = 10000)
public void testEnableQuorumAuthenticationConfigurations() throws Exception {
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_LOGIN_CONTEXT, "QuorumLearner");
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "false");
    // case-1) 'quorum.auth.enableSasl' is off. Tries to enable server sasl.
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "false");
    MainThread mthread = new MainThread(1, PortAssignment.unique(), "", authConfigs);
    String[] args = new String[1];
    args[0] = mthread.getConfFile().toString();
    try {
        new QuorumPeerMain() {

            @Override
            protected void initializeAndRun(String[] args) throws ConfigException, IOException, AdminServer.AdminServerException {
                super.initializeAndRun(args);
            }
        }.initializeAndRun(args);
        Assert.fail("Must throw exception as quorum sasl is not enabled!");
    } catch (ConfigException e) {
    // expected
    }
    // case-1) 'quorum.auth.enableSasl' is off. Tries to enable learner sasl.
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "false");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "true");
    try {
        new QuorumPeerMain() {

            @Override
            protected void initializeAndRun(String[] args) throws ConfigException, IOException, AdminServer.AdminServerException {
                super.initializeAndRun(args);
            }
        }.initializeAndRun(args);
        Assert.fail("Must throw exception as quorum sasl is not enabled!");
    } catch (ConfigException e) {
    // expected
    }
}
Also used : MainThread(org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread) QuorumPeerMain(org.apache.zookeeper.server.quorum.QuorumPeerMain) HashMap(java.util.HashMap) ConfigException(org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with QuorumPeerMain

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerMain in project hbase by apache.

the class HQuorumPeer method runZKServer.

private static void runZKServer(QuorumPeerConfig zkConfig) throws IOException, AdminServer.AdminServerException {
    /**
     *  Start and schedule the purge task
     *  autopurge.purgeInterval is 0 by default,so in fact the DatadirCleanupManager task will not
     *  be started to clean the logs by default. Config is recommended only for standalone server.
     */
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(zkConfig.getDataDir(), zkConfig.getDataLogDir(), zkConfig.getSnapRetainCount(), zkConfig.getPurgeInterval());
    purgeMgr.start();
    if (zkConfig.isDistributed()) {
        QuorumPeerMain qp = new QuorumPeerMain();
        qp.runFromConfig(zkConfig);
    } else {
        ZooKeeperServerMain zk = new ZooKeeperServerMain();
        ServerConfig serverConfig = new ServerConfig();
        serverConfig.readFrom(zkConfig);
        zk.runFromConfig(serverConfig);
    }
}
Also used : DatadirCleanupManager(org.apache.zookeeper.server.DatadirCleanupManager) ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerMain(org.apache.zookeeper.server.quorum.QuorumPeerMain) ZooKeeperServerMain(org.apache.zookeeper.server.ZooKeeperServerMain)

Example 5 with QuorumPeerMain

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

the class FlinkZooKeeperQuorumPeer method runFlinkZkQuorumPeer.

// ------------------------------------------------------------------------
/**
 * Runs a ZooKeeper {@link QuorumPeer} if further peers are configured or a single {@link
 * ZooKeeperServer} if no further peers are configured.
 *
 * @param zkConfigFile ZooKeeper config file 'zoo.cfg'
 * @param peerId ID for the 'myid' file
 */
public static void runFlinkZkQuorumPeer(String zkConfigFile, int peerId) throws Exception {
    Properties zkProps = new Properties();
    try (InputStream inStream = new FileInputStream(new File(zkConfigFile))) {
        zkProps.load(inStream);
    }
    LOG.info("Configuration: " + zkProps);
    // Set defaults for required properties
    setRequiredProperties(zkProps);
    // Write peer id to myid file
    writeMyIdToDataDir(zkProps, peerId);
    // The myid file needs to be written before creating the instance. Otherwise, this
    // will fail.
    QuorumPeerConfig conf = new QuorumPeerConfig();
    conf.parseProperties(zkProps);
    if (conf.isDistributed()) {
        // Run quorum peer
        LOG.info("Running distributed ZooKeeper quorum peer (total peers: {}).", conf.getServers().size());
        QuorumPeerMain qp = new QuorumPeerMain();
        qp.runFromConfig(conf);
    } else {
        // Run standalone
        LOG.info("Running standalone ZooKeeper quorum peer.");
        ZooKeeperServerMain zk = new ZooKeeperServerMain();
        ServerConfig sc = new ServerConfig();
        sc.readFrom(conf);
        zk.runFromConfig(sc);
    }
}
Also used : ServerConfig(org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig) QuorumPeerMain(org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerMain) QuorumPeerConfig(org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) ZooKeeperServerMain(org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ZooKeeperServerMain)

Aggregations

QuorumPeerMain (org.apache.zookeeper.server.quorum.QuorumPeerMain)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)2 ServerConfig (org.apache.zookeeper.server.ServerConfig)2 ZooKeeperServerMain (org.apache.zookeeper.server.ZooKeeperServerMain)2 ConfigException (org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException)2 MainThread (org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread)2 Test (org.junit.Test)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 UnknownHostException (java.net.UnknownHostException)1 Properties (java.util.Properties)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 DatadirCleanupManager (org.apache.zookeeper.server.DatadirCleanupManager)1