Java Code Examples for org.apache.zookeeper.server.quorum.QuorumPeerConfig#ConfigException
The following examples show how to use
org.apache.zookeeper.server.quorum.QuorumPeerConfig#ConfigException .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrZkServer.java From lucene-solr with Apache License 2.0 | 6 votes |
public void parseConfig() { if (zkProps == null) { zkProps = new SolrZkServerProps(); // set default data dir // TODO: use something based on IP+port??? support ensemble all from same solr home? zkProps.setDataDir(dataHome); zkProps.zkRun = zkRun; zkProps.solrPort = Integer.toString(solrPort); } try { props = SolrZkServerProps.getProperties(confHome + '/' + "zoo.cfg"); SolrZkServerProps.injectServers(props, zkRun, zkHost); if (props.getProperty("clientPort") == null) { props.setProperty("clientPort", Integer.toString(solrPort + 1000)); } zkProps.parseProperties(props); } catch (QuorumPeerConfig.ConfigException | IOException e) { if (zkRun != null) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e); } }
Example 2
Source File: MiniZooKeeperCluster.java From util with Apache License 2.0 | 6 votes |
public MiniZooKeeperCluster(final String dataDir) throws IOException { final int zkPort = getFreePort(); zkNodes = "localhost:" + zkPort; server = new Hack(); zkServerThread = new Thread(new Runnable() { @Override public void run() { try { server.initializeAndRun(new String[]{Integer.toString(zkPort), dataDir}); } catch (QuorumPeerConfig.ConfigException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } }); zkServerThread.setDaemon(true); zkServerThread.start(); waitForServerStartup(); }
Example 3
Source File: Curator.java From vespa with Apache License 2.0 | 5 votes |
private static ZKClientConfig createClientConfig(Optional<File> clientConfigFile) { if (clientConfigFile.isPresent()) { boolean useSecureClient = Boolean.parseBoolean(getEnvironmentVariable("VESPA_USE_TLS_FOR_ZOOKEEPER_CLIENT").orElse("false")); String config = "zookeeper.client.secure=" + useSecureClient + "\n"; clientConfigFile.get().getParentFile().mkdirs(); IOUtils.writeFile(clientConfigFile.get(), Utf8.toBytes(config)); try { return new ZKClientConfig(clientConfigFile.get()); } catch (QuorumPeerConfig.ConfigException e) { throw new RuntimeException("Unable to create ZooKeeper client config file " + clientConfigFile.get()); } } else { return new ZKClientConfig(); } }
Example 4
Source File: ZkStarter.java From incubator-pinot with Apache License 2.0 | 5 votes |
@Override public void initializeAndRun(String[] args) throws QuorumPeerConfig.ConfigException, IOException { // org.apache.log4j.jmx.* is not compatible under log4j-1.2-api, which provides the backward compatibility for // log4j 1.* api for log4j2. In order to avoid 'class not found error', the following line disables log4j jmx // bean registration for local zookeeper instance System.setProperty("zookeeper.jmx.log4j.disable", "true"); super.initializeAndRun(args); }
Example 5
Source File: ZkStarter.java From uReplicator with Apache License 2.0 | 4 votes |
@Override public void initializeAndRun(String[] args) throws QuorumPeerConfig.ConfigException, IOException { super.initializeAndRun(args); }
Example 6
Source File: LocalZKServer.java From oryx with Apache License 2.0 | 4 votes |
/** * Starts Zookeeper. * * @throws IOException if an error occurs during initialization * @throws InterruptedException if an error occurs during initialization */ public synchronized void start() throws IOException, InterruptedException { log.info("Starting Zookeeper on port {}", port); dataDir = Files.createTempDirectory(LocalZKServer.class.getSimpleName()); dataDir.toFile().deleteOnExit(); QuorumPeerConfig quorumConfig = new QuorumPeerConfig(); try { quorumConfig.parseProperties(ConfigUtils.keyValueToProperties( "dataDir", dataDir.toAbsolutePath(), "clientPort", port )); } catch (QuorumPeerConfig.ConfigException e) { throw new IllegalArgumentException(e); } purgeManager = new DatadirCleanupManager(quorumConfig.getDataDir(), quorumConfig.getDataLogDir(), quorumConfig.getSnapRetainCount(), quorumConfig.getPurgeInterval()); purgeManager.start(); ServerConfig serverConfig = new ServerConfig(); serverConfig.readFrom(quorumConfig); zkServer = new ZooKeeperServer(); zkServer.setTickTime(serverConfig.getTickTime()); zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout()); zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout()); // These two ServerConfig methods returned String in 3.4.x and File in 3.5.x transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()), new File(serverConfig.getDataDir().toString())); zkServer.setTxnLogFactory(transactionLog); connectionFactory = ServerCnxnFactory.createFactory(); connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns()); connectionFactory.startup(zkServer); }
Example 7
Source File: ZkStarter.java From incubator-pinot with Apache License 2.0 | 4 votes |
@Override public void runFromConfig(final ServerConfig config) throws IOException { ServerConfig newServerConfig = new ServerConfig() { public void parse(String[] args) { config.parse(args); } public void parse(String path) throws QuorumPeerConfig.ConfigException { config.parse(path); } public void readFrom(QuorumPeerConfig otherConfig) { config.readFrom(otherConfig); } public InetSocketAddress getClientPortAddress() { return config.getClientPortAddress(); } public String getDataDir() { return config.getDataDir(); } public String getDataLogDir() { return config.getDataLogDir(); } public int getTickTime() { return config.getTickTime(); } public int getMaxClientCnxns() { dataDir = getDataDir(); dataLogDir = getDataLogDir(); tickTime = getTickTime(); minSessionTimeout = getMinSessionTimeout(); maxSessionTimeout = getMaxSessionTimeout(); maxClientCnxns = 0; return 0; } public int getMinSessionTimeout() { return config.getMinSessionTimeout(); } public int getMaxSessionTimeout() { return config.getMaxSessionTimeout(); } }; newServerConfig.getMaxClientCnxns(); super.runFromConfig(newServerConfig); }
Example 8
Source File: MiniZooKeeperCluster.java From util with Apache License 2.0 | 4 votes |
@Override public void initializeAndRun(String[] args) throws QuorumPeerConfig.ConfigException, IOException { super.initializeAndRun(args); }