Skip to content

Commit

Permalink
Changes for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
santanusinha committed Dec 19, 2024
1 parent 4a91f6c commit f9ad532
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"iterations" : 4,
"threads" : 1,
"forks" : 3,
"mean_ops" : 812476.3197574528
"mean_ops" : 764043.6230133567
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"iterations" : 4,
"threads" : 1,
"forks" : 3,
"mean_ops" : 592802.8071907263
"mean_ops" : 584064.863102317
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Set<Service> services() {
.host(config.getHost())
.port(config.getPort() == 0 ? defaultPort() : config.getPort())
.encodedPath("/ranger/services/v1")
.addQueryParameter("skipReplicationSources", Objects.toString(config.isReplicationSource()))
.addQueryParameter("skipDataFromReplicationSources", Objects.toString(config.isReplicationSource()))
.build();
val request = new Request.Builder()
.url(httpUrl)
Expand Down Expand Up @@ -110,7 +110,7 @@ public List<ServiceNode<T>> listNodes(
.host(config.getHost())
.port(config.getPort() == 0 ? defaultPort() : config.getPort())
.encodedPath(url)
.addQueryParameter("skipReplicationSources", Objects.toString(config.isReplicationSource()))
.addQueryParameter("skipDataFromReplicationSources", Objects.toString(config.isReplicationSource()))
.build();
val request = new Request.Builder()
.url(httpUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void testServiceDataSource(WireMockRuntimeInfo wireMockRuntimeInfo) throws IOExc
RangerTestUtils.getService("test-n", "test-s2")
))
.build();
stubFor(get(urlEqualTo("/ranger/services/v1?skipReplicationSources=false"))
stubFor(get(urlEqualTo("/ranger/services/v1?skipDataFromReplicationSources=false"))
.willReturn(aResponse()
.withBody(MAPPER.writeValueAsBytes(responseObjReplicated))
.withStatus(200)));
Expand All @@ -54,7 +54,7 @@ void testServiceDataSource(WireMockRuntimeInfo wireMockRuntimeInfo) throws IOExc
RangerTestUtils.getService("test-n", "test-s"),
RangerTestUtils.getService("test-n", "test-s1")))
.build();
stubFor(get(urlEqualTo("/ranger/services/v1?skipReplicationSources=true"))
stubFor(get(urlEqualTo("/ranger/services/v1?skipDataFromReplicationSources=true"))
.willReturn(aResponse()
.withBody(MAPPER.writeValueAsBytes(responseObjReplicationSkipped))
.withStatus(200)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public RangerResource(List<RangerHubClient<T, R>> rangerHubs) {
@Path("/services/v1")
@Timed
public GenericResponse<Set<Service>> getServices(
@QueryParam("skipReplicationSources") @DefaultValue("false") boolean skipReplicationSources) {
@QueryParam("skipDataFromReplicationSources") @DefaultValue("false") boolean skipDataFromReplicationSources) {
return GenericResponse.<Set<Service>>builder()
.data(rangerHubs.stream()
.filter(hub -> !skipReplicationSources || !hub.isReplicationSource())
.filter(hub -> !skipDataFromReplicationSources || !hub.isReplicationSource())
.map(RangerHubClient::getRegisteredServices)
.flatMap(Collection::stream)
.collect(Collectors.toSet()))
Expand All @@ -68,11 +68,11 @@ public GenericResponse<Set<Service>> getServices(
public GenericResponse<Collection<ServiceNode<T>>> getNodes(
@NotNull @NotEmpty @PathParam("namespace") final String namespace,
@NotNull @NotEmpty @PathParam("serviceName") final String serviceName,
@QueryParam("skipReplicationSources") @DefaultValue("false") boolean skipReplicationSources) {
@QueryParam("skipDataFromReplicationSources") @DefaultValue("false") boolean skipDataFromReplicationSources) {
val service = Service.builder().namespace(namespace).serviceName(serviceName).build();
return GenericResponse.<Collection<ServiceNode<T>>>builder()
.data(rangerHubs.stream()
.filter(hub -> !skipReplicationSources || !hub.isReplicationSource())
.filter(hub -> !(skipDataFromReplicationSources && hub.isReplicationSource()))
.map(hub -> hub.getAllNodes(service))
.flatMap(List::stream)
.collect(Collectors.toMap(node -> node.getHost() + ":" + node.getPort(),
Expand Down

0 comments on commit f9ad532

Please sign in to comment.