OneSizeFitsQuorum commented on code in PR #13191:
URL: https://github.com/apache/iotdb/pull/13191#discussion_r1718200269
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java:
##########
@@ -637,14 +625,32 @@ private TSStatus checkRegionMigrate(
&&
ConsensusFactory.SIMPLE_CONSENSUS.equals(conf.getSchemaRegionConsensusProtocolClass()))
{
failMessage =
"The region you are trying to migrate is using SimpleConsensus, and
SimpleConsensus not supports region migration.";
- } else if (anotherMigrateProcedure.isPresent()) {
+ } else if (0 !=
RegionOperationProcedure.getRegionOperations(regionGroupId)) {
+ Optional<Procedure<ConfigNodeProcedureEnv>> anotherMigrateProcedure =
Review Comment:
why need to traversal? Cannot we use
`RegionOperationProcedure.getRegionOperations(regionGroupId)` to get is
directly?
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/region/RegionOperationProcedure.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.iotdb.confignode.procedure.impl.region;
+
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
+import org.apache.iotdb.commons.utils.ThriftCommonsSerDeUtils;
+import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv;
+import org.apache.iotdb.confignode.procedure.impl.StateMachineProcedure;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class RegionOperationProcedure<TState>
+ extends StateMachineProcedure<ConfigNodeProcedureEnv, TState> {
+
+ // regionId -> regionOperationProcedure id
+ private static final Map<TConsensusGroupId, Integer> regionOperationsMap =
new HashMap<>();
Review Comment:
concurrenthashmap?
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/region/RegionOperationProcedure.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.iotdb.confignode.procedure.impl.region;
+
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
+import org.apache.iotdb.commons.utils.ThriftCommonsSerDeUtils;
+import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv;
+import org.apache.iotdb.confignode.procedure.impl.StateMachineProcedure;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class RegionOperationProcedure<TState>
+ extends StateMachineProcedure<ConfigNodeProcedureEnv, TState> {
+
+ // regionId -> regionOperationProcedure id
+ private static final Map<TConsensusGroupId, Integer> regionOperationsMap =
new HashMap<>();
+
+ TConsensusGroupId consensusGroupId;
+
+ RegionOperationProcedure() {
+ super();
+ }
+
+ RegionOperationProcedure(TConsensusGroupId consensusGroupId) {
+ super();
+ this.consensusGroupId = consensusGroupId;
+ addToMap(consensusGroupId, this.getProcId());
+ }
+
+ private static synchronized void addToMap(TConsensusGroupId
consensusGroupId, long procId) {
+ regionOperationsMap.putIfAbsent(consensusGroupId, 0);
+ regionOperationsMap.compute(consensusGroupId, (k, v) -> v + 1);
+ }
+
+ @Override
+ protected void procedureEndHook() {
+ synchronized (RegionOperationProcedure.class) {
Review Comment:
do not need this if we use concurrenthashmap?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]