Java Code Examples for org.apache.zookeeper.server.quorum.QuorumPeerConfig#parseProperties()
The following examples show how to use
org.apache.zookeeper.server.quorum.QuorumPeerConfig#parseProperties() .
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: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 6 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 2
Source File: HQuorumPeer.java From hbase with Apache License 2.0 | 6 votes |
/** * 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) ZKUtil.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); } }
Example 3
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 6 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 4
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 6 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 5
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 6 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 6
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 6 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 7
Source File: LocalZookeeper.java From beam with Apache License 2.0 | 5 votes |
LocalZookeeper(int port) throws Exception { Properties localProperties = new Properties(); localProperties.setProperty("clientPort", String.valueOf(port)); localProperties.setProperty("dataDir", Files.createTempDirectory("zookeeper-").toString()); QuorumPeerConfig config = new QuorumPeerConfig(); config.parseProperties(localProperties); serverConfig = new ServerConfig(); serverConfig.readFrom(config); executor = Executors.newSingleThreadExecutor(); }
Example 8
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 9
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 10
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 11
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 12
Source File: LocalServer.java From flow-platform-x with Apache License 2.0 | 5 votes |
public void run() { try { QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); ServerConfig configuration = new ServerConfig(); quorumPeerConfig.parseProperties(properties); configuration.readFrom(quorumPeerConfig); this.runFromConfig(configuration); } catch (Exception e) { throw new ZookeeperException("Unable to start embedded zookeeper server: {}", e.getMessage()); } }
Example 13
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 14
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 15
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 16
Source File: LocalServer.java From flow-platform-x with Apache License 2.0 | 5 votes |
public void run() { try { QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); ServerConfig configuration = new ServerConfig(); quorumPeerConfig.parseProperties(properties); configuration.readFrom(quorumPeerConfig); this.runFromConfig(configuration); } catch (IOException | ConfigException e) { throw new ZookeeperException("Unable to start embedded zookeeper server: {}", e.getMessage()); } }
Example 17
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 18
Source File: EmbeddedZooKeeper.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Override public void run() { try { Properties properties = new Properties(); File file = new File(System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID()); file.deleteOnExit(); properties.setProperty("dataDir", file.getAbsolutePath()); properties.setProperty("clientPort", String.valueOf(clientPort)); QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(properties); zkServer = new ZooKeeperServerMain(); ServerConfig configuration = new ServerConfig(); configuration.readFrom(quorumPeerConfig); zkServer.runFromConfig(configuration); } catch (Exception e) { if (errorHandler != null) { errorHandler.handleError(e); } else { logger.error("Exception running embedded ZooKeeper", e); } } }
Example 19
Source File: ZooKeeperStateServer.java From nifi with Apache License 2.0 | 4 votes |
private ZooKeeperStateServer(final Properties zkProperties) throws IOException, ConfigException { quorumPeerConfig = new QuorumPeerConfig(); quorumPeerConfig.parseProperties(zkProperties); }
Example 20
Source File: QuorumConfigBuilder.java From curator with Apache License 2.0 | 4 votes |
public QuorumPeerConfig buildConfig(int instanceIndex) throws Exception { boolean isCluster = (instanceSpecs.size() > 1); InstanceSpec spec = instanceSpecs.get(instanceIndex); if ( isCluster ) { Files.write(Integer.toString(spec.getServerId()).getBytes(), new File(spec.getDataDirectory(), "myid")); } Properties properties = new Properties(); properties.setProperty("initLimit", "10"); properties.setProperty("syncLimit", "5"); properties.setProperty("dataDir", spec.getDataDirectory().getCanonicalPath()); properties.setProperty("clientPort", Integer.toString(spec.getPort())); String tickTime = Integer.toString((spec.getTickTime() >= 0) ? spec.getTickTime() : new Timing2().tickTime()); properties.setProperty("tickTime", tickTime); properties.setProperty("minSessionTimeout", tickTime); int maxClientCnxns = spec.getMaxClientCnxns(); if ( maxClientCnxns >= 0 ) { properties.setProperty("maxClientCnxns", Integer.toString(maxClientCnxns)); } if ( isCluster ) { for ( InstanceSpec thisSpec : instanceSpecs ) { properties.setProperty("server." + thisSpec.getServerId(), String.format("%s:%d:%d;%s:%d", thisSpec.getHostname(), thisSpec.getQuorumPort(), thisSpec.getElectionPort(), thisSpec.getHostname(), thisSpec.getPort())); } } Map<String,Object> customProperties = spec.getCustomProperties(); if (customProperties != null) { for (Map.Entry<String,Object> property : customProperties.entrySet()) { properties.put(property.getKey(), property.getValue()); } } QuorumPeerConfig config = new QuorumPeerConfig() { { if ( fakeConfigFile != null ) { configFileStr = fakeConfigFile.getPath(); } } }; config.parseProperties(properties); return config; }