Skip to content

Commit 24d423b

Browse files
author
codeba
committed
doc: Adding Comments
1 parent 5964a59 commit 24d423b

File tree

28 files changed

+314
-63
lines changed

28 files changed

+314
-63
lines changed

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/CacheTemplateProvider.java

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
22
* Copyright (c) 2024-2025, redis-keeper ([email protected])
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1515
*/
1616

1717
package org.codeba.redis.keeper.core;
@@ -34,16 +34,34 @@
3434
*/
3535
public class CacheTemplateProvider<T> implements LoadBalanceProvider<T>, Serializable {
3636

37+
/**
38+
* The Counter.
39+
*/
3740
private final AtomicInteger counter = new AtomicInteger(0);
3841

42+
/**
43+
* The Random.
44+
*/
3945
private final ThreadLocalRandom random = ThreadLocalRandom.current();
4046

47+
/**
48+
* The Status counter.
49+
*/
4150
private final AtomicInteger statusCounter = new AtomicInteger(0);
4251

52+
/**
53+
* The Status random.
54+
*/
4355
private final ThreadLocalRandom statusRandom = ThreadLocalRandom.current();
4456

57+
/**
58+
* The Datasource map.
59+
*/
4560
private final Map<String, T> datasourceMap;
4661

62+
/**
63+
* The Datasources map.
64+
*/
4765
private final Map<String, List<T>> datasourcesMap;
4866

4967
/**
@@ -112,6 +130,13 @@ public Optional<T> randomTemplate(String name, CacheDatasourceStatus status) {
112130
return random(list, statusRandom);
113131
}
114132

133+
/**
134+
* Poll optional.
135+
*
136+
* @param list the list
137+
* @param counter the counter
138+
* @return the optional
139+
*/
115140
private Optional<T> poll(List<T> list, AtomicInteger counter) {
116141
if (null == list || list.isEmpty()) {
117142
return Optional.empty();
@@ -123,6 +148,13 @@ private Optional<T> poll(List<T> list, AtomicInteger counter) {
123148
return Optional.ofNullable(list.get(index));
124149
}
125150

151+
/**
152+
* Random optional.
153+
*
154+
* @param list the list
155+
* @param threadLocalRandom the thread local random
156+
* @return the optional
157+
*/
126158
private Optional<T> random(List<T> list, ThreadLocalRandom threadLocalRandom) {
127159
if (null == list || list.isEmpty()) {
128160
return Optional.empty();

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KBloomFilter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import java.util.concurrent.CompletableFuture;
2020

21+
/**
22+
* The interface K bloom filter.
23+
*/
2124
public interface KBloomFilter {
2225
/**
2326
* Bf add boolean.

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KGeneric.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import java.util.concurrent.TimeUnit;
2020

21+
/**
22+
* The interface K generic.
23+
*/
2124
public interface KGeneric extends KGenericAsync {
2225
/**
2326
* Exists long.

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KGenericAsync.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import java.util.concurrent.CompletableFuture;
2020
import java.util.concurrent.TimeUnit;
2121

22+
/**
23+
* The interface K generic async.
24+
*/
2225
public interface KGenericAsync {
2326
/**
2427
* Exists async completable future.

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KHyperLogLog.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import java.util.Collection;
2020

21+
/**
22+
* The interface K hyper log log.
23+
*/
2124
public interface KHyperLogLog extends KHyperLogLogAsync {
2225

2326
/**

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KHyperLogLogAsync.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import java.util.Collection;
2020
import java.util.concurrent.CompletableFuture;
2121

22+
/**
23+
* The interface K hyper log log async.
24+
*/
2225
public interface KHyperLogLogAsync {
2326
/**
2427
* Pf add async completable future.

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KList.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import java.util.Optional;
2222
import java.util.concurrent.TimeUnit;
2323

24+
/**
25+
* The interface K list.
26+
*/
2427
public interface KList extends KListAsync {
2528
/**
2629
* Bl move optional.

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KListAsync.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import java.util.concurrent.CompletableFuture;
2222
import java.util.concurrent.TimeUnit;
2323

24+
/**
25+
* The interface K list async.
26+
*/
2427
public interface KListAsync {
2528
/**
2629
* Bl move async completable future.

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KLock.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import java.util.concurrent.CompletableFuture;
2020
import java.util.concurrent.TimeUnit;
2121

22+
/**
23+
* The interface K lock.
24+
*/
2225
public interface KLock {
2326
/**
2427
* Try lock boolean.

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KRateLimiter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import java.util.concurrent.CompletableFuture;
2020

21+
/**
22+
* The interface K rate limiter.
23+
*/
2124
public interface KRateLimiter {
2225
/**
2326
* Try set rate limiter boolean.

0 commit comments

Comments
 (0)