use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project fabric8 by jboss-fuse.
the class GitDataStoreImplTestSupport method startZooKeeper.
private NIOServerCnxnFactory startZooKeeper(int port, String directory) throws Exception {
ServerConfig cfg = new ServerConfig();
cfg.parse(new String[] { Integer.toString(port), directory });
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 zookeeper by apache.
the class ZooKeeperServerEmbeddedImpl method start.
@Override
public void start(long startupTimeout) throws Exception {
switch(exitHandler) {
case EXIT:
ServiceUtils.setSystemExitProcedure(ServiceUtils.SYSTEM_EXIT);
break;
case LOG_ONLY:
ServiceUtils.setSystemExitProcedure(ServiceUtils.LOG_ONLY);
break;
default:
ServiceUtils.setSystemExitProcedure(ServiceUtils.SYSTEM_EXIT);
break;
}
final CompletableFuture<String> started = new CompletableFuture<>();
if (config.getServers().size() > 1 || config.isDistributed()) {
LOG.info("Running ZK Server in single Quorum MODE");
maincluster = new QuorumPeerMain() {
protected QuorumPeer getQuorumPeer() throws SaslException {
return new QuorumPeer() {
@Override
public void start() {
super.start();
LOG.info("ZK Server {} started", this);
started.complete(null);
}
};
}
};
// Start and schedule the the purge task
purgeMgr = new DatadirCleanupManager(config.getDataDir(), config.getDataLogDir(), config.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
thread = new Thread("zkservermainrunner") {
@Override
public void run() {
try {
maincluster.runFromConfig(config);
maincluster.close();
LOG.info("ZK server died. Requsting stop on JVM");
if (!stopping) {
ServiceUtils.requestSystemExit(ExitCode.EXECUTION_FINISHED.getValue());
}
} catch (Throwable t) {
LOG.error("error during server lifecycle", t);
maincluster.close();
if (!stopping) {
ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
}
}
}
};
thread.start();
} else {
LOG.info("Running ZK Server in single STANDALONE MODE");
mainsingle = new ZooKeeperServerMain() {
@Override
public void serverStarted() {
LOG.info("ZK Server started");
started.complete(null);
}
};
purgeMgr = new DatadirCleanupManager(config.getDataDir(), config.getDataLogDir(), config.getSnapRetainCount(), config.getPurgeInterval());
purgeMgr.start();
thread = new Thread("zkservermainrunner") {
@Override
public void run() {
try {
ServerConfig cc = new ServerConfig();
cc.readFrom(config);
LOG.info("ZK server starting");
mainsingle.runFromConfig(cc);
LOG.info("ZK server died. Requesting stop on JVM");
if (!stopping) {
ServiceUtils.requestSystemExit(ExitCode.EXECUTION_FINISHED.getValue());
}
} catch (Throwable t) {
LOG.error("error during server lifecycle", t);
mainsingle.close();
if (!stopping) {
ServiceUtils.requestSystemExit(ExitCode.INVALID_INVOCATION.getValue());
}
}
}
};
thread.start();
}
try {
started.get(startupTimeout, TimeUnit.MILLISECONDS);
} catch (TimeoutException err) {
LOG.info("Startup timed out, trying to close");
close();
throw err;
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project zookeeper by apache.
the class ControllerServerConfig method getZooKeeperServerConfig.
public ServerConfig getZooKeeperServerConfig() {
ServerConfig serverConfig = new ServerConfig();
serverConfig.readFrom(this);
return serverConfig;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project coprhd-controller by CoprHD.
the class CoordinatorImpl method start.
@Override
public synchronized void start() throws IOException {
if (new File(UNCOMMITTED_DATA_REVISION_FLAG).exists()) {
_log.error("Uncommitted data revision detected. Manual relink db/zk data directory");
throw new RuntimeException("Uncommited data revision");
}
_log.info(String.format("%s: %s", SpringQuorumPeerConfig.READONLY_MODE_ENABLED, System.getProperty(SpringQuorumPeerConfig.READONLY_MODE_ENABLED)));
// snapshot clean up runs at regular interval and leaves desired snapshots
// behind
_exe.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
try {
PurgeTxnLog.purge(new File(_config.getDataDir()), new File(_config.getDataDir()), _config.getSnapRetainCount());
} catch (Exception e) {
_log.debug("Exception is throwed when purging snapshots and logs", e);
}
}
}, 0, _config.getPurgeInterval(), TimeUnit.MINUTES);
startMutexReaper();
// Starts JMX server for analysis and data backup
try {
if (_jmxServer != null) {
_jmxServer.start();
}
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
if (_config.getServers().size() == 0) {
// standalone
ServerConfig config = new ServerConfig();
config.readFrom(_config);
server = new ZKMain();
server.runFromConfig(config);
} else {
// cluster
try {
ManagedUtil.registerLog4jMBeans();
} catch (JMException e) {
_log.warn("Unable to register log4j JMX control", e);
}
try {
runFromConfig(_config);
// Dual coordinator - a hack for 1+0 (dev environment only) in DR. End customer uses 2+1 or 3+2 only and never goes into this case.
//
// We run 2 zookeeper instances for 1+0 to address a limitation in ZOOKEEPER-1692 in 3.4.6. ZK doesn't
// allow observers for standalone zookeeper(single zk participants). So we run 2 zookeeper servers here to
// simulate 2 zk participants and bypass this limitation, then we are able to add zk observers for DR sites.
// /etc/genconfig.d/coordinator generates 2 zk servers to coordinator-var.xml, and here we start
//
// ZK 3.5 introduces new parameter standaloneEnabled to address this limitation. Need revisit this hack after upgraded to zk 3.5
int serverCnt = _config.getNumberOfParitipants();
if (serverCnt == 2 && _config.getPeerType().equals(LearnerType.PARTICIPANT)) {
_log.info("Starting the other peer to run zk in cluster mode. Aim to address a ZK 3.4.6 limitation(cannot add observers to standalone server)");
Properties prop = new Properties();
prop.setProperty("dataDir", _config.getDataDir() + "/peer2");
// a deferent port
prop.setProperty("clientPort", DUAL_COORDINATOR_CLIENT_PORT);
SpringQuorumPeerConfig newConfig = _config.createNewConfig(prop, 2);
runFromConfig(newConfig);
}
} catch (Exception ex) {
_log.error("Unexpected error when starting Zookeeper peer", ex);
throw new IllegalStateException("Fail to start zookeeper", ex);
}
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.ServerConfig in project coprhd-controller by CoprHD.
the class ZkSimulator method start.
/**
* Starts standalone Zookeeper service
*/
public void start() throws Exception {
final ServerConfig serverConfig = new ServerConfig();
serverConfig.readFrom(config);
final ZooKeeperServerMain server = new ZooKeeperServerMain();
Thread zkService = new Thread(new Runnable() {
@Override
public void run() {
try {
server.runFromConfig(serverConfig);
} catch (IOException e) {
log.error("coordinator start failure", e);
}
}
});
zkService.setDaemon(true);
zkService.start();
coordinatorClient = connectClient();
}
Aggregations