MCPcopy Create free account
hub / github.com/apache/fluss / ApiMethod

Class ApiMethod

fluss-rpc/src/main/java/org/apache/fluss/rpc/protocol/ApiMethod.java:33–122  ·  view source on GitHub ↗

Describes an RPC API method to be invoked.

Source from the content-addressed store, hash-verified

31
32/** Describes an RPC API method to be invoked. */
33@ThreadSafe
34public class ApiMethod {
35 /** The API key of the RPC API. */
36 private final ApiKeys apiKey;
37
38 /** The class of the request message. */
39 private final Class<?> requestClass;
40
41 /** The class of the response message. */
42 private final Class<?> responseClass;
43
44 /** The constructor of the request message. */
45 private final Supplier<ApiMessage> requestConstructor;
46
47 /** The constructor of the response message. */
48 private final Supplier<ApiMessage> responseConstructor;
49
50 /** The RPC method to be invoked. */
51 final Method method;
52
53 /** The providers of the RPC API. */
54 final List<ServerType> providers;
55
56 ApiMethod(
57 ApiKeys apiKey,
58 Class<?> requestClass,
59 Class<?> responseClass,
60 Method method,
61 ImmutableList<ServerType> providers) {
62 this.apiKey = apiKey;
63 this.requestClass = requestClass;
64 this.responseClass = responseClass;
65 this.requestConstructor = new ApiMessageConstructor(requestClass);
66 this.responseConstructor = new ApiMessageConstructor(responseClass);
67 this.method = method;
68 this.providers = providers;
69 }
70
71 public boolean inScope(ServerType provider) {
72 return providers.contains(provider);
73 }
74
75 public ApiMethod copyAndAddProvider(ServerType additional) {
76 List<ServerType> tmp = new ArrayList<>();
77 tmp.add(additional);
78 tmp.addAll(providers);
79 return new ApiMethod(
80 apiKey, requestClass, responseClass, method, ImmutableList.copyOf(tmp));
81 }
82
83 public ApiKeys getApiKey() {
84 return apiKey;
85 }
86
87 public Supplier<ApiMessage> getRequestConstructor() {
88 return requestConstructor;
89 }
90

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected