diff --git a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/DefaultRegionKVService.java b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/DefaultRegionKVService.java index fa095eba8..73593d898 100644 --- a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/DefaultRegionKVService.java +++ b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/DefaultRegionKVService.java @@ -455,7 +455,7 @@ public void handleScanRequest(final ScanRequest request, response.setRegionEpoch(getRegionEpoch()); try { KVParameterRequires.requireSameEpoch(request, getRegionEpoch()); - BaseKVStoreClosure KVStoreClosure = new BaseKVStoreClosure() { + final BaseKVStoreClosure kvStoreClosure = new BaseKVStoreClosure() { @SuppressWarnings("unchecked") @Override @@ -470,10 +470,10 @@ public void run(final Status status) { }; if (request.isReverse()) { this.rawKVStore.reverseScan(request.getStartKey(), request.getEndKey(), request.getLimit(), - request.isReadOnlySafe(), request.isReturnValue(), KVStoreClosure); + request.isReadOnlySafe(), request.isReturnValue(), kvStoreClosure); } else { this.rawKVStore.scan(request.getStartKey(), request.getEndKey(), request.getLimit(), - request.isReadOnlySafe(), request.isReturnValue(), KVStoreClosure); + request.isReadOnlySafe(), request.isReturnValue(), kvStoreClosure); } } catch (final Throwable t) { LOG.error("Failed to handle: {}, {}.", request, StackTraceUtil.stackTrace(t)); diff --git a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultRheaKVStore.java b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultRheaKVStore.java index 259952f2c..0ab0a0d14 100644 --- a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultRheaKVStore.java +++ b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/client/DefaultRheaKVStore.java @@ -623,8 +623,8 @@ private FutureGroup> internalScan(final byte[] startKey, final byt final ListRetryCallable retryCallable = retryCause -> internalScan(subStartKey, subEndKey, readOnlySafe, returnValue, retriesLeft - 1, retryCause); final ListFailoverFuture future = new ListFailoverFuture<>(retriesLeft, retryCallable); - internalRegionScan(region, subStartKey, subEndKey, false, readOnlySafe, returnValue, future, retriesLeft, lastError, - this.onlyLeaderRead); + internalRegionScan(region, subStartKey, subEndKey, false, readOnlySafe, returnValue, future, retriesLeft, + lastError, this.onlyLeaderRead); futures.add(future); } return new FutureGroup<>(futures); @@ -761,8 +761,8 @@ private FutureGroup> internalReverseScan(final byte[] startKey, fi final ListRetryCallable retryCallable = retryCause -> internalReverseScan(subStartKey, subEndKey, readOnlySafe, returnValue, retriesLeft - 1, retryCause); final ListFailoverFuture future = new ListFailoverFuture<>(retriesLeft, retryCallable); - internalRegionScan(region, subStartKey, subEndKey, true, readOnlySafe, returnValue, future, retriesLeft, lastError, - this.onlyLeaderRead ); + internalRegionScan(region, subStartKey, subEndKey, true, readOnlySafe, returnValue, future, retriesLeft, + lastError, this.onlyLeaderRead ); futures.add(future); } return new FutureGroup<>(futures); diff --git a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/BaseRawKVStore.java b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/BaseRawKVStore.java index d8d2a0699..8a9eee199 100644 --- a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/BaseRawKVStore.java +++ b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/BaseRawKVStore.java @@ -128,13 +128,14 @@ public long getSafeEndValueForSequence(final long startVal, final int step) { } /** - * If limit == 0, it will be modified to Integer.MAX_VALUE on the server - * and then queried. So 'limit == 0' means that the number of queries is - * not limited. This is because serialization uses varint to compress - * numbers. In the case of 0, only 1 byte is occupied, and Integer.MAX_VALUE - * takes 5 bytes. - * @param limit - * @return + * If limit == 0, it will be modified to Integer.MAX_VALUE on the server + * and then queried. So 'limit == 0' means that the number of queries is + * not limited. This is because serialization uses varint to compress + * numbers. In the case of 0, only 1 byte is occupied, and Integer.MAX_VALUE + * takes 5 bytes. + * + * @param limit input limit + * @return normalize limit */ protected int normalizeLimit(final int limit) { return limit > 0 ? limit : Integer.MAX_VALUE; diff --git a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/MemoryRawKVStore.java b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/MemoryRawKVStore.java index d1597e229..54b1e56a0 100644 --- a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/MemoryRawKVStore.java +++ b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/MemoryRawKVStore.java @@ -143,7 +143,7 @@ public void scan(final byte[] startKey, final byte[] endKey, final int limit, final KVStoreClosure closure) { final Timer.Context timeCtx = getTimeContext("SCAN"); final List entries = Lists.newArrayList(); - int maxCount = normalizeLimit(limit); + final int maxCount = normalizeLimit(limit); final ConcurrentNavigableMap subMap; final byte[] realStartKey = BytesUtil.nullToEmpty(startKey); if (endKey == null) { @@ -174,7 +174,7 @@ public void reverseScan(final byte[] startKey, final byte[] endKey, final int li final KVStoreClosure closure) { final Timer.Context timeCtx = getTimeContext("REVERSE_SCAN"); final List entries = Lists.newArrayList(); - int maxCount = normalizeLimit(limit); + final int maxCount = normalizeLimit(limit); final ConcurrentNavigableMap subMap; final byte[] realEndKey = BytesUtil.nullToEmpty(endKey); if (startKey == null) { diff --git a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RaftRawKVStore.java b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RaftRawKVStore.java index 5e5c28bd1..d0dc82217 100644 --- a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RaftRawKVStore.java +++ b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RaftRawKVStore.java @@ -255,11 +255,11 @@ public void run(final Status status, final long index, final byte[] reqCtx) { } RaftRawKVStore.this.readIndexExecutor.execute(() -> { if (isLeader()) { - LOG.warn("Fail to [reverse scan] with 'ReadIndex': {}, try to applying to the state machine.", status); + LOG.warn("Fail to [reverseScan] with 'ReadIndex': {}, try to applying to the state machine.", status); // If 'read index' read fails, try to applying to the state machine at the leader node applyOperation(KVOperation.createReverseScan(startKey, endKey, limit, returnValue), closure); } else { - LOG.warn("Fail to [reverse scan] with 'ReadIndex': {}.", status); + LOG.warn("Fail to [reverseScan] with 'ReadIndex': {}.", status); // Client will retry to leader node new KVClosureAdapter(closure, null).run(status); } diff --git a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RocksRawKVStore.java b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RocksRawKVStore.java index d313637d1..06e149969 100644 --- a/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RocksRawKVStore.java +++ b/jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/storage/RocksRawKVStore.java @@ -308,7 +308,7 @@ public void scan(final byte[] startKey, final byte[] endKey, final int limit, final KVStoreClosure closure) { final Timer.Context timeCtx = getTimeContext("SCAN"); final List entries = Lists.newArrayList(); - int maxCount = normalizeLimit(limit); + final int maxCount = normalizeLimit(limit); final Lock readLock = this.readWriteLock.readLock(); readLock.lock(); try (final RocksIterator it = this.db.newIterator()) {