use of 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.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.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.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.zookeeper.server.ServerConfig in project hbase by apache.
the class HQuorumPeer method runZKServer.
private static void runZKServer(QuorumPeerConfig zkConfig) throws UnknownHostException, IOException {
if (zkConfig.isDistributed()) {
QuorumPeerMain qp = new QuorumPeerMain();
qp.runFromConfig(zkConfig);
} else {
ZooKeeperServerMain zk = new ZooKeeperServerMain();
ServerConfig serverConfig = new ServerConfig();
serverConfig.readFrom(zkConfig);
zk.runFromConfig(serverConfig);
}
}
Aggregations