use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project fabric8 by jboss-fuse.
the class ZookeeperPortServiceTest method startZooKeeper.
private NIOServerCnxnFactory startZooKeeper(int port) throws Exception {
String testDirectory = "target/zk-ports/data" + System.currentTimeMillis();
FileUtils.deleteDirectory(new File(testDirectory));
ServerConfig cfg = new ServerConfig();
cfg.parse(new String[] { Integer.toString(port), testDirectory });
ZooKeeperServer zkServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(cfg.getDataLogDir()), new File(cfg.getDataDir()));
zkServer.setTxnLogFactory(ftxn);
zkServer.setTickTime(cfg.getTickTime());
zkServer.setMinSessionTimeout(cfg.getMinSessionTimeout());
zkServer.setMaxSessionTimeout(cfg.getMaxSessionTimeout());
NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
cnxnFactory.configure(cfg.getClientPortAddress(), cfg.getMaxClientCnxns());
cnxnFactory.startup(zkServer);
return cnxnFactory;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project fabric8 by jboss-fuse.
the class ZooKeeperUtils method getServerConfig.
private static ServerConfig getServerConfig(QuorumPeerConfig peerConfig) {
ServerConfig serverConfig = new ServerConfig();
serverConfig.readFrom(peerConfig);
LOGGER.info("Created zookeeper server configuration: {}", serverConfig);
return serverConfig;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig 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);
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig 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();
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig 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");
}
}
Aggregations