Skip to content

Commit

Permalink
feat: remoove NonblockingConcurrentHashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjiachun committed Jan 20, 2025
1 parent 9029048 commit 75a0912
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 3,601 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ SOFAJRaft was ported from Baidu's [braft](https://github.com/brpc/braft) with so
## License
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.
In addition, SOFAJRaft also directly references some code (possibly with minor changes), which open source protocol is Apache License 2.0, including
- NonBlockingHashMap/NonBlockingHashMapLong in [JCTools](https://github.com/JCTools/JCTools)
- HashedWheelTimer in [Netty](https://github.com/netty/netty), also referenced Netty's Pipeline design
- Efficient encoding/decoding of UTF8 String in [Protobuf](https://github.com/protocolbuffers/protobuf)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.alipay.sofa.jraft.rhea.util.concurrent.collection.NonBlockingHashMap;
import com.alipay.sofa.jraft.rhea.util.concurrent.collection.NonBlockingHashMapLong;
import com.alipay.sofa.jraft.util.Ints;
import com.alipay.sofa.jraft.util.Requires;
import com.alipay.sofa.jraft.util.SystemPropertyUtil;
import com.alipay.sofa.jraft.util.internal.UnsafeUtil;

/**
* Static utility methods pertaining to {@link Map} instances.
Expand All @@ -38,9 +34,6 @@
*/
public final class Maps {

private static final boolean USE_NON_BLOCKING_HASH = SystemPropertyUtil.getBoolean("rhea.use.non_blocking_hash",
true);

/**
* Creates a mutable, empty {@code HashMap} instance.
*/
Expand Down Expand Up @@ -89,9 +82,6 @@ public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() {
* Creates a mutable, empty {@code ConcurrentMap} instance.
*/
public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
if (USE_NON_BLOCKING_HASH && UnsafeUtil.hasUnsafe()) {
return new NonBlockingHashMap<>();
}
return new ConcurrentHashMap<>();
}

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

/**
* Creates a mutable, empty {@code NonBlockingHashMapLong} instance.
* Creates a mutable, empty {@code ConcurrentHashMap} instance.
*/
public static <V> ConcurrentMap<Long, V> newConcurrentMapLong() {
if (USE_NON_BLOCKING_HASH && UnsafeUtil.hasUnsafe()) {
return new NonBlockingHashMapLong<>();
}
return new ConcurrentHashMap<>();
}

/**
* Creates a {@code NonBlockingHashMapLong} instance, with a high enough "initial capacity"
* Creates a {@code ConcurrentHashMap} instance, with a high enough "initial capacity"
* that it should hold {@code expectedSize} elements without growth.
*/
public static <V> ConcurrentMap<Long, V> newConcurrentMapLong(int initialCapacity) {
if (USE_NON_BLOCKING_HASH) {
return new NonBlockingHashMapLong<>(initialCapacity);
}
return new ConcurrentHashMap<>(initialCapacity);
}

Expand Down

This file was deleted.

Loading

0 comments on commit 75a0912

Please sign in to comment.