Search in sources :

Example 6 with QuorumPeerConfig

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project tesb-rt-se by Talend.

the class ZookeeperServerImpl method getZookeeperServer.

public static ZookeeperServer getZookeeperServer(Properties props) throws Exception {
    QuorumPeerConfig config = new QuorumPeerConfig();
    config.parseProperties(props);
    if (config.getServers().size() > 0) {
        return new MyQuorumPeerMain(config);
    } else {
        return new MyZooKeeperServerMain(config);
    }
}
Also used : QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig)

Example 7 with QuorumPeerConfig

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

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

the class ServerConfigTest method testJvmPauseMonitorConfigured.

@Test
public void testJvmPauseMonitorConfigured() {
    final Long sleepTime = 444L;
    final Long warnTH = 5555L;
    final Long infoTH = 555L;
    QuorumPeerConfig qpConfig = mock(QuorumPeerConfig.class);
    when(qpConfig.isJvmPauseMonitorToRun()).thenReturn(true);
    when(qpConfig.getJvmPauseSleepTimeMs()).thenReturn(sleepTime);
    when(qpConfig.getJvmPauseWarnThresholdMs()).thenReturn(warnTH);
    when(qpConfig.getJvmPauseInfoThresholdMs()).thenReturn(infoTH);
    serverConfig.readFrom(qpConfig);
    assertEquals(sleepTime, Long.valueOf(serverConfig.getJvmPauseSleepTimeMs()));
    assertEquals(warnTH, Long.valueOf(serverConfig.getJvmPauseWarnThresholdMs()));
    assertEquals(infoTH, Long.valueOf(serverConfig.getJvmPauseInfoThresholdMs()));
    assertTrue(serverConfig.isJvmPauseMonitorToRun());
}
Also used : QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) Test(org.junit.jupiter.api.Test)

Example 9 with QuorumPeerConfig

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

the class ServerConfig method parse.

/**
 * Parse a ZooKeeper configuration file
 * @param path the patch of the configuration file
 * @throws ConfigException error processing configuration
 */
public void parse(String path) throws ConfigException {
    QuorumPeerConfig config = new QuorumPeerConfig();
    config.parse(path);
    // let qpconfig parse the file and then pull the stuff we are
    // interested in
    readFrom(config);
}
Also used : QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig)

Example 10 with QuorumPeerConfig

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

the class JvmPauseMonitorTest method testJvmPauseMonitorExceedInfoThreshold.

@Test
@Timeout(value = 5)
public void testJvmPauseMonitorExceedInfoThreshold() throws InterruptedException {
    QuorumPeerConfig qpConfig = mock(QuorumPeerConfig.class);
    when(qpConfig.getJvmPauseSleepTimeMs()).thenReturn(sleepTime);
    when(qpConfig.getJvmPauseInfoThresholdMs()).thenReturn(infoTH);
    pauseMonitor = new JvmPauseMonitor(qpConfig);
    pauseMonitor.serviceStart();
    assertEquals(sleepTime, Long.valueOf(pauseMonitor.sleepTimeMs));
    assertEquals(infoTH, Long.valueOf(pauseMonitor.infoThresholdMs));
    while (pauseMonitor.getNumGcInfoThresholdExceeded() == 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)

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