You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by rp...@apache.org on 2025/04/10 12:08:01 UTC
(ignite-3) branch main updated: IGNITE-25085 Remove ConcurrentHashSet (#5599)
This is an automated email from the ASF dual-hosted git repository.
rpuch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 4afd5aabbc1 IGNITE-25085 Remove ConcurrentHashSet (#5599)
4afd5aabbc1 is described below
commit 4afd5aabbc1fbf21dbb51d903702b08cfe4ef02e
Author: Roman Puchkovskiy <ro...@gmail.com>
AuthorDate: Thu Apr 10 16:07:56 2025 +0400
IGNITE-25085 Remove ConcurrentHashSet (#5599)
---
.../apache/ignite/raft/jraft/core/ItNodeTest.java | 4 +-
.../raft/jraft/rpc/impl/AbstractClientService.java | 3 +-
.../jraft/util/concurrent/ConcurrentHashSet.java | 93 ----------------------
.../java/org/apache/ignite/internal/Cluster.java | 4 +-
.../ItDisasterRecoveryReconfigurationTest.java | 6 +-
5 files changed, 8 insertions(+), 102 deletions(-)
diff --git a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java
index 748af1fe2fd..d19ce97ec1f 100644
--- a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java
+++ b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java
@@ -73,6 +73,7 @@ import java.util.NavigableSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.CountDownLatch;
@@ -158,7 +159,6 @@ import org.apache.ignite.raft.jraft.util.Bits;
import org.apache.ignite.raft.jraft.util.ExecutorServiceHelper;
import org.apache.ignite.raft.jraft.util.ExponentialBackoffTimeoutStrategy;
import org.apache.ignite.raft.jraft.util.Utils;
-import org.apache.ignite.raft.jraft.util.concurrent.ConcurrentHashSet;
import org.apache.ignite.raft.jraft.util.concurrent.FixedThreadsExecutorGroup;
import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.AfterAll;
@@ -4450,7 +4450,7 @@ public class ItNodeTest extends BaseIgniteAbstractTest {
NavigableSet<Integer> successfullyExecuted = new ConcurrentSkipListSet<>();
NavigableMap<Integer, Throwable> exceptions = new ConcurrentSkipListMap<>();
NavigableMap<Integer, String> statusErrors = new ConcurrentSkipListMap<>();
- Set<Integer> resultOrRunCalled = new ConcurrentHashSet<>();
+ Set<Integer> resultOrRunCalled = ConcurrentHashMap.newKeySet();
CompletableFuture<Void> tasksFuture = new CompletableFuture<>();
try {
diff --git a/modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/AbstractClientService.java b/modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/AbstractClientService.java
index 97b2bbd68bd..52174a44307 100644
--- a/modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/AbstractClientService.java
+++ b/modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/AbstractClientService.java
@@ -48,7 +48,6 @@ import org.apache.ignite.raft.jraft.rpc.RpcRequests;
import org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse;
import org.apache.ignite.raft.jraft.rpc.RpcResponseClosure;
import org.apache.ignite.raft.jraft.util.Utils;
-import org.apache.ignite.raft.jraft.util.concurrent.ConcurrentHashSet;
/**
* Abstract RPC client service based.
@@ -65,7 +64,7 @@ public abstract class AbstractClientService implements ClientService, TopologyEv
/**
* The set of pinged consistent IDs.
*/
- private final Set<String> readyConsistentIds = new ConcurrentHashSet<>();
+ private final Set<String> readyConsistentIds = ConcurrentHashMap.newKeySet();
public RpcClient getRpcClient() {
return this.rpcClient;
diff --git a/modules/raft/src/main/java/org/apache/ignite/raft/jraft/util/concurrent/ConcurrentHashSet.java b/modules/raft/src/main/java/org/apache/ignite/raft/jraft/util/concurrent/ConcurrentHashSet.java
deleted file mode 100644
index 8cd43fa2dbe..00000000000
--- a/modules/raft/src/main/java/org/apache/ignite/raft/jraft/util/concurrent/ConcurrentHashSet.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ignite.raft.jraft.util.concurrent;
-
-import java.util.AbstractSet;
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Concurrent hash set.
- *
- * Fork from bolt
- */
-public class ConcurrentHashSet<E> extends AbstractSet<E> {
- private ConcurrentHashMap<E, Boolean> map;
-
- /**
- * constructor
- */
- public ConcurrentHashSet() {
- super();
- map = new ConcurrentHashMap<>();
- }
-
- /**
- * return the size of the map
- *
- * @see java.util.AbstractCollection#size()
- */
- @Override
- public int size() {
- return map.size();
- }
-
- /**
- * @see java.util.AbstractCollection#contains(Object)
- */
- @SuppressWarnings("SuspiciousMethodCalls")
- @Override
- public boolean contains(Object o) {
- return map.containsKey(o);
- }
-
- /**
- * @see java.util.AbstractCollection#iterator()
- */
- @Override
- public Iterator<E> iterator() {
- return map.keySet().iterator();
- }
-
- /**
- * add an obj to set, if exist, return false, else return true
- *
- * @see java.util.AbstractCollection#add(Object)
- */
- @Override
- public boolean add(E o) {
- return map.putIfAbsent(o, Boolean.TRUE) == null;
- }
-
- /**
- * @see java.util.AbstractCollection#remove(Object)
- */
- @Override
- public boolean remove(Object o) {
- return map.remove(o) != null;
- }
-
- /**
- * clear the set
- *
- * @see java.util.AbstractCollection#clear()
- */
- @Override
- public void clear() {
- map.clear();
- }
-}
diff --git a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/Cluster.java b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/Cluster.java
index eaaa121ae03..e0702dd193f 100644
--- a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/Cluster.java
+++ b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/Cluster.java
@@ -39,6 +39,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
@@ -67,7 +68,6 @@ import org.apache.ignite.raft.jraft.Status;
import org.apache.ignite.raft.jraft.core.NodeImpl;
import org.apache.ignite.raft.jraft.entity.PeerId;
import org.apache.ignite.raft.jraft.error.RaftError;
-import org.apache.ignite.raft.jraft.util.concurrent.ConcurrentHashSet;
import org.apache.ignite.sql.IgniteSql;
import org.apache.ignite.sql.ResultSet;
import org.apache.ignite.sql.SqlRow;
@@ -98,7 +98,7 @@ public class Cluster {
private volatile int seedCountOverride = -1;
/** Indices of nodes that have been knocked out. */
- private final Set<Integer> knockedOutNodesIndices = new ConcurrentHashSet<>();
+ private final Set<Integer> knockedOutNodesIndices = ConcurrentHashMap.newKeySet();
/**
* Creates a new cluster.
diff --git a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
index f32e0b180dd..b168ec7acbb 100644
--- a/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
+++ b/modules/transactions/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
@@ -66,6 +66,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -123,7 +124,6 @@ import org.apache.ignite.raft.jraft.entity.LogId;
import org.apache.ignite.raft.jraft.error.RaftError;
import org.apache.ignite.raft.jraft.rpc.RpcRequests.AppendEntriesRequest;
import org.apache.ignite.raft.jraft.rpc.WriteActionRequest;
-import org.apache.ignite.raft.jraft.util.concurrent.ConcurrentHashSet;
import org.apache.ignite.table.KeyValueView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
@@ -1001,7 +1001,7 @@ public class ItDisasterRecoveryReconfigurationTest extends ClusterPerTestIntegra
followerNodes.remove(leaderName);
// The nodes that we block AppendEntriesRequest to.
- Set<String> blockedNodes = new ConcurrentHashSet<>();
+ Set<String> blockedNodes = ConcurrentHashMap.newKeySet();
// Exclude one of the nodes from data(2).
int node0IndexInFollowers = followerNodes.indexOf(node0.name());
@@ -1140,7 +1140,7 @@ public class ItDisasterRecoveryReconfigurationTest extends ClusterPerTestIntegra
followerNodes.remove(leaderName);
// The nodes that we block AppendEntriesRequest to.
- Set<String> blockedNodes = new ConcurrentHashSet<>();
+ Set<String> blockedNodes = ConcurrentHashMap.newKeySet();
// Exclude one of the nodes from data(2).
int node0IndexInFollowers = followerNodes.indexOf(node0.name());