diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/TableHandler.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/TableHandler.java index d93eeceb..b2bff7a0 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/TableHandler.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/TableHandler.java @@ -255,7 +255,7 @@ public void onRpcReply(ClientRequestRound round, long cachedConfigVersion, Strin } client_operator operator = round.getOperator(); - interceptorManger.interceptAfter(round, operator.rpc_error.errno, this); + interceptorManger.after(round, operator.rpc_error.errno, this); boolean needQueryMeta = false; switch (operator.rpc_error.errno) { case ERR_OK: @@ -363,7 +363,7 @@ void call(final ClientRequestRound round) { tableConfig.replicas.get(round.getOperator().get_gpid().get_pidx()); if (handle.primarySession != null) { - interceptorManger.interceptBefore(round, this); + interceptorManger.before(round, this); // send request to primary handle.primarySession.asyncSend( round.getOperator(), diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/BackupRequestInterceptor.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/BackupRequestInterceptor.java index 642cbcf6..272d5a5c 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/BackupRequestInterceptor.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/BackupRequestInterceptor.java @@ -18,12 +18,12 @@ public BackupRequestInterceptor(boolean isOpen) { } @Override - public void interceptBefore(ClientRequestRound clientRequestRound, TableHandler tableHandler) { + public void before(ClientRequestRound clientRequestRound, TableHandler tableHandler) { backupCall(clientRequestRound, tableHandler); } @Override - public void interceptAfter( + public void after( ClientRequestRound clientRequestRound, error_types errno, TableHandler tableHandler) { // cancel the backup request task ScheduledFuture backupRequestTask = clientRequestRound.backupRequestTask(); diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/InterceptorManger.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/InterceptorManger.java index 347467b1..8535330f 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/InterceptorManger.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/InterceptorManger.java @@ -15,21 +15,21 @@ public InterceptorManger(TableOptions options) { register(new BackupRequestInterceptor(options.enableBackupRequest())); } - public InterceptorManger register(TableInterceptor interceptor) { + private InterceptorManger register(TableInterceptor interceptor) { interceptors.add(interceptor); return this; } - public void interceptBefore(ClientRequestRound clientRequestRound, TableHandler tableHandler) { + public void before(ClientRequestRound clientRequestRound, TableHandler tableHandler) { for (TableInterceptor interceptor : interceptors) { - interceptor.interceptBefore(clientRequestRound, tableHandler); + interceptor.before(clientRequestRound, tableHandler); } } - public void interceptAfter( + public void after( ClientRequestRound clientRequestRound, error_types errno, TableHandler tableHandler) { for (TableInterceptor interceptor : interceptors) { - interceptor.interceptAfter(clientRequestRound, errno, tableHandler); + interceptor.after(clientRequestRound, errno, tableHandler); } } } diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/TableInterceptor.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/TableInterceptor.java index fb35c45b..4f78b11f 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/TableInterceptor.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/TableInterceptor.java @@ -6,8 +6,7 @@ public interface TableInterceptor { // The behavior before sending the RPC to a table. - void interceptBefore(ClientRequestRound clientRequestRound, TableHandler tableHandler); + void before(ClientRequestRound clientRequestRound, TableHandler tableHandler); // The behavior after getting reply or failure of the RPC. - void interceptAfter( - ClientRequestRound clientRequestRound, error_types errno, TableHandler tableHandler); + void after(ClientRequestRound clientRequestRound, error_types errno, TableHandler tableHandler); }