use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project Dempsy by Dempsy.
the class ZookeeperTestServer method startZookeeper.
private static TestZookeeperServerIntern startZookeeper(Properties zkConfig) {
logger.debug("Starting the test zookeeper server on port " + zkConfig.get("clientPort"));
final TestZookeeperServerIntern server = new TestZookeeperServerIntern();
try {
QuorumPeerConfig qpConfig = new QuorumPeerConfig();
qpConfig.parseProperties(zkConfig);
final ServerConfig sConfig = new ServerConfig();
sConfig.readFrom(qpConfig);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
server.runFromConfig(sConfig);
} catch (IOException ioe) {
logger.error(MarkerFactory.getMarker("FATAL"), "", ioe);
fail("can't start zookeeper");
}
}
});
t.start();
// give the server time to start
Thread.sleep(2000);
} catch (Exception e) {
logger.error("Can't start zookeeper", e);
fail("Can't start zookeeper");
}
return server;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig 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);
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project lucene-solr by apache.
the class ZkTestServer method run.
public void run() throws InterruptedException {
log.info("STARTING ZK TEST SERVER");
// we don't call super.distribSetUp
zooThread = new Thread() {
@Override
public void run() {
ServerConfig config = new ServerConfig() {
{
setClientPort(ZkTestServer.this.clientPort);
this.dataDir = zkDir;
this.dataLogDir = zkDir;
this.tickTime = theTickTime;
}
public void setClientPort(int clientPort) {
if (clientPortAddress != null) {
try {
this.clientPortAddress = new InetSocketAddress(InetAddress.getByName(clientPortAddress.getHostName()), clientPort);
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
} else {
this.clientPortAddress = new InetSocketAddress(clientPort);
}
log.info("client port:" + this.clientPortAddress);
}
};
try {
zkServer.runFromConfig(config);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
};
zooThread.setDaemon(true);
zooThread.start();
int cnt = 0;
int port = -1;
try {
port = getPort();
} catch (IllegalStateException e) {
}
while (port < 1) {
Thread.sleep(100);
try {
port = getPort();
} catch (IllegalStateException e) {
}
if (cnt == 500) {
throw new RuntimeException("Could not get the port for ZooKeeper server");
}
cnt++;
}
log.info("start zk server on port:" + port);
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig 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);
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project fabric8 by jboss-fuse.
the class GroupTest method startZooKeeper.
private NIOServerCnxnFactory startZooKeeper(int port) throws Exception {
ServerConfig cfg = new ServerConfig();
cfg.parse(new String[] { Integer.toString(port), "target/zk/data" });
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(6000);
zkServer.setMaxSessionTimeout(9000);
NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
cnxnFactory.configure(cfg.getClientPortAddress(), cfg.getMaxClientCnxns());
cnxnFactory.startup(zkServer);
return cnxnFactory;
}
Aggregations