Browse Source

Increase block-until-connected in ZookeeperRegistryTestCase (#16041)

upstream-dev
Wenjun Ruan 6 months ago committed by GitHub
parent
commit
e4df01a033
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistry.java
  2. 2
      dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/test/resources/application.yaml

12
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistry.java

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.registry.api.Registry;
import org.apache.dolphinscheduler.registry.api.RegistryException; import org.apache.dolphinscheduler.registry.api.RegistryException;
import org.apache.dolphinscheduler.registry.api.SubscribeListener; import org.apache.dolphinscheduler.registry.api.SubscribeListener;
import org.apache.commons.lang3.time.DurationUtils;
import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.ACLProvider; import org.apache.curator.framework.api.ACLProvider;
@ -76,8 +77,8 @@ final class ZookeeperRegistry implements Registry {
.connectString(properties.getConnectString()) .connectString(properties.getConnectString())
.retryPolicy(retryPolicy) .retryPolicy(retryPolicy)
.namespace(properties.getNamespace()) .namespace(properties.getNamespace())
.sessionTimeoutMs((int) properties.getSessionTimeout().toMillis()) .sessionTimeoutMs(DurationUtils.toMillisInt(properties.getSessionTimeout()))
.connectionTimeoutMs((int) properties.getConnectionTimeout().toMillis()); .connectionTimeoutMs(DurationUtils.toMillisInt(properties.getConnectionTimeout()));
final String digest = properties.getDigest(); final String digest = properties.getDigest();
if (!Strings.isNullOrEmpty(digest)) { if (!Strings.isNullOrEmpty(digest)) {
@ -102,9 +103,10 @@ final class ZookeeperRegistry implements Registry {
public void start() { public void start() {
client.start(); client.start();
try { try {
if (!client.blockUntilConnected((int) properties.getBlockUntilConnected().toMillis(), MILLISECONDS)) { if (!client.blockUntilConnected(DurationUtils.toMillisInt(properties.getBlockUntilConnected()),
MILLISECONDS)) {
client.close(); client.close();
throw new RegistryException("zookeeper connect timeout: " + properties.getConnectString()); throw new RegistryException("zookeeper connect failed in : " + properties.getConnectString() + "ms");
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
@ -120,7 +122,7 @@ final class ZookeeperRegistry implements Registry {
@Override @Override
public void connectUntilTimeout(@NonNull Duration timeout) throws RegistryException { public void connectUntilTimeout(@NonNull Duration timeout) throws RegistryException {
try { try {
if (!client.blockUntilConnected((int) timeout.toMillis(), MILLISECONDS)) { if (!client.blockUntilConnected(DurationUtils.toMillisInt(timeout), MILLISECONDS)) {
throw new RegistryException( throw new RegistryException(
String.format("Cannot connect to registry in %s s", timeout.getSeconds())); String.format("Cannot connect to registry in %s s", timeout.getSeconds()));
} }

2
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/test/resources/application.yaml

@ -26,5 +26,5 @@ registry:
max-retries: 5 max-retries: 5
session-timeout: 30s session-timeout: 30s
connection-timeout: 9s connection-timeout: 9s
block-until-connected: 600ms block-until-connected: 3s
digest: ~ digest: ~

Loading…
Cancel
Save