diff --git a/CHANGELOG.md b/CHANGELOG.md index da7a88c4..2ccdca2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## [1.1-RC2] + +- Pertaining to PR : https://github.com/appform-io/ranger/pull/22/, building of a ServiceFinderHub and a ServiceFinder are bounded. + ## [1.0-RC18] - Version bump to release lexicographically higher version than 1.0-dw3-RC17 diff --git a/pom.xml b/pom.xml index 9ddd681d..8e6da551 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ io.appform.ranger ranger pom - 1.1-RC1 + 1.1-RC2 Ranger https://github.com/appform-io/ranger Service Discovery for Java diff --git a/ranger-client/pom.xml b/ranger-client/pom.xml index 7967bf0a..e842fa5b 100644 --- a/ranger-client/pom.xml +++ b/ranger-client/pom.xml @@ -5,7 +5,7 @@ ranger io.appform.ranger - 1.1-RC1 + 1.1-RC2 4.0.0 diff --git a/ranger-client/src/main/java/io/appform/ranger/client/AbstractRangerHubClient.java b/ranger-client/src/main/java/io/appform/ranger/client/AbstractRangerHubClient.java index 66d20017..10b69080 100644 --- a/ranger-client/src/main/java/io/appform/ranger/client/AbstractRangerHubClient.java +++ b/ranger-client/src/main/java/io/appform/ranger/client/AbstractRangerHubClient.java @@ -21,12 +21,8 @@ import io.appform.ranger.core.finderhub.ServiceDataSource; import io.appform.ranger.core.finderhub.ServiceFinderFactory; import io.appform.ranger.core.finderhub.ServiceFinderHub; -import io.appform.ranger.core.model.Deserializer; -import io.appform.ranger.core.model.Service; -import io.appform.ranger.core.model.ServiceNode; -import io.appform.ranger.core.model.ServiceNodeSelector; -import io.appform.ranger.core.model.ServiceRegistry; -import io.appform.ranger.core.model.ShardSelector; +import io.appform.ranger.core.model.*; + import java.util.Collection; import java.util.Collections; import java.util.List; @@ -40,7 +36,7 @@ @Slf4j @Getter @SuperBuilder -public abstract class AbstractRangerHubClient, D extends Deserializer> implements RangerHubClient { +public abstract class AbstractRangerHubClient, D extends Deserializer> implements RangerHubClient { private final String namespace; private final ObjectMapper mapper; @@ -50,6 +46,8 @@ public abstract class AbstractRangerHubClient, D private int nodeRefreshTimeMs; private ServiceFinderHub hub; private ServiceDataSource serviceDataSource; + private long serviceRefreshDurationMs; + private long hubRefreshDurationMs; @Override public void start() { @@ -57,12 +55,27 @@ public void start() { Preconditions.checkNotNull(namespace, "namespace can't be null"); Preconditions.checkNotNull(deserializer, "deserializer can't be null"); - if (this.nodeRefreshTimeMs < RangerClientConstants.MINIMUM_REFRESH_TIME) { + if (this.nodeRefreshTimeMs < HubConstants.MINIMUM_REFRESH_TIME_MS) { log.warn("Node info update interval too low: {} ms. Has been upgraded to {} ms ", this.nodeRefreshTimeMs, - RangerClientConstants.MINIMUM_REFRESH_TIME); + HubConstants.MINIMUM_REFRESH_TIME_MS); + } + this.nodeRefreshTimeMs = Math.max(HubConstants.MINIMUM_REFRESH_TIME_MS, this.nodeRefreshTimeMs); + + if (this.serviceRefreshDurationMs <= 0) { + log.warn("Service Refresh interval too low: {} ms. Has been upgraded to {} ms ", + this.serviceRefreshDurationMs, + HubConstants.SERVICE_REFRESH_DURATION_MS); + this.serviceRefreshDurationMs = HubConstants.SERVICE_REFRESH_DURATION_MS; } - this.nodeRefreshTimeMs = Math.max(RangerClientConstants.MINIMUM_REFRESH_TIME, this.nodeRefreshTimeMs); + + if (this.hubRefreshDurationMs <= 0) { + log.warn("Hub Refresh interval too low: {} ms. Has been upgraded to {} ms ", + this.hubRefreshDurationMs, + HubConstants.HUB_REFRESH_DURATION_MS); + this.hubRefreshDurationMs = HubConstants.HUB_REFRESH_DURATION_MS; + } + if(null == this.serviceDataSource){ this.serviceDataSource = getDefaultDataSource(); } diff --git a/ranger-core/pom.xml b/ranger-core/pom.xml index fbf825b6..2d043721 100644 --- a/ranger-core/pom.xml +++ b/ranger-core/pom.xml @@ -5,7 +5,7 @@ ranger io.appform.ranger - 1.1-RC1 + 1.1-RC2 4.0.0 diff --git a/ranger-core/src/main/java/io/appform/ranger/core/finderhub/ServiceFinderHub.java b/ranger-core/src/main/java/io/appform/ranger/core/finderhub/ServiceFinderHub.java index 4246dd0e..ef1a2083 100644 --- a/ranger-core/src/main/java/io/appform/ranger/core/finderhub/ServiceFinderHub.java +++ b/ranger-core/src/main/java/io/appform/ranger/core/finderhub/ServiceFinderHub.java @@ -16,8 +16,11 @@ package io.appform.ranger.core.finderhub; import com.github.rholder.retry.RetryerBuilder; +import com.github.rholder.retry.StopStrategies; import com.google.common.base.Stopwatch; +import com.google.common.base.Supplier; import io.appform.ranger.core.finder.ServiceFinder; +import io.appform.ranger.core.model.HubConstants; import io.appform.ranger.core.model.Service; import io.appform.ranger.core.model.ServiceRegistry; import io.appform.ranger.core.signals.ExternalTriggeredSignal; @@ -66,11 +69,26 @@ public class ServiceFinderHub> { private final AtomicBoolean alreadyUpdating = new AtomicBoolean(false); private Future monitorFuture = null; + private final long serviceRefreshDurationMs; + private final long hubRefreshDurationMs; + + public ServiceFinderHub( + ServiceDataSource serviceDataSource, + ServiceFinderFactory finderFactory + ) { + this(serviceDataSource, finderFactory, + HubConstants.SERVICE_REFRESH_DURATION_MS, HubConstants.HUB_REFRESH_DURATION_MS); + } + public ServiceFinderHub( ServiceDataSource serviceDataSource, - ServiceFinderFactory finderFactory) { + ServiceFinderFactory finderFactory, + long serviceRefreshDurationMs, + long hubRefreshDurationMs) { this.serviceDataSource = serviceDataSource; this.finderFactory = finderFactory; + this.serviceRefreshDurationMs = serviceRefreshDurationMs; + this.hubRefreshDurationMs = hubRefreshDurationMs; this.refreshSignals.add(new ScheduledSignal<>("service-hub-updater", () -> null, Collections.emptyList(), @@ -190,13 +208,31 @@ private void updateRegistry() { } private void waitTillHubIsReady() { - serviceDataSource.services().forEach(this::waitTillServiceIsReady); + val hubRefresher = CompletableFuture.allOf( + serviceDataSource.services() + .stream() + .map(service -> CompletableFuture.supplyAsync((Supplier) () -> { + waitTillServiceIsReady(service); + return null; + })).toArray(CompletableFuture[]::new) + ); + try { + hubRefresher.get(hubRefreshDurationMs, TimeUnit.MILLISECONDS); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + Exceptions + .illegalState("Couldn't perform hub refresh at this time. Refresh exceeded the start up time specified"); + } catch (Exception e) { + Exceptions + .illegalState("Couldn't perform hub refresh at this time", e); + } } private void waitTillServiceIsReady(Service service) { try { RetryerBuilder.newBuilder() .retryIfResult(r -> !r) + .withStopStrategy(StopStrategies.stopAfterDelay(serviceRefreshDurationMs, TimeUnit.MILLISECONDS)) .build() .call(() -> Optional.ofNullable(getFinders().get().get(service)) .map(ServiceFinder::getServiceRegistry) diff --git a/ranger-core/src/main/java/io/appform/ranger/core/finderhub/ServiceFinderHubBuilder.java b/ranger-core/src/main/java/io/appform/ranger/core/finderhub/ServiceFinderHubBuilder.java index 8f2e483c..2a32f11e 100644 --- a/ranger-core/src/main/java/io/appform/ranger/core/finderhub/ServiceFinderHubBuilder.java +++ b/ranger-core/src/main/java/io/appform/ranger/core/finderhub/ServiceFinderHubBuilder.java @@ -16,6 +16,7 @@ package io.appform.ranger.core.finderhub; import com.google.common.base.Preconditions; +import io.appform.ranger.core.model.HubConstants; import io.appform.ranger.core.model.ServiceRegistry; import io.appform.ranger.core.signals.ScheduledSignal; import io.appform.ranger.core.signals.Signal; @@ -33,10 +34,12 @@ public abstract class ServiceFinderHubBuilder> { private ServiceDataSource serviceDataSource; private ServiceFinderFactory serviceFinderFactory; - private long refreshFrequencyMs = 10_000; + private long refreshFrequencyMs = HubConstants.REFRESH_FREQUENCY_MS; private final List> extraStartSignalConsumers = new ArrayList<>(); private final List> extraStopSignalConsumers = new ArrayList<>(); private final List> extraRefreshSignals = new ArrayList<>(); + private long serviceRefreshDurationMs = HubConstants.SERVICE_REFRESH_DURATION_MS; + private long hubRefreshDurationMs = HubConstants.HUB_REFRESH_DURATION_MS; public ServiceFinderHubBuilder withServiceDataSource(ServiceDataSource serviceDataSource) { this.serviceDataSource = serviceDataSource; @@ -68,12 +71,23 @@ public ServiceFinderHubBuilder withExtraRefreshSignal(Signal extraRe return this; } + public ServiceFinderHubBuilder withServiceRefreshDuration(long serviceRefreshDurationMs) { + this.serviceRefreshDurationMs = serviceRefreshDurationMs; + return this; + } + + public ServiceFinderHubBuilder withHubRefreshDuration(long hubRefreshDurationMs) { + this.hubRefreshDurationMs = hubRefreshDurationMs; + return this; + } + public ServiceFinderHub build() { preBuild(); Preconditions.checkNotNull(serviceDataSource, "Provide a non-null service data source"); Preconditions.checkNotNull(serviceFinderFactory, "Provide a non-null service finder factory"); - val hub = new ServiceFinderHub<>(serviceDataSource, serviceFinderFactory); + val hub = new ServiceFinderHub<>(serviceDataSource, serviceFinderFactory, + serviceRefreshDurationMs, hubRefreshDurationMs); final ScheduledSignal 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