Search in sources :

Example 11 with QuorumPeerConfig

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

the class JvmPauseMonitorTest method testJvmPauseMonitorExceedWarnThreshold.

@Test
@Timeout(value = 5)
public void testJvmPauseMonitorExceedWarnThreshold() throws InterruptedException {
    QuorumPeerConfig qpConfig = mock(QuorumPeerConfig.class);
    when(qpConfig.getJvmPauseSleepTimeMs()).thenReturn(sleepTime);
    when(qpConfig.getJvmPauseWarnThresholdMs()).thenReturn(warnTH);
    pauseMonitor = new JvmPauseMonitor(qpConfig);
    pauseMonitor.serviceStart();
    assertEquals(sleepTime, Long.valueOf(pauseMonitor.sleepTimeMs));
    assertEquals(warnTH, Long.valueOf(pauseMonitor.warnThresholdMs));
    while (pauseMonitor.getNumGcWarnThresholdExceeded() == 0) {
        Thread.sleep(200);
    }
}
Also used : QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Example 12 with QuorumPeerConfig

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

the class EmbeddedKafka method startZookeeper.

/**
 * Will start Zookeeper server via {@link ServerCnxnFactory}
 */
private void startZookeeper() {
    QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
    try {
        quorumConfiguration.parseProperties(this.zookeeperConfig);
        ServerConfig configuration = new ServerConfig();
        configuration.readFrom(quorumConfiguration);
        FileTxnSnapLog txnLog = new FileTxnSnapLog(new File(configuration.getDataLogDir()), new File(configuration.getDataDir()));
        zkServer.setTxnLogFactory(txnLog);
        zkServer.setTickTime(configuration.getTickTime());
        zkServer.setMinSessionTimeout(configuration.getMinSessionTimeout());
        zkServer.setMaxSessionTimeout(configuration.getMaxSessionTimeout());
        ServerCnxnFactory zookeeperConnectionFactory = ServerCnxnFactory.createFactory();
        zookeeperConnectionFactory.configure(configuration.getClientPortAddress(), configuration.getMaxClientCnxns());
        zookeeperConnectionFactory.startup(zkServer);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start Zookeeper server", e);
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) ServerCnxnFactory(org.apache.zookeeper.server.ServerCnxnFactory) File(java.io.File) FileTxnSnapLog(org.apache.zookeeper.server.persistence.FileTxnSnapLog) IOException(java.io.IOException)

Example 13 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project fabric8 by jboss-fuse.

the class ZooKeeperServerFactory method getPeerConfig.

private QuorumPeerConfig getPeerConfig(Properties props) throws IOException, ConfigException {
    QuorumPeerConfig peerConfig = new QuorumPeerConfig();
    peerConfig.parseProperties(props);
    LOGGER.info("Created zookeeper peer configuration: {}", peerConfig);
    return peerConfig;
}
Also used : QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig)

Example 14 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project fabric8 by jboss-fuse.

the class ZooKeeperUtils method getPeerConfig.

private static QuorumPeerConfig getPeerConfig(Properties props) throws IOException, QuorumPeerConfig.ConfigException {
    QuorumPeerConfig peerConfig = new QuorumPeerConfig();
    peerConfig.parseProperties(props);
    LOGGER.info("Created zookeeper peer configuration: {}", peerConfig);
    return peerConfig;
}
Also used : QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig)

Example 15 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project ecf by eclipse.

the class ZooDiscoveryContainer method startQuorumPeer.

/**
 * Start a local ZooKeeer server to write nodes to. It plays as a peer
 * within a replicated servers configuration. Implied by
 * {@link IDiscoveryConfig#ZOODISCOVERY_FLAVOR_REPLICATED} configuration.
 *
 * @param conf
 */
void startQuorumPeer(final Configuration conf) {
    if (this.quorumPeer != null && this.quorumPeer.isAlive()) {
        return;
    } else if (this.quorumPeer != null && !this.quorumPeer.isAlive()) {
        this.quorumPeer.start();
        return;
    }
    try {
        final QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
        quorumPeerConfig.parse(conf.getConfFile());
        QuorumPeer.Factory qpFactory = new QuorumPeer.Factory() {

            public QuorumPeer create(NIOServerCnxn.Factory cnxnFactory) throws IOException {
                ServerConfig serverConfig = new ServerConfig();
                serverConfig.readFrom(quorumPeerConfig);
                QuorumPeer peer = new QuorumPeer(quorumPeerConfig.getServers(), new File(serverConfig.getDataDir()), new File(serverConfig.getDataLogDir()), quorumPeerConfig.getElectionAlg(), quorumPeerConfig.getServerId(), quorumPeerConfig.getTickTime(), quorumPeerConfig.getInitLimit(), quorumPeerConfig.getSyncLimit(), cnxnFactory, quorumPeerConfig.getQuorumVerifier());
                ZooDiscoveryContainer.this.quorumPeer = peer;
                return peer;
            }

            public NIOServerCnxn.Factory createConnectionFactory() throws IOException {
                return new NIOServerCnxn.Factory(quorumPeerConfig.getClientPortAddress());
            }
        };
        quorumPeer = qpFactory.create(qpFactory.createConnectionFactory());
        quorumPeer.start();
        quorumPeer.setDaemon(true);
        isQuorumPeerReady = true;
    } catch (Exception e) {
        // $NON-NLS-1$
        Logger.log(LogService.LOG_ERROR, "Zookeeper quorum cannot be started! ", e);
        isQuorumPeerReady = false;
    }
}
Also used : ServerConfig(org.apache.zookeeper.server.ServerConfig) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) NIOServerCnxn(org.apache.zookeeper.server.NIOServerCnxn) QuorumPeer(org.apache.zookeeper.server.quorum.QuorumPeer) Factory(org.apache.zookeeper.server.NIOServerCnxn.Factory) File(java.io.File) IOException(java.io.IOException) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException)

Aggregations

QuorumPeerConfig (org.apache.zookeeper.server.quorum.QuorumPeerConfig)21 IOException (java.io.IOException)12 ServerConfig (org.apache.zookeeper.server.ServerConfig)10 Properties (java.util.Properties)9 File (java.io.File)8 ZooKeeperServerMain (org.apache.zookeeper.server.ZooKeeperServerMain)5 InputStream (java.io.InputStream)3 FileTxnSnapLog (org.apache.zookeeper.server.persistence.FileTxnSnapLog)3 Test (org.junit.jupiter.api.Test)3 ServerCnxnFactory (org.apache.zookeeper.server.ServerCnxnFactory)2 QuorumPeer (org.apache.zookeeper.server.quorum.QuorumPeer)2 Timeout (org.junit.jupiter.api.Timeout)2 RuntimeProperties (io.fabric8.api.RuntimeProperties)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 Map (java.util.Map)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