Skip to content

Commit 5387a10

Browse files
authored
Modify regionMigrateService's ThreadPool to IoTThreadPoolFactory.cachedThreadPool (#13548)
* modify regionMigratePool to IoTThreadPool * fix ut crash
1 parent e5e4980 commit 5387a10

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private void initSchemaRegion() {
197197
for (SchemaRegionId schemaRegionId : v) {
198198
PartialPath database;
199199
try {
200-
database = new PartialPath(k);
200+
database = PartialPath.getDatabasePath(k);
201201
} catch (IllegalPathException e) {
202202
logger.warn("Illegal database path: {}", k);
203203
continue;

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/RegionMigrateService.java

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.apache.iotdb.db.consensus.DataRegionConsensusImpl;
4141
import org.apache.iotdb.db.consensus.SchemaRegionConsensusImpl;
4242
import org.apache.iotdb.db.protocol.thrift.impl.DataNodeRegionManager;
43-
import org.apache.iotdb.db.storageengine.rescon.memory.AbstractPoolManager;
4443
import org.apache.iotdb.mpp.rpc.thrift.TMaintainPeerReq;
4544
import org.apache.iotdb.mpp.rpc.thrift.TRegionMigrateResult;
4645
import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq;
@@ -53,6 +52,7 @@
5352
import java.util.List;
5453
import java.util.Map;
5554
import java.util.concurrent.ConcurrentHashMap;
55+
import java.util.concurrent.ExecutorService;
5656
import java.util.stream.Collectors;
5757

5858
public class RegionMigrateService implements IService {
@@ -65,7 +65,7 @@ public class RegionMigrateService implements IService {
6565

6666
private static final int SLEEP_MILLIS = 5000;
6767

68-
private RegionMigratePool regionMigratePool;
68+
private ExecutorService regionMigratePool;
6969

7070
// Map<taskId, taskStatus>
7171
// TODO: Due to the use of procedureId as taskId, it is currently unable to handle the situation
@@ -199,15 +199,15 @@ private boolean addToTaskResultMap(long taskId) {
199199

200200
@Override
201201
public void start() throws StartupException {
202-
regionMigratePool = new RegionMigratePool();
203-
regionMigratePool.start();
202+
regionMigratePool =
203+
IoTDBThreadPoolFactory.newCachedThreadPool(ThreadName.REGION_MIGRATE.getName());
204204
LOGGER.info("Region migrate service start");
205205
}
206206

207207
@Override
208208
public void stop() {
209209
if (regionMigratePool != null) {
210-
regionMigratePool.stop();
210+
regionMigratePool.shutdown();
211211
}
212212
LOGGER.info("Region migrate service stop");
213213
}
@@ -217,32 +217,6 @@ public ServiceType getID() {
217217
return ServiceType.DATA_NODE_REGION_MIGRATE_SERVICE;
218218
}
219219

220-
private static class RegionMigratePool extends AbstractPoolManager {
221-
222-
private final Logger poolLogger = LoggerFactory.getLogger(RegionMigratePool.class);
223-
224-
private RegionMigratePool() {
225-
this.pool = IoTDBThreadPoolFactory.newCachedThreadPool(ThreadName.REGION_MIGRATE.getName());
226-
}
227-
228-
@Override
229-
public Logger getLogger() {
230-
return poolLogger;
231-
}
232-
233-
@Override
234-
public void start() {
235-
if (this.pool != null) {
236-
poolLogger.info("DataNode region migrate pool start");
237-
}
238-
}
239-
240-
@Override
241-
public String getName() {
242-
return "migrate region";
243-
}
244-
}
245-
246220
private static class AddRegionPeerTask implements Runnable {
247221

248222
private static final Logger taskLogger = LoggerFactory.getLogger(AddRegionPeerTask.class);

0 commit comments

Comments
 (0)