Skip to content

Ranger Clients

Koushik Ramachandra edited this page Apr 28, 2022 · 1 revision

Ranger clients have been introduced as utility interfaces to fetch the node information from the service data source. Clients come in both sharded and unsharded types for both the simple ranger and the hub. The two different clients available are zookeeper and HTTP. All clients during initialization need

  • initialCriteria - A predicate that is supposed to be applied always during shard selection.

Zookeeper Client

A zookeeper client (simple or hub) to be initialized needs the following common properties

  • serviceName - The service name against which said client should operate
  • nameSpace - A namespace for the service. For example, the team name this service belongs to.
  • _disableWatchers - To enable or disable zookeeper watchers
  • Zookeeper details - Can be any one of the following:
    • Connection String - Zookeeper connections string to connect to ZK cluster.
    • CuratorFramework object - A prebuilt CuratorFramework object.
  • nodeRefreshIntervalMs - Time to refresh the registry for the node.
  • shardSelector - If you want to provide a custom shard selector other than the ones pre-bundled, you could choose to, the default is MatchingShardSelector

To now initialize a simple zookeeper client. This internally creates the required service finder.

val client = SimpleRangerZKClient.<TestNodeData>builder()
                .curatorFramework(curatorFramework)
                .deserializer(deserializer)
                .namespace(namespace)
                .serviceName(servicename)
                .disableWatchers(disableWatchers)
                .mapper(mapper)
                .build();

To initialize the sharded hub client. This internally creates the required service finder factory and the service data source respectively.

val client = ShardedRangerZKHubClient.<TestNodeData>builder()
                .curatorFramework(curatorFramework)
                .deserializer(deserializer)
                .namespace(namespace)
                .serviceName(servicename)
                .disableWatchers(disableWatchers)
                .mapper(mapper)
                .build();

To initialize the unsharded hub client

val client = ShardedRangerZKHubClient.<TestNodeData>builder()
                .curatorFramework(curatorFramework)
                .deserializer(deserializer)
                .namespace(namespace)
                .serviceName(servicename)
                .disableWatchers(disableWatchers)
                .mapper(mapper)
                .build();

HTTP Client

An HTTP client (simple or hub) to be initialized needs the following common properties

  • HttpClientConfig - Contains the following
    • host - Http host where the data repository is housed
    • port - Http port where the data repository is housed
    • secure - If the connection is on HTTPS on HTTP.
    • connectionTimeoutMs - Connection timeout in ms
    • operationTimeoutMs - Operation timeout (read/write) in ms
  • Objectmapper - To help for serialization/deserialization
  • shardSelector - If you want to provide a custom shard selector other than the ones pre bundled, you could choose to, the default is MatchingShardSelector
  • deserializer - A deserializer implementation that will be used to deserialize the retrieved shard information from the service data source
  • nodeRefreshIntervalMs - Time to refresh the service data source to fetch the new node information

To initialize the standard HTTP client

val client = SimpleRangerHttpClient.<TestNodeData>builder()
                .clientConfig(clientConfig)
                .mapper(objectMapper)
                .deserializer(deserializer)
                .namespace(namespace)
                .serviceName(serviceName)
                .nodeRefreshIntervalMs(nodeRefreshIntervalMs)
                .build();

To initialize the sharded HTTP hub client

val client = ShardedRangerHttpHubClient.<TestNodeData>builder()
                 .clientConfig(clientConfig)
                .mapper(objectMapper)
                .deserializer(deserializer)
                .namespace(namespace)
                .serviceName(serviceName)
                .nodeRefreshIntervalMs(nodeRefreshIntervalMs)
                .build();

To initialize the unsharded HTTP hub client

val client = UnShardedRangerHttpHubClient.<TestNodeData>builder()
                 .clientConfig(clientConfig)
                .mapper(objectMapper)
                .deserializer(deserializer)
                .namespace(namespace)
                .serviceName(serviceName)
                .nodeRefreshIntervalMs(nodeRefreshIntervalMs)
                .build();

Usage

To start a client

client.start();

To stop a client

client.stop();
Clone this wiki locally