Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jitendra Dhawan committed Nov 21, 2024
1 parent 63d292c commit 6f37b09
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ public List<ServiceNode<T>> getAllNodes(
@Override
public Collection<Service> getRegisteredServices() {
try {
return this.getHub().getServiceDataSource().services()
.stream()
.filter(service -> !excludedServices.contains(service.getServiceName()))
.collect(Collectors.toSet());
return this.getHub().getServiceDataSource().services();
}
catch (Exception e) {
log.error("Call to the hub failed with exception, {}", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class ServiceFinderHub<T, R extends ServiceRegistry<T>> {
public ServiceFinderHub(
ServiceDataSource serviceDataSource,
ServiceFinderFactory<T, R> finderFactory
) {
) {
this(serviceDataSource, finderFactory,
HubConstants.SERVICE_REFRESH_TIMEOUT_MS, HubConstants.HUB_START_TIMEOUT_MS, Set.of());
}
Expand All @@ -98,9 +98,9 @@ public ServiceFinderHub(
this.serviceRefreshTimeoutMs = serviceRefreshTimeoutMs == 0 ? HubConstants.SERVICE_REFRESH_TIMEOUT_MS : serviceRefreshTimeoutMs;
this.hubStartTimeoutMs = hubStartTimeoutMs == 0 ? HubConstants.HUB_START_TIMEOUT_MS : hubStartTimeoutMs;
this.refreshSignals.add(new ScheduledSignal<>("service-hub-updater",
() -> null,
Collections.emptyList(),
10_000));
() -> null,
Collections.emptyList(),
10_000));
this.refresherPool = createRefresherPool();
this.excludedServices = excludedServices;
}
Expand Down Expand Up @@ -245,10 +245,10 @@ private void updateRegistry() {
private void waitTillHubIsReady() {
val services = getEligibleServices();
val timeToRefresh = Math.max(hubStartTimeoutMs,
(serviceRefreshTimeoutMs * services.size()) / refresherPool.getParallelism());
(serviceRefreshTimeoutMs * services.size()) / refresherPool.getParallelism());
if (timeToRefresh != hubStartTimeoutMs) {
log.warn("Max hub refresh time has been dynamically adjusted to {} ms from the provided {} ms as the " +
"provided time would have been insufficient to refresh {} services.",
"provided time would have been insufficient to refresh {} services.",
timeToRefresh, hubStartTimeoutMs, services.size());
}
val hubRefresher = CompletableFuture.allOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ public ServiceFinderHubBuilder<T, R> withExtraRefreshSignal(Signal<Void> extraRe
return this;
}

public ServiceFinderHubBuilder<T, R> withServiceRefreshDuration(long serviceRefreshDurationMs) {
this.serviceRefreshTimeoutMs = serviceRefreshDurationMs;
public ServiceFinderHubBuilder<T, R> withServiceRefreshTimeout(long serviceRefreshTimeoutMs) {
this.serviceRefreshTimeoutMs = serviceRefreshTimeoutMs;
return this;
}

public ServiceFinderHubBuilder<T, R> withHubRefreshDuration(long hubRefreshDurationMs) {
this.hubStartTimeoutMs = hubRefreshDurationMs;
public ServiceFinderHubBuilder<T, R> withHubStartTimeout(long hubStartTimeoutMs) {
this.hubStartTimeoutMs = hubStartTimeoutMs;
return this;
}

Expand All @@ -97,9 +97,9 @@ public ServiceFinderHub<T, R> build() {
val hub = new ServiceFinderHub<>(serviceDataSource, serviceFinderFactory, serviceRefreshTimeoutMs,
hubStartTimeoutMs, excludedServices);
final ScheduledSignal<Void> refreshSignal = new ScheduledSignal<>("service-hub-refresh-timer",
() -> null,
Collections.emptyList(),
refreshFrequencyMs);
() -> null,
Collections.emptyList(),
refreshFrequencyMs);
hub.registerUpdateSignal(refreshSignal);
extraRefreshSignals.forEach(hub::registerUpdateSignal);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void testDelayedServiceAddition() {
.withServiceName(service.getServiceName())
.withDeserializer(new Deserializer<TestNodeData>() {})
.withSleepDuration(1)
.build(), 5_000, 5_000,Set.of()
.build(), 5_000, 5_000, Set.of()
);
serviceFinderHub.start();
Assertions.assertTrue(serviceFinderHub.finder(new Service("NS", "SERVICE")).isPresent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ protected ServiceDataSource getDefaultDataSource() {
@Override
protected ServiceFinderHub<T, R> buildHub() {
return new DroveServiceFinderHubBuilder<T, R>()
.withServiceDataSource(getServiceDataSource())
.withServiceFinderFactory(getFinderFactory())
.withRefreshFrequencyMs(getNodeRefreshTimeMs())
.withHubRefreshDuration(getHubStartTimeoutMs())
.withServiceRefreshDuration(getServiceRefreshTimeoutMs())
.withExcludedServices(getExcludedServices())
.build();
.withServiceDataSource(getServiceDataSource())
.withServiceFinderFactory(getFinderFactory())
.withRefreshFrequencyMs(getNodeRefreshTimeMs())
.withHubStartTimeout(getHubStartTimeoutMs())
.withServiceRefreshTimeout(getServiceRefreshTimeoutMs())
.withExcludedServices(getExcludedServices())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ protected ServiceFinderHub<T, R> buildHub() {
.withServiceDataSource(getServiceDataSource())
.withServiceFinderFactory(getFinderFactory())
.withRefreshFrequencyMs(getNodeRefreshTimeMs())
.withHubRefreshDuration(getHubStartTimeoutMs())
.withServiceRefreshDuration(getServiceRefreshTimeoutMs())
.withHubStartTimeout(getHubStartTimeoutMs())
.withServiceRefreshTimeout(getServiceRefreshTimeoutMs())
.withExcludedServices(getExcludedServices())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public HttpServiceDataSource(HttpClientConfig config, HttpCommunicator<T> httpCl

@Override
public Collection<Service> services() {
Objects.requireNonNull(config, "client config has not been set for node data");
Objects.requireNonNull(config, "client config has not been set for node data");
return httpCommunicator.services();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected List<Signal<ShardInfo>> withLifecycleSignals(U configuration) {

@Override
protected List<HealthCheck> withHealthChecks(U configuration) {
return Collections.singletonList((HealthCheck) new RangerHealthCheck(curatorFrameworks));
return List.of(new RangerHealthCheck(curatorFrameworks));
}

@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ public class RangerServerConfiguration {
Set<String> excludedServices;

public Set<String> getExcludedServices() {
return Objects.isNull(excludedServices)
? Collections.emptySet() :
excludedServices;
return Objects.requireNonNullElseGet(excludedServices,Set::of);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ protected ServiceFinderHub<T, R> buildHub() {
.withRefreshFrequencyMs(getNodeRefreshTimeMs())
.withServiceDataSource(getServiceDataSource())
.withServiceFinderFactory(getFinderFactory())
.withHubRefreshDuration(getHubStartTimeoutMs())
.withServiceRefreshDuration(getServiceRefreshTimeoutMs())
.withHubStartTimeout(getHubStartTimeoutMs())
.withServiceRefreshTimeout(getServiceRefreshTimeoutMs())
.withExcludedServices(getExcludedServices())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.appform.ranger.core.finderhub.ServiceDataSource;
import io.appform.ranger.core.model.Service;
import io.appform.ranger.zookeeper.util.PathBuilder;
import java.util.Set;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
Expand Down

0 comments on commit 6f37b09

Please sign in to comment.