Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Apache Dolphinscheduler RPC Client Proxy Pattern

From Leeroopedia


Knowledge Sources
Domains Distributed_Systems, RPC
Last Updated 2026-02-10 00:00 GMT

Overview

A transparent RPC proxy pattern using JDK dynamic proxies and Guava caching that allows remote service invocation with the same syntax as local method calls.

Description

The RPC Client Proxy Pattern provides location-transparent remote service invocation. The Clients utility class provides a fluent builder API: Clients.withService(IMyService.class).withHost("host:port") returns a JDK dynamic proxy that implements the service interface. When a method is called on this proxy, the ClientInvocationHandler serializes the arguments, sends them via NettyRemotingClient, and deserializes the response. Proxies are cached using a Guava LoadingCache with 1-hour expiry to avoid repeated proxy creation.

This pattern allows application code to call remote services as if they were local objects, completely abstracting away the network communication layer.

Usage

Use Clients.withService().withHost() whenever you need to call a remote service in DolphinScheduler. The returned proxy implements the service interface and handles all serialization, networking, and deserialization transparently.

Theoretical Basis

The RPC Client Proxy applies the Proxy Pattern with Transparent Remoting:

  • Proxy: JDK Proxy.newProxyInstance() creates a runtime proxy implementing the service interface
  • Invocation Handler: ClientInvocationHandler intercepts all method calls
  • Caching: Guava LoadingCache<(host, interface), proxy> prevents redundant proxy creation
  • Transport: NettyRemotingClient handles the actual network communication
// Proxy creation and invocation flow
proxy = Clients.withService(IWorkflowControlClient.class)
               .withHost("master-host:5678")

// Method call on proxy triggers:
// 1. ClientInvocationHandler.invoke(method, args)
// 2. Serialize args to Transporter
// 3. NettyRemotingClient.sendSync(host, transporter)
// 4. Deserialize response
// 5. Return result to caller

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment