or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

client-connection.mdconnection-handling.mdensemble-providers.mdindex.mdpath-utilities.mdretry-policies.mdtracing-metrics.md
tile.json

tessl/maven-org-apache-curator--curator-client

Low-level API for Apache ZooKeeper client library providing connection management, retry policies, and basic ZooKeeper operations

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.apache.curator/curator-client@4.3.x

To install, run

npx @tessl/cli install tessl/maven-org-apache-curator--curator-client@4.3.0

index.mddocs/

Apache Curator Client

Apache Curator Client is the foundational low-level API component of Apache Curator, providing essential ZooKeeper client functionality with robust connection management, retry policies, and utility classes. It serves as the stable foundation for distributed applications requiring reliable ZooKeeper coordination.

Package Information

  • Package Name: curator-client
  • Package Type: maven
  • Group ID: org.apache.curator
  • Language: Java
  • Installation: Add to Maven pom.xml:
<dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-client</artifactId>
    <version>4.3.0</version>
</dependency>

Core Imports

import org.apache.curator.CuratorZookeeperClient;
import org.apache.curator.RetryPolicy;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.ensemble.fixed.FixedEnsembleProvider;
import org.apache.curator.utils.ZKPaths;
import org.apache.curator.utils.PathUtils;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.utils.ThreadUtils;

Basic Usage

import org.apache.curator.CuratorZookeeperClient;
import org.apache.curator.RetryPolicy;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.RetryLoop;

// Configure retry policy and create client
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
CuratorZookeeperClient client = new CuratorZookeeperClient(
    "localhost:2181", 
    5000, 
    5000,
    null, 
    retryPolicy
);

try {
    // Start client connection
    client.start();
    client.blockUntilConnectedOrTimedOut();
    
    // Use retry loop for ZooKeeper operations
    RetryLoop retryLoop = client.newRetryLoop();
    while (retryLoop.shouldContinue()) {
        try {
            // Perform ZooKeeper operations with client.getZooKeeper()
            // ... your ZooKeeper operations here ...
            retryLoop.markComplete();
        } catch (Exception e) {
            retryLoop.takeException(e);
        }
    }
} finally {
    client.close();
}

Architecture

Apache Curator Client is organized around several key architectural components:

  • Connection Management: CuratorZookeeperClient provides robust connection handling with automatic reconnection
  • Retry Framework: Comprehensive retry policies for handling transient failures in distributed environments
  • Ensemble Providers: Dynamic and static connection string management for ZooKeeper cluster discovery
  • Tracing System: Pluggable metrics and tracing framework for monitoring ZooKeeper operations
  • Utility Classes: Comprehensive path manipulation, resource management, and helper utilities

Capabilities

Client Connection Management

Core ZooKeeper client wrapper providing connection management, retry integration, and session handling for reliable distributed coordination.

public class CuratorZookeeperClient implements Closeable {
    public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, 
                                 int connectionTimeoutMs, Watcher watcher, 
                                 RetryPolicy retryPolicy);
    
    public void start() throws Exception;
    public void close() throws IOException;
    public boolean isConnected();
    public ZooKeeper getZooKeeper() throws Exception;
    public RetryLoop newRetryLoop();
}

Client Connection Management

Retry Policies

Comprehensive retry policy implementations for handling transient failures and network issues in distributed ZooKeeper operations.

public interface RetryPolicy {
    boolean allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper sleeper);
}

public class ExponentialBackoffRetry implements RetryPolicy {
    public ExponentialBackoffRetry(int baseSleepTimeMs, int maxRetries);
    public ExponentialBackoffRetry(int baseSleepTimeMs, int maxRetries, int maxSleepMs);
}

public class RetryNTimes implements RetryPolicy {
    public RetryNTimes(int n, int sleepMsBetweenRetries);
}

Retry Policies

Ensemble Providers

Connection string providers for static and dynamic ZooKeeper cluster configuration, including integration with Netflix Exhibitor for service discovery.

public interface EnsembleProvider extends Closeable {
    void start() throws Exception;
    String getConnectionString();
    void setConnectionString(String connectionString);
    boolean updateServerListEnabled();
}

public class FixedEnsembleProvider implements EnsembleProvider {
    public FixedEnsembleProvider(String connectionString);
}

public class ExhibitorEnsembleProvider implements EnsembleProvider {
    // Constructor and methods for dynamic ensemble discovery
}

Ensemble Providers

ZooKeeper Path Utilities

Comprehensive path manipulation utilities for ZooKeeper node operations, including path validation, tree operations, and node management.

public class ZKPaths {
    public static final String PATH_SEPARATOR = "/";
    
    public static String makePath(String parent, String child);
    public static String getNodeFromPath(String path);
    public static PathAndNode getPathAndNode(String path);
    public static List<String> split(String path);
    public static void mkdirs(ZooKeeper zookeeper, String path) throws Exception;
    public static void deleteChildren(ZooKeeper zookeeper, String path, boolean deleteSelf) throws Exception;
}

ZooKeeper Path Utilities

Tracing and Metrics

Pluggable tracing framework for monitoring ZooKeeper operations, connection events, and performance metrics.

public interface TracerDriver {
    void addTrace(String name, long time, TimeUnit unit);
    void addCount(String name, int increment);
}

public class TimeTrace {
    public TimeTrace(String name, TracerDriver driver);
    public void commit();
}

Tracing and Metrics

Connection Handling

Advanced connection handling policies and thread-local retry management for fine-grained control over ZooKeeper connection behavior.

public interface ConnectionHandlingPolicy {
    CheckTimeoutsResult checkTimeouts() throws Exception;
    <T> T callWithRetry(CuratorZookeeperClient client, Callable<T> proc) throws Exception;
}

public class StandardConnectionHandlingPolicy implements ConnectionHandlingPolicy {
    // Standard connection handling implementation
}

Connection Handling

Types

Core Exception Types

public class CuratorConnectionLossException extends ConnectionLossException {
    // Specialized ConnectionLossException for Curator-specific timeouts
}

Connection State Enumeration

public enum ConnectionState {
    CONNECTED,
    SUSPENDED, 
    RECONNECTED,
    LOST,
    READ_ONLY
}

Path Utilities Types

public static class ZKPaths.PathAndNode {
    public String getPath();
    public String getNode();
}