use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project motan by weibocom.
the class EmbeddedZookeeper method start.
public void start() throws IOException, QuorumPeerConfig.ConfigException {
Properties properties = new Properties();
InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg");
properties.load(in);
QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
quorumConfiguration.parseProperties(properties);
in.close();
zookeeperServer = new ZooKeeperServerMain();
final ServerConfig configuration = new ServerConfig();
configuration.readFrom(quorumConfiguration);
t1 = new Thread(new Runnable() {
@Override
public void run() {
try {
zookeeperServer.runFromConfig(configuration);
} catch (IOException e) {
}
}
});
t1.start();
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project motan by weibocom.
the class EmbeddedZookeeper method start.
public void start() throws IOException, QuorumPeerConfig.ConfigException {
Properties properties = new Properties();
InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg");
properties.load(in);
QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
quorumConfiguration.parseProperties(properties);
in.close();
zookeeperServer = new ZooKeeperServerMain();
final ServerConfig configuration = new ServerConfig();
configuration.readFrom(quorumConfiguration);
t1 = new Thread(new Runnable() {
@Override
public void run() {
try {
zookeeperServer.runFromConfig(configuration);
} catch (IOException e) {
}
}
});
t1.start();
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project flink by apache.
the class FlinkZooKeeperQuorumPeer method runFlinkZkQuorumPeer.
// ------------------------------------------------------------------------
/**
* Runs a ZooKeeper {@link QuorumPeer} if further peers are configured or a single {@link
* ZooKeeperServer} if no further peers are configured.
*
* @param zkConfigFile ZooKeeper config file 'zoo.cfg'
* @param peerId ID for the 'myid' file
*/
public static void runFlinkZkQuorumPeer(String zkConfigFile, int peerId) throws Exception {
Properties zkProps = new Properties();
try (InputStream inStream = new FileInputStream(new File(zkConfigFile))) {
zkProps.load(inStream);
}
LOG.info("Configuration: " + zkProps);
// Set defaults for required properties
setRequiredProperties(zkProps);
// Write peer id to myid file
writeMyIdToDataDir(zkProps, peerId);
// The myid file needs to be written before creating the instance. Otherwise, this
// will fail.
QuorumPeerConfig conf = new QuorumPeerConfig();
conf.parseProperties(zkProps);
if (conf.isDistributed()) {
// Run quorum peer
LOG.info("Running distributed ZooKeeper quorum peer (total peers: {}).", conf.getServers().size());
QuorumPeerMain qp = new QuorumPeerMain();
qp.runFromConfig(conf);
} else {
// Run standalone
LOG.info("Running standalone ZooKeeper quorum peer.");
ZooKeeperServerMain zk = new ZooKeeperServerMain();
ServerConfig sc = new ServerConfig();
sc.readFrom(conf);
zk.runFromConfig(sc);
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project jmxtrans by jmxtrans.
the class EmbeddedZookeeper method before.
@Override
public void before() throws Exception {
LOGGER.info("Starting Zookeeper");
Properties properties = getResourceAsProperties("zookeeper.properties");
dataDir = temporaryFolder.newFolder("zookeeper");
properties.setProperty("dataDir", dataDir.getAbsolutePath());
QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
try {
quorumConfiguration.parseProperties(properties);
} catch (Exception e) {
throw new RuntimeException(e);
}
final ServerConfig configuration = new ServerConfig();
configuration.readFrom(quorumConfiguration);
// Start Zookeeper in separate thread
executor.execute(new Runnable() {
@Override
public void run() {
runServer(configuration);
}
});
// Wait for Zookeeper to be started
await().atMost(5, TimeUnit.SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return getServerCnxnFactory() != null;
}
});
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.server.quorum.QuorumPeerConfig in project hbase by apache.
the class HQuorumPeer method main.
/**
* Parse ZooKeeper configuration from HBase XML config and run a QuorumPeer.
* @param args String[] of command line arguments. Not used.
*/
public static void main(String[] args) {
Configuration conf = HBaseConfiguration.create();
try {
Properties zkProperties = ZKConfig.makeZKProps(conf);
writeMyID(zkProperties);
QuorumPeerConfig zkConfig = new QuorumPeerConfig();
zkConfig.parseProperties(zkProperties);
// login the zookeeper server principal (if using security)
ZKAuthentication.loginServer(conf, HConstants.ZK_SERVER_KEYTAB_FILE, HConstants.ZK_SERVER_KERBEROS_PRINCIPAL, zkConfig.getClientPortAddress().getHostName());
runZKServer(zkConfig);
} catch (Exception e) {
LOG.error("Failed to start ZKServer", e);
System.exit(-1);
}
}
Aggregations