/** * Tries to execute an RPC defined as a {@link RpcCallable}. Metrics will be recorded based on * the provided rpc name. * * If a {@link UnavailableException} occurs, a reconnection will be tried through * {@link #connect()} and the action will be re-executed. * * @param rpc the RPC call to be executed * @param rpcName the human readable name of the RPC call * @param <V> type of return value of the RPC call * @return the return value of the RPC call */ protected synchronized <V> V retryRPC(RpcCallable<V> rpc, String rpcName) throws AlluxioStatusException { try (Timer.Context ctx = MetricsSystem.timer(getQualifiedMetricName(rpcName)).time()) { return retryRPCInternal(rpc, () -> { MetricsSystem.counter(getQualifiedRetryMetricName(rpcName)).inc(); return null; }); } catch (Exception e) { MetricsSystem.counter(getQualifiedFailureMetricName(rpcName)).inc(); throw e; } }
/** * Tries to execute an RPC defined as a {@link RpcCallable}. Metrics will be recorded based on * the provided rpc name. * * If a {@link UnavailableException} occurs, a reconnection will be tried through * {@link #connect()} and the action will be re-executed. * * @param rpc the RPC call to be executed * @param rpcName the human readable name of the RPC call * @param <V> type of return value of the RPC call * @return the return value of the RPC call */ protected synchronized <V> V retryRPC(RpcCallable<V> rpc, String rpcName) throws AlluxioStatusException { try (Timer.Context ctx = MetricsSystem.timer(getQualifiedMetricName(rpcName)).time()) { return retryRPCInternal(rpc, () -> { MetricsSystem.counter(getQualifiedRetryMetricName(rpcName)).inc(); return null; }); } catch (Exception e) { MetricsSystem.counter(getQualifiedFailureMetricName(rpcName)).inc(); throw e; } }