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 8ed2d501..c4c39eac 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 @@ -10,6 +10,11 @@ import java.util.concurrent.TimeUnit; public class BackupRequestInterceptor implements TableInterceptor { + private final long backupRequestDelayMs; + + public BackupRequestInterceptor(long backupRequestDelayMs) { + this.backupRequestDelayMs = backupRequestDelayMs; + } @Override public void before(ClientRequestRound clientRequestRound, TableHandler tableHandler) { @@ -53,7 +58,7 @@ private void backupCall(ClientRequestRound clientRequestRound, TableHandler tabl clientRequestRound.timeoutMs(), true); }, - tableHandler.backupRequestDelayMs(), + backupRequestDelayMs, TimeUnit.MILLISECONDS)); } } 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 6a276c42..cc1a27e9 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 @@ -12,15 +12,13 @@ public class InterceptorManger { private List interceptors = new ArrayList<>(); public InterceptorManger(TableOptions options) { - this.register(new BackupRequestInterceptor(), options.enableBackupRequest()) - .register(new CompressionInterceptor(), options.enableCompression()); - } + if (options.enableBackupRequest()) { + interceptors.add(new BackupRequestInterceptor(options.backupRequestDelayMs())); + } - private InterceptorManger register(TableInterceptor interceptor, boolean enable) { - if (enable) { - interceptors.add(interceptor); + if (options.enableCompression()) { + interceptors.add(new CompressionInterceptor()); } - return this; } public void before(ClientRequestRound clientRequestRound, TableHandler tableHandler) {