You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2019/10/28 16:39:14 UTC
[aries-rsa] branch master updated: ARIES-1780 - Start zookeeper
synchronously as it should not block anyway
This is an automated email from the ASF dual-hosted git repository.
cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
The following commit(s) were added to refs/heads/master by this push:
new 0459da9 ARIES-1780 - Start zookeeper synchronously as it should not block anyway
0459da9 is described below
commit 0459da97d86601a9643b96082247bcd8d574e688
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Mon Oct 28 17:36:38 2019 +0100
ARIES-1780 - Start zookeeper synchronously as it should not block anyway
---
.../rsa/discovery/zookeeper/ClientManager.java | 29 +---------------------
1 file changed, 1 insertion(+), 28 deletions(-)
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/ClientManager.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/ClientManager.java
index 691cc50..9ba3fd2 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/ClientManager.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/ClientManager.java
@@ -19,7 +19,6 @@
package org.apache.aries.rsa.discovery.zookeeper;
import java.io.IOException;
-import java.net.Socket;
import java.util.Hashtable;
import java.util.concurrent.CompletableFuture;
@@ -46,7 +45,6 @@ import org.slf4j.LoggerFactory;
)
public class ClientManager implements Watcher {
- private static final int MAX_PORT_WAIT_MS = 2000;
private static final Logger LOG = LoggerFactory.getLogger(ClientManager.class);
private ZooKeeper zkClient;
@@ -59,11 +57,7 @@ public class ClientManager implements Watcher {
this.config = config;
this.context = context;
LOG.debug("Received configuration update for Zookeeper Discovery: {}", config);
- CompletableFuture.runAsync(new Runnable() {
- public void run() {
- startClient();
- }
- });
+ startClient();
}
private void startClient() {
@@ -76,7 +70,6 @@ public class ClientManager implements Watcher {
protected ZooKeeper createClient(DiscoveryConfig config) throws IOException {
LOG.info("ZooKeeper discovery connecting to {}:{} with timeout {}", config.zookeeper_host(), config.zookeeper_port(), config.zookeeper_timeout());
- waitPort(config);
return new ZooKeeper(config.zookeeper_host() + ":" + config.zookeeper_port(), config.zookeeper_timeout(), this);
}
@@ -119,26 +112,6 @@ public class ClientManager implements Watcher {
}
}
- private void waitPort(DiscoveryConfig config) {
- String host = config.zookeeper_host();
- Integer port = Integer.parseInt(config.zookeeper_port());
- long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < MAX_PORT_WAIT_MS) {
- try (Socket socket = new Socket(host, port)) {
- return;
- } catch (IOException e) {
- safeSleep();
- }
- }
- }
-
- private void safeSleep() {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e1) {
- }
- }
-
@ObjectClassDefinition(name = "Zookeeper discovery config")
public @interface DiscoveryConfig {
String zookeeper_host() default "localhost";