Skip to content

Commit 3461280

Browse files
authored
feat: remoove NonblockingConcurrentHashMap (#1176)
1 parent d592cbb commit 3461280

File tree

8 files changed

+2
-3601
lines changed

8 files changed

+2
-3601
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ SOFAJRaft was ported from Baidu's [braft](https://github.com/brpc/braft) with so
4343
## License
4444
SOFAJRaft is licensed under the [Apache License 2.0](./LICENSE). SOFAJRaft relies on some third-party components, and their open source protocol is also Apache License 2.0.
4545
In addition, SOFAJRaft also directly references some code (possibly with minor changes), which open source protocol is Apache License 2.0, including
46-
- NonBlockingHashMap/NonBlockingHashMapLong in [JCTools](https://github.com/JCTools/JCTools)
4746
- HashedWheelTimer in [Netty](https://github.com/netty/netty), also referenced Netty's Pipeline design
4847
- Efficient encoding/decoding of UTF8 String in [Protobuf](https://github.com/protocolbuffers/protobuf)
4948

README_zh_CN.md

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ SOFAJRaft 是从百度的 [braft](https://github.com/brpc/braft) 移植而来,
4141
## 开源许可
4242
SOFAJRaft 基于 [Apache License 2.0](./LICENSE) 协议,SOFAJRaft 依赖了一些第三方组件,它们的开源协议也为 Apache License 2.0,
4343
另外 SOFAJRaft 也直接引用了一些开源协议为 Apache License 2.0 的代码(可能有一些小小的改动)包括:
44-
- [JCTools](https://github.com/JCTools/JCTools) 中的 NonBlockingHashMap/NonBlockingHashMapLong
4544
- [Netty](https://github.com/netty/netty) 中的 HashedWheelTimer,另外还参考了 Netty 的 Pipeline 设计
4645
- [Protobuf](https://github.com/protocolbuffers/protobuf) 中对 UTF8 String 高效的编码/解码
4746

jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/util/Maps.java

+2-21
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@
2424
import java.util.concurrent.ConcurrentHashMap;
2525
import java.util.concurrent.ConcurrentMap;
2626

27-
import com.alipay.sofa.jraft.rhea.util.concurrent.collection.NonBlockingHashMap;
28-
import com.alipay.sofa.jraft.rhea.util.concurrent.collection.NonBlockingHashMapLong;
2927
import com.alipay.sofa.jraft.util.Ints;
3028
import com.alipay.sofa.jraft.util.Requires;
31-
import com.alipay.sofa.jraft.util.SystemPropertyUtil;
32-
import com.alipay.sofa.jraft.util.internal.UnsafeUtil;
3329

3430
/**
3531
* Static utility methods pertaining to {@link Map} instances.
@@ -38,9 +34,6 @@
3834
*/
3935
public final class Maps {
4036

41-
private static final boolean USE_NON_BLOCKING_HASH = SystemPropertyUtil.getBoolean("rhea.use.non_blocking_hash",
42-
true);
43-
4437
/**
4538
* Creates a mutable, empty {@code HashMap} instance.
4639
*/
@@ -89,9 +82,6 @@ public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() {
8982
* Creates a mutable, empty {@code ConcurrentMap} instance.
9083
*/
9184
public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
92-
if (USE_NON_BLOCKING_HASH && UnsafeUtil.hasUnsafe()) {
93-
return new NonBlockingHashMap<>();
94-
}
9585
return new ConcurrentHashMap<>();
9686
}
9787

@@ -100,30 +90,21 @@ public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
10090
* that it should hold {@code expectedSize} elements without growth.
10191
*/
10292
public static <K, V> ConcurrentMap<K, V> newConcurrentMap(int initialCapacity) {
103-
if (USE_NON_BLOCKING_HASH && UnsafeUtil.hasUnsafe()) {
104-
return new NonBlockingHashMap<>(initialCapacity);
105-
}
10693
return new ConcurrentHashMap<>(initialCapacity);
10794
}
10895

10996
/**
110-
* Creates a mutable, empty {@code NonBlockingHashMapLong} instance.
97+
* Creates a mutable, empty {@code ConcurrentHashMap} instance.
11198
*/
11299
public static <V> ConcurrentMap<Long, V> newConcurrentMapLong() {
113-
if (USE_NON_BLOCKING_HASH && UnsafeUtil.hasUnsafe()) {
114-
return new NonBlockingHashMapLong<>();
115-
}
116100
return new ConcurrentHashMap<>();
117101
}
118102

119103
/**
120-
* Creates a {@code NonBlockingHashMapLong} instance, with a high enough "initial capacity"
104+
* Creates a {@code ConcurrentHashMap} instance, with a high enough "initial capacity"
121105
* that it should hold {@code expectedSize} elements without growth.
122106
*/
123107
public static <V> ConcurrentMap<Long, V> newConcurrentMapLong(int initialCapacity) {
124-
if (USE_NON_BLOCKING_HASH) {
125-
return new NonBlockingHashMapLong<>(initialCapacity);
126-
}
127108
return new ConcurrentHashMap<>(initialCapacity);
128109
}
129110

jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/util/concurrent/collection/AbstractEntry.java

-90
This file was deleted.

0 commit comments

Comments
 (0)