@Override public boolean equals(Object obj) { if (!(obj instanceof ZooKeeperReplicationConfig)) { return false; } if (obj == this) { return true; } final ZooKeeperReplicationConfig that = (ZooKeeperReplicationConfig) obj; return serverId() == that.serverId() && servers().equals(that.servers()) && additionalProperties().equals(that.additionalProperties()) && timeoutMillis() == that.timeoutMillis() && numWorkers() == that.numWorkers() && maxLogCount() == that.maxLogCount() && minLogAgeMillis() == that.minLogAgeMillis(); }
private static int findServerId(Map<Integer, ZooKeeperAddress> servers, int currentServerId, NetworkInterface iface) { for (final Enumeration<InetAddress> ea = iface.getInetAddresses(); ea.hasMoreElements();) { currentServerId = findServerId(servers, currentServerId, ea.nextElement()); } return currentServerId; }
private EmbeddedZooKeeper startZooKeeper() throws Exception { logger.info("Starting the ZooKeeper peer ({}) ..", cfg.serverId()); EmbeddedZooKeeper peer = null; boolean success = false; out.write((cfg.serverId() + "\n").getBytes(StandardCharsets.US_ASCII)); final StringBuilder buf = new StringBuilder(); final String newline = System.lineSeparator(); final String escapedSecret = jaasValueEscaper.escape(cfg.secret()); ImmutableList.of("Server", EmbeddedZooKeeper.SASL_SERVER_LOGIN_CONTEXT).forEach(name -> { buf.append(name).append(" {").append(newline); zkProps.setProperty("clientPort", String.valueOf(cfg.serverAddress().clientPort())); cfg.servers().forEach((id, addr) -> { zkProps.setProperty( "server." + id,
private void deleteLogs() throws Exception { final List<String> children = curator.getChildren().forPath(absolutePath(LOG_PATH)); if (children.size() <= cfg.maxLogCount()) { return; final long minAllowedTimestamp = System.currentTimeMillis() - cfg.minLogAgeMillis(); final int targetCount = children.size() - cfg.maxLogCount(); final List<String> deleted = new ArrayList<>(targetCount); children.sort(Comparator.comparingLong(Long::parseLong));
"127.0.0.1:" + quorumPeer.getClientPort(), cfg.timeoutMillis(), cfg.timeoutMillis(), (retryCount, elapsedTimeMs, sleeper) -> { return retryPolicy.allowRetry(retryCount, elapsedTimeMs, sleeper); cfg.numWorkers(), cfg.numWorkers(), 60, TimeUnit.SECONDS, new LinkedTransferQueue<>(), new DefaultThreadFactory("zookeeper-command-executor", true));
@Override public int replicaId() { return cfg.serverId(); }
private void copyZkProperty(Properties zkProps, String key, String defaultValue) { zkProps.setProperty(key, cfg.additionalProperties().getOrDefault(key, defaultValue)); }
private EmbeddedZooKeeper startZooKeeper() throws Exception { logger.info("Starting the ZooKeeper peer ({}) ..", cfg.serverId()); EmbeddedZooKeeper peer = null; boolean success = false; out.write((cfg.serverId() + "\n").getBytes(StandardCharsets.US_ASCII)); final StringBuilder buf = new StringBuilder(); final String newline = System.lineSeparator(); final String escapedSecret = jaasValueEscaper.escape(cfg.secret()); ImmutableList.of("Server", EmbeddedZooKeeper.SASL_SERVER_LOGIN_CONTEXT).forEach(name -> { buf.append(name).append(" {").append(newline); zkProps.setProperty("clientPort", String.valueOf(cfg.serverAddress().clientPort())); cfg.servers().forEach((id, addr) -> { zkProps.setProperty( "server." + id,
private void deleteLogs() throws Exception { final List<String> children = curator.getChildren().forPath(absolutePath(LOG_PATH)); if (children.size() <= cfg.maxLogCount()) { return; final long minAllowedTimestamp = System.currentTimeMillis() - cfg.minLogAgeMillis(); final int targetCount = children.size() - cfg.maxLogCount(); final List<String> deleted = new ArrayList<>(targetCount); children.sort(Comparator.comparingLong(Long::parseLong));
"127.0.0.1:" + quorumPeer.getClientPort(), cfg.timeoutMillis(), cfg.timeoutMillis(), (retryCount, elapsedTimeMs, sleeper) -> { return retryPolicy.allowRetry(retryCount, elapsedTimeMs, sleeper); cfg.numWorkers(), cfg.numWorkers(), 60, TimeUnit.SECONDS, new LinkedTransferQueue<>(), new DefaultThreadFactory("zookeeper-command-executor", true));
@Override public int replicaId() { return cfg.serverId(); }
private void copyZkProperty(Properties zkProps, String key, String defaultValue) { zkProps.setProperty(key, cfg.additionalProperties().getOrDefault(key, defaultValue)); }
@Override public boolean equals(Object obj) { if (!(obj instanceof ZooKeeperReplicationConfig)) { return false; } if (obj == this) { return true; } final ZooKeeperReplicationConfig that = (ZooKeeperReplicationConfig) obj; return serverId() == that.serverId() && servers().equals(that.servers()) && additionalProperties().equals(that.additionalProperties()) && timeoutMillis() == that.timeoutMillis() && numWorkers() == that.numWorkers() && maxLogCount() == that.maxLogCount() && minLogAgeMillis() == that.minLogAgeMillis(); }
private EmbeddedZooKeeper startZooKeeper() throws Exception { logger.info("Starting the ZooKeeper peer ({}) ..", cfg.serverId()); EmbeddedZooKeeper peer = null; boolean success = false; out.write((cfg.serverId() + "\n").getBytes(StandardCharsets.US_ASCII)); final StringBuilder buf = new StringBuilder(); final String newline = System.lineSeparator(); final String escapedSecret = jaasValueEscaper.escape(cfg.secret()); ImmutableList.of("Server", EmbeddedZooKeeper.SASL_SERVER_LOGIN_CONTEXT).forEach(name -> { buf.append(name).append(" {").append(newline); zkProps.setProperty("clientPort", String.valueOf(cfg.serverAddress().clientPort())); cfg.servers().forEach((id, addr) -> { zkProps.setProperty( "server." + id,
private void deleteLogs() throws Exception { final List<String> children = curator.getChildren().forPath(absolutePath(LOG_PATH)); if (children.size() <= cfg.maxLogCount()) { return; final long minAllowedTimestamp = System.currentTimeMillis() - cfg.minLogAgeMillis(); final int targetCount = children.size() - cfg.maxLogCount(); final List<String> deleted = new ArrayList<>(targetCount); children.sort(Comparator.comparingLong(Long::parseLong));
"127.0.0.1:" + quorumPeer.getClientPort(), cfg.timeoutMillis(), cfg.timeoutMillis(), (retryCount, elapsedTimeMs, sleeper) -> { return retryPolicy.allowRetry(retryCount, elapsedTimeMs, sleeper); cfg.numWorkers(), cfg.numWorkers(), 60, TimeUnit.SECONDS, new LinkedTransferQueue<>(), new DefaultThreadFactory("zookeeper-command-executor", true));
private static int findServerId(Map<Integer, ZooKeeperAddress> servers, int currentServerId, NetworkInterface iface) { for (final Enumeration<InetAddress> ea = iface.getInetAddresses(); ea.hasMoreElements();) { currentServerId = findServerId(servers, currentServerId, ea.nextElement()); } return currentServerId; }
@Override public int replicaId() { return cfg.serverId(); }
private void copyZkProperty(Properties zkProps, String key, String defaultValue) { zkProps.setProperty(key, cfg.additionalProperties().getOrDefault(key, defaultValue)); }
@Override public boolean equals(Object obj) { if (!(obj instanceof ZooKeeperReplicationConfig)) { return false; } if (obj == this) { return true; } final ZooKeeperReplicationConfig that = (ZooKeeperReplicationConfig) obj; return serverId() == that.serverId() && servers().equals(that.servers()) && additionalProperties().equals(that.additionalProperties()) && timeoutMillis() == that.timeoutMillis() && numWorkers() == that.numWorkers() && maxLogCount() == that.maxLogCount() && minLogAgeMillis() == that.minLogAgeMillis(); }