public final class RpcUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
RpcUtils.RpcCallableThrowsIOException<T>
An interface representing a callable which can only throw Alluxio or IO exceptions.
|
static interface |
RpcUtils.StreamingRpcCallable<T>
An interface representing a streaming RPC callable.
|
Modifier and Type | Field and Description |
---|---|
static SensitiveConfigMask |
SENSITIVE_CONFIG_MASKER |
Modifier and Type | Method and Description |
---|---|
static <T> void |
call(org.slf4j.Logger logger,
RpcUtils.RpcCallableThrowsIOException<T> callable,
String methodName,
boolean failureOk,
String description,
io.grpc.stub.StreamObserver<T> responseObserver,
Object... args)
Calls the given
RpcUtils.RpcCallableThrowsIOException and handles any exceptions thrown. |
static <T> void |
call(org.slf4j.Logger logger,
RpcUtils.RpcCallableThrowsIOException<T> callable,
String methodName,
String description,
io.grpc.stub.StreamObserver<T> responseObserver,
Object... args)
Calls the given
RpcUtils.RpcCallableThrowsIOException and handles any exceptions thrown. |
static <T> T |
callAndReturn(org.slf4j.Logger logger,
RpcUtils.RpcCallableThrowsIOException<T> callable,
String methodName,
boolean failureOk,
String description,
Object... args)
Calls the given
RpcUtils.RpcCallableThrowsIOException and returns its result. |
protected static Object[] |
processObjects(org.slf4j.Logger logger,
Object... args) |
static <T> void |
streamingRPCAndLog(org.slf4j.Logger logger,
RpcUtils.StreamingRpcCallable<T> callable,
String methodName,
boolean sendResponse,
boolean completeResponse,
io.grpc.stub.StreamObserver<T> responseObserver,
String description,
Object... args)
Handles a streaming RPC callable with logging.
|
public static final SensitiveConfigMask SENSITIVE_CONFIG_MASKER
public static <T> void call(org.slf4j.Logger logger, RpcUtils.RpcCallableThrowsIOException<T> callable, String methodName, String description, io.grpc.stub.StreamObserver<T> responseObserver, Object... args)
RpcUtils.RpcCallableThrowsIOException
and handles any exceptions thrown. If the
RPC fails, a warning or error will be logged.T
- the return type of the callablelogger
- the logger to use for this callcallable
- the callable to callmethodName
- the name of the method, used for metricsdescription
- the format string of the description, used for loggingresponseObserver
- gRPC response observerargs
- the arguments for the descriptionpublic static <T> void call(org.slf4j.Logger logger, RpcUtils.RpcCallableThrowsIOException<T> callable, String methodName, boolean failureOk, String description, io.grpc.stub.StreamObserver<T> responseObserver, Object... args)
RpcUtils.RpcCallableThrowsIOException
and handles any exceptions thrown.
The failureOk parameter indicates whether or not AlluxioExceptions and IOExceptions are
expected results (for example it would be false for the exists() call). In this case, we do not
log the failure or increment failure metrics. When a RuntimeException is thrown, we always
treat it as a failure and log an error and increment metrics.T
- the return type of the callablelogger
- the logger to use for this callcallable
- the callable to callmethodName
- the name of the method, used for metricsfailureOk
- whether failures are expected (affects logging and metrics)description
- the format string of the description, used for loggingresponseObserver
- gRPC response observerargs
- the arguments for the descriptionpublic static <T> T callAndReturn(org.slf4j.Logger logger, RpcUtils.RpcCallableThrowsIOException<T> callable, String methodName, boolean failureOk, String description, Object... args) throws io.grpc.StatusException
RpcUtils.RpcCallableThrowsIOException
and returns its result. Exceptions are
logged, accounted for in metrics and then rethrown at the end.
The failureOk parameter indicates whether or not AlluxioExceptions and IOExceptions are
expected results (for example it would be false for the exists() call). In this case, we do not
log the failure or increment failure metrics. When a RuntimeException is thrown, we always
treat it as a failure and log an error and increment metrics.T
- the return type of the callablelogger
- the logger to use for this callcallable
- the callable to callmethodName
- the name of the method, used for metricsfailureOk
- whether failures are expected (affects logging and metrics)description
- the format string of the description, used for loggingargs
- the arguments for the descriptionio.grpc.StatusException
public static <T> void streamingRPCAndLog(org.slf4j.Logger logger, RpcUtils.StreamingRpcCallable<T> callable, String methodName, boolean sendResponse, boolean completeResponse, io.grpc.stub.StreamObserver<T> responseObserver, String description, Object... args)
T
- the return type of the callablelogger
- the logger to use for this callcallable
- the callable to callmethodName
- the name of the method, used for metricssendResponse
- whether a response should send to the clientcompleteResponse
- whether onComplete should be called on the response observerresponseObserver
- gRPC response observerdescription
- the format string of the description, used for loggingargs
- the arguments for the descriptionCopyright © 2023. All Rights Reserved.