refreshSignal = new ScheduledSignal<>("service-hub-refresh-timer",
() -> null,
Collections.emptyList(),
diff --git a/ranger-client/src/main/java/io/appform/ranger/client/RangerClientConstants.java b/ranger-core/src/main/java/io/appform/ranger/core/model/HubConstants.java
similarity index 62%
rename from ranger-client/src/main/java/io/appform/ranger/client/RangerClientConstants.java
rename to ranger-core/src/main/java/io/appform/ranger/core/model/HubConstants.java
index 3b8a6fc9..58d09e9c 100644
--- a/ranger-client/src/main/java/io/appform/ranger/client/RangerClientConstants.java
+++ b/ranger-core/src/main/java/io/appform/ranger/core/model/HubConstants.java
@@ -1,24 +1,27 @@
/*
* Copyright 2015 Flipkart Internet Pvt. Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.appform.ranger.client;
+package io.appform.ranger.core.model;
import lombok.experimental.UtilityClass;
@UtilityClass
-public class RangerClientConstants {
- public static final int CONNECTION_RETRY_TIME = 5000;
- public static final int MINIMUM_REFRESH_TIME = 5000;
+public class HubConstants {
+ public static final long SERVICE_REFRESH_DURATION_MS = 10_000;
+ public static final long HUB_REFRESH_DURATION_MS = 30_000;
+ public static final long REFRESH_FREQUENCY_MS = 10_000;
+ public static final int CONNECTION_RETRY_TIME_MS = 5_000;
+ public static final int MINIMUM_REFRESH_TIME_MS = 5_000;
}
diff --git a/ranger-core/src/test/java/io/appform/ranger/core/finderhub/ServiceFinderHubTest.java b/ranger-core/src/test/java/io/appform/ranger/core/finderhub/ServiceFinderHubTest.java
index cc76b11c..43a92024 100644
--- a/ranger-core/src/test/java/io/appform/ranger/core/finderhub/ServiceFinderHubTest.java
+++ b/ranger-core/src/test/java/io/appform/ranger/core/finderhub/ServiceFinderHubTest.java
@@ -11,6 +11,8 @@
import io.appform.ranger.core.model.*;
import io.appform.ranger.core.units.TestNodeData;
import java.util.Optional;
+
+import io.appform.ranger.core.utils.RangerTestUtils;
import lombok.val;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -41,9 +43,7 @@ void testDynamicServiceAddition() {
Assertions.assertEquals("HOST", node.get().getHost());
Assertions.assertEquals(0, node.get().getPort());
- serviceFinderHub.buildFinder(new Service("NS", "SERVICE")).join();
- val dynamicServiceFinder = serviceFinderHub.finder(new Service("NS", "SERVICE"))
- .orElseThrow(() -> new IllegalStateException("Finder should be present"));
+ val dynamicServiceFinder = serviceFinderHub.buildFinder(new Service("NS", "SERVICE")).join();
val dynamicServiceNode = dynamicServiceFinder.get(null, (criteria, serviceRegistry) -> serviceRegistry.nodeList());
Assertions.assertTrue(dynamicServiceNode.isPresent());
Assertions.assertEquals("HOST", dynamicServiceNode.get().getHost());
@@ -51,20 +51,31 @@ void testDynamicServiceAddition() {
}
@Test
- void testDynamicServiceAdditionAsync() throws InterruptedException {
+ void testDelayedServiceAddition() {
+ val delayedHub = new ServiceFinderHub<>(new DynamicDataSource(Lists.newArrayList(new Service("NS", "SERVICE"))),
+ service -> new TestServiceFinderBuilder()
+ .withNamespace(service.getNamespace())
+ .withServiceName(service.getServiceName())
+ .withDeserializer(new Deserializer() {})
+ .withSleepDuration(5)
+ .build(), 1_000, 5_000
+ );
+ Assertions.assertThrows(IllegalStateException.class, delayedHub::start);
+ val serviceFinderHub = new ServiceFinderHub<>(new DynamicDataSource(Lists.newArrayList(new Service("NS", "SERVICE"))),
+ service -> new TestServiceFinderBuilder()
+ .withNamespace(service.getNamespace())
+ .withServiceName(service.getServiceName())
+ .withDeserializer(new Deserializer() {})
+ .withSleepDuration(1)
+ .build(), 2_000, 5_000
+ );
serviceFinderHub.start();
- serviceFinderHub.buildFinder(new Service("NS", "SERVICE_NAME"));
- val finderOpt = serviceFinderHub.finder(new Service("NS", "SERVICE_NAME"));
- Assertions.assertFalse(finderOpt.isPresent(), "Finders will not be availbale immediately");
- Thread.sleep(1000);
- val finderAfterWaitOpt = serviceFinderHub.finder(new Service("NS", "SERVICE_NAME"));
- Assertions.assertTrue(finderAfterWaitOpt.isPresent(), "Finders should be availble after some time");
+ Assertions.assertTrue(serviceFinderHub.finder(new Service("NS", "SERVICE")).isPresent());
}
@Test
void testDynamicServiceAdditionWithNonDynamicDataSource() {
-
val serviceFinderHub = new ServiceFinderHub<>(new StaticDataSource(new HashSet<>()), service -> new TestServiceFinderBuilder()
.withNamespace(service.getNamespace())
.withServiceName(service.getServiceName())
@@ -73,8 +84,7 @@ void testDynamicServiceAdditionWithNonDynamicDataSource() {
.build());
serviceFinderHub.start();
try {
- val future = serviceFinderHub.buildFinder(new Service("NS", "SERVICE_NAME"));
- future.join();
+ serviceFinderHub.buildFinder(new Service("NS", "SERVICE_NAME")).join();
Assertions.fail("Exception should have been thrown");
} catch (Exception exception) {
Assertions.assertTrue(exception instanceof UnsupportedOperationException, "Unsupported exception should be thrown");
@@ -83,6 +93,8 @@ void testDynamicServiceAdditionWithNonDynamicDataSource() {
private static class TestServiceFinderBuilder extends BaseServiceFinderBuilder, ServiceFinder>, TestServiceFinderBuilder, Deserializer> {
+ private int finderSleepDurationSeconds = 0;
+
@Override
public ServiceFinder> build() {
val bf = buildFinder();
@@ -97,11 +109,16 @@ protected NodeDataSource> dataSource(Se
@Override
protected ServiceFinder> buildFinder(Service service, ShardSelector> shardSelector, ServiceNodeSelector nodeSelector) {
+ RangerTestUtils.sleepUntil(finderSleepDurationSeconds);
if (null == shardSelector) {
shardSelector = new MatchingShardSelector<>();
}
return new SimpleShardedServiceFinder<>(new MapBasedServiceRegistry<>(service), shardSelector, nodeSelector);
+ }
+ public TestServiceFinderBuilder withSleepDuration(final int finderSleepDurationSeconds) {
+ this.finderSleepDurationSeconds = finderSleepDurationSeconds;
+ return this;
}
private static class TestNodeDataSource implements NodeDataSource> {
diff --git a/ranger-discovery-bundle/pom.xml b/ranger-discovery-bundle/pom.xml
index de53430a..da1cd12a 100644
--- a/ranger-discovery-bundle/pom.xml
+++ b/ranger-discovery-bundle/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0
diff --git a/ranger-drove-client/pom.xml b/ranger-drove-client/pom.xml
index a0306e6d..ea1a8031 100644
--- a/ranger-drove-client/pom.xml
+++ b/ranger-drove-client/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0
diff --git a/ranger-drove-client/src/main/java/io/appform/ranger/client/drove/AbstractRangerDroveHubClient.java b/ranger-drove-client/src/main/java/io/appform/ranger/client/drove/AbstractRangerDroveHubClient.java
index 90136c6c..0109c672 100644
--- a/ranger-drove-client/src/main/java/io/appform/ranger/client/drove/AbstractRangerDroveHubClient.java
+++ b/ranger-drove-client/src/main/java/io/appform/ranger/client/drove/AbstractRangerDroveHubClient.java
@@ -54,6 +54,8 @@ protected ServiceFinderHub buildHub() {
.withServiceDataSource(getServiceDataSource())
.withServiceFinderFactory(getFinderFactory())
.withRefreshFrequencyMs(getNodeRefreshTimeMs())
+ .withHubRefreshDuration(getHubRefreshDurationMs())
+ .withServiceRefreshDuration(getServiceRefreshDurationMs())
.build();
}
}
diff --git a/ranger-drove/pom.xml b/ranger-drove/pom.xml
index 147fde4e..24c79302 100644
--- a/ranger-drove/pom.xml
+++ b/ranger-drove/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
1.29
diff --git a/ranger-http-client/pom.xml b/ranger-http-client/pom.xml
index 1068efa0..2ecb3574 100644
--- a/ranger-http-client/pom.xml
+++ b/ranger-http-client/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0
diff --git a/ranger-http-client/src/main/java/io/appform/ranger/client/http/AbstractRangerHttpHubClient.java b/ranger-http-client/src/main/java/io/appform/ranger/client/http/AbstractRangerHttpHubClient.java
index eef30766..0dc6eda8 100644
--- a/ranger-http-client/src/main/java/io/appform/ranger/client/http/AbstractRangerHttpHubClient.java
+++ b/ranger-http-client/src/main/java/io/appform/ranger/client/http/AbstractRangerHttpHubClient.java
@@ -59,6 +59,8 @@ protected ServiceFinderHub buildHub() {
.withServiceDataSource(getServiceDataSource())
.withServiceFinderFactory(getFinderFactory())
.withRefreshFrequencyMs(getNodeRefreshTimeMs())
+ .withHubRefreshDuration(getHubRefreshDurationMs())
+ .withServiceRefreshDuration(getServiceRefreshDurationMs())
.build();
}
}
diff --git a/ranger-http-model/pom.xml b/ranger-http-model/pom.xml
index 79f859cb..2c84e62f 100644
--- a/ranger-http-model/pom.xml
+++ b/ranger-http-model/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0
diff --git a/ranger-http/pom.xml b/ranger-http/pom.xml
index 66063983..616d3bc7 100644
--- a/ranger-http/pom.xml
+++ b/ranger-http/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0
diff --git a/ranger-hub-server-bundle/pom.xml b/ranger-hub-server-bundle/pom.xml
index 088b53c4..7b5505e5 100644
--- a/ranger-hub-server-bundle/pom.xml
+++ b/ranger-hub-server-bundle/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
diff --git a/ranger-hub-server-bundle/src/main/java/io/appform/ranger/hub/server/bundle/RangerHubServerBundle.java b/ranger-hub-server-bundle/src/main/java/io/appform/ranger/hub/server/bundle/RangerHubServerBundle.java
index 306b9ba3..f2ebd03e 100644
--- a/ranger-hub-server-bundle/src/main/java/io/appform/ranger/hub/server/bundle/RangerHubServerBundle.java
+++ b/ranger-hub-server-bundle/src/main/java/io/appform/ranger/hub/server/bundle/RangerHubServerBundle.java
@@ -19,13 +19,13 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.base.Strings;
import com.phonepe.drove.models.api.ExposedAppInfo;
-import io.appform.ranger.client.RangerClientConstants;
import io.appform.ranger.client.RangerHubClient;
import io.appform.ranger.client.drove.UnshardedRangerDroveHubClient;
import io.appform.ranger.client.http.UnshardedRangerHttpHubClient;
import io.appform.ranger.client.zk.UnshardedRangerZKHubClient;
import io.appform.ranger.common.server.ShardInfo;
import io.appform.ranger.core.finder.serviceregistry.ListBasedServiceRegistry;
+import io.appform.ranger.core.model.HubConstants;
import io.appform.ranger.core.model.ServiceNode;
import io.appform.ranger.core.signals.Signal;
import io.appform.ranger.drove.config.DroveUpstreamConfig;
@@ -97,7 +97,7 @@ private RangerHubClient> addCurat
val curatorFramework = CuratorFrameworkFactory.builder()
.connectString(zookeeper)
.namespace(namespace)
- .retryPolicy(new RetryForever(RangerClientConstants.CONNECTION_RETRY_TIME))
+ .retryPolicy(new RetryForever(HubConstants.CONNECTION_RETRY_TIME_MS))
.build();
curatorFrameworks.add(curatorFramework);
return UnshardedRangerZKHubClient.builder()
diff --git a/ranger-hub-server-bundle/src/main/java/io/appform/ranger/hub/server/bundle/configuration/RangerUpstreamConfiguration.java b/ranger-hub-server-bundle/src/main/java/io/appform/ranger/hub/server/bundle/configuration/RangerUpstreamConfiguration.java
index 10e6bcb1..fbae8341 100644
--- a/ranger-hub-server-bundle/src/main/java/io/appform/ranger/hub/server/bundle/configuration/RangerUpstreamConfiguration.java
+++ b/ranger-hub-server-bundle/src/main/java/io/appform/ranger/hub/server/bundle/configuration/RangerUpstreamConfiguration.java
@@ -17,7 +17,7 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import io.appform.ranger.client.RangerClientConstants;
+import io.appform.ranger.core.model.HubConstants;
import io.appform.ranger.hub.server.bundle.models.BackendType;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -38,8 +38,8 @@ public abstract class RangerUpstreamConfiguration {
@NotNull
private BackendType type;
- @Min(RangerClientConstants.MINIMUM_REFRESH_TIME)
- private int nodeRefreshTimeMs = RangerClientConstants.MINIMUM_REFRESH_TIME;
+ @Min(HubConstants.MINIMUM_REFRESH_TIME_MS)
+ private int nodeRefreshTimeMs = HubConstants.MINIMUM_REFRESH_TIME_MS;
protected RangerUpstreamConfiguration(BackendType type) {
this.type = type;
diff --git a/ranger-server-bundle/pom.xml b/ranger-server-bundle/pom.xml
index 9bea4a16..15f59c34 100644
--- a/ranger-server-bundle/pom.xml
+++ b/ranger-server-bundle/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0
diff --git a/ranger-server-common/pom.xml b/ranger-server-common/pom.xml
index e496a4aa..e52ae92a 100644
--- a/ranger-server-common/pom.xml
+++ b/ranger-server-common/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0
diff --git a/ranger-server/pom.xml b/ranger-server/pom.xml
index deb708c8..81df1daf 100644
--- a/ranger-server/pom.xml
+++ b/ranger-server/pom.xml
@@ -6,7 +6,7 @@
io.appform.ranger
ranger
- 1.1-RC1
+ 1.1-RC2
ranger-server
diff --git a/ranger-zk-client/pom.xml b/ranger-zk-client/pom.xml
index 36ab7a01..72f422e0 100644
--- a/ranger-zk-client/pom.xml
+++ b/ranger-zk-client/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0
diff --git a/ranger-zk-client/src/main/java/io/appform/ranger/client/zk/AbstractRangerZKHubClient.java b/ranger-zk-client/src/main/java/io/appform/ranger/client/zk/AbstractRangerZKHubClient.java
index 9322073c..56854f02 100644
--- a/ranger-zk-client/src/main/java/io/appform/ranger/client/zk/AbstractRangerZKHubClient.java
+++ b/ranger-zk-client/src/main/java/io/appform/ranger/client/zk/AbstractRangerZKHubClient.java
@@ -46,6 +46,8 @@ protected ServiceFinderHub buildHub() {
.withRefreshFrequencyMs(getNodeRefreshTimeMs())
.withServiceDataSource(getServiceDataSource())
.withServiceFinderFactory(getFinderFactory())
+ .withHubRefreshDuration(getHubRefreshDurationMs())
+ .withServiceRefreshDuration(getServiceRefreshDurationMs())
.build();
}
diff --git a/ranger-zk-client/src/main/java/io/appform/ranger/client/zk/SimpleRangerZKClient.java b/ranger-zk-client/src/main/java/io/appform/ranger/client/zk/SimpleRangerZKClient.java
index ed8d245f..0206764c 100644
--- a/ranger-zk-client/src/main/java/io/appform/ranger/client/zk/SimpleRangerZKClient.java
+++ b/ranger-zk-client/src/main/java/io/appform/ranger/client/zk/SimpleRangerZKClient.java
@@ -18,10 +18,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions;
import io.appform.ranger.client.AbstractRangerClient;
-import io.appform.ranger.client.RangerClientConstants;
import io.appform.ranger.core.finder.SimpleShardedServiceFinder;
import io.appform.ranger.core.finder.serviceregistry.MapBasedServiceRegistry;
import io.appform.ranger.core.finder.shardselector.MatchingShardSelector;
+import io.appform.ranger.core.model.HubConstants;
import io.appform.ranger.core.model.ShardSelector;
import io.appform.ranger.zookeeper.ServiceFinderBuilders;
import io.appform.ranger.zookeeper.serde.ZkNodeDataDeserializer;
@@ -60,11 +60,11 @@ public void start() {
int effectiveRefreshTime = nodeRefreshIntervalMs;
- if (effectiveRefreshTime < RangerClientConstants.MINIMUM_REFRESH_TIME) {
- effectiveRefreshTime = RangerClientConstants.MINIMUM_REFRESH_TIME;
+ if (effectiveRefreshTime < HubConstants.MINIMUM_REFRESH_TIME_MS) {
+ effectiveRefreshTime = HubConstants.MINIMUM_REFRESH_TIME_MS;
log.warn("Node info update interval too low: {} ms. Has been upgraded to {} ms ",
nodeRefreshIntervalMs,
- RangerClientConstants.MINIMUM_REFRESH_TIME);
+ HubConstants.MINIMUM_REFRESH_TIME_MS);
}
if (null == curatorFramework) {
@@ -72,7 +72,7 @@ public void start() {
curatorFramework = CuratorFrameworkFactory.builder()
.connectString(connectionString)
.namespace(namespace)
- .retryPolicy(new RetryForever(RangerClientConstants.CONNECTION_RETRY_TIME))
+ .retryPolicy(new RetryForever(HubConstants.CONNECTION_RETRY_TIME_MS))
.build();
}
diff --git a/ranger-zookeeper/pom.xml b/ranger-zookeeper/pom.xml
index c7829a76..fd172855 100644
--- a/ranger-zookeeper/pom.xml
+++ b/ranger-zookeeper/pom.xml
@@ -5,7 +5,7 @@
ranger
io.appform.ranger
- 1.1-RC1
+ 1.1-RC2
4.0.0