Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP : Ranger HTTP client implementations #41

Closed
wants to merge 53 commits into from

Conversation

koushikr
Copy link

@koushikr koushikr commented Oct 18, 2021

Apologies for the massive-ish PR. I understand the incredible burden of having to go through it.

Split the T of serviceNode and Criteria and that contributed to one ridiculous spur of changes. Didn't make sense breaking that in parts, and the tests to support the same have been added too - again didn't make sense to submit code and test in parts.

The additional ones are the additional modules, ranger-http-client, ranger-zk-client, and ranger-server (Really small interface classes). The split of criteria and T of serviceNode has bloated the PR up.

This is an extension of, #31

Why separate T and Criteria

  • To facilitate for clients to dynamically bind inline criteria when implementing shard selectors, to decouple the type of such criteria bound with the generic T type that has been saved as a part of serviceNode.
  • This will help clients further wing out their own implementations of criteria basis their individual parameters and supply a matcher during node group (shard) selection.

Major LLD Callouts

  • The shardSelector implementation after the introduction of Criteria can be either of ShardSelector<T, C extends Criteria<T>> implements ShardSelector<T, C, R extends Registry<T>> or ShardSelector<T> implements ShardSelector<T, Criteria<T>, R extends Registry<T>>. Chose the former to keep the Criteria implementation fluid and to be able to have clients define their shardSelector within the bound of any Criteria implementation.
  • Added clients as different modules to avoid everyone having to implement the same boilerplate code to create hubs (zk or http). Creating a hub is now just a new instance creation.

Changelist

  • The T in the ServiceNode has been broken from the Criteria used in the shard selectors, to help for dynamic binding of criteria, so node filters can be dictated by the clients who are using the bundle, basis any of the client-specific parameters.
  • The unclusteredFinder has been renamed to unsharededFinder and a list-based shardSelector to work with the criteria has been introduced.
  • The ranger module has been further broken down into ranger-core (To define the core framework of ranger), ranger-zookeeper, and ranger-HTTP (To appropriate the ranger-core with the respective implementations for zookeeper and HTTP data sources). ranger-zookeeper-client and ranger-HTTP-client(To appropriate the finder-hub implementations for zookeeper and HTTP data sources)
  • A sample ranger-server has been added to facilitate writing an HTTP finder back-end, atop a service hub.
  • An extensive test suite to test the multiple modules has been added as well.
  • Added license in the files missing license.

Koushik R and others added 30 commits September 23, 2021 18:56
…erviceprovider and servicehub package structures, each workflow has a containment

2. Added an implementation for http node data sink and registration
Added a dummy project structure for ranger-server
…t custom criteria could be passed to the shardSelector which can help in shardSelection
… one for mapBasedRegistry and one for listBasedServiceRegistry

b) Tests added for the broken down criteria across all the modules
…y purposes and to manage the lifecycle within

package com.flipkart.ranger.core.finder.unsharded;
public class Constants {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduce a private Constructor

@@ -13,17 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.flipkart.ranger.client;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it showing up as a rename of the file?

serviceNodes.add(new ServiceNode<>("localhost-2", 9001, TestNodeData.builder().nodeId(2).build()));
serviceNodes.add(new ServiceNode<>("localhost-3", 9002, TestNodeData.builder().nodeId(3).build()));
ServiceNode<TestNodeData> select = roundRobinSelector.select(serviceNodes);
Assert.assertTrue(select.getHost().equalsIgnoreCase("localhost-2"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why equalsIgnoreCase etc? use Assert.assertEquals

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in all places

@@ -39,7 +48,7 @@ public HttpNodeDataStoreConnector(
.connectionPool(new ConnectionPool(1, 30, TimeUnit.SECONDS))
.build();
this.config = config;
this.mapper = mapper;
this.mapper = null != mapper ? mapper : new ObjectMapper();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not create object mapper inside constructor

@Builder
public class ServiceDataSourceResponse {
private boolean success;
private List<Service> data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an error message here

log.error("No data returned from server: " + httpUrl);

if (null != serviceNodesResponse && null != serviceNodesResponse.getData() &&
!serviceNodesResponse.getData().isEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is error message in the response, log that


@Test
public void testProvider() throws Exception {
TestNodeData nm5NodeData = TestNodeData.builder().farmId("nm5").build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val

@Test
public void testProvider() throws Exception {
TestNodeData nm5NodeData = TestNodeData.builder().farmId("nm5").build();
ServiceNode<TestNodeData> testNode = new ServiceNode<>("localhost-1", 80, nm5NodeData);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val .. make things consistent

@GET
@Path("/nodes/{namespace}/{serviceName}")
@Timed
@ExceptionMetered
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just do @metered and removed the above two anotations


private final RangerConfiguration rangerConfiguration;

private final UnshardedRangerZKHubClient<T, C> zkHubClient;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to rethink this. Ideally this should be abstract here, so that the server can, if it wants, add some in-memory cached decorator to the hub

@koushikr
Copy link
Author

Closing this PR. Broke this into #42 and #43 to be able to track better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants