From 6029a589f7ecc751ec0dd46bd66d054c2d32a7aa Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 28 May 2024 15:22:51 +0800 Subject: [PATCH 01/52] init thrift --- .../src/main/thrift/confignode.thrift | 15 +++++++++++++++ .../thrift-datanode/src/main/thrift/client.thrift | 2 ++ .../src/main/thrift/datanode.thrift | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift index 28978144ae8f..6197758c2661 100644 --- a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift +++ b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift @@ -528,6 +528,15 @@ struct TShowVariablesResp { 2: optional TClusterParameters clusterParameters } +struct TTestConnectionResult { + 1: required bool success + 2: optional string reason +} + +struct TTestConnectionResp { + 1: required map resultMap +} + // Show datanodes struct TDataNodeInfo { 1: required i32 dataNodeId @@ -1357,6 +1366,12 @@ service IConfigNodeRPCService { /** Show cluster Databases' information */ TShowDatabaseResp showDatabase(TGetDatabaseReq req) + /** Test connection of every node in the cluster */ + TTestConnectionResult submitTestConnectionTask() + + /** Empty rpc, only for connection test */ + common.TSStatus testConnection() + /** * Show the matched cluster Regions' information * See https://apache-iotdb.feishu.cn/docx/doxcnOzmIlaE2MX5tKjmYWuMSRg for detailed matching rules diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift index a99a8e599c93..8bef8e594b7e 100644 --- a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift +++ b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift @@ -655,4 +655,6 @@ service IClientRPCService { TSBackupConfigurationResp getBackupConfiguration(); TSConnectionInfoResp fetchAllConnectionsInfo(); + + common.TSStatus testConnection() } \ No newline at end of file diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift b/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift index f5d6839ce6c3..7f7d73d29e02 100644 --- a/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift +++ b/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift @@ -991,6 +991,9 @@ service IDataNodeRPCService { * Fetch fragment instance statistics for EXPLAIN ANALYZE */ TFetchFragmentInstanceStatisticsResp fetchFragmentInstanceStatistics(TFetchFragmentInstanceStatisticsReq req) + + /** Empty rpc, only for connection test */ + common.TSStatus testConnection() } service MPPDataExchangeService { @@ -1003,4 +1006,7 @@ service MPPDataExchangeService { void onNewDataBlockEvent(TNewDataBlockEvent e); void onEndOfDataBlockEvent(TEndOfDataBlockEvent e); + + /** Empty rpc, only for connection test */ + common.TSStatus testConnection() } From 42e651f1cb62eaaaab61ac7c4ee96d5ae7f8d99c Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 28 May 2024 15:23:41 +0800 Subject: [PATCH 02/52] antlr grammar --- .../antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4 | 1 + .../antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 6 +++++- .../src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4 index e6ed5147ad2e..2e92b524d807 100644 --- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4 +++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4 @@ -63,6 +63,7 @@ keyWords | CONDITION | CONFIGNODES | CONFIGURATION + | CONNECTION | CONNECTOR | CONTAIN | CONTAINS diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 index c3620a843171..85856c6774f6 100644 --- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 +++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 @@ -64,7 +64,7 @@ ddlStatement | createContinuousQuery | dropContinuousQuery | showContinuousQueries // Cluster | showVariables | showCluster | showRegions | showDataNodes | showConfigNodes | showClusterId - | getRegionId | getTimeSlotList | countTimeSlotList | getSeriesSlotList | migrateRegion + | getRegionId | getTimeSlotList | countTimeSlotList | getSeriesSlotList | migrateRegion | verifyConnection // Quota | setSpaceQuota | showSpaceQuota | setThrottleQuota | showThrottleQuota // View @@ -529,6 +529,10 @@ migrateRegion : MIGRATE REGION regionId=INTEGER_LITERAL FROM fromId=INTEGER_LITERAL TO toId=INTEGER_LITERAL ; +verifyConnection + : VERIFY CONNECTION + ; + // Pipe Task ========================================================================================= createPipe : CREATE PIPE pipeName=identifier diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 index 46fba9403650..23a25c73f39e 100644 --- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 +++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 @@ -165,6 +165,10 @@ CONFIGURATION : C O N F I G U R A T I O N ; +CONNECTION + : C O N N E C T I O N + ; + CONNECTOR : C O N N E C T O R ; From 9a9ac6ecef7cb033123698c08532c8b247e9af31 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 29 May 2024 11:14:12 +0800 Subject: [PATCH 03/52] make AsyncDataNodeClientPool nice and clear --- .../client/async/AsyncDataNodeClientPool.java | 226 +++++------------- 1 file changed, 64 insertions(+), 162 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index dd201a66b574..03a7ee8bd0ea 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -32,6 +32,7 @@ import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; @@ -190,315 +191,216 @@ private void sendAsyncRequestToDataNode( try { AsyncDataNodeInternalServiceClient client; client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); + Object request = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler abstractHandler = + clientHandler.createAsyncRPCHandler(requestId, targetDataNode); switch (clientHandler.getRequestType()) { case SET_TTL: - client.setTTL( - (TSetTTLReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.setTTL((TSetTTLReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case CREATE_DATA_REGION: client.createDataRegion( - (TCreateDataRegionReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TCreateDataRegionReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case DELETE_REGION: client.deleteRegion( - (TConsensusGroupId) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TConsensusGroupId) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case CREATE_SCHEMA_REGION: client.createSchemaRegion( - (TCreateSchemaRegionReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TCreateSchemaRegionReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case CREATE_FUNCTION: client.createFunction( - (TCreateFunctionInstanceReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TCreateFunctionInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case DROP_FUNCTION: client.dropFunction( - (TDropFunctionInstanceReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TDropFunctionInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case CREATE_TRIGGER_INSTANCE: client.createTriggerInstance( - (TCreateTriggerInstanceReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TCreateTriggerInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case DROP_TRIGGER_INSTANCE: client.dropTriggerInstance( - (TDropTriggerInstanceReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TDropTriggerInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case ACTIVE_TRIGGER_INSTANCE: client.activeTriggerInstance( - (TActiveTriggerInstanceReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TActiveTriggerInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case INACTIVE_TRIGGER_INSTANCE: client.inactiveTriggerInstance( - (TInactiveTriggerInstanceReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TInactiveTriggerInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case UPDATE_TRIGGER_LOCATION: client.updateTriggerLocation( - (TUpdateTriggerLocationReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TUpdateTriggerLocationReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case CREATE_PIPE_PLUGIN: client.createPipePlugin( - (TCreatePipePluginInstanceReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TCreatePipePluginInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case DROP_PIPE_PLUGIN: client.dropPipePlugin( - (TDropPipePluginInstanceReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TDropPipePluginInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case PIPE_PUSH_ALL_META: - client.pushPipeMeta( - (TPushPipeMetaReq) clientHandler.getRequest(requestId), - (PipePushMetaRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.pushPipeMeta((TPushPipeMetaReq) request, (PipePushMetaRPCHandler) abstractHandler); break; case PIPE_PUSH_SINGLE_META: client.pushSinglePipeMeta( - (TPushSinglePipeMetaReq) clientHandler.getRequest(requestId), - (PipePushMetaRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TPushSinglePipeMetaReq) request, (PipePushMetaRPCHandler) abstractHandler); break; case PIPE_PUSH_MULTI_META: client.pushMultiPipeMeta( - (TPushMultiPipeMetaReq) clientHandler.getRequest(requestId), - (PipePushMetaRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TPushMultiPipeMetaReq) request, (PipePushMetaRPCHandler) abstractHandler); break; case TOPIC_PUSH_ALL_META: client.pushTopicMeta( - (TPushTopicMetaReq) clientHandler.getRequest(requestId), - (TopicPushMetaRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TPushTopicMetaReq) request, (TopicPushMetaRPCHandler) abstractHandler); break; case TOPIC_PUSH_SINGLE_META: client.pushSingleTopicMeta( - (TPushSingleTopicMetaReq) clientHandler.getRequest(requestId), - (TopicPushMetaRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TPushSingleTopicMetaReq) request, (TopicPushMetaRPCHandler) abstractHandler); break; case TOPIC_PUSH_MULTI_META: client.pushMultiTopicMeta( - (TPushMultiTopicMetaReq) clientHandler.getRequest(requestId), - (TopicPushMetaRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TPushMultiTopicMetaReq) request, (TopicPushMetaRPCHandler) abstractHandler); break; case CONSUMER_GROUP_PUSH_ALL_META: client.pushConsumerGroupMeta( - (TPushConsumerGroupMetaReq) clientHandler.getRequest(requestId), - (ConsumerGroupPushMetaRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TPushConsumerGroupMetaReq) request, + (ConsumerGroupPushMetaRPCHandler) abstractHandler); break; case CONSUMER_GROUP_PUSH_SINGLE_META: client.pushSingleConsumerGroupMeta( - (TPushSingleConsumerGroupMetaReq) clientHandler.getRequest(requestId), - (ConsumerGroupPushMetaRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TPushSingleConsumerGroupMetaReq) request, + (ConsumerGroupPushMetaRPCHandler) abstractHandler); break; case PIPE_HEARTBEAT: client.pipeHeartbeat( - (TPipeHeartbeatReq) clientHandler.getRequest(requestId), - (PipeHeartbeatRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TPipeHeartbeatReq) request, (PipeHeartbeatRPCHandler) abstractHandler); break; case MERGE: case FULL_MERGE: - client.merge( - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.merge((AsyncTSStatusRPCHandler) abstractHandler); break; case FLUSH: - client.flush( - (TFlushReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.flush((TFlushReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case CLEAR_CACHE: - client.clearCache( - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.clearCache((AsyncTSStatusRPCHandler) abstractHandler); break; case START_REPAIR_DATA: - client.startRepairData( - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.startRepairData((AsyncTSStatusRPCHandler) abstractHandler); break; case STOP_REPAIR_DATA: - client.stopRepairData( - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.stopRepairData((AsyncTSStatusRPCHandler) abstractHandler); break; case LOAD_CONFIGURATION: - client.loadConfiguration( - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.loadConfiguration((AsyncTSStatusRPCHandler) abstractHandler); break; case SET_SYSTEM_STATUS: - client.setSystemStatus( - (String) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.setSystemStatus((String) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case UPDATE_REGION_ROUTE_MAP: client.updateRegionCache( - (TRegionRouteReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TRegionRouteReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case CHANGE_REGION_LEADER: client.changeRegionLeader( - (TRegionLeaderChangeReq) clientHandler.getRequest(requestId), - (TransferLeaderRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TRegionLeaderChangeReq) request, (TransferLeaderRPCHandler) abstractHandler); break; case CONSTRUCT_SCHEMA_BLACK_LIST: client.constructSchemaBlackList( - (TConstructSchemaBlackListReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TConstructSchemaBlackListReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case ROLLBACK_SCHEMA_BLACK_LIST: client.rollbackSchemaBlackList( - (TRollbackSchemaBlackListReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TRollbackSchemaBlackListReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case FETCH_SCHEMA_BLACK_LIST: client.fetchSchemaBlackList( - (TFetchSchemaBlackListReq) clientHandler.getRequest(requestId), - (FetchSchemaBlackListRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TFetchSchemaBlackListReq) request, (FetchSchemaBlackListRPCHandler) abstractHandler); break; case INVALIDATE_MATCHED_SCHEMA_CACHE: client.invalidateMatchedSchemaCache( - (TInvalidateMatchedSchemaCacheReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TInvalidateMatchedSchemaCacheReq) request, + (AsyncTSStatusRPCHandler) abstractHandler); break; case DELETE_DATA_FOR_DELETE_SCHEMA: client.deleteDataForDeleteSchema( - (TDeleteDataForDeleteSchemaReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TDeleteDataForDeleteSchemaReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case DELETE_TIMESERIES: client.deleteTimeSeries( - (TDeleteTimeSeriesReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TDeleteTimeSeriesReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE: client.constructSchemaBlackListWithTemplate( - (TConstructSchemaBlackListWithTemplateReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TConstructSchemaBlackListWithTemplateReq) request, + (SchemaUpdateRPCHandler) abstractHandler); break; case ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE: client.rollbackSchemaBlackListWithTemplate( - (TRollbackSchemaBlackListWithTemplateReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TRollbackSchemaBlackListWithTemplateReq) request, + (SchemaUpdateRPCHandler) abstractHandler); break; case DEACTIVATE_TEMPLATE: client.deactivateTemplate( - (TDeactivateTemplateReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TDeactivateTemplateReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case UPDATE_TEMPLATE: client.updateTemplate( - (TUpdateTemplateReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TUpdateTemplateReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case COUNT_PATHS_USING_TEMPLATE: client.countPathsUsingTemplate( - (TCountPathsUsingTemplateReq) clientHandler.getRequest(requestId), - (CountPathsUsingTemplateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TCountPathsUsingTemplateReq) request, + (CountPathsUsingTemplateRPCHandler) abstractHandler); break; case CHECK_SCHEMA_REGION_USING_TEMPLATE: client.checkSchemaRegionUsingTemplate( - (TCheckSchemaRegionUsingTemplateReq) clientHandler.getRequest(requestId), - (CheckSchemaRegionUsingTemplateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TCheckSchemaRegionUsingTemplateReq) request, + (CheckSchemaRegionUsingTemplateRPCHandler) abstractHandler); break; case CHECK_TIMESERIES_EXISTENCE: client.checkTimeSeriesExistence( - (TCheckTimeSeriesExistenceReq) clientHandler.getRequest(requestId), - (CheckTimeSeriesExistenceRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TCheckTimeSeriesExistenceReq) request, + (CheckTimeSeriesExistenceRPCHandler) abstractHandler); break; case CONSTRUCT_VIEW_SCHEMA_BLACK_LIST: client.constructViewSchemaBlackList( - (TConstructViewSchemaBlackListReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TConstructViewSchemaBlackListReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case ROLLBACK_VIEW_SCHEMA_BLACK_LIST: client.rollbackViewSchemaBlackList( - (TRollbackViewSchemaBlackListReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TRollbackViewSchemaBlackListReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case DELETE_VIEW: client.deleteViewSchema( - (TDeleteViewSchemaReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TDeleteViewSchemaReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case ALTER_VIEW: - client.alterView( - (TAlterViewReq) clientHandler.getRequest(requestId), - (SchemaUpdateRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.alterView((TAlterViewReq) request, (SchemaUpdateRPCHandler) abstractHandler); break; case KILL_QUERY_INSTANCE: - client.killQueryInstance( - (String) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + client.killQueryInstance((String) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case SET_SPACE_QUOTA: client.setSpaceQuota( - (TSetSpaceQuotaReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TSetSpaceQuotaReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case SET_THROTTLE_QUOTA: client.setThrottleQuota( - (TSetThrottleQuotaReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TSetThrottleQuotaReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; case RESET_PEER_LIST: client.resetPeerList( - (TResetPeerListReq) clientHandler.getRequest(requestId), - (AsyncTSStatusRPCHandler) - clientHandler.createAsyncRPCHandler(requestId, targetDataNode)); + (TResetPeerListReq) request, (AsyncTSStatusRPCHandler) abstractHandler); break; default: LOGGER.error( From a40e53ba8f0fadbefafc0c7a821a18419160be5c Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 29 May 2024 11:15:54 +0800 Subject: [PATCH 04/52] make AsyncDataNodeClientPool nice and clear --- .../client/async/AsyncDataNodeClientPool.java | 132 ++++++++---------- 1 file changed, 55 insertions(+), 77 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index 03a7ee8bd0ea..8cc4223978c7 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -191,216 +191,194 @@ private void sendAsyncRequestToDataNode( try { AsyncDataNodeInternalServiceClient client; client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); - Object request = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler abstractHandler = + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler handler = clientHandler.createAsyncRPCHandler(requestId, targetDataNode); switch (clientHandler.getRequestType()) { case SET_TTL: - client.setTTL((TSetTTLReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.setTTL((TSetTTLReq) req, (AsyncTSStatusRPCHandler) handler); break; case CREATE_DATA_REGION: - client.createDataRegion( - (TCreateDataRegionReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.createDataRegion((TCreateDataRegionReq) req, (AsyncTSStatusRPCHandler) handler); break; case DELETE_REGION: - client.deleteRegion( - (TConsensusGroupId) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.deleteRegion((TConsensusGroupId) req, (AsyncTSStatusRPCHandler) handler); break; case CREATE_SCHEMA_REGION: client.createSchemaRegion( - (TCreateSchemaRegionReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TCreateSchemaRegionReq) req, (AsyncTSStatusRPCHandler) handler); break; case CREATE_FUNCTION: client.createFunction( - (TCreateFunctionInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TCreateFunctionInstanceReq) req, (AsyncTSStatusRPCHandler) handler); break; case DROP_FUNCTION: - client.dropFunction( - (TDropFunctionInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.dropFunction((TDropFunctionInstanceReq) req, (AsyncTSStatusRPCHandler) handler); break; case CREATE_TRIGGER_INSTANCE: client.createTriggerInstance( - (TCreateTriggerInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TCreateTriggerInstanceReq) req, (AsyncTSStatusRPCHandler) handler); break; case DROP_TRIGGER_INSTANCE: client.dropTriggerInstance( - (TDropTriggerInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TDropTriggerInstanceReq) req, (AsyncTSStatusRPCHandler) handler); break; case ACTIVE_TRIGGER_INSTANCE: client.activeTriggerInstance( - (TActiveTriggerInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TActiveTriggerInstanceReq) req, (AsyncTSStatusRPCHandler) handler); break; case INACTIVE_TRIGGER_INSTANCE: client.inactiveTriggerInstance( - (TInactiveTriggerInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TInactiveTriggerInstanceReq) req, (AsyncTSStatusRPCHandler) handler); break; case UPDATE_TRIGGER_LOCATION: client.updateTriggerLocation( - (TUpdateTriggerLocationReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TUpdateTriggerLocationReq) req, (AsyncTSStatusRPCHandler) handler); break; case CREATE_PIPE_PLUGIN: client.createPipePlugin( - (TCreatePipePluginInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TCreatePipePluginInstanceReq) req, (AsyncTSStatusRPCHandler) handler); break; case DROP_PIPE_PLUGIN: client.dropPipePlugin( - (TDropPipePluginInstanceReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + (TDropPipePluginInstanceReq) req, (AsyncTSStatusRPCHandler) handler); break; case PIPE_PUSH_ALL_META: - client.pushPipeMeta((TPushPipeMetaReq) request, (PipePushMetaRPCHandler) abstractHandler); + client.pushPipeMeta((TPushPipeMetaReq) req, (PipePushMetaRPCHandler) handler); break; case PIPE_PUSH_SINGLE_META: - client.pushSinglePipeMeta( - (TPushSinglePipeMetaReq) request, (PipePushMetaRPCHandler) abstractHandler); + client.pushSinglePipeMeta((TPushSinglePipeMetaReq) req, (PipePushMetaRPCHandler) handler); break; case PIPE_PUSH_MULTI_META: - client.pushMultiPipeMeta( - (TPushMultiPipeMetaReq) request, (PipePushMetaRPCHandler) abstractHandler); + client.pushMultiPipeMeta((TPushMultiPipeMetaReq) req, (PipePushMetaRPCHandler) handler); break; case TOPIC_PUSH_ALL_META: - client.pushTopicMeta( - (TPushTopicMetaReq) request, (TopicPushMetaRPCHandler) abstractHandler); + client.pushTopicMeta((TPushTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); break; case TOPIC_PUSH_SINGLE_META: client.pushSingleTopicMeta( - (TPushSingleTopicMetaReq) request, (TopicPushMetaRPCHandler) abstractHandler); + (TPushSingleTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); break; case TOPIC_PUSH_MULTI_META: client.pushMultiTopicMeta( - (TPushMultiTopicMetaReq) request, (TopicPushMetaRPCHandler) abstractHandler); + (TPushMultiTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); break; case CONSUMER_GROUP_PUSH_ALL_META: client.pushConsumerGroupMeta( - (TPushConsumerGroupMetaReq) request, - (ConsumerGroupPushMetaRPCHandler) abstractHandler); + (TPushConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); break; case CONSUMER_GROUP_PUSH_SINGLE_META: client.pushSingleConsumerGroupMeta( - (TPushSingleConsumerGroupMetaReq) request, - (ConsumerGroupPushMetaRPCHandler) abstractHandler); + (TPushSingleConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); break; case PIPE_HEARTBEAT: - client.pipeHeartbeat( - (TPipeHeartbeatReq) request, (PipeHeartbeatRPCHandler) abstractHandler); + client.pipeHeartbeat((TPipeHeartbeatReq) req, (PipeHeartbeatRPCHandler) handler); break; case MERGE: case FULL_MERGE: - client.merge((AsyncTSStatusRPCHandler) abstractHandler); + client.merge((AsyncTSStatusRPCHandler) handler); break; case FLUSH: - client.flush((TFlushReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.flush((TFlushReq) req, (AsyncTSStatusRPCHandler) handler); break; case CLEAR_CACHE: - client.clearCache((AsyncTSStatusRPCHandler) abstractHandler); + client.clearCache((AsyncTSStatusRPCHandler) handler); break; case START_REPAIR_DATA: - client.startRepairData((AsyncTSStatusRPCHandler) abstractHandler); + client.startRepairData((AsyncTSStatusRPCHandler) handler); break; case STOP_REPAIR_DATA: - client.stopRepairData((AsyncTSStatusRPCHandler) abstractHandler); + client.stopRepairData((AsyncTSStatusRPCHandler) handler); break; case LOAD_CONFIGURATION: - client.loadConfiguration((AsyncTSStatusRPCHandler) abstractHandler); + client.loadConfiguration((AsyncTSStatusRPCHandler) handler); break; case SET_SYSTEM_STATUS: - client.setSystemStatus((String) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.setSystemStatus((String) req, (AsyncTSStatusRPCHandler) handler); break; case UPDATE_REGION_ROUTE_MAP: - client.updateRegionCache( - (TRegionRouteReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.updateRegionCache((TRegionRouteReq) req, (AsyncTSStatusRPCHandler) handler); break; case CHANGE_REGION_LEADER: client.changeRegionLeader( - (TRegionLeaderChangeReq) request, (TransferLeaderRPCHandler) abstractHandler); + (TRegionLeaderChangeReq) req, (TransferLeaderRPCHandler) handler); break; case CONSTRUCT_SCHEMA_BLACK_LIST: client.constructSchemaBlackList( - (TConstructSchemaBlackListReq) request, (SchemaUpdateRPCHandler) abstractHandler); + (TConstructSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_SCHEMA_BLACK_LIST: client.rollbackSchemaBlackList( - (TRollbackSchemaBlackListReq) request, (SchemaUpdateRPCHandler) abstractHandler); + (TRollbackSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case FETCH_SCHEMA_BLACK_LIST: client.fetchSchemaBlackList( - (TFetchSchemaBlackListReq) request, (FetchSchemaBlackListRPCHandler) abstractHandler); + (TFetchSchemaBlackListReq) req, (FetchSchemaBlackListRPCHandler) handler); break; case INVALIDATE_MATCHED_SCHEMA_CACHE: client.invalidateMatchedSchemaCache( - (TInvalidateMatchedSchemaCacheReq) request, - (AsyncTSStatusRPCHandler) abstractHandler); + (TInvalidateMatchedSchemaCacheReq) req, (AsyncTSStatusRPCHandler) handler); break; case DELETE_DATA_FOR_DELETE_SCHEMA: client.deleteDataForDeleteSchema( - (TDeleteDataForDeleteSchemaReq) request, (SchemaUpdateRPCHandler) abstractHandler); + (TDeleteDataForDeleteSchemaReq) req, (SchemaUpdateRPCHandler) handler); break; case DELETE_TIMESERIES: - client.deleteTimeSeries( - (TDeleteTimeSeriesReq) request, (SchemaUpdateRPCHandler) abstractHandler); + client.deleteTimeSeries((TDeleteTimeSeriesReq) req, (SchemaUpdateRPCHandler) handler); break; case CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE: client.constructSchemaBlackListWithTemplate( - (TConstructSchemaBlackListWithTemplateReq) request, - (SchemaUpdateRPCHandler) abstractHandler); + (TConstructSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE: client.rollbackSchemaBlackListWithTemplate( - (TRollbackSchemaBlackListWithTemplateReq) request, - (SchemaUpdateRPCHandler) abstractHandler); + (TRollbackSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); break; case DEACTIVATE_TEMPLATE: - client.deactivateTemplate( - (TDeactivateTemplateReq) request, (SchemaUpdateRPCHandler) abstractHandler); + client.deactivateTemplate((TDeactivateTemplateReq) req, (SchemaUpdateRPCHandler) handler); break; case UPDATE_TEMPLATE: - client.updateTemplate( - (TUpdateTemplateReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.updateTemplate((TUpdateTemplateReq) req, (AsyncTSStatusRPCHandler) handler); break; case COUNT_PATHS_USING_TEMPLATE: client.countPathsUsingTemplate( - (TCountPathsUsingTemplateReq) request, - (CountPathsUsingTemplateRPCHandler) abstractHandler); + (TCountPathsUsingTemplateReq) req, (CountPathsUsingTemplateRPCHandler) handler); break; case CHECK_SCHEMA_REGION_USING_TEMPLATE: client.checkSchemaRegionUsingTemplate( - (TCheckSchemaRegionUsingTemplateReq) request, - (CheckSchemaRegionUsingTemplateRPCHandler) abstractHandler); + (TCheckSchemaRegionUsingTemplateReq) req, + (CheckSchemaRegionUsingTemplateRPCHandler) handler); break; case CHECK_TIMESERIES_EXISTENCE: client.checkTimeSeriesExistence( - (TCheckTimeSeriesExistenceReq) request, - (CheckTimeSeriesExistenceRPCHandler) abstractHandler); + (TCheckTimeSeriesExistenceReq) req, (CheckTimeSeriesExistenceRPCHandler) handler); break; case CONSTRUCT_VIEW_SCHEMA_BLACK_LIST: client.constructViewSchemaBlackList( - (TConstructViewSchemaBlackListReq) request, (SchemaUpdateRPCHandler) abstractHandler); + (TConstructViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_VIEW_SCHEMA_BLACK_LIST: client.rollbackViewSchemaBlackList( - (TRollbackViewSchemaBlackListReq) request, (SchemaUpdateRPCHandler) abstractHandler); + (TRollbackViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case DELETE_VIEW: - client.deleteViewSchema( - (TDeleteViewSchemaReq) request, (SchemaUpdateRPCHandler) abstractHandler); + client.deleteViewSchema((TDeleteViewSchemaReq) req, (SchemaUpdateRPCHandler) handler); break; case ALTER_VIEW: - client.alterView((TAlterViewReq) request, (SchemaUpdateRPCHandler) abstractHandler); + client.alterView((TAlterViewReq) req, (SchemaUpdateRPCHandler) handler); break; case KILL_QUERY_INSTANCE: - client.killQueryInstance((String) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.killQueryInstance((String) req, (AsyncTSStatusRPCHandler) handler); break; case SET_SPACE_QUOTA: - client.setSpaceQuota( - (TSetSpaceQuotaReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.setSpaceQuota((TSetSpaceQuotaReq) req, (AsyncTSStatusRPCHandler) handler); break; case SET_THROTTLE_QUOTA: - client.setThrottleQuota( - (TSetThrottleQuotaReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.setThrottleQuota((TSetThrottleQuotaReq) req, (AsyncTSStatusRPCHandler) handler); break; case RESET_PEER_LIST: - client.resetPeerList( - (TResetPeerListReq) request, (AsyncTSStatusRPCHandler) abstractHandler); + client.resetPeerList((TResetPeerListReq) req, (AsyncTSStatusRPCHandler) handler); break; default: LOGGER.error( From c1126ce0b160f126d1eb2f1d2ad2fee5c3eb84dd Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 29 May 2024 11:21:51 +0800 Subject: [PATCH 05/52] make AsyncDataNodeClientPool nice and clear --- .../client/async/AsyncDataNodeClientPool.java | 64 ++++++++----------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index 8cc4223978c7..f9cf85c31f16 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -194,55 +194,47 @@ private void sendAsyncRequestToDataNode( Object req = clientHandler.getRequest(requestId); AbstractAsyncRPCHandler handler = clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; switch (clientHandler.getRequestType()) { case SET_TTL: - client.setTTL((TSetTTLReq) req, (AsyncTSStatusRPCHandler) handler); + client.setTTL((TSetTTLReq) req, defaultHandler); break; case CREATE_DATA_REGION: - client.createDataRegion((TCreateDataRegionReq) req, (AsyncTSStatusRPCHandler) handler); + client.createDataRegion((TCreateDataRegionReq) req, defaultHandler); break; case DELETE_REGION: - client.deleteRegion((TConsensusGroupId) req, (AsyncTSStatusRPCHandler) handler); + client.deleteRegion((TConsensusGroupId) req, defaultHandler); break; case CREATE_SCHEMA_REGION: - client.createSchemaRegion( - (TCreateSchemaRegionReq) req, (AsyncTSStatusRPCHandler) handler); + client.createSchemaRegion((TCreateSchemaRegionReq) req, defaultHandler); break; case CREATE_FUNCTION: - client.createFunction( - (TCreateFunctionInstanceReq) req, (AsyncTSStatusRPCHandler) handler); + client.createFunction((TCreateFunctionInstanceReq) req, defaultHandler); break; case DROP_FUNCTION: - client.dropFunction((TDropFunctionInstanceReq) req, (AsyncTSStatusRPCHandler) handler); + client.dropFunction((TDropFunctionInstanceReq) req, defaultHandler); break; case CREATE_TRIGGER_INSTANCE: - client.createTriggerInstance( - (TCreateTriggerInstanceReq) req, (AsyncTSStatusRPCHandler) handler); + client.createTriggerInstance((TCreateTriggerInstanceReq) req, defaultHandler); break; case DROP_TRIGGER_INSTANCE: - client.dropTriggerInstance( - (TDropTriggerInstanceReq) req, (AsyncTSStatusRPCHandler) handler); + client.dropTriggerInstance((TDropTriggerInstanceReq) req, defaultHandler); break; case ACTIVE_TRIGGER_INSTANCE: - client.activeTriggerInstance( - (TActiveTriggerInstanceReq) req, (AsyncTSStatusRPCHandler) handler); + client.activeTriggerInstance((TActiveTriggerInstanceReq) req, defaultHandler); break; case INACTIVE_TRIGGER_INSTANCE: - client.inactiveTriggerInstance( - (TInactiveTriggerInstanceReq) req, (AsyncTSStatusRPCHandler) handler); + client.inactiveTriggerInstance((TInactiveTriggerInstanceReq) req, defaultHandler); break; case UPDATE_TRIGGER_LOCATION: - client.updateTriggerLocation( - (TUpdateTriggerLocationReq) req, (AsyncTSStatusRPCHandler) handler); + client.updateTriggerLocation((TUpdateTriggerLocationReq) req, defaultHandler); break; case CREATE_PIPE_PLUGIN: - client.createPipePlugin( - (TCreatePipePluginInstanceReq) req, (AsyncTSStatusRPCHandler) handler); + client.createPipePlugin((TCreatePipePluginInstanceReq) req, defaultHandler); break; case DROP_PIPE_PLUGIN: - client.dropPipePlugin( - (TDropPipePluginInstanceReq) req, (AsyncTSStatusRPCHandler) handler); + client.dropPipePlugin((TDropPipePluginInstanceReq) req, defaultHandler); break; case PIPE_PUSH_ALL_META: client.pushPipeMeta((TPushPipeMetaReq) req, (PipePushMetaRPCHandler) handler); @@ -277,28 +269,28 @@ private void sendAsyncRequestToDataNode( break; case MERGE: case FULL_MERGE: - client.merge((AsyncTSStatusRPCHandler) handler); + client.merge(defaultHandler); break; case FLUSH: - client.flush((TFlushReq) req, (AsyncTSStatusRPCHandler) handler); + client.flush((TFlushReq) req, defaultHandler); break; case CLEAR_CACHE: - client.clearCache((AsyncTSStatusRPCHandler) handler); + client.clearCache(defaultHandler); break; case START_REPAIR_DATA: - client.startRepairData((AsyncTSStatusRPCHandler) handler); + client.startRepairData(defaultHandler); break; case STOP_REPAIR_DATA: - client.stopRepairData((AsyncTSStatusRPCHandler) handler); + client.stopRepairData(defaultHandler); break; case LOAD_CONFIGURATION: - client.loadConfiguration((AsyncTSStatusRPCHandler) handler); + client.loadConfiguration(defaultHandler); break; case SET_SYSTEM_STATUS: - client.setSystemStatus((String) req, (AsyncTSStatusRPCHandler) handler); + client.setSystemStatus((String) req, defaultHandler); break; case UPDATE_REGION_ROUTE_MAP: - client.updateRegionCache((TRegionRouteReq) req, (AsyncTSStatusRPCHandler) handler); + client.updateRegionCache((TRegionRouteReq) req, defaultHandler); break; case CHANGE_REGION_LEADER: client.changeRegionLeader( @@ -318,7 +310,7 @@ private void sendAsyncRequestToDataNode( break; case INVALIDATE_MATCHED_SCHEMA_CACHE: client.invalidateMatchedSchemaCache( - (TInvalidateMatchedSchemaCacheReq) req, (AsyncTSStatusRPCHandler) handler); + (TInvalidateMatchedSchemaCacheReq) req, defaultHandler); break; case DELETE_DATA_FOR_DELETE_SCHEMA: client.deleteDataForDeleteSchema( @@ -339,7 +331,7 @@ private void sendAsyncRequestToDataNode( client.deactivateTemplate((TDeactivateTemplateReq) req, (SchemaUpdateRPCHandler) handler); break; case UPDATE_TEMPLATE: - client.updateTemplate((TUpdateTemplateReq) req, (AsyncTSStatusRPCHandler) handler); + client.updateTemplate((TUpdateTemplateReq) req, defaultHandler); break; case COUNT_PATHS_USING_TEMPLATE: client.countPathsUsingTemplate( @@ -369,16 +361,16 @@ private void sendAsyncRequestToDataNode( client.alterView((TAlterViewReq) req, (SchemaUpdateRPCHandler) handler); break; case KILL_QUERY_INSTANCE: - client.killQueryInstance((String) req, (AsyncTSStatusRPCHandler) handler); + client.killQueryInstance((String) req, defaultHandler); break; case SET_SPACE_QUOTA: - client.setSpaceQuota((TSetSpaceQuotaReq) req, (AsyncTSStatusRPCHandler) handler); + client.setSpaceQuota((TSetSpaceQuotaReq) req, defaultHandler); break; case SET_THROTTLE_QUOTA: - client.setThrottleQuota((TSetThrottleQuotaReq) req, (AsyncTSStatusRPCHandler) handler); + client.setThrottleQuota((TSetThrottleQuotaReq) req, defaultHandler); break; case RESET_PEER_LIST: - client.resetPeerList((TResetPeerListReq) req, (AsyncTSStatusRPCHandler) handler); + client.resetPeerList((TResetPeerListReq) req, defaultHandler); break; default: LOGGER.error( From 179f13049efbb9d0fb0f91a2b7ca9bc93e453b97 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 29 May 2024 15:23:29 +0800 Subject: [PATCH 06/52] fxxk, tooooo complicated --- .../client/DataNodeRequestType.java | 3 ++ .../client/async/AsyncDataNodeClientPool.java | 6 +++ .../confignode/manager/ClusterManager.java | 22 ++++++++++ .../confignode/manager/ConfigManager.java | 6 +++ .../iotdb/confignode/manager/IManager.java | 3 ++ .../thrift/ConfigNodeRPCServiceProcessor.java | 11 +++++ .../db/protocol/client/ConfigNodeClient.java | 23 ++++++++++ .../impl/DataNodeInternalRPCServiceImpl.java | 44 +++++++++++++++++++ .../execution/config/ConfigTaskVisitor.java | 8 ++++ .../executor/ClusterConfigTaskExecutor.java | 13 ++++++ .../config/executor/IConfigTaskExecutor.java | 2 + .../queryengine/plan/parser/ASTVisitor.java | 6 +++ .../plan/statement/StatementVisitor.java | 5 +++ .../src/main/thrift/common.thrift | 17 +++++++ .../src/main/thrift/confignode.thrift | 13 ++---- .../src/main/thrift/client.thrift | 4 ++ .../src/main/thrift/datanode.thrift | 2 + 17 files changed, 178 insertions(+), 10 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java index 381ae40be921..428fcdbf719d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java @@ -33,6 +33,9 @@ public enum DataNodeRequestType { LOAD_CONFIGURATION, SET_SYSTEM_STATUS, + SUBMIT_TEST_CONNECTION_TASK, + TEST_CONNECTION, + // Region Maintenance CREATE_DATA_REGION, CREATE_SCHEMA_REGION, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index f9cf85c31f16..e22d975b26c7 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.common.rpc.thrift.TFlushReq; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; @@ -40,6 +41,7 @@ import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.SchemaUpdateRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.TestConnectionRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.TransferLeaderRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; @@ -372,6 +374,10 @@ private void sendAsyncRequestToDataNode( case RESET_PEER_LIST: client.resetPeerList((TResetPeerListReq) req, defaultHandler); break; + case SUBMIT_TEST_CONNECTION_TASK: + client.submitTestConnectionTask((TNodeLocations) req, (TestConnectionRPCHandler) handler); + case TEST_CONNECTION: + client.testConnection(defaultHandler); default: LOGGER.error( "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 0dc662aa13a9..5066ecc394eb 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -19,6 +19,11 @@ package org.apache.iotdb.confignode.manager; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; +import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; +import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; import org.apache.iotdb.confignode.persistence.ClusterInfo; import org.apache.iotdb.consensus.exception.ConsensusException; @@ -77,4 +82,21 @@ private void generateClusterId() { LOGGER.warn(CONSENSUS_WRITE_ERROR, e); } } + + public void submitTestConnectionTask() {} + + private void submitTestConnectionTaskToAllDataNode() { + + AsyncClientHandler clientHandler = + new AsyncClientHandler<>( + DataNodeRequestType.TEST_CONNECTION, + null, + configManager.getNodeManager().getRegisteredDataNodeLocations()); + AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + clientHandler.getResponseMap(); + } + + private void submitTestConnectionTaskToAllConfigNode() { + // AsyncClientHandler + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java index 1be83c2beba0..315264b0b09b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java @@ -186,6 +186,7 @@ import org.apache.iotdb.confignode.rpc.thrift.TShowVariablesResp; import org.apache.iotdb.confignode.rpc.thrift.TSpaceQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TSubscribeReq; +import org.apache.iotdb.confignode.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.rpc.thrift.TThrottleQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TTimeSlotList; import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq; @@ -1620,6 +1621,11 @@ public TShowDatabaseResp showDatabase(TGetDatabaseReq req) { } } + @Override + public TTestConnectionResp submitTestConnectionTask() { + clusterManager.submitTestConnectionTask(); + } + @Override public ProcedureManager getProcedureManager() { return procedureManager; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java index 1529f436c4bc..4f7ab84717d2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java @@ -118,6 +118,7 @@ import org.apache.iotdb.confignode.rpc.thrift.TShowTopicResp; import org.apache.iotdb.confignode.rpc.thrift.TShowVariablesResp; import org.apache.iotdb.confignode.rpc.thrift.TSubscribeReq; +import org.apache.iotdb.confignode.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq; import org.apache.iotdb.confignode.rpc.thrift.TUnsubscribeReq; import org.apache.iotdb.consensus.common.DataSet; @@ -516,6 +517,8 @@ TDataPartitionTableResp getOrCreateDataPartition( */ TShowDatabaseResp showDatabase(TGetDatabaseReq req); + TTestConnectionResp submitTestConnectionTask(); + /** * Create schemaengine template. * diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java index 6cb52ef7f278..16d58a476ec3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java @@ -164,6 +164,7 @@ import org.apache.iotdb.confignode.rpc.thrift.TSpaceQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TSubscribeReq; import org.apache.iotdb.confignode.rpc.thrift.TSystemConfigurationResp; +import org.apache.iotdb.confignode.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.rpc.thrift.TTestOperation; import org.apache.iotdb.confignode.rpc.thrift.TThrottleQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq; @@ -887,6 +888,16 @@ public TShowDatabaseResp showDatabase(TGetDatabaseReq req) { return configManager.showDatabase(req); } + @Override + public TTestConnectionResp submitTestConnectionTask() throws TException { + return configManager.submitTestConnectionTask(); + } + + @Override + public TSStatus testConnection() throws TException { + return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); + } + @Override public TSStatus createSchemaTemplate(TCreateSchemaTemplateReq req) { return configManager.createSchemaTemplate(req); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java index f38ca2c0b682..fb90bd546be7 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java @@ -23,10 +23,12 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.common.rpc.thrift.TFlushReq; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.commons.client.ClientManager; import org.apache.iotdb.commons.client.ThriftClient; import org.apache.iotdb.commons.client.factory.ThriftClientFactory; @@ -706,6 +708,27 @@ public TShowDatabaseResp showDatabase(TGetDatabaseReq req) throws TException { () -> client.showDatabase(req), resp -> !updateConfigNodeLeader(resp.status)); } + @Override + public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) + throws TException { + return executeRemoteCallWithRetry( + () -> client.submitTestConnectionTask(nodeLocations), + resp -> !updateConfigNodeLeader(resp.getStatus())); + } + + @Override + public TTestConnectionResp submitTestConnectionTaskToLeader() throws TException { + return executeRemoteCallWithRetry( + () -> client.submitTestConnectionTaskToLeader(), + resp -> !updateConfigNodeLeader(resp.getStatus())); + } + + @Override + public TSStatus testConnection() throws TException { + return executeRemoteCallWithRetry( + () -> client.testConnection(), resp -> !updateConfigNodeLeader(resp)); + } + @Override public TRegionRouteMapResp getLatestRegionRouteMap() throws TException { return executeRemoteCallWithRetry( diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index c575ca0781df..1986f9efd0c2 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -19,15 +19,23 @@ package org.apache.iotdb.db.protocol.thrift.impl; +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.common.rpc.thrift.TFlushReq; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSettleReq; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; +import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; +import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.commons.conf.CommonConfig; import org.apache.iotdb.commons.conf.CommonDescriptor; @@ -1409,6 +1417,42 @@ public TFetchFragmentInstanceStatisticsResp fetchFragmentInstanceStatistics( return resp; } + @Override + public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) + throws TException { + TTestConnectionResp resp = new TTestConnectionResp(); + IClientManager + dataNodeInternalServiceClientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); + IClientManager + configNodeInternalServiceClientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncConfigNodeHeartbeatServiceClientPoolFactory()); + try { + for (TDataNodeLocation dataNodeLocation : nodeLocations.dataNodeLocations) { + dataNodeInternalServiceClientManager + .borrowClient(dataNodeLocation.getInternalEndPoint()) + .testConnection(null); + } + for (TConfigNodeLocation configNodeLocation : nodeLocations.configNodeLocations) { + configNodeInternalServiceClientManager + .borrowClient(configNodeLocation.getInternalEndPoint()) + .testConnection(null); + } + } catch (ClientManagerException e) { + throw new RuntimeException(e); + } + // TODO: 其它service + } + + @Override + public TSStatus testConnection() throws TException { + return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); + } + private PathPatternTree filterPathPatternTree(PathPatternTree patternTree, String storageGroup) { PathPatternTree filteredPatternTree = new PathPatternTree(); try { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java index b024ea5a62a3..a5297de5ab7b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java @@ -73,6 +73,7 @@ import org.apache.iotdb.db.queryengine.plan.execution.config.sys.SetSystemStatusTask; import org.apache.iotdb.db.queryengine.plan.execution.config.sys.StartRepairDataTask; import org.apache.iotdb.db.queryengine.plan.execution.config.sys.StopRepairDataTask; +import org.apache.iotdb.db.queryengine.plan.execution.config.sys.TestConnectionTask; import org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.AlterPipeTask; import org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.CreatePipeTask; import org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.DropPipeTask; @@ -152,6 +153,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.sys.SetSystemStatusStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.StartRepairDataStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.StopRepairDataStatement; +import org.apache.iotdb.db.queryengine.plan.statement.sys.TestConnectionStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetSpaceQuotaStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetThrottleQuotaStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.ShowSpaceQuotaStatement; @@ -238,6 +240,12 @@ public IConfigTask visitShowClusterId( return new ShowClusterIdTask(); } + @Override + public IConfigTask visitTestConnection( + TestConnectionStatement testConnectionStatement, MPPQueryContext context) { + return new TestConnectionTask(); + } + @Override public IConfigTask visitAuthor(AuthorStatement statement, MPPQueryContext context) { return new AuthorizerTask(statement); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java index 26f35e0cd633..d17532ce3340 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java @@ -101,6 +101,7 @@ import org.apache.iotdb.confignode.rpc.thrift.TShowTopicResp; import org.apache.iotdb.confignode.rpc.thrift.TShowVariablesResp; import org.apache.iotdb.confignode.rpc.thrift.TSpaceQuotaResp; +import org.apache.iotdb.confignode.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.confignode.rpc.thrift.TThrottleQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq; import org.apache.iotdb.db.conf.IoTDBConfig; @@ -1243,6 +1244,18 @@ public SettableFuture showClusterId() { return future; } + @Override + public SettableFuture testConnection() { + SettableFuture future = SettableFuture.create(); + try (ConfigNodeClient client = + CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { + // TODO: now sync, maybe async in future + TTestConnectionResult result = client.submitTestConnectionTask(); + } catch (Exception e) { + future.setException(e); + } + } + @Override public SettableFuture showTTL(ShowTTLStatement showTTLStatement) { SettableFuture future = SettableFuture.create(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java index df24fec47da6..8d12a4e9ca2d 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java @@ -132,6 +132,8 @@ public interface IConfigTaskExecutor { SettableFuture showClusterId(); + SettableFuture testConnection(); + SettableFuture showTTL(ShowTTLStatement showTTLStatement); SettableFuture showRegion(ShowRegionStatement showRegionStatement); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java index 3d3efc1b8c3c..a8f36a9cffdc 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java @@ -199,6 +199,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowVersionStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.StartRepairDataStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.StopRepairDataStatement; +import org.apache.iotdb.db.queryengine.plan.statement.sys.TestConnectionStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetSpaceQuotaStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetThrottleQuotaStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.ShowSpaceQuotaStatement; @@ -3966,6 +3967,11 @@ public Statement visitMigrateRegion(IoTDBSqlParser.MigrateRegionContext ctx) { Integer.parseInt(ctx.toId.getText())); } + @Override + public Statement visitVerifyConnection(IoTDBSqlParser.VerifyConnectionContext ctx) { + return new TestConnectionStatement(); + } + // Quota @Override public Statement visitSetSpaceQuota(IoTDBSqlParser.SetSpaceQuotaContext ctx) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java index d8dba82f490b..c6d2a88680bd 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java @@ -117,6 +117,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowVersionStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.StartRepairDataStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.StopRepairDataStatement; +import org.apache.iotdb.db.queryengine.plan.statement.sys.TestConnectionStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetSpaceQuotaStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetThrottleQuotaStatement; import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.ShowSpaceQuotaStatement; @@ -213,6 +214,10 @@ public R visitShowClusterId(ShowClusterIdStatement showClusterIdStatement, C con return visitStatement(showClusterIdStatement, context); } + public R visitTestConnection(TestConnectionStatement testConnectionStatement, C context) { + return visitStatement(testConnectionStatement, context); + } + // UDF public R visitCreateFunction(CreateFunctionStatement createFunctionStatement, C context) { return visitStatement(createFunctionStatement, context); diff --git a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift index f30914280a23..fabf0e578594 100644 --- a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift +++ b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift @@ -185,6 +185,23 @@ struct TLicense { 9: required i16 mlNodeNumLimit } +struct TTestConnectionResult { + 1: required bool success + 2: optional string reason +} + +struct TTestConnectionResp { + 1: required TSStatus status; + 2: required map resultMap +} + +struct TTestConnection + +struct TNodeLocations { + 1: optional list configNodeLocations + 2: optional list dataNodeLocations +} + enum TAggregationType { COUNT, AVG, diff --git a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift index 6197758c2661..54a916acc7a3 100644 --- a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift +++ b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift @@ -528,15 +528,6 @@ struct TShowVariablesResp { 2: optional TClusterParameters clusterParameters } -struct TTestConnectionResult { - 1: required bool success - 2: optional string reason -} - -struct TTestConnectionResp { - 1: required map resultMap -} - // Show datanodes struct TDataNodeInfo { 1: required i32 dataNodeId @@ -1367,7 +1358,9 @@ service IConfigNodeRPCService { TShowDatabaseResp showDatabase(TGetDatabaseReq req) /** Test connection of every node in the cluster */ - TTestConnectionResult submitTestConnectionTask() + common.TTestConnectionResp submitTestConnectionTask(common.TNodeLocations nodeLocations) + + common.TTestConnectionResp submitTestConnectionTaskToLeader() /** Empty rpc, only for connection test */ common.TSStatus testConnection() diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift index 8bef8e594b7e..88b4c9475d27 100644 --- a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift +++ b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift @@ -656,5 +656,9 @@ service IClientRPCService { TSConnectionInfoResp fetchAllConnectionsInfo(); + /** For other node's call */ common.TSStatus testConnection() + + /** For user's call */ + common.TSStatus SubmitTestConnectionTask() } \ No newline at end of file diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift b/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift index 7f7d73d29e02..5cfb13c48309 100644 --- a/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift +++ b/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift @@ -992,6 +992,8 @@ service IDataNodeRPCService { */ TFetchFragmentInstanceStatisticsResp fetchFragmentInstanceStatistics(TFetchFragmentInstanceStatisticsReq req) + common.TTestConnectionResp submitTestConnectionTask(common.TNodeLocations nodeLocations) + /** Empty rpc, only for connection test */ common.TSStatus testConnection() } From 2d128414b504d191e7c83f422e8e63256ac95392 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 29 May 2024 15:23:54 +0800 Subject: [PATCH 07/52] fxxk, tooooo complicated --- .../rpc/TestConnectionRPCHandler.java | 57 +++++++++++++++++++ .../config/sys/TestConnectionTask.java | 34 +++++++++++ .../sys/TestConnectionStatement.java | 52 +++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TestConnectionRPCHandler.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/TestConnectionStatement.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TestConnectionRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TestConnectionRPCHandler.java new file mode 100644 index 000000000000..53e4fdfc888e --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TestConnectionRPCHandler.java @@ -0,0 +1,57 @@ +/* + * 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.client.async.handlers.rpc; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; +import org.apache.iotdb.confignode.client.DataNodeRequestType; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public class TestConnectionRPCHandler extends AbstractAsyncRPCHandler { + + private static final Logger LOGGER = LoggerFactory.getLogger(TestConnectionRPCHandler.class); + + protected TestConnectionRPCHandler( + DataNodeRequestType requestType, + int requestId, + TDataNodeLocation targetDataNode, + Map dataNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + super(requestType, requestId, targetDataNode, dataNodeLocationMap, responseMap, countDownLatch); + } + + @Override + public void onComplete(TTestConnectionResp resp) { + responseMap.put(requestId, resp); + dataNodeLocationMap.remove(requestId); + } + + // TODO: 什么情况下会error? + @Override + public void onError(Exception e) { + LOGGER.error("gg", e); + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java new file mode 100644 index 000000000000..58883e3f3707 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -0,0 +1,34 @@ +/* + * 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.db.queryengine.plan.execution.config.sys; + +import org.apache.iotdb.db.queryengine.plan.execution.config.ConfigTaskResult; +import org.apache.iotdb.db.queryengine.plan.execution.config.IConfigTask; +import org.apache.iotdb.db.queryengine.plan.execution.config.executor.IConfigTaskExecutor; + +import com.google.common.util.concurrent.ListenableFuture; + +public class TestConnectionTask implements IConfigTask { + @Override + public ListenableFuture execute(IConfigTaskExecutor configTaskExecutor) + throws InterruptedException { + return configTaskExecutor.testConnection(); + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/TestConnectionStatement.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/TestConnectionStatement.java new file mode 100644 index 000000000000..280febd80545 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/TestConnectionStatement.java @@ -0,0 +1,52 @@ +/* + * 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.db.queryengine.plan.statement.sys; + +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.db.queryengine.plan.analyze.QueryType; +import org.apache.iotdb.db.queryengine.plan.statement.IConfigStatement; +import org.apache.iotdb.db.queryengine.plan.statement.Statement; +import org.apache.iotdb.db.queryengine.plan.statement.StatementVisitor; + +import java.util.Collections; +import java.util.List; + +public class TestConnectionStatement extends Statement implements IConfigStatement { + @Override + public QueryType getQueryType() { + return QueryType.READ; + } + + @Override + public List getPaths() { + return Collections.emptyList(); + } + + @Override + public R accept(StatementVisitor visitor, C context) { + return visitor.visitTestConnection(this, context); + } + + @Override + public TSStatus checkPermissionBeforeProcess(String userName) { + return super.checkPermissionBeforeProcess(userName); + } +} From 0cf3803da2ffe12350a466a681097c52a52ce9d2 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 4 Jun 2024 15:31:34 +0800 Subject: [PATCH 08/52] save --- .../async/handlers/AsyncClientHandler.java | 1 + .../confignode/conf/ConfigNodeConfig.java | 15 ++++ .../confignode/manager/ClusterManager.java | 89 ++++++++++++++++++- .../confignode/manager/ConfigManager.java | 7 -- .../iotdb/confignode/manager/IManager.java | 3 - .../iotdb/confignode/service/ConfigNode.java | 4 +- .../thrift/ConfigNodeRPCServiceProcessor.java | 17 +++- .../db/protocol/client/ConfigNodeClient.java | 6 +- .../executor/ClusterConfigTaskExecutor.java | 4 +- .../src/main/thrift/common.thrift | 27 ++++-- 10 files changed, 144 insertions(+), 29 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java index d4b0e7f52b71..89533462ec2f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java @@ -286,6 +286,7 @@ public AbstractAsyncRPCHandler createAsyncRPCHandler( case UPDATE_TEMPLATE: case KILL_QUERY_INSTANCE: case RESET_PEER_LIST: + case TEST_CONNECTION: default: return new AsyncTSStatusRPCHandler( requestType, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java index 3875bf090806..74a9e1c458cc 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java @@ -19,6 +19,7 @@ package org.apache.iotdb.confignode.conf; +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.commons.client.property.ClientPoolProperty.DefaultProperty; import org.apache.iotdb.commons.conf.IoTDBConstant; @@ -1230,4 +1231,18 @@ public void setDataRegionRatisPeriodicSnapshotInterval( long dataRegionRatisPeriodicSnapshotInterval) { this.dataRegionRatisPeriodicSnapshotInterval = dataRegionRatisPeriodicSnapshotInterval; } + + public TConfigNodeLocation generateLocalConfigNodeLocation(int configNodeId) { + return new TConfigNodeLocation( + configNodeId, + new TEndPoint(getInternalAddress(), getInternalPort()), + new TEndPoint(getInternalAddress(), getConsensusPort())); + } + + public TConfigNodeLocation generateLocalConfigNodeLocation() { + return new TConfigNodeLocation( + getConfigNodeId(), + new TEndPoint(getInternalAddress(), getInternalPort()), + new TEndPoint(getInternalAddress(), getConsensusPort())); + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 5066ecc394eb..3bd9d4b46cf0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -19,19 +19,43 @@ package org.apache.iotdb.confignode.manager; +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.common.rpc.thrift.TSender; +import org.apache.iotdb.common.rpc.thrift.TServiceProvider; +import org.apache.iotdb.common.rpc.thrift.TServiceType; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; +import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; import org.apache.iotdb.confignode.persistence.ClusterInfo; import org.apache.iotdb.consensus.exception.ConsensusException; +import org.apache.iotdb.db.protocol.client.ConfigNodeClient; +import org.apache.iotdb.db.protocol.client.ConfigNodeClientManager; +import org.apache.iotdb.db.protocol.client.ConfigNodeInfo; +import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; +import org.apache.iotdb.rpc.TSStatusCode; +import org.apache.thrift.TException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.UUID; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class ClusterManager { @@ -83,14 +107,14 @@ private void generateClusterId() { } } - public void submitTestConnectionTask() {} + public TTestConnectionResp submitTestConnectionTaskToEveryNode() {} private void submitTestConnectionTaskToAllDataNode() { AsyncClientHandler clientHandler = new AsyncClientHandler<>( - DataNodeRequestType.TEST_CONNECTION, - null, + DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + new TNodeLocations(), configManager.getNodeManager().getRegisteredDataNodeLocations()); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); clientHandler.getResponseMap(); @@ -99,4 +123,63 @@ private void submitTestConnectionTaskToAllDataNode() { private void submitTestConnectionTaskToAllConfigNode() { // AsyncClientHandler } + + public List doConnectionTest(TNodeLocations nodeLocations) { + List result = nodeLocations.getConfigNodeLocations().stream().map(this::testConfigNodeConnection).flatMap(Collection::stream).collect(Collectors.toList()); + List dataNodeResult = testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); + result.addAll(dataNodeResult); + return result; + } + + private List testConfigNodeConnection( + TConfigNodeLocation configNodeLocation) { + final TSender sender = new TSender().setConfigNodeLocation(ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); + final TTestConnectionResult result = new TTestConnectionResult(); + result.setServiceProvider(new TServiceProvider(configNodeLocation.getInternalEndPoint(), TServiceType.ConfigNodeInternalService)); + result.setSender(sender); + List results = new ArrayList<>(); + try (ConfigNodeClient client = ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { + TSStatus status = client.testConnection(); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason("unknown"); + } + } catch (Exception e) { + LOGGER.error("Test connection fail", e); + result.setSuccess(false); + result.setReason(e.getMessage()); + } + results.add(result); + return results; + } + + private List testAllDataNodeConnection( + List dataNodeLocations) { + final TSender sender = new TSender().setConfigNodeLocation(ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); + Map dataNodeLocationMap = dataNodeLocations.stream().collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + AsyncClientHandler clientHandler = + new AsyncClientHandler<>( + DataNodeRequestType.TEST_CONNECTION, + null, + dataNodeLocationMap); + AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + List results = new ArrayList<>(); + clientHandler.getResponseMap().forEach((dataNodeId, status) -> { + TEndPoint endPoint = dataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); + TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); + return results; + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java index 315264b0b09b..04fca120e221 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java @@ -186,7 +186,6 @@ import org.apache.iotdb.confignode.rpc.thrift.TShowVariablesResp; import org.apache.iotdb.confignode.rpc.thrift.TSpaceQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TSubscribeReq; -import org.apache.iotdb.confignode.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.rpc.thrift.TThrottleQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TTimeSlotList; import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq; @@ -200,7 +199,6 @@ import org.apache.iotdb.rpc.TSStatusCode; import org.apache.iotdb.service.rpc.thrift.TPipeTransferReq; import org.apache.iotdb.service.rpc.thrift.TPipeTransferResp; - import org.apache.tsfile.utils.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1621,11 +1619,6 @@ public TShowDatabaseResp showDatabase(TGetDatabaseReq req) { } } - @Override - public TTestConnectionResp submitTestConnectionTask() { - clusterManager.submitTestConnectionTask(); - } - @Override public ProcedureManager getProcedureManager() { return procedureManager; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java index 4f7ab84717d2..1529f436c4bc 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java @@ -118,7 +118,6 @@ import org.apache.iotdb.confignode.rpc.thrift.TShowTopicResp; import org.apache.iotdb.confignode.rpc.thrift.TShowVariablesResp; import org.apache.iotdb.confignode.rpc.thrift.TSubscribeReq; -import org.apache.iotdb.confignode.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq; import org.apache.iotdb.confignode.rpc.thrift.TUnsubscribeReq; import org.apache.iotdb.consensus.common.DataSet; @@ -517,8 +516,6 @@ TDataPartitionTableResp getOrCreateDataPartition( */ TShowDatabaseResp showDatabase(TGetDatabaseReq req); - TTestConnectionResp submitTestConnectionTask(); - /** * Create schemaengine template. * diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java index cc8bdfe89599..df95895658f8 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java @@ -184,7 +184,7 @@ public void active() { configManager .getNodeManager() .applyConfigNode( - generateConfigNodeLocation(SEED_CONFIG_NODE_ID), + CONF.generateLocalConfigNodeLocation(SEED_CONFIG_NODE_ID), new TNodeVersionInfo(IoTDBConstant.VERSION, IoTDBConstant.BUILD_INFO)); setUpMetricService(); // Notice: We always set up Seed-ConfigNode's RPC service lastly to ensure @@ -321,7 +321,7 @@ private void sendRegisterConfigNodeRequest() throws StartupException, IOExceptio TConfigNodeRegisterReq req = new TConfigNodeRegisterReq( configManager.getClusterParameters(), - generateConfigNodeLocation(INIT_NON_SEED_CONFIG_NODE_ID)); + CONF.generateLocalConfigNodeLocation(INIT_NON_SEED_CONFIG_NODE_ID)); req.setVersionInfo(new TNodeVersionInfo(IoTDBConstant.VERSION, IoTDBConstant.BUILD_INFO)); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java index 16d58a476ec3..5b0879eaf398 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java @@ -22,10 +22,12 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TFlushReq; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.commons.auth.AuthException; import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.consensus.ConsensusGroupId; @@ -164,7 +166,6 @@ import org.apache.iotdb.confignode.rpc.thrift.TSpaceQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TSubscribeReq; import org.apache.iotdb.confignode.rpc.thrift.TSystemConfigurationResp; -import org.apache.iotdb.confignode.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.rpc.thrift.TTestOperation; import org.apache.iotdb.confignode.rpc.thrift.TThrottleQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq; @@ -888,11 +889,21 @@ public TShowDatabaseResp showDatabase(TGetDatabaseReq req) { return configManager.showDatabase(req); } + /** Call by ConfigNode leader */ @Override - public TTestConnectionResp submitTestConnectionTask() throws TException { - return configManager.submitTestConnectionTask(); + public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) + throws TException { + return new TTestConnectionResp( + configManager.getClusterManager().doConnectionTest(nodeLocations)); } + /** Call by client connected DataNode */ + @Override + public TTestConnectionResp submitTestConnectionTaskToLeader() throws TException { + return configManager.getClusterManager().submitTestConnectionTaskToEveryNode(); + } + + /** Call by every other nodes */ @Override public TSStatus testConnection() throws TException { return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java index fb90bd546be7..bd5d69a68707 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java @@ -239,7 +239,7 @@ private void tryToConnect() throws TException { try { connect(configLeader); return; - } catch (TException e) { + } catch (TException ignore) { logger.warn("The current node may have been down {},try next node", configLeader); configLeader = null; } @@ -247,7 +247,7 @@ private void tryToConnect() throws TException { try { // Wait to start the next try Thread.sleep(RETRY_INTERVAL_MS); - } catch (InterruptedException e) { + } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); logger.warn("Unexpected interruption when waiting to try to connect to ConfigNode"); } @@ -264,7 +264,7 @@ private void tryToConnect() throws TException { try { connect(tryEndpoint); return; - } catch (TException e) { + } catch (TException ignore) { logger.warn("The current node may have been down {},try next node", tryEndpoint); } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java index d17532ce3340..fe9e8d564fdb 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java @@ -25,6 +25,7 @@ import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSpaceQuota; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TThrottleQuota; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.exception.ClientManagerException; @@ -101,7 +102,6 @@ import org.apache.iotdb.confignode.rpc.thrift.TShowTopicResp; import org.apache.iotdb.confignode.rpc.thrift.TShowVariablesResp; import org.apache.iotdb.confignode.rpc.thrift.TSpaceQuotaResp; -import org.apache.iotdb.confignode.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.confignode.rpc.thrift.TThrottleQuotaResp; import org.apache.iotdb.confignode.rpc.thrift.TUnsetSchemaTemplateReq; import org.apache.iotdb.db.conf.IoTDBConfig; @@ -1250,7 +1250,7 @@ public SettableFuture testConnection() { try (ConfigNodeClient client = CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { // TODO: now sync, maybe async in future - TTestConnectionResult result = client.submitTestConnectionTask(); + TTestConnectionResp result = client.submitTestConnectionTaskToLeader(); } catch (Exception e) { future.setException(e); } diff --git a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift index fabf0e578594..8663ed53fdc5 100644 --- a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift +++ b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift @@ -185,18 +185,33 @@ struct TLicense { 9: required i16 mlNodeNumLimit } +enum TServiceType { + ConfigNodeInternalService, + DataNodeInternalService, +} + +struct TServiceProvider { + 1: required TEndPoint endPoint + 2: required TServiceType serviceType +} + +struct TSender { + 1: optional TDataNodeLocation dataNodeLocation + 2: optional TConfigNodeLocation configNodeLocation +} + struct TTestConnectionResult { - 1: required bool success - 2: optional string reason + 1: required TServiceProvider serviceProvider + 2: required TSender sender + 3: required bool success + 4: optional string reason } struct TTestConnectionResp { - 1: required TSStatus status; - 2: required map resultMap + 1: optional TSStatus status + 2: required list resultList } -struct TTestConnection - struct TNodeLocations { 1: optional list configNodeLocations 2: optional list dataNodeLocations From f90770f96f08de52b207514d220ef2dd8c179404 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 4 Jun 2024 17:39:31 +0800 Subject: [PATCH 09/52] ConfigNodeClient --- .../db/protocol/client/ConfigNodeClient.java | 94 ++++++++++++++----- 1 file changed, 68 insertions(+), 26 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java index bd5d69a68707..aec534ef4774 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java @@ -176,13 +176,11 @@ public class ConfigNodeClient implements IConfigNodeRPCService.Iface, ThriftClie private TTransport transport; - private TEndPoint configLeader; + private List configNodeEndPoints; - private List configNodes; + private Cursor cursor; - private TEndPoint configNode; - - private int cursor = 0; + private boolean needRediscoverLeader = false; private boolean isFirstInitiated; @@ -197,11 +195,11 @@ public ConfigNodeClient( ThriftClientProperty property, ClientManager clientManager) throws TException { - this.configNodes = configNodes; + this.configNodeEndPoints = configNodes; this.property = property; this.clientManager = clientManager; // Set the first configNode as configLeader for a tentative connection - this.configLeader = this.configNodes.get(0); + this.cursor = new Cursor(0); this.isFirstInitiated = true; connectAndSync(); @@ -216,7 +214,6 @@ public void connect(TEndPoint endpoint) throws TException { if (!transport.isOpen()) { transport.open(); } - configNode = endpoint; } catch (TTransportException e) { throw new TException(e); } @@ -235,13 +232,13 @@ private void connectAndSync() throws TException { } private void tryToConnect() throws TException { - if (configLeader != null) { + if (!needRediscoverLeader) { try { - connect(configLeader); + connect(currentConnection()); return; } catch (TException ignore) { - logger.warn("The current node may have been down {},try next node", configLeader); - configLeader = null; + logger.warn("The current node may have been down {},try next node", currentConnection()); + needRediscoverLeader = true; } } else { try { @@ -257,9 +254,9 @@ private void tryToConnect() throws TException { transport.close(); } - for (int tryHostNum = 0; tryHostNum < configNodes.size(); tryHostNum++) { - cursor = (cursor + 1) % configNodes.size(); - TEndPoint tryEndpoint = configNodes.get(cursor); + for (int tryHostNum = 0; tryHostNum < configNodeEndPoints.size(); tryHostNum++) { + cursor.set((cursor.get() + 1) % configNodeEndPoints.size()); + TEndPoint tryEndpoint = configNodeEndPoints.get(cursor.get()); try { connect(tryEndpoint); @@ -272,13 +269,25 @@ private void tryToConnect() throws TException { throw new TException(MSG_RECONNECTION_FAIL); } + private TEndPoint currentConnection() { + return configNodeEndPoints.get(cursor.get()); + } + + public void manuallySelectConfigNode(TEndPoint endPoint) { + if (!configNodeEndPoints.contains(endPoint)) { + logger.warn("You cannot do this !"); + return; + } + cursor.setAndLock(configNodeEndPoints.indexOf(endPoint)); + } + public TTransport getTransport() { return transport; } public void syncLatestConfigNodeList() { - configNodes = ConfigNodeInfo.getInstance().getLatestConfigNodes(); - cursor = 0; + configNodeEndPoints = ConfigNodeInfo.getInstance().getLatestConfigNodes(); + cursor.set(0); } @Override @@ -305,16 +314,19 @@ private boolean updateConfigNodeLeader(TSStatus status) { try { if (status.getCode() == TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode()) { if (status.isSetRedirectNode()) { - configLeader = - new TEndPoint(status.getRedirectNode().getIp(), status.getRedirectNode().getPort()); + if (!configNodeEndPoints.contains(status.getRedirectNode())) { + configNodeEndPoints.add(status.getRedirectNode()); + } + cursor.set(configNodeEndPoints.indexOf(status.getRedirectNode())); + needRediscoverLeader = false; } else { - configLeader = null; + needRediscoverLeader = true; } if (!isFirstInitiated) { logger.info( "Failed to connect to ConfigNode {} from DataNode {}, because the current node is not " + "leader or not ready yet, will try again later", - configNode, + currentConnection(), config.getAddressAndPort()); } return true; @@ -346,11 +358,11 @@ private T executeRemoteCallWithRetry(final Operation call, final Predicat final String message = String.format( MSG_RECONNECTION_DATANODE_FAIL, - configNode, + currentConnection(), config.getAddressAndPort(), Thread.currentThread().getStackTrace()[2].getMethodName()); logger.warn(message, e); - configLeader = null; + needRediscoverLeader = true; } connectAndSync(); } @@ -389,16 +401,16 @@ public TDataNodeRegisterResp registerDataNode(TDataNodeRegisterReq req) throws T for (TConfigNodeLocation configNodeLocation : resp.getConfigNodeList()) { newConfigNodes.add(configNodeLocation.getInternalEndPoint()); } - configNodes = newConfigNodes; + configNodeEndPoints = newConfigNodes; } catch (TException e) { String message = String.format( MSG_RECONNECTION_DATANODE_FAIL, - configNode, + currentConnection(), config.getAddressAndPort(), Thread.currentThread().getStackTrace()[1].getMethodName()); logger.warn(message, e); - configLeader = null; + needRediscoverLeader = false; } connectAndSync(); } @@ -1133,4 +1145,34 @@ public boolean validateObject( .orElse(false); } } + + private class Cursor { + private int value; + private boolean locked = false; + + public Cursor(int value) { + this.value = value; + } + + public int get() { + return value; + } + + public void set(int value) { + if (!locked) { + this.value = value; + } else { + logger.warn("ConfigNodeClient cursor will keep {} and won't change to {}, because it has been locked.", configNodeEndPoints.get(this.value), configNodeEndPoints.get(value)); + } + } + + public void setAndLock(int value) { + set(value); + locked = true; + } + + public void unlock() { + locked = false; + } + } } From 5bbd64fdcc77444f06896436fac055aab6eefd64 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 5 Jun 2024 10:14:18 +0800 Subject: [PATCH 10/52] save --- .../confignode/manager/ClusterManager.java | 48 +++++++++++-------- .../common/header/ColumnHeaderConstant.java | 11 +++++ .../config/sys/TestConnectionTask.java | 35 ++++++++++++++ .../iotdb/commons/client/ClientManager.java | 2 +- 4 files changed, 76 insertions(+), 20 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 3bd9d4b46cf0..40c40972ead0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -29,7 +29,12 @@ import org.apache.iotdb.common.rpc.thrift.TServiceType; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; +import org.apache.iotdb.commons.client.ClientManager; import org.apache.iotdb.commons.client.exception.ClientManagerException; +import org.apache.iotdb.commons.client.property.ThriftClientProperty; +import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient; +import org.apache.iotdb.commons.conf.CommonConfig; +import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; @@ -133,25 +138,30 @@ public List doConnectionTest(TNodeLocations nodeLocations private List testConfigNodeConnection( TConfigNodeLocation configNodeLocation) { - final TSender sender = new TSender().setConfigNodeLocation(ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); - final TTestConnectionResult result = new TTestConnectionResult(); - result.setServiceProvider(new TServiceProvider(configNodeLocation.getInternalEndPoint(), TServiceType.ConfigNodeInternalService)); - result.setSender(sender); - List results = new ArrayList<>(); - try (ConfigNodeClient client = ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { - TSStatus status = client.testConnection(); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason("unknown"); - } - } catch (Exception e) { - LOGGER.error("Test connection fail", e); - result.setSuccess(false); - result.setReason(e.getMessage()); - } - results.add(result); + final CommonConfig conf = CommonDescriptor.getInstance().getConfig(); + SyncConfigNodeIServiceClient client = new SyncConfigNodeIServiceClient.Factory(new ClientManager<>(), new ThriftClientProperty.Builder() + .setConnectionTimeoutMs(conf.getConnectionTimeoutInMS()) + .setRpcThriftCompressionEnabled(conf.isRpcThriftCompressionEnabled()) + .build()); +// final TSender sender = new TSender().setConfigNodeLocation(ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); +// final TTestConnectionResult result = new TTestConnectionResult(); +// result.setServiceProvider(new TServiceProvider(configNodeLocation.getInternalEndPoint(), TServiceType.ConfigNodeInternalService)); +// result.setSender(sender); +// List results = new ArrayList<>(); +// try (ConfigNodeClient client = ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { +// TSStatus status = client.testConnection(); +// if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { +// result.setSuccess(true); +// } else { +// result.setSuccess(false); +// result.setReason("unknown"); +// } +// } catch (Exception e) { +// LOGGER.error("Test connection fail", e); +// result.setSuccess(false); +// result.setReason(e.getMessage()); +// } +// results.add(result); return results; } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/ColumnHeaderConstant.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/ColumnHeaderConstant.java index cb76c13aa0be..3316f1c66620 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/ColumnHeaderConstant.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/ColumnHeaderConstant.java @@ -94,6 +94,11 @@ private ColumnHeaderConstant() { // column names for show clusterId statement public static final String CLUSTER_ID = "ClusterId"; + // column names for verify connection statement + public static final String SERVICE_PROVIDER = "ServiceProvider"; + public static final String SENDER = "Sender"; + public static final String CONNECTION = "Connection"; + // column names for show functions statement public static final String FUNCTION_NAME = "FunctionName"; public static final String FUNCTION_TYPE = "FunctionType"; @@ -367,6 +372,12 @@ private ColumnHeaderConstant() { public static final List showClusterIdColumnHeaders = ImmutableList.of(new ColumnHeader(CLUSTER_ID, TSDataType.TEXT)); + public static final List testConnectionColumnHeaders = + ImmutableList.of( + new ColumnHeader(SERVICE_PROVIDER, TSDataType.TEXT), + new ColumnHeader(SENDER, TSDataType.TEXT), + new ColumnHeader(CONNECTION, TSDataType.TEXT)); + public static final List showVariablesColumnHeaders = ImmutableList.of( new ColumnHeader(VARIABLE, TSDataType.TEXT), new ColumnHeader(VALUE, TSDataType.TEXT)); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index 58883e3f3707..961910e1e536 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -19,16 +19,51 @@ package org.apache.iotdb.db.queryengine.plan.execution.config.sys; +import com.google.common.util.concurrent.SettableFuture; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; +import org.apache.iotdb.db.queryengine.common.header.ColumnHeader; +import org.apache.iotdb.db.queryengine.common.header.ColumnHeaderConstant; import org.apache.iotdb.db.queryengine.plan.execution.config.ConfigTaskResult; import org.apache.iotdb.db.queryengine.plan.execution.config.IConfigTask; import org.apache.iotdb.db.queryengine.plan.execution.config.executor.IConfigTaskExecutor; import com.google.common.util.concurrent.ListenableFuture; +import org.apache.tsfile.common.conf.TSFileConfig; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.block.TsBlockBuilder; +import org.apache.tsfile.utils.Binary; + +import java.util.List; +import java.util.stream.Collectors; public class TestConnectionTask implements IConfigTask { + @Override public ListenableFuture execute(IConfigTaskExecutor configTaskExecutor) throws InterruptedException { return configTaskExecutor.testConnection(); } + + public static void buildTSBlock(TTestConnectionResp resp, SettableFuture future) { + List outputDataTypes = + ColumnHeaderConstant.testConnectionColumnHeaders.stream() + .map(ColumnHeader::getColumnType) + .collect(Collectors.toList()); + TsBlockBuilder builder = new TsBlockBuilder(outputDataTypes); + + for (TTestConnectionResult result : resp.getResultList()) { + builder.getTimeColumnBuilder().writeLong(0); + builder.getColumnBuilder(0).writeBinary(new Binary(result.getServiceProvider().toString(), TSFileConfig.STRING_CHARSET)); + builder.getColumnBuilder(1).writeBinary(new Binary(result.getSender().toString(), TSFileConfig.STRING_CHARSET)); + String connectionStatus; + if (result.isSuccess()) { + connectionStatus = "up"; + } else { + connectionStatus = "down" + " (" + result.getReason() + ")"; + } + builder.getColumnBuilder(2).writeBinary(new Binary(connectionStatus, TSFileConfig.STRING_CHARSET)); + builder.declarePosition(); + } + } } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java index f04569d752ac..212b38a49978 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java @@ -35,7 +35,7 @@ public class ClientManager implements IClientManager { private final KeyedObjectPool pool; - ClientManager(IClientPoolFactory factory) { + public ClientManager(IClientPoolFactory factory) { pool = factory.createClientPool(this); } From 81a8e35559c1173818f1e7fd5463f3537f98858f Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 5 Jun 2024 14:55:08 +0800 Subject: [PATCH 11/52] ConfigNode -> all internal service done --- .../client/ConfigNodeRequestType.java | 4 +- .../client/sync/SyncConfigNodeClientPool.java | 5 + .../confignode/conf/ConfigNodeConfig.java | 12 +- .../confignode/manager/ClusterManager.java | 164 +++++++++++------- .../confignode/manager/ConfigManager.java | 1 + .../db/protocol/client/ConfigNodeClient.java | 5 +- .../thrift/impl/ClientRPCServiceImpl.java | 10 ++ .../impl/DataNodeInternalRPCServiceImpl.java | 1 + .../common/header/DatasetHeaderFactory.java | 4 + .../exchange/MPPDataExchangeManager.java | 7 + .../executor/ClusterConfigTaskExecutor.java | 3 + .../config/sys/TestConnectionTask.java | 74 +++++++- 12 files changed, 208 insertions(+), 82 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java index e9aa1e93f9d7..f8f78d411693 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java @@ -27,5 +27,7 @@ public enum ConfigNodeRequestType { REMOVE_CONFIG_NODE, DELETE_CONFIG_NODE_PEER, REPORT_CONFIG_NODE_SHUTDOWN, - STOP_CONFIG_NODE + STOP_CONFIG_NODE, + SUBMIT_TEST_CONNECTION_TASK, + TEST_CONNECTION, } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java index 04d2c0917698..730fec57f19a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java @@ -21,6 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; @@ -88,6 +89,10 @@ public Object sendSyncRequestToConfigNodeWithRetry( case STOP_CONFIG_NODE: // Only use stopConfigNode when the ConfigNode is removed. return client.stopConfigNode((TConfigNodeLocation) req); + case SUBMIT_TEST_CONNECTION_TASK: + return client.submitTestConnectionTask((TNodeLocations) req); + case TEST_CONNECTION: + return client.testConnection(); default: return RpcUtils.getStatus( TSStatusCode.EXECUTE_STATEMENT_ERROR, "Unknown request type: " + requestType); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java index 74a9e1c458cc..ae0e1698860a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java @@ -1234,15 +1234,15 @@ public void setDataRegionRatisPeriodicSnapshotInterval( public TConfigNodeLocation generateLocalConfigNodeLocation(int configNodeId) { return new TConfigNodeLocation( - configNodeId, - new TEndPoint(getInternalAddress(), getInternalPort()), - new TEndPoint(getInternalAddress(), getConsensusPort())); + configNodeId, + new TEndPoint(getInternalAddress(), getInternalPort()), + new TEndPoint(getInternalAddress(), getConsensusPort())); } public TConfigNodeLocation generateLocalConfigNodeLocation() { return new TConfigNodeLocation( - getConfigNodeId(), - new TEndPoint(getInternalAddress(), getInternalPort()), - new TEndPoint(getInternalAddress(), getConsensusPort())); + getConfigNodeId(), + new TEndPoint(getInternalAddress(), getInternalPort()), + new TEndPoint(getInternalAddress(), getConsensusPort())); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 40c40972ead0..714da0ba9f66 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -20,6 +20,7 @@ package org.apache.iotdb.confignode.manager; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.common.rpc.thrift.TNodeLocations; @@ -29,38 +30,27 @@ import org.apache.iotdb.common.rpc.thrift.TServiceType; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; -import org.apache.iotdb.commons.client.ClientManager; -import org.apache.iotdb.commons.client.exception.ClientManagerException; -import org.apache.iotdb.commons.client.property.ThriftClientProperty; -import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient; -import org.apache.iotdb.commons.conf.CommonConfig; -import org.apache.iotdb.commons.conf.CommonDescriptor; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; import org.apache.iotdb.confignode.persistence.ClusterInfo; import org.apache.iotdb.consensus.exception.ConsensusException; - -import org.apache.iotdb.db.protocol.client.ConfigNodeClient; -import org.apache.iotdb.db.protocol.client.ConfigNodeClientManager; -import org.apache.iotdb.db.protocol.client.ConfigNodeInfo; import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; import org.apache.iotdb.rpc.TSStatusCode; -import org.apache.thrift.TException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.function.Function; import java.util.stream.Collectors; -import java.util.stream.Stream; public class ClusterManager { @@ -112,7 +102,33 @@ private void generateClusterId() { } } - public TTestConnectionResp submitTestConnectionTaskToEveryNode() {} + public TTestConnectionResp submitTestConnectionTaskToEveryNode() { + TNodeLocations nodeLocations = new TNodeLocations(); + nodeLocations.setConfigNodeLocations(configManager.getNodeManager().getRegisteredConfigNodes()); + nodeLocations.setDataNodeLocations( + configManager.getNodeManager().getRegisteredDataNodes().stream() + .map(TDataNodeConfiguration::getLocation) + .collect(Collectors.toList())); + TTestConnectionResp resp = new TTestConnectionResp(); + resp.resultList = new ArrayList<>(); + resp.setStatus(new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode())); + for (TConfigNodeLocation configNodeLocation : + configManager.getNodeManager().getRegisteredConfigNodes()) { + TTestConnectionResp anotherResp = + (TTestConnectionResp) + SyncConfigNodeClientPool.getInstance() + .sendSyncRequestToConfigNodeWithRetry( + configNodeLocation.getInternalEndPoint(), + nodeLocations, + ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK); + merge(resp, anotherResp); + } + return resp; + } + + private static void merge(TTestConnectionResp resp1, TTestConnectionResp resp2) { + resp1.resultList.addAll(resp2.getResultList()); + } private void submitTestConnectionTaskToAllDataNode() { @@ -125,71 +141,89 @@ private void submitTestConnectionTaskToAllDataNode() { clientHandler.getResponseMap(); } - private void submitTestConnectionTaskToAllConfigNode() { - // AsyncClientHandler - } + private void submitTestConnectionTaskToAllConfigNode() {} public List doConnectionTest(TNodeLocations nodeLocations) { - List result = nodeLocations.getConfigNodeLocations().stream().map(this::testConfigNodeConnection).flatMap(Collection::stream).collect(Collectors.toList()); - List dataNodeResult = testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); + List result = + nodeLocations.getConfigNodeLocations().stream() + .map(this::testConfigNodeConnection) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + List dataNodeResult = + testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); result.addAll(dataNodeResult); return result; } private List testConfigNodeConnection( TConfigNodeLocation configNodeLocation) { - final CommonConfig conf = CommonDescriptor.getInstance().getConfig(); - SyncConfigNodeIServiceClient client = new SyncConfigNodeIServiceClient.Factory(new ClientManager<>(), new ThriftClientProperty.Builder() - .setConnectionTimeoutMs(conf.getConnectionTimeoutInMS()) - .setRpcThriftCompressionEnabled(conf.isRpcThriftCompressionEnabled()) - .build()); -// final TSender sender = new TSender().setConfigNodeLocation(ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); -// final TTestConnectionResult result = new TTestConnectionResult(); -// result.setServiceProvider(new TServiceProvider(configNodeLocation.getInternalEndPoint(), TServiceType.ConfigNodeInternalService)); -// result.setSender(sender); -// List results = new ArrayList<>(); -// try (ConfigNodeClient client = ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { -// TSStatus status = client.testConnection(); -// if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { -// result.setSuccess(true); -// } else { -// result.setSuccess(false); -// result.setReason("unknown"); -// } -// } catch (Exception e) { -// LOGGER.error("Test connection fail", e); -// result.setSuccess(false); -// result.setReason(e.getMessage()); -// } -// results.add(result); + final TSender sender = + new TSender() + .setConfigNodeLocation( + ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); + final TTestConnectionResult result = new TTestConnectionResult(); + result.setServiceProvider( + new TServiceProvider( + configNodeLocation.getInternalEndPoint(), TServiceType.ConfigNodeInternalService)); + result.setSender(sender); + List results = new ArrayList<>(); + try { + TSStatus status = + (TSStatus) + SyncConfigNodeClientPool.getInstance() + .sendSyncRequestToConfigNodeWithRetry( + configNodeLocation.getInternalEndPoint(), + null, + ConfigNodeRequestType.TEST_CONNECTION); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason("unknown"); + } + } catch (Exception e) { + LOGGER.error("Test connection fail", e); + result.setSuccess(false); + result.setReason(e.getMessage()); + } + results.add(result); return results; } private List testAllDataNodeConnection( List dataNodeLocations) { - final TSender sender = new TSender().setConfigNodeLocation(ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); - Map dataNodeLocationMap = dataNodeLocations.stream().collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( - DataNodeRequestType.TEST_CONNECTION, - null, - dataNodeLocationMap); + final TSender sender = + new TSender() + .setConfigNodeLocation( + ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); + Map dataNodeLocationMap = + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + AsyncClientHandler clientHandler = + new AsyncClientHandler<>(DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + Map anotherDataNodeLocationMap = + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); List results = new ArrayList<>(); - clientHandler.getResponseMap().forEach((dataNodeId, status) -> { - TEndPoint endPoint = dataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); - TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); + clientHandler + .getResponseMap() + .forEach( + (dataNodeId, status) -> { + TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); return results; } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java index 04fca120e221..1be83c2beba0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java @@ -199,6 +199,7 @@ import org.apache.iotdb.rpc.TSStatusCode; import org.apache.iotdb.service.rpc.thrift.TPipeTransferReq; import org.apache.iotdb.service.rpc.thrift.TPipeTransferResp; + import org.apache.tsfile.utils.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java index aec534ef4774..88192016bfcd 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java @@ -1162,7 +1162,10 @@ public void set(int value) { if (!locked) { this.value = value; } else { - logger.warn("ConfigNodeClient cursor will keep {} and won't change to {}, because it has been locked.", configNodeEndPoints.get(this.value), configNodeEndPoints.get(value)); + logger.warn( + "ConfigNodeClient cursor will keep {} and won't change to {}, because it has been locked.", + configNodeEndPoints.get(this.value), + configNodeEndPoints.get(value)); } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java index fb8fc40ba461..f2c34e9c7f04 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java @@ -2595,6 +2595,16 @@ public TSConnectionInfoResp fetchAllConnectionsInfo() { return SESSION_MANAGER.getAllConnectionInfo(); } + @Override + public TSStatus testConnection() throws TException { + return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); + } + + @Override + public TSStatus SubmitTestConnectionTask() throws TException { + throw new UnsupportedOperationException(); + } + @Override public TSStatus insertStringRecord(final TSInsertStringRecordReq req) { final long t1 = System.nanoTime(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 1986f9efd0c2..2c8b07440d88 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -1445,6 +1445,7 @@ public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations } catch (ClientManagerException e) { throw new RuntimeException(e); } + throw new UnsupportedOperationException(); // TODO: 其它service } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeaderFactory.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeaderFactory.java index 78250b05bcb7..9c0f89b19a57 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeaderFactory.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeaderFactory.java @@ -99,6 +99,10 @@ public static DatasetHeader getShowClusterIdHeader() { return new DatasetHeader(ColumnHeaderConstant.showClusterIdColumnHeaders, true); } + public static DatasetHeader getTestConnectionHeader() { + return new DatasetHeader(ColumnHeaderConstant.testConnectionColumnHeaders, true); + } + public static DatasetHeader getShowFunctionsHeader() { return new DatasetHeader(ColumnHeaderConstant.showFunctionsColumnHeaders, true); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManager.java index 2b59d72cd070..2a07c497c103 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManager.java @@ -20,6 +20,7 @@ package org.apache.iotdb.db.queryengine.execution.exchange; import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.sync.SyncDataNodeMPPDataExchangeServiceClient; import org.apache.iotdb.db.queryengine.exception.exchange.GetTsBlockFromClosedOrAbortedChannelException; @@ -49,6 +50,7 @@ import org.apache.iotdb.mpp.rpc.thrift.TGetDataBlockRequest; import org.apache.iotdb.mpp.rpc.thrift.TGetDataBlockResponse; import org.apache.iotdb.mpp.rpc.thrift.TNewDataBlockEvent; +import org.apache.iotdb.rpc.TSStatusCode; import org.apache.commons.lang3.Validate; import org.apache.thrift.TException; @@ -283,6 +285,11 @@ public void onEndOfDataBlockEvent(TEndOfDataBlockEvent e) throws TException { sourceHandle.setNoMoreTsBlocks(e.getLastSequenceId()); } } + + @Override + public TSStatus testConnection() throws TException { + return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); + } } // endregion diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java index fe9e8d564fdb..987f86f7d8ed 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java @@ -146,6 +146,7 @@ import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.template.ShowNodesInSchemaTemplateTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.template.ShowPathSetTemplateTask; import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.template.ShowSchemaTemplateTask; +import org.apache.iotdb.db.queryengine.plan.execution.config.sys.TestConnectionTask; import org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.ShowPipeTask; import org.apache.iotdb.db.queryengine.plan.execution.config.sys.quota.ShowSpaceQuotaTask; import org.apache.iotdb.db.queryengine.plan.execution.config.sys.quota.ShowThrottleQuotaTask; @@ -1251,9 +1252,11 @@ public SettableFuture testConnection() { CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { // TODO: now sync, maybe async in future TTestConnectionResp result = client.submitTestConnectionTaskToLeader(); + TestConnectionTask.buildTSBlock(result, future); } catch (Exception e) { future.setException(e); } + return future; } @Override diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index 961910e1e536..fe1974e2ce60 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -19,22 +19,26 @@ package org.apache.iotdb.db.queryengine.plan.execution.config.sys; -import com.google.common.util.concurrent.SettableFuture; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.db.queryengine.common.header.ColumnHeader; import org.apache.iotdb.db.queryengine.common.header.ColumnHeaderConstant; +import org.apache.iotdb.db.queryengine.common.header.DatasetHeaderFactory; import org.apache.iotdb.db.queryengine.plan.execution.config.ConfigTaskResult; import org.apache.iotdb.db.queryengine.plan.execution.config.IConfigTask; import org.apache.iotdb.db.queryengine.plan.execution.config.executor.IConfigTaskExecutor; +import org.apache.iotdb.rpc.TSStatusCode; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; import org.apache.tsfile.common.conf.TSFileConfig; import org.apache.tsfile.enums.TSDataType; import org.apache.tsfile.read.common.block.TsBlockBuilder; import org.apache.tsfile.utils.Binary; import java.util.List; +import java.util.function.Function; import java.util.stream.Collectors; public class TestConnectionTask implements IConfigTask { @@ -45,25 +49,77 @@ public ListenableFuture execute(IConfigTaskExecutor configTask return configTaskExecutor.testConnection(); } - public static void buildTSBlock(TTestConnectionResp resp, SettableFuture future) { + public static void buildTSBlock( + TTestConnectionResp resp, SettableFuture future) { List outputDataTypes = - ColumnHeaderConstant.testConnectionColumnHeaders.stream() - .map(ColumnHeader::getColumnType) - .collect(Collectors.toList()); + ColumnHeaderConstant.testConnectionColumnHeaders.stream() + .map(ColumnHeader::getColumnType) + .collect(Collectors.toList()); TsBlockBuilder builder = new TsBlockBuilder(outputDataTypes); - + sortTestConnectionResp(resp); + // ServiceProvider column for (TTestConnectionResult result : resp.getResultList()) { builder.getTimeColumnBuilder().writeLong(0); - builder.getColumnBuilder(0).writeBinary(new Binary(result.getServiceProvider().toString(), TSFileConfig.STRING_CHARSET)); - builder.getColumnBuilder(1).writeBinary(new Binary(result.getSender().toString(), TSFileConfig.STRING_CHARSET)); + String serviceStr = endPointToString(result.getServiceProvider().getEndPoint()); + serviceStr += " (" + result.getServiceProvider().getServiceType() + ")"; + builder + .getColumnBuilder(0) + .writeBinary( + new Binary(serviceStr, TSFileConfig.STRING_CHARSET)); + // Sender column + String senderStr; + if (result.getSender().isSetConfigNodeLocation()) { + senderStr = endPointToString(result.getSender().getConfigNodeLocation().getInternalEndPoint()); + senderStr += " (ConfigNode)"; + } else { + senderStr = endPointToString(result.getSender().getDataNodeLocation().getInternalEndPoint()); + senderStr += " (DataNode)"; + } + builder + .getColumnBuilder(1) + .writeBinary(new Binary(senderStr, TSFileConfig.STRING_CHARSET)); + // Connection column String connectionStatus; if (result.isSuccess()) { connectionStatus = "up"; } else { connectionStatus = "down" + " (" + result.getReason() + ")"; } - builder.getColumnBuilder(2).writeBinary(new Binary(connectionStatus, TSFileConfig.STRING_CHARSET)); + builder + .getColumnBuilder(2) + .writeBinary(new Binary(connectionStatus, TSFileConfig.STRING_CHARSET)); builder.declarePosition(); } + + future.set( + new ConfigTaskResult( + TSStatusCode.SUCCESS_STATUS, + builder.build(), + DatasetHeaderFactory.getTestConnectionHeader())); + } + + private static String endPointToString(TEndPoint endPoint) { + return endPoint.getIp() + ":" + endPoint.getPort(); + } + + private static void sortTestConnectionResp(TTestConnectionResp origin) { + origin.getResultList().sort((o1, o2) -> { + if (!o1.getServiceProvider().equals(o2.getServiceProvider())) { + return endPointToString(o1.getServiceProvider().getEndPoint()).compareTo(endPointToString(o2.getServiceProvider().getEndPoint())); + } + TEndPoint sender1; + if (o1.getSender().isSetConfigNodeLocation()) { + sender1 = o1.getSender().getConfigNodeLocation().getInternalEndPoint(); + } else { + sender1 = o1.getSender().getDataNodeLocation().getInternalEndPoint(); + } + TEndPoint sender2; + if (o2.getSender().isSetConfigNodeLocation()) { + sender2 = o2.getSender().getConfigNodeLocation().getInternalEndPoint(); + } else { + sender2 = o2.getSender().getDataNodeLocation().getInternalEndPoint(); + } + return endPointToString(sender1).compareTo(endPointToString(sender2)); + }); } } From 9343fe367461a88c4644894a159547759680cc43 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 5 Jun 2024 18:39:33 +0800 Subject: [PATCH 12/52] ConfigNode asynchronize --- .../async/AsyncConfigNodeClientPool.java | 194 ++++++++++++++++++ .../client/async/AsyncDataNodeClientPool.java | 4 +- .../AsyncConfigNodeClientHandler.java | 164 +++++++++++++++ .../async/handlers/TestConnectionHandler.java | 39 ++++ .../rpc/AbstractAsyncRPCHandler2.java | 85 ++++++++ .../rpc/AsyncTSStatusRPCHandler2.java | 89 ++++++++ ...> SubmitTestConnectionTaskRPCHandler.java} | 7 +- ...tConnectionTaskToConfigNodeRPCHandler.java | 64 ++++++ .../confignode/manager/ClusterManager.java | 55 ++++- 9 files changed, 688 insertions(+), 13 deletions(-) create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/{TestConnectionRPCHandler.java => SubmitTestConnectionTaskRPCHandler.java} (87%) create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java new file mode 100644 index 000000000000..de04c7fc6d41 --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java @@ -0,0 +1,194 @@ +/* + * 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.client.async; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; +import org.apache.iotdb.commons.client.exception.ClientManagerException; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler2; +import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; +import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskRPCHandler; + +import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ +public class AsyncConfigNodeClientPool { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); + + private final IClientManager clientManager; + + private static final int MAX_RETRY_NUM = 6; + + private AsyncConfigNodeClientPool() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncConfigNodeIServiceClientPoolFactory()); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + * @param timeoutInMs timeout in milliseconds + */ + public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( + AsyncConfigNodeClientHandler clientHandler, long timeoutInMs) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + */ + public void sendAsyncRequestToConfigNodeWithRetry(AsyncConfigNodeClientHandler clientHandler) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); + } + + public void sendAsyncRequestToConfigNode(AsyncConfigNodeClientHandler clientHandler) { + sendAsyncRequest(clientHandler, 1, null); + } + + private void sendAsyncRequest( + AsyncConfigNodeClientHandler clientHandler, int retryNum, Long timeoutInMs) { + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } + + ConfigNodeRequestType requestType = clientHandler.getRequestType(); + for (int retry = 0; retry < retryNum; retry++) { + // Always Reset CountDownLatch first + clientHandler.resetCountDownLatch(); + + // Send requests to all targetConfigNodes + for (int requestId : clientHandler.getRequestIndices()) { + TConfigNodeLocation targetConfigNode = clientHandler.getConfigNodeLocation(requestId); + sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); + } + + // Wait for this batch of asynchronous RPC requests finish + try { + if (timeoutInMs == null) { + clientHandler.getCountDownLatch().await(); + } else { + if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { + LOGGER.warn( + "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + } + } + } catch (InterruptedException e) { + LOGGER.error( + "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + Thread.currentThread().interrupt(); + } + + // Check if there is a ConfigNode that fails to execute the request, and retry if there exists + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } + } + + if (!clientHandler.getRequestIndices().isEmpty()) { + LOGGER.warn( + "Failed to {} on ConfigNode after {} retries, requestIndices: {}", + requestType, + retryNum, + clientHandler.getRequestIndices()); + } + } + + private void sendAsyncRequestToConfigNode( + AsyncConfigNodeClientHandler clientHandler, + int requestId, + TConfigNodeLocation targetConfigNode, + int retryCount) { + + try { + AsyncConfigNodeIServiceClient client; + client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler2 handler = + clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); + AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; + + switch (clientHandler.getRequestType()) { + case SUBMIT_TEST_CONNECTION_TASK: + client.submitTestConnectionTask((TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); + case TEST_CONNECTION: + client.testConnection(defaultHandler); + default: + LOGGER.error( + "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on ConfigNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetConfigNode.getInternalEndPoint(), + e.getMessage(), + retryCount); + } + } + + /** + * Always call this interface when a ConfigNode is restarted or removed. + * + * @param endPoint The specific ConfigNode + */ + public void resetClient(TEndPoint endPoint) { + clientManager.clear(endPoint); + } + + public AsyncConfigNodeIServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) + throws ClientManagerException { + return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + } + + // TODO: Is the ClientPool must be a singleton? + private static class ClientPoolHolder { + + private static final AsyncConfigNodeClientPool INSTANCE = new AsyncConfigNodeClientPool(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncConfigNodeClientPool getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index e22d975b26c7..1bc604f1fc16 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -41,7 +41,7 @@ import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.SchemaUpdateRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.TestConnectionRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.TransferLeaderRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; @@ -375,7 +375,7 @@ private void sendAsyncRequestToDataNode( client.resetPeerList((TResetPeerListReq) req, defaultHandler); break; case SUBMIT_TEST_CONNECTION_TASK: - client.submitTestConnectionTask((TNodeLocations) req, (TestConnectionRPCHandler) handler); + client.submitTestConnectionTask((TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); case TEST_CONNECTION: client.testConnection(defaultHandler); default: diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java new file mode 100644 index 000000000000..12bcb5d01999 --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java @@ -0,0 +1,164 @@ +/* + * 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.client.async.handlers; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler2; +import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncConfigNodeClientHandler { + + // Type of RPC request + protected final ConfigNodeRequestType requestType; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The corresponding RPC request + */ + private final Map requestMap; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap only + * if its corresponding RPC request success + */ + private final Map configNodeLocationMap; + + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + private final Map responseMap; + + private CountDownLatch countDownLatch; + + /** Custom constructor. */ + public AsyncConfigNodeClientHandler(ConfigNodeRequestType requestType) { + this.requestType = requestType; + this.requestMap = new ConcurrentHashMap<>(); + this.configNodeLocationMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + public void putRequest(int requestId, Q request) { + requestMap.put(requestId, request); + } + + public void putConfigNodeLocation(int requestId, TConfigNodeLocation configNodeLocation) { + configNodeLocationMap.put(requestId, configNodeLocation); + } + + /** Constructor for null requests. */ + public AsyncConfigNodeClientHandler( + ConfigNodeRequestType requestType, Map configNodeLocationMap) { + this.requestType = requestType; + this.configNodeLocationMap = configNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + /** Constructor for unique request. */ + public AsyncConfigNodeClientHandler( + ConfigNodeRequestType requestType, + Q request, + Map configNodeLocationMap) { + this.requestType = requestType; + this.configNodeLocationMap = configNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.configNodeLocationMap + .keySet() + .forEach(configNodeId -> this.requestMap.put(configNodeId, request)); + + this.responseMap = new ConcurrentHashMap<>(); + } + + public ConfigNodeRequestType getRequestType() { + return requestType; + } + + public List getRequestIndices() { + return new ArrayList<>(configNodeLocationMap.keySet()); + } + + public Q getRequest(int requestId) { + return requestMap.get(requestId); + } + + public TConfigNodeLocation getConfigNodeLocation(int requestId) { + return configNodeLocationMap.get(requestId); + } + + public List getResponseList() { + return new ArrayList<>(responseMap.values()); + } + + public Map getResponseMap() { + return responseMap; + } + + /** Always reset CountDownLatch before retry. */ + public void resetCountDownLatch() { + countDownLatch = new CountDownLatch(configNodeLocationMap.size()); + } + + public CountDownLatch getCountDownLatch() { + return countDownLatch; + } + + public AbstractAsyncRPCHandler2 createAsyncRPCHandler( + int requestId, TConfigNodeLocation targetConfigNode) { + switch (requestType) { + case SUBMIT_TEST_CONNECTION_TASK: + case TEST_CONNECTION: + default: + return new AsyncTSStatusRPCHandler2( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + (Map) responseMap, + countDownLatch); + } + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java new file mode 100644 index 000000000000..fca7d67a594d --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java @@ -0,0 +1,39 @@ +/* + * 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.client.async.handlers; + +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.thrift.async.AsyncMethodCallback; + +import java.util.concurrent.ConcurrentHashMap; + +public class TestConnectionHandler implements AsyncMethodCallback { +// public TestConnectionHandler(ConcurrentHashMap) + + @Override + public void onComplete(TSStatus tsStatus) { + + } + + @Override + public void onError(Exception e) { + + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java new file mode 100644 index 000000000000..50c984c342df --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java @@ -0,0 +1,85 @@ +/* + * 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.client.async.handlers.rpc; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; + +import org.apache.thrift.async.AsyncMethodCallback; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public abstract class AbstractAsyncRPCHandler2 implements AsyncMethodCallback { + + // Type of RPC request + protected final ConfigNodeRequestType requestType; + // Index of request + protected final int requestId; + // Target ConfigNode + protected final TConfigNodeLocation targetConfigNode; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap only + * if its corresponding RPC request success + */ + protected final Map configNodeLocationMap; + + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + protected final Map responseMap; + + // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished + protected final CountDownLatch countDownLatch; + + protected final String formattedTargetLocation; + + protected AbstractAsyncRPCHandler2( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + this.requestType = requestType; + this.requestId = requestId; + this.targetConfigNode = targetConfigNode; + this.formattedTargetLocation = + "{id=" + + targetConfigNode.getConfigNodeId() + + ", internalEndPoint=" + + targetConfigNode.getInternalEndPoint() + + "}"; + + this.configNodeLocationMap = configNodeLocationMap; + this.responseMap = responseMap; + this.countDownLatch = countDownLatch; + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java new file mode 100644 index 000000000000..34f32d7120bd --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java @@ -0,0 +1,89 @@ +/* + * 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.client.async.handlers.rpc; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.rpc.RpcUtils; +import org.apache.iotdb.rpc.TSStatusCode; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +/** General RPC handler for TSStatus response type. */ +public class AsyncTSStatusRPCHandler2 extends AbstractAsyncRPCHandler2 { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); + + public AsyncTSStatusRPCHandler2( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + super(requestType, requestId, targetConfigNode, configNodeLocationMap, responseMap, countDownLatch); + } + + @Override + public void onComplete(TSStatus response) { + // Put response + responseMap.put(requestId, response); + + if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + // Remove only if success + configNodeLocationMap.remove(requestId); + LOGGER.info("Successfully {} on ConfigNode: {}", requestType, formattedTargetLocation); + } else { + LOGGER.error( + "Failed to {} on ConfigNode: {}, response: {}", + requestType, + formattedTargetLocation, + response); + } + + // Always CountDown + countDownLatch.countDown(); + } + + @Override + public void onError(Exception e) { + String errorMsg = + "Failed to " + + requestType + + " on ConfigNode: " + + formattedTargetLocation + + ", exception: " + + e.getMessage(); + LOGGER.error(errorMsg); + + responseMap.put( + requestId, + new TSStatus( + RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(), errorMsg))); + + // Always CountDown + countDownLatch.countDown(); + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TestConnectionRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java similarity index 87% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TestConnectionRPCHandler.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index 53e4fdfc888e..50ea6f4c697a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TestConnectionRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -22,18 +22,17 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.DataNodeRequestType; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Map; import java.util.concurrent.CountDownLatch; -public class TestConnectionRPCHandler extends AbstractAsyncRPCHandler { +public class SubmitTestConnectionTaskRPCHandler extends AbstractAsyncRPCHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(TestConnectionRPCHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskRPCHandler.class); - protected TestConnectionRPCHandler( + protected SubmitTestConnectionTaskRPCHandler( DataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java new file mode 100644 index 000000000000..ce8f7758e0a1 --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -0,0 +1,64 @@ +/* + * 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.client.async.handlers.rpc; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.rpc.TSStatusCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public class SubmitTestConnectionTaskToConfigNodeRPCHandler extends AbstractAsyncRPCHandler2 { + + private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskToConfigNodeRPCHandler.class); + + protected SubmitTestConnectionTaskToConfigNodeRPCHandler( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + super(requestType, requestId, targetConfigNode, configNodeLocationMap, responseMap, countDownLatch); + } + + @Override + public void onComplete(TTestConnectionResp resp) { + responseMap.put(requestId, resp); + configNodeLocationMap.remove(requestId); + countDownLatch.countDown(); + } + + // TODO: 什么情况下会error? + @Override + public void onError(Exception e) { + LOGGER.error("gg", e); + TTestConnectionResp resp = new TTestConnectionResp(); + resp.setStatus(new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())); + responseMap.put(requestId, new TTestConnectionResp()); + configNodeLocationMap.remove(requestId); + countDownLatch.countDown(); + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 714da0ba9f66..79116ceebb75 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -32,8 +32,11 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.async.AsyncConfigNodeClientPool; +import org.apache.iotdb.confignode.client.async.AsyncConfigNodeHeartbeatClientPool; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; @@ -144,15 +147,16 @@ private void submitTestConnectionTaskToAllDataNode() { private void submitTestConnectionTaskToAllConfigNode() {} public List doConnectionTest(TNodeLocations nodeLocations) { - List result = - nodeLocations.getConfigNodeLocations().stream() - .map(this::testConfigNodeConnection) - .flatMap(Collection::stream) - .collect(Collectors.toList()); +// List result = +// nodeLocations.getConfigNodeLocations().stream() +// .map(this::testConfigNodeConnection) +// .flatMap(Collection::stream) +// .collect(Collectors.toList()); + List configNodeResult = testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); List dataNodeResult = testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); - result.addAll(dataNodeResult); - return result; + configNodeResult.addAll(dataNodeResult); + return configNodeResult; } private List testConfigNodeConnection( @@ -190,6 +194,43 @@ private List testConfigNodeConnection( return results; } + private List testAllConfigNodeConnection( + List configNodeLocations) { + final TSender sender = + new TSender() + .setConfigNodeLocation( + ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); + Map configNodeLocationMap = + configNodeLocations.stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + AsyncConfigNodeClientHandler clientHandler = + new AsyncConfigNodeClientHandler<>(ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); + AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNodeWithRetry(clientHandler); + Map anotherConfigNodeLocationMap = + configNodeLocations.stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + List results = new ArrayList<>(); + clientHandler + .getResponseMap() + .forEach( + (configNodeId, status) -> { + TEndPoint endPoint = anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); + return results; + } + private List testAllDataNodeConnection( List dataNodeLocations) { final TSender sender = From c223d3cc0ee565501b3cd52fd13b44a85b771e5f Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 6 Jun 2024 15:35:07 +0800 Subject: [PATCH 13/52] all internal service async --- .../async/AsyncConfigNodeClientPool.java | 7 +- .../client/async/AsyncDataNodeClientPool.java | 8 +- .../async/handlers/AsyncClientHandler.java | 10 + .../AsyncConfigNodeClientHandler.java | 10 + .../SubmitTestConnectionTaskRPCHandler.java | 6 +- ...tConnectionTaskToConfigNodeRPCHandler.java | 14 +- .../confignode/manager/ClusterManager.java | 53 +++-- .../org/apache/iotdb/db/conf/IoTDBConfig.java | 12 ++ .../client/cn/AbstractAsyncRPCHandler2.java | 83 ++++++++ .../cn/AsyncConfigNodeClientHandler.java | 161 +++++++++++++++ .../client/cn/AsyncConfigNodeClientPool.java | 189 ++++++++++++++++++ .../client/cn/AsyncTSStatusRPCHandler2.java | 87 ++++++++ .../client/cn/ConfigNodeRequestType.java | 33 +++ .../client/dn/AbstractAsyncRPCHandler.java | 83 ++++++++ .../client/dn/AsyncClientHandler.java | 159 +++++++++++++++ .../client/dn/AsyncDataNodeClientPool.java | 185 +++++++++++++++++ .../client/dn/AsyncTSStatusRPCHandler.java | 87 ++++++++ .../client/dn/DataNodeRequestType.java | 122 +++++++++++ .../impl/DataNodeInternalRPCServiceImpl.java | 95 ++++++++- .../config/sys/TestConnectionTask.java | 13 ++ 20 files changed, 1386 insertions(+), 31 deletions(-) create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeRequestType.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeRequestType.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java index de04c7fc6d41..27a15ca88c5d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java @@ -142,13 +142,18 @@ private void sendAsyncRequestToConfigNode( Object req = clientHandler.getRequest(requestId); AbstractAsyncRPCHandler2 handler = clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); - AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; + AsyncTSStatusRPCHandler2 defaultHandler = null; + if (handler instanceof AsyncTSStatusRPCHandler2) { + defaultHandler = (AsyncTSStatusRPCHandler2) handler; + } switch (clientHandler.getRequestType()) { case SUBMIT_TEST_CONNECTION_TASK: client.submitTestConnectionTask((TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); + break; case TEST_CONNECTION: client.testConnection(defaultHandler); + break; default: LOGGER.error( "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index 1bc604f1fc16..4e573a606b2d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -196,7 +196,11 @@ private void sendAsyncRequestToDataNode( Object req = clientHandler.getRequest(requestId); AbstractAsyncRPCHandler handler = clientHandler.createAsyncRPCHandler(requestId, targetDataNode); - AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; + + AsyncTSStatusRPCHandler defaultHandler = null; + if (handler instanceof AsyncTSStatusRPCHandler) { + defaultHandler = (AsyncTSStatusRPCHandler) handler; + } switch (clientHandler.getRequestType()) { case SET_TTL: @@ -376,8 +380,10 @@ private void sendAsyncRequestToDataNode( break; case SUBMIT_TEST_CONNECTION_TASK: client.submitTestConnectionTask((TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); + break; case TEST_CONNECTION: client.testConnection(defaultHandler); + break; default: LOGGER.error( "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java index 89533462ec2f..764a7cbddbaa 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java @@ -21,6 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler; @@ -30,6 +31,7 @@ import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.SchemaUpdateRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.TransferLeaderRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; @@ -263,6 +265,14 @@ public AbstractAsyncRPCHandler createAsyncRPCHandler( dataNodeLocationMap, (Map) responseMap, countDownLatch); + case SUBMIT_TEST_CONNECTION_TASK: + return new SubmitTestConnectionTaskRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case SET_TTL: case CREATE_DATA_REGION: case CREATE_SCHEMA_REGION: diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java index 12bcb5d01999..bb27c7e9ab57 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java @@ -21,9 +21,11 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler2; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; +import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; import java.util.ArrayList; import java.util.List; @@ -150,6 +152,14 @@ public AbstractAsyncRPCHandler2 createAsyncRPCHandler( int requestId, TConfigNodeLocation targetConfigNode) { switch (requestType) { case SUBMIT_TEST_CONNECTION_TASK: + return new SubmitTestConnectionTaskToConfigNodeRPCHandler( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + (Map) responseMap, + countDownLatch + ); case TEST_CONNECTION: default: return new AsyncTSStatusRPCHandler2( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index 50ea6f4c697a..86d7f1ae7474 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -32,7 +32,7 @@ public class SubmitTestConnectionTaskRPCHandler extends AbstractAsyncRPCHandler< private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskRPCHandler.class); - protected SubmitTestConnectionTaskRPCHandler( + public SubmitTestConnectionTaskRPCHandler( DataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, @@ -46,11 +46,15 @@ protected SubmitTestConnectionTaskRPCHandler( public void onComplete(TTestConnectionResp resp) { responseMap.put(requestId, resp); dataNodeLocationMap.remove(requestId); + countDownLatch.countDown(); } // TODO: 什么情况下会error? @Override public void onError(Exception e) { LOGGER.error("gg", e); + responseMap.put(requestId, new TTestConnectionResp()); + dataNodeLocationMap.remove(requestId); + countDownLatch.countDown(); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index ce8f7758e0a1..106b1fb73e37 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -34,13 +34,13 @@ public class SubmitTestConnectionTaskToConfigNodeRPCHandler extends AbstractAsyn private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskToConfigNodeRPCHandler.class); - protected SubmitTestConnectionTaskToConfigNodeRPCHandler( - ConfigNodeRequestType requestType, - int requestId, - TConfigNodeLocation targetConfigNode, - Map configNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { + public SubmitTestConnectionTaskToConfigNodeRPCHandler( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { super(requestType, requestId, targetConfigNode, configNodeLocationMap, responseMap, countDownLatch); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 79116ceebb75..e87cc1919c1b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -38,6 +38,7 @@ import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; +import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; import org.apache.iotdb.confignode.persistence.ClusterInfo; @@ -106,26 +107,43 @@ private void generateClusterId() { } public TTestConnectionResp submitTestConnectionTaskToEveryNode() { + TTestConnectionResp resp = new TTestConnectionResp(); + resp.resultList = new ArrayList<>(); + resp.setStatus(new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode())); TNodeLocations nodeLocations = new TNodeLocations(); nodeLocations.setConfigNodeLocations(configManager.getNodeManager().getRegisteredConfigNodes()); nodeLocations.setDataNodeLocations( configManager.getNodeManager().getRegisteredDataNodes().stream() .map(TDataNodeConfiguration::getLocation) .collect(Collectors.toList())); - TTestConnectionResp resp = new TTestConnectionResp(); - resp.resultList = new ArrayList<>(); - resp.setStatus(new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode())); - for (TConfigNodeLocation configNodeLocation : - configManager.getNodeManager().getRegisteredConfigNodes()) { - TTestConnectionResp anotherResp = - (TTestConnectionResp) - SyncConfigNodeClientPool.getInstance() - .sendSyncRequestToConfigNodeWithRetry( - configNodeLocation.getInternalEndPoint(), - nodeLocations, - ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK); - merge(resp, anotherResp); - } + Map configNodeLocationMap = + configManager.getNodeManager().getRegisteredConfigNodes().stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + AsyncConfigNodeClientHandler configNodeClientHandler = + new AsyncConfigNodeClientHandler<>(ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); + AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNode(configNodeClientHandler); + configNodeClientHandler.getResponseMap().values().forEach(configNodeResp -> { + if (configNodeResp.isSetResultList()) { + merge(resp, configNodeResp); + } else { + // TODO: 展示错误 + LOGGER.warn("Some problem"); + } + }); + Map dataNodeLocationMap = + configManager.getNodeManager().getRegisteredDataNodes().stream().map(TDataNodeConfiguration::getLocation) + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + AsyncClientHandler dataNodeClientHandler = + new AsyncClientHandler<>(DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); + AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNode(dataNodeClientHandler); + dataNodeClientHandler.getResponseMap().values().forEach(dataNodeResp -> { + if (dataNodeResp.isSetResultList()) { + merge(resp, dataNodeResp); + } else { + // TODO: 展示错误 + LOGGER.warn("Some problem"); + } + }); return resp; } @@ -135,7 +153,7 @@ private static void merge(TTestConnectionResp resp1, TTestConnectionResp resp2) private void submitTestConnectionTaskToAllDataNode() { - AsyncClientHandler clientHandler = + AsyncClientHandler clientHandler = new AsyncClientHandler<>( DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, new TNodeLocations(), @@ -147,11 +165,6 @@ private void submitTestConnectionTaskToAllDataNode() { private void submitTestConnectionTaskToAllConfigNode() {} public List doConnectionTest(TNodeLocations nodeLocations) { -// List result = -// nodeLocations.getConfigNodeLocations().stream() -// .map(this::testConfigNodeConnection) -// .flatMap(Collection::stream) -// .collect(Collectors.toList()); List configNodeResult = testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); List dataNodeResult = testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java index 5e481330d090..4043f2fd9a4b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java @@ -19,6 +19,7 @@ package org.apache.iotdb.db.conf; +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.commons.client.property.ClientPoolProperty.DefaultProperty; import org.apache.iotdb.commons.conf.CommonDescriptor; @@ -3914,4 +3915,15 @@ public void setInnerCompactionTaskSelectionDiskRedundancy( double innerCompactionTaskSelectionDiskRedundancy) { this.innerCompactionTaskSelectionDiskRedundancy = innerCompactionTaskSelectionDiskRedundancy; } + + public TDataNodeLocation generateLocalDataNodeLocation() { + TDataNodeLocation result = new TDataNodeLocation(); + result.setDataNodeId(getDataNodeId()); + result.setClientRpcEndPoint(new TEndPoint(getInternalAddress(), getRpcPort())); + result.setInternalEndPoint(new TEndPoint(getInternalAddress(), getInternalPort())); + result.setMPPDataExchangeEndPoint(new TEndPoint(getInternalAddress(), getMppDataExchangePort())); + result.setDataRegionConsensusEndPoint(new TEndPoint(getInternalAddress(), getDataRegionConsensusPort())); + result.setSchemaRegionConsensusEndPoint(new TEndPoint(getInternalAddress(), getSchemaRegionConsensusPort())); + return result; + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java new file mode 100644 index 000000000000..8ae66a2f679d --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java @@ -0,0 +1,83 @@ +/* + * 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.db.protocol.client.cn; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.thrift.async.AsyncMethodCallback; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public abstract class AbstractAsyncRPCHandler2 implements AsyncMethodCallback { + + // Type of RPC request + protected final ConfigNodeRequestType requestType; + // Index of request + protected final int requestId; + // Target ConfigNode + protected final TConfigNodeLocation targetConfigNode; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap only + * if its corresponding RPC request success + */ + protected final Map configNodeLocationMap; + + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + protected final Map responseMap; + + // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished + protected final CountDownLatch countDownLatch; + + protected final String formattedTargetLocation; + + protected AbstractAsyncRPCHandler2( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + this.requestType = requestType; + this.requestId = requestId; + this.targetConfigNode = targetConfigNode; + this.formattedTargetLocation = + "{id=" + + targetConfigNode.getConfigNodeId() + + ", internalEndPoint=" + + targetConfigNode.getInternalEndPoint() + + "}"; + + this.configNodeLocationMap = configNodeLocationMap; + this.responseMap = responseMap; + this.countDownLatch = countDownLatch; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java new file mode 100644 index 000000000000..b45fd19064c7 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java @@ -0,0 +1,161 @@ +/* + * 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.db.protocol.client.cn; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncConfigNodeClientHandler { + + // Type of RPC request + protected final ConfigNodeRequestType requestType; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The corresponding RPC request + */ + private final Map requestMap; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap only + * if its corresponding RPC request success + */ + private final Map configNodeLocationMap; + + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + private final Map responseMap; + + private CountDownLatch countDownLatch; + + /** Custom constructor. */ + public AsyncConfigNodeClientHandler(ConfigNodeRequestType requestType) { + this.requestType = requestType; + this.requestMap = new ConcurrentHashMap<>(); + this.configNodeLocationMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + public void putRequest(int requestId, Q request) { + requestMap.put(requestId, request); + } + + public void putConfigNodeLocation(int requestId, TConfigNodeLocation configNodeLocation) { + configNodeLocationMap.put(requestId, configNodeLocation); + } + + /** Constructor for null requests. */ + public AsyncConfigNodeClientHandler( + ConfigNodeRequestType requestType, Map configNodeLocationMap) { + this.requestType = requestType; + this.configNodeLocationMap = configNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + /** Constructor for unique request. */ + public AsyncConfigNodeClientHandler( + ConfigNodeRequestType requestType, + Q request, + Map configNodeLocationMap) { + this.requestType = requestType; + this.configNodeLocationMap = configNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.configNodeLocationMap + .keySet() + .forEach(configNodeId -> this.requestMap.put(configNodeId, request)); + + this.responseMap = new ConcurrentHashMap<>(); + } + + public ConfigNodeRequestType getRequestType() { + return requestType; + } + + public List getRequestIndices() { + return new ArrayList<>(configNodeLocationMap.keySet()); + } + + public Q getRequest(int requestId) { + return requestMap.get(requestId); + } + + public TConfigNodeLocation getConfigNodeLocation(int requestId) { + return configNodeLocationMap.get(requestId); + } + + public List getResponseList() { + return new ArrayList<>(responseMap.values()); + } + + public Map getResponseMap() { + return responseMap; + } + + /** Always reset CountDownLatch before retry. */ + public void resetCountDownLatch() { + countDownLatch = new CountDownLatch(configNodeLocationMap.size()); + } + + public CountDownLatch getCountDownLatch() { + return countDownLatch; + } + + public AbstractAsyncRPCHandler2 createAsyncRPCHandler( + int requestId, TConfigNodeLocation targetConfigNode) { + switch (requestType) { + case SUBMIT_TEST_CONNECTION_TASK: + case TEST_CONNECTION: + default: + return new AsyncTSStatusRPCHandler2( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + (Map) responseMap, + countDownLatch); + } + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java new file mode 100644 index 000000000000..054f5fd6d1af --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java @@ -0,0 +1,189 @@ +/* + * 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.db.protocol.client.cn; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; +import org.apache.iotdb.commons.client.exception.ClientManagerException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ +public class AsyncConfigNodeClientPool { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); + + private final IClientManager clientManager; + + private static final int MAX_RETRY_NUM = 6; + + private AsyncConfigNodeClientPool() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncConfigNodeIServiceClientPoolFactory()); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + * @param timeoutInMs timeout in milliseconds + */ + public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( + AsyncConfigNodeClientHandler clientHandler, long timeoutInMs) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + */ + public void sendAsyncRequestToConfigNodeWithRetry(AsyncConfigNodeClientHandler clientHandler) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); + } + + public void sendAsyncRequestToConfigNode(AsyncConfigNodeClientHandler clientHandler) { + sendAsyncRequest(clientHandler, 1, null); + } + + private void sendAsyncRequest( + AsyncConfigNodeClientHandler clientHandler, int retryNum, Long timeoutInMs) { + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } + + ConfigNodeRequestType requestType = clientHandler.getRequestType(); + for (int retry = 0; retry < retryNum; retry++) { + // Always Reset CountDownLatch first + clientHandler.resetCountDownLatch(); + + // Send requests to all targetConfigNodes + for (int requestId : clientHandler.getRequestIndices()) { + TConfigNodeLocation targetConfigNode = clientHandler.getConfigNodeLocation(requestId); + sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); + } + + // Wait for this batch of asynchronous RPC requests finish + try { + if (timeoutInMs == null) { + clientHandler.getCountDownLatch().await(); + } else { + if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { + LOGGER.warn( + "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + } + } + } catch (InterruptedException e) { + LOGGER.error( + "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + Thread.currentThread().interrupt(); + } + + // Check if there is a ConfigNode that fails to execute the request, and retry if there exists + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } + } + + if (!clientHandler.getRequestIndices().isEmpty()) { + LOGGER.warn( + "Failed to {} on ConfigNode after {} retries, requestIndices: {}", + requestType, + retryNum, + clientHandler.getRequestIndices()); + } + } + + private void sendAsyncRequestToConfigNode( + AsyncConfigNodeClientHandler clientHandler, + int requestId, + TConfigNodeLocation targetConfigNode, + int retryCount) { + + try { + AsyncConfigNodeIServiceClient client; + client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler2 handler = + clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); + AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; + + switch (clientHandler.getRequestType()) { +// case SUBMIT_TEST_CONNECTION_TASK: +// client.submitTestConnectionTask((TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); +// break; + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on ConfigNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetConfigNode.getInternalEndPoint(), + e.getMessage(), + retryCount); + } + } + + /** + * Always call this interface when a ConfigNode is restarted or removed. + * + * @param endPoint The specific ConfigNode + */ + public void resetClient(TEndPoint endPoint) { + clientManager.clear(endPoint); + } + + public AsyncConfigNodeIServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) + throws ClientManagerException { + return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + } + + // TODO: Is the ClientPool must be a singleton? + private static class ClientPoolHolder { + + private static final AsyncConfigNodeClientPool INSTANCE = new AsyncConfigNodeClientPool(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncConfigNodeClientPool getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java new file mode 100644 index 000000000000..2b2ae721ce6b --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java @@ -0,0 +1,87 @@ +/* + * 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.db.protocol.client.cn; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.rpc.RpcUtils; +import org.apache.iotdb.rpc.TSStatusCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +/** General RPC handler for TSStatus response type. */ +public class AsyncTSStatusRPCHandler2 extends AbstractAsyncRPCHandler2 { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); + + public AsyncTSStatusRPCHandler2( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + super(requestType, requestId, targetConfigNode, configNodeLocationMap, responseMap, countDownLatch); + } + + @Override + public void onComplete(TSStatus response) { + // Put response + responseMap.put(requestId, response); + + if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + // Remove only if success + configNodeLocationMap.remove(requestId); + LOGGER.info("Successfully {} on ConfigNode: {}", requestType, formattedTargetLocation); + } else { + LOGGER.error( + "Failed to {} on ConfigNode: {}, response: {}", + requestType, + formattedTargetLocation, + response); + } + + // Always CountDown + countDownLatch.countDown(); + } + + @Override + public void onError(Exception e) { + String errorMsg = + "Failed to " + + requestType + + " on ConfigNode: " + + formattedTargetLocation + + ", exception: " + + e.getMessage(); + LOGGER.error(errorMsg); + + responseMap.put( + requestId, + new TSStatus( + RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(), errorMsg))); + + // Always CountDown + countDownLatch.countDown(); + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeRequestType.java new file mode 100644 index 000000000000..adaa83889fff --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeRequestType.java @@ -0,0 +1,33 @@ +/* + * 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.db.protocol.client.cn; + +public enum ConfigNodeRequestType { + ADD_CONSENSUS_GROUP, + NOTIFY_REGISTER_SUCCESS, + REGISTER_CONFIG_NODE, + RESTART_CONFIG_NODE, + REMOVE_CONFIG_NODE, + DELETE_CONFIG_NODE_PEER, + REPORT_CONFIG_NODE_SHUTDOWN, + STOP_CONFIG_NODE, + SUBMIT_TEST_CONNECTION_TASK, + TEST_CONNECTION, +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java new file mode 100644 index 000000000000..8c2e726afd6e --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java @@ -0,0 +1,83 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.thrift.async.AsyncMethodCallback; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { + + // Type of RPC request + protected final DataNodeRequestType requestType; + // Index of request + protected final int requestId; + // Target DataNode + protected final TDataNodeLocation targetDataNode; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target DataNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetDataNode from the dataNodeLocationMap only + * if its corresponding RPC request success + */ + protected final Map dataNodeLocationMap; + + /** + * Map key: The indices(targetDataNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + protected final Map responseMap; + + // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished + protected final CountDownLatch countDownLatch; + + protected final String formattedTargetLocation; + + protected AbstractAsyncRPCHandler( + DataNodeRequestType requestType, + int requestId, + TDataNodeLocation targetDataNode, + Map dataNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + this.requestType = requestType; + this.requestId = requestId; + this.targetDataNode = targetDataNode; + this.formattedTargetLocation = + "{id=" + + targetDataNode.getDataNodeId() + + ", internalEndPoint=" + + targetDataNode.getInternalEndPoint() + + "}"; + + this.dataNodeLocationMap = dataNodeLocationMap; + this.responseMap = responseMap; + this.countDownLatch = countDownLatch; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java new file mode 100644 index 000000000000..f13d5cb864a5 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java @@ -0,0 +1,159 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncClientHandler { + + // Type of RPC request + protected final DataNodeRequestType requestType; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The corresponding RPC request + */ + private final Map requestMap; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target DataNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetDataNode from the dataNodeLocationMap only + * if its corresponding RPC request success + */ + private final Map dataNodeLocationMap; + + /** + * Map key: The indices(targetDataNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + private final Map responseMap; + + private CountDownLatch countDownLatch; + + /** Custom constructor. */ + public AsyncClientHandler(DataNodeRequestType requestType) { + this.requestType = requestType; + this.requestMap = new ConcurrentHashMap<>(); + this.dataNodeLocationMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + public void putRequest(int requestId, Q request) { + requestMap.put(requestId, request); + } + + public void putDataNodeLocation(int requestId, TDataNodeLocation dataNodeLocation) { + dataNodeLocationMap.put(requestId, dataNodeLocation); + } + + /** Constructor for null requests. */ + public AsyncClientHandler( + DataNodeRequestType requestType, Map dataNodeLocationMap) { + this.requestType = requestType; + this.dataNodeLocationMap = dataNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + /** Constructor for unique request. */ + public AsyncClientHandler( + DataNodeRequestType requestType, + Q request, + Map dataNodeLocationMap) { + this.requestType = requestType; + this.dataNodeLocationMap = dataNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.dataNodeLocationMap + .keySet() + .forEach(dataNodeId -> this.requestMap.put(dataNodeId, request)); + + this.responseMap = new ConcurrentHashMap<>(); + } + + public DataNodeRequestType getRequestType() { + return requestType; + } + + public List getRequestIndices() { + return new ArrayList<>(dataNodeLocationMap.keySet()); + } + + public Q getRequest(int requestId) { + return requestMap.get(requestId); + } + + public TDataNodeLocation getDataNodeLocation(int requestId) { + return dataNodeLocationMap.get(requestId); + } + + public List getResponseList() { + return new ArrayList<>(responseMap.values()); + } + + public Map getResponseMap() { + return responseMap; + } + + /** Always reset CountDownLatch before retry. */ + public void resetCountDownLatch() { + countDownLatch = new CountDownLatch(dataNodeLocationMap.size()); + } + + public CountDownLatch getCountDownLatch() { + return countDownLatch; + } + + public AbstractAsyncRPCHandler createAsyncRPCHandler( + int requestId, TDataNodeLocation targetDataNode) { + switch (requestType) { + default: + return new AsyncTSStatusRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + } + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java new file mode 100644 index 000000000000..2be827163fe6 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java @@ -0,0 +1,185 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; +import org.apache.iotdb.commons.client.exception.ClientManagerException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +/** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ +public class AsyncDataNodeClientPool { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeClientPool.class); + + private final IClientManager clientManager; + + private static final int MAX_RETRY_NUM = 6; + + private AsyncDataNodeClientPool() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); + } + + /** + * Send asynchronous requests to the specified DataNodes with default retry num + * + *

Notice: The DataNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + * @param timeoutInMs timeout in milliseconds + */ + public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + AsyncClientHandler clientHandler, long timeoutInMs) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); + } + + /** + * Send asynchronous requests to the specified DataNodes with default retry num + * + *

Notice: The DataNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + */ + public void sendAsyncRequestToDataNodeWithRetry(AsyncClientHandler clientHandler) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); + } + + public void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler) { + sendAsyncRequest(clientHandler, 1, null); + } + + private void sendAsyncRequest( + AsyncClientHandler clientHandler, int retryNum, Long timeoutInMs) { + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } + + DataNodeRequestType requestType = clientHandler.getRequestType(); + for (int retry = 0; retry < retryNum; retry++) { + // Always Reset CountDownLatch first + clientHandler.resetCountDownLatch(); + + // Send requests to all targetDataNodes + for (int requestId : clientHandler.getRequestIndices()) { + TDataNodeLocation targetDataNode = clientHandler.getDataNodeLocation(requestId); + sendAsyncRequestToDataNode(clientHandler, requestId, targetDataNode, retry); + } + + // Wait for this batch of asynchronous RPC requests finish + try { + if (timeoutInMs == null) { + clientHandler.getCountDownLatch().await(); + } else { + if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { + LOGGER.warn( + "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + } + } + } catch (InterruptedException e) { + LOGGER.error( + "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + Thread.currentThread().interrupt(); + } + + // Check if there is a DataNode that fails to execute the request, and retry if there exists + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } + } + + if (!clientHandler.getRequestIndices().isEmpty()) { + LOGGER.warn( + "Failed to {} on ConfigNode after {} retries, requestIndices: {}", + requestType, + retryNum, + clientHandler.getRequestIndices()); + } + } + + private void sendAsyncRequestToDataNode( + AsyncClientHandler clientHandler, + int requestId, + TDataNodeLocation targetDataNode, + int retryCount) { + + try { + AsyncDataNodeInternalServiceClient client; + client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler handler = + clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; + + switch (clientHandler.getRequestType()) { + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on DataNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetDataNode.getInternalEndPoint(), + e.getMessage(), + retryCount); + } + } + + /** + * Always call this interface when a DataNode is restarted or removed. + * + * @param endPoint The specific DataNode + */ + public void resetClient(TEndPoint endPoint) { + clientManager.clear(endPoint); + } + + public AsyncDataNodeInternalServiceClient getAsyncClient(TDataNodeLocation targetDataNode) + throws ClientManagerException { + return clientManager.borrowClient(targetDataNode.getInternalEndPoint()); + } + + // TODO: Is the ClientPool must be a singleton? + private static class ClientPoolHolder { + + private static final AsyncDataNodeClientPool INSTANCE = new AsyncDataNodeClientPool(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncDataNodeClientPool getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java new file mode 100644 index 000000000000..d05ac9e9af90 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java @@ -0,0 +1,87 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.rpc.RpcUtils; +import org.apache.iotdb.rpc.TSStatusCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +/** General RPC handler for TSStatus response type. */ +public class AsyncTSStatusRPCHandler extends AbstractAsyncRPCHandler { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler.class); + + public AsyncTSStatusRPCHandler( + DataNodeRequestType requestType, + int requestId, + TDataNodeLocation targetDataNode, + Map dataNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + super(requestType, requestId, targetDataNode, dataNodeLocationMap, responseMap, countDownLatch); + } + + @Override + public void onComplete(TSStatus response) { + // Put response + responseMap.put(requestId, response); + + if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + // Remove only if success + dataNodeLocationMap.remove(requestId); + LOGGER.info("Successfully {} on DataNode: {}", requestType, formattedTargetLocation); + } else { + LOGGER.error( + "Failed to {} on DataNode: {}, response: {}", + requestType, + formattedTargetLocation, + response); + } + + // Always CountDown + countDownLatch.countDown(); + } + + @Override + public void onError(Exception e) { + String errorMsg = + "Failed to " + + requestType + + " on DataNode: " + + formattedTargetLocation + + ", exception: " + + e.getMessage(); + LOGGER.error(errorMsg); + + responseMap.put( + requestId, + new TSStatus( + RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(), errorMsg))); + + // Always CountDown + countDownLatch.countDown(); + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeRequestType.java new file mode 100644 index 000000000000..41f371677cb5 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeRequestType.java @@ -0,0 +1,122 @@ +/* + * 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.db.protocol.client.dn; + +public enum DataNodeRequestType { + + // Node Maintenance + DISABLE_DATA_NODE, + STOP_DATA_NODE, + + FLUSH, + MERGE, + FULL_MERGE, + START_REPAIR_DATA, + STOP_REPAIR_DATA, + LOAD_CONFIGURATION, + SET_SYSTEM_STATUS, + + SUBMIT_TEST_CONNECTION_TASK, + TEST_CONNECTION, + + // Region Maintenance + CREATE_DATA_REGION, + CREATE_SCHEMA_REGION, + DELETE_REGION, + + CREATE_NEW_REGION_PEER, + ADD_REGION_PEER, + REMOVE_REGION_PEER, + DELETE_OLD_REGION_PEER, + RESET_PEER_LIST, + + UPDATE_REGION_ROUTE_MAP, + CHANGE_REGION_LEADER, + + // PartitionCache + INVALIDATE_PARTITION_CACHE, + INVALIDATE_PERMISSION_CACHE, + INVALIDATE_SCHEMA_CACHE, + CLEAR_CACHE, + + // Function + CREATE_FUNCTION, + DROP_FUNCTION, + + // Trigger + CREATE_TRIGGER_INSTANCE, + DROP_TRIGGER_INSTANCE, + ACTIVE_TRIGGER_INSTANCE, + INACTIVE_TRIGGER_INSTANCE, + UPDATE_TRIGGER_LOCATION, + + // Pipe Plugin + CREATE_PIPE_PLUGIN, + DROP_PIPE_PLUGIN, + + // Pipe Task + PIPE_PUSH_ALL_META, + PIPE_PUSH_SINGLE_META, + PIPE_PUSH_MULTI_META, + PIPE_HEARTBEAT, + + // Subscription + TOPIC_PUSH_ALL_META, + TOPIC_PUSH_SINGLE_META, + TOPIC_PUSH_MULTI_META, + CONSUMER_GROUP_PUSH_ALL_META, + CONSUMER_GROUP_PUSH_SINGLE_META, + + // CQ + EXECUTE_CQ, + + // TEMPLATE + UPDATE_TEMPLATE, + + // Schema + SET_TTL, + + CONSTRUCT_SCHEMA_BLACK_LIST, + ROLLBACK_SCHEMA_BLACK_LIST, + FETCH_SCHEMA_BLACK_LIST, + INVALIDATE_MATCHED_SCHEMA_CACHE, + DELETE_DATA_FOR_DELETE_SCHEMA, + DELETE_TIMESERIES, + + CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + DEACTIVATE_TEMPLATE, + COUNT_PATHS_USING_TEMPLATE, + CHECK_SCHEMA_REGION_USING_TEMPLATE, + CHECK_TIMESERIES_EXISTENCE, + + CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, + ROLLBACK_VIEW_SCHEMA_BLACK_LIST, + DELETE_VIEW, + + ALTER_VIEW, + + // TODO Need to migrate to Node Maintenance + KILL_QUERY_INSTANCE, + + // Quota + SET_SPACE_QUOTA, + SET_THROTTLE_QUOTA, +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 2c8b07440d88..1dbe1458446b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -26,11 +26,15 @@ import org.apache.iotdb.common.rpc.thrift.TFlushReq; import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.common.rpc.thrift.TSender; +import org.apache.iotdb.common.rpc.thrift.TServiceProvider; +import org.apache.iotdb.common.rpc.thrift.TServiceType; import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSettleReq; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; @@ -74,6 +78,12 @@ import org.apache.iotdb.db.exception.StorageEngineException; import org.apache.iotdb.db.pipe.agent.PipeAgent; import org.apache.iotdb.db.protocol.client.ConfigNodeInfo; +import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientHandler; +import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientPool; +import org.apache.iotdb.db.protocol.client.cn.ConfigNodeRequestType; +import org.apache.iotdb.db.protocol.client.dn.AsyncClientHandler; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeClientPool; +import org.apache.iotdb.db.protocol.client.dn.DataNodeRequestType; import org.apache.iotdb.db.protocol.session.IClientSession; import org.apache.iotdb.db.protocol.session.InternalClientSession; import org.apache.iotdb.db.protocol.session.SessionManager; @@ -1418,7 +1428,90 @@ public TFetchFragmentInstanceStatisticsResp fetchFragmentInstanceStatistics( } @Override - public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) + public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) throws TException { + List configNodeResult = testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); + List dataNodeResult = + testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); + configNodeResult.addAll(dataNodeResult); + return new TTestConnectionResp(configNodeResult); + } + + private List testAllConfigNodeConnection( + List configNodeLocations) { + final TSender sender = + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + Map configNodeLocationMap = + configNodeLocations.stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + AsyncConfigNodeClientHandler clientHandler = + new AsyncConfigNodeClientHandler<>(ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); + AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNodeWithRetry(clientHandler); + Map anotherConfigNodeLocationMap = + configNodeLocations.stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + List results = new ArrayList<>(); + clientHandler + .getResponseMap() + .forEach( + (configNodeId, status) -> { + TEndPoint endPoint = anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); + return results; + } + + private List testAllDataNodeConnection( + List dataNodeLocations) { + final TSender sender = + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + Map dataNodeLocationMap = + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + AsyncClientHandler clientHandler = + new AsyncClientHandler<>(DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + Map anotherDataNodeLocationMap = + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + List results = new ArrayList<>(); + clientHandler + .getResponseMap() + .forEach( + (dataNodeId, status) -> { + TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); + return results; + } + + // @Override + public TTestConnectionResp submitTestConnectionTask1(TNodeLocations nodeLocations) throws TException { TTestConnectionResp resp = new TTestConnectionResp(); IClientManager diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index fe1974e2ce60..01b2f2ffcd67 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -83,6 +83,7 @@ public static void buildTSBlock( if (result.isSuccess()) { connectionStatus = "up"; } else { +// connectionStatus = addLineBreak("down" + " (" + result.getReason() + ")", 60); connectionStatus = "down" + " (" + result.getReason() + ")"; } builder @@ -122,4 +123,16 @@ private static void sortTestConnectionResp(TTestConnectionResp origin) { return endPointToString(sender1).compareTo(endPointToString(sender2)); }); } + + private static String addLineBreak(String origin, int interval) { + if (origin.length() < interval) { + return origin; + } + StringBuilder builder = new StringBuilder(origin.substring(0, interval)); + for (int i = interval; i < origin.length(); i += interval) { + builder.append("\n"); + builder.append(origin, i, Math.min(origin.length(), i+interval)); + } + return builder.toString(); + } } From d12e8b5a243d4b17c35a085be1d3da22f8f9abaa Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 6 Jun 2024 18:34:31 +0800 Subject: [PATCH 14/52] mpp, external service done --- .../async/AsyncConfigNodeClientPool.java | 286 +++++++++--------- .../client/async/AsyncDataNodeClientPool.java | 3 +- .../AsyncConfigNodeClientHandler.java | 257 ++++++++-------- .../async/handlers/TestConnectionHandler.java | 17 +- .../rpc/AbstractAsyncRPCHandler2.java | 94 +++--- .../rpc/AsyncTSStatusRPCHandler2.java | 96 +++--- .../SubmitTestConnectionTaskRPCHandler.java | 7 +- ...tConnectionTaskToConfigNodeRPCHandler.java | 27 +- .../confignode/manager/ClusterManager.java | 125 ++++---- .../org/apache/iotdb/db/conf/IoTDBConfig.java | 19 +- .../client/cn/AbstractAsyncRPCHandler2.java | 95 +++--- .../cn/AsyncConfigNodeClientHandler.java | 242 +++++++-------- .../client/cn/AsyncConfigNodeClientPool.java | 279 ++++++++--------- .../client/cn/AsyncTSStatusRPCHandler2.java | 97 +++--- .../client/dn/AbstractAsyncRPCHandler.java | 1 + .../client/dn/AsyncDataNodeClientPool.java | 60 +--- ...syncDataNodeExternalServiceClientPool.java | 88 ++++++ ...syncDataNodeInternalServiceClientPool.java | 90 ++++++ .../dn/AsyncDataNodeMPPServiceClientPool.java | 89 ++++++ .../client/dn/AsyncTSStatusRPCHandler.java | 1 + .../impl/DataNodeInternalRPCServiceImpl.java | 198 +++++++----- .../config/sys/TestConnectionTask.java | 84 +++-- .../commons/client/ClientPoolFactory.java | 26 ++ .../AsyncDataNodeExternalServiceClient.java | 173 +++++++++++ .../src/main/thrift/common.thrift | 2 + 25 files changed, 1495 insertions(+), 961 deletions(-) create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncDataNodeExternalServiceClient.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java index 27a15ca88c5d..8ecf7a050340 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java @@ -30,9 +30,8 @@ import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler2; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; -import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskRPCHandler; - import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,159 +40,160 @@ /** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ public class AsyncConfigNodeClientPool { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); - - private final IClientManager clientManager; - - private static final int MAX_RETRY_NUM = 6; - - private AsyncConfigNodeClientPool() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncConfigNodeIServiceClientPoolFactory()); - } - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - * @param timeoutInMs timeout in milliseconds - */ - public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( - AsyncConfigNodeClientHandler clientHandler, long timeoutInMs) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); - } - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - */ - public void sendAsyncRequestToConfigNodeWithRetry(AsyncConfigNodeClientHandler clientHandler) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); - } - - public void sendAsyncRequestToConfigNode(AsyncConfigNodeClientHandler clientHandler) { - sendAsyncRequest(clientHandler, 1, null); + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); + + private final IClientManager clientManager; + + private static final int MAX_RETRY_NUM = 6; + + private AsyncConfigNodeClientPool() { + clientManager = + new IClientManager.Factory() + .createClientManager(new ClientPoolFactory.AsyncConfigNodeIServiceClientPoolFactory()); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + * @param timeoutInMs timeout in milliseconds + */ + public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( + AsyncConfigNodeClientHandler clientHandler, long timeoutInMs) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + */ + public void sendAsyncRequestToConfigNodeWithRetry( + AsyncConfigNodeClientHandler clientHandler) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); + } + + public void sendAsyncRequestToConfigNode(AsyncConfigNodeClientHandler clientHandler) { + sendAsyncRequest(clientHandler, 1, null); + } + + private void sendAsyncRequest( + AsyncConfigNodeClientHandler clientHandler, int retryNum, Long timeoutInMs) { + if (clientHandler.getRequestIndices().isEmpty()) { + return; } - private void sendAsyncRequest( - AsyncConfigNodeClientHandler clientHandler, int retryNum, Long timeoutInMs) { - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - - ConfigNodeRequestType requestType = clientHandler.getRequestType(); - for (int retry = 0; retry < retryNum; retry++) { - // Always Reset CountDownLatch first - clientHandler.resetCountDownLatch(); - - // Send requests to all targetConfigNodes - for (int requestId : clientHandler.getRequestIndices()) { - TConfigNodeLocation targetConfigNode = clientHandler.getConfigNodeLocation(requestId); - sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); - } - - // Wait for this batch of asynchronous RPC requests finish - try { - if (timeoutInMs == null) { - clientHandler.getCountDownLatch().await(); - } else { - if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { - LOGGER.warn( - "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - } - } - } catch (InterruptedException e) { - LOGGER.error( - "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - Thread.currentThread().interrupt(); - } - - // Check if there is a ConfigNode that fails to execute the request, and retry if there exists - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - } - - if (!clientHandler.getRequestIndices().isEmpty()) { + ConfigNodeRequestType requestType = clientHandler.getRequestType(); + for (int retry = 0; retry < retryNum; retry++) { + // Always Reset CountDownLatch first + clientHandler.resetCountDownLatch(); + + // Send requests to all targetConfigNodes + for (int requestId : clientHandler.getRequestIndices()) { + TConfigNodeLocation targetConfigNode = clientHandler.getConfigNodeLocation(requestId); + sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); + } + + // Wait for this batch of asynchronous RPC requests finish + try { + if (timeoutInMs == null) { + clientHandler.getCountDownLatch().await(); + } else { + if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { LOGGER.warn( - "Failed to {} on ConfigNode after {} retries, requestIndices: {}", - requestType, - retryNum, - clientHandler.getRequestIndices()); + "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + } } + } catch (InterruptedException e) { + LOGGER.error( + "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + Thread.currentThread().interrupt(); + } + + // Check if there is a ConfigNode that fails to execute the request, and retry if there exists + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } } - private void sendAsyncRequestToConfigNode( - AsyncConfigNodeClientHandler clientHandler, - int requestId, - TConfigNodeLocation targetConfigNode, - int retryCount) { - - try { - AsyncConfigNodeIServiceClient client; - client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler2 handler = - clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); - AsyncTSStatusRPCHandler2 defaultHandler = null; - if (handler instanceof AsyncTSStatusRPCHandler2) { - defaultHandler = (AsyncTSStatusRPCHandler2) handler; - } - - switch (clientHandler.getRequestType()) { - case SUBMIT_TEST_CONNECTION_TASK: - client.submitTestConnectionTask((TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); - break; - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", - clientHandler.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on ConfigNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetConfigNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } + if (!clientHandler.getRequestIndices().isEmpty()) { + LOGGER.warn( + "Failed to {} on ConfigNode after {} retries, requestIndices: {}", + requestType, + retryNum, + clientHandler.getRequestIndices()); } - - /** - * Always call this interface when a ConfigNode is restarted or removed. - * - * @param endPoint The specific ConfigNode - */ - public void resetClient(TEndPoint endPoint) { - clientManager.clear(endPoint); + } + + private void sendAsyncRequestToConfigNode( + AsyncConfigNodeClientHandler clientHandler, + int requestId, + TConfigNodeLocation targetConfigNode, + int retryCount) { + + try { + AsyncConfigNodeIServiceClient client; + client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler2 handler = + clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); + AsyncTSStatusRPCHandler2 defaultHandler = null; + if (handler instanceof AsyncTSStatusRPCHandler2) { + defaultHandler = (AsyncTSStatusRPCHandler2) handler; + } + + switch (clientHandler.getRequestType()) { + case SUBMIT_TEST_CONNECTION_TASK: + client.submitTestConnectionTask( + (TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); + break; + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on ConfigNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetConfigNode.getInternalEndPoint(), + e.getMessage(), + retryCount); } + } - public AsyncConfigNodeIServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) - throws ClientManagerException { - return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - } + /** + * Always call this interface when a ConfigNode is restarted or removed. + * + * @param endPoint The specific ConfigNode + */ + public void resetClient(TEndPoint endPoint) { + clientManager.clear(endPoint); + } - // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { + public AsyncConfigNodeIServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) + throws ClientManagerException { + return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + } - private static final AsyncConfigNodeClientPool INSTANCE = new AsyncConfigNodeClientPool(); + // TODO: Is the ClientPool must be a singleton? + private static class ClientPoolHolder { - private ClientPoolHolder() { - // Empty constructor - } - } + private static final AsyncConfigNodeClientPool INSTANCE = new AsyncConfigNodeClientPool(); - public static AsyncConfigNodeClientPool getInstance() { - return ClientPoolHolder.INSTANCE; + private ClientPoolHolder() { + // Empty constructor } + } + + public static AsyncConfigNodeClientPool getInstance() { + return ClientPoolHolder.INSTANCE; + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index 4e573a606b2d..3d4df4160fba 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -379,7 +379,8 @@ private void sendAsyncRequestToDataNode( client.resetPeerList((TResetPeerListReq) req, defaultHandler); break; case SUBMIT_TEST_CONNECTION_TASK: - client.submitTestConnectionTask((TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); + client.submitTestConnectionTask( + (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); break; case TEST_CONNECTION: client.testConnection(defaultHandler); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java index bb27c7e9ab57..e4ddd7581dbf 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java @@ -41,134 +41,133 @@ */ public class AsyncConfigNodeClientHandler { - // Type of RPC request - protected final ConfigNodeRequestType requestType; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The corresponding RPC request - */ - private final Map requestMap; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target ConfigNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap only - * if its corresponding RPC request success - */ - private final Map configNodeLocationMap; - - /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - private final Map responseMap; - - private CountDownLatch countDownLatch; - - /** Custom constructor. */ - public AsyncConfigNodeClientHandler(ConfigNodeRequestType requestType) { - this.requestType = requestType; - this.requestMap = new ConcurrentHashMap<>(); - this.configNodeLocationMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - public void putRequest(int requestId, Q request) { - requestMap.put(requestId, request); - } - - public void putConfigNodeLocation(int requestId, TConfigNodeLocation configNodeLocation) { - configNodeLocationMap.put(requestId, configNodeLocation); - } - - /** Constructor for null requests. */ - public AsyncConfigNodeClientHandler( - ConfigNodeRequestType requestType, Map configNodeLocationMap) { - this.requestType = requestType; - this.configNodeLocationMap = configNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - /** Constructor for unique request. */ - public AsyncConfigNodeClientHandler( - ConfigNodeRequestType requestType, - Q request, - Map configNodeLocationMap) { - this.requestType = requestType; - this.configNodeLocationMap = configNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.configNodeLocationMap - .keySet() - .forEach(configNodeId -> this.requestMap.put(configNodeId, request)); - - this.responseMap = new ConcurrentHashMap<>(); - } - - public ConfigNodeRequestType getRequestType() { - return requestType; - } - - public List getRequestIndices() { - return new ArrayList<>(configNodeLocationMap.keySet()); - } - - public Q getRequest(int requestId) { - return requestMap.get(requestId); - } - - public TConfigNodeLocation getConfigNodeLocation(int requestId) { - return configNodeLocationMap.get(requestId); - } - - public List getResponseList() { - return new ArrayList<>(responseMap.values()); - } - - public Map getResponseMap() { - return responseMap; - } - - /** Always reset CountDownLatch before retry. */ - public void resetCountDownLatch() { - countDownLatch = new CountDownLatch(configNodeLocationMap.size()); - } - - public CountDownLatch getCountDownLatch() { - return countDownLatch; - } - - public AbstractAsyncRPCHandler2 createAsyncRPCHandler( - int requestId, TConfigNodeLocation targetConfigNode) { - switch (requestType) { - case SUBMIT_TEST_CONNECTION_TASK: - return new SubmitTestConnectionTaskToConfigNodeRPCHandler( - requestType, - requestId, - targetConfigNode, - configNodeLocationMap, - (Map) responseMap, - countDownLatch - ); - case TEST_CONNECTION: - default: - return new AsyncTSStatusRPCHandler2( - requestType, - requestId, - targetConfigNode, - configNodeLocationMap, - (Map) responseMap, - countDownLatch); - } + // Type of RPC request + protected final ConfigNodeRequestType requestType; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The corresponding RPC request + */ + private final Map requestMap; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap + * only if its corresponding RPC request success + */ + private final Map configNodeLocationMap; + + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + private final Map responseMap; + + private CountDownLatch countDownLatch; + + /** Custom constructor. */ + public AsyncConfigNodeClientHandler(ConfigNodeRequestType requestType) { + this.requestType = requestType; + this.requestMap = new ConcurrentHashMap<>(); + this.configNodeLocationMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + public void putRequest(int requestId, Q request) { + requestMap.put(requestId, request); + } + + public void putConfigNodeLocation(int requestId, TConfigNodeLocation configNodeLocation) { + configNodeLocationMap.put(requestId, configNodeLocation); + } + + /** Constructor for null requests. */ + public AsyncConfigNodeClientHandler( + ConfigNodeRequestType requestType, Map configNodeLocationMap) { + this.requestType = requestType; + this.configNodeLocationMap = configNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + /** Constructor for unique request. */ + public AsyncConfigNodeClientHandler( + ConfigNodeRequestType requestType, + Q request, + Map configNodeLocationMap) { + this.requestType = requestType; + this.configNodeLocationMap = configNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.configNodeLocationMap + .keySet() + .forEach(configNodeId -> this.requestMap.put(configNodeId, request)); + + this.responseMap = new ConcurrentHashMap<>(); + } + + public ConfigNodeRequestType getRequestType() { + return requestType; + } + + public List getRequestIndices() { + return new ArrayList<>(configNodeLocationMap.keySet()); + } + + public Q getRequest(int requestId) { + return requestMap.get(requestId); + } + + public TConfigNodeLocation getConfigNodeLocation(int requestId) { + return configNodeLocationMap.get(requestId); + } + + public List getResponseList() { + return new ArrayList<>(responseMap.values()); + } + + public Map getResponseMap() { + return responseMap; + } + + /** Always reset CountDownLatch before retry. */ + public void resetCountDownLatch() { + countDownLatch = new CountDownLatch(configNodeLocationMap.size()); + } + + public CountDownLatch getCountDownLatch() { + return countDownLatch; + } + + public AbstractAsyncRPCHandler2 createAsyncRPCHandler( + int requestId, TConfigNodeLocation targetConfigNode) { + switch (requestType) { + case SUBMIT_TEST_CONNECTION_TASK: + return new SubmitTestConnectionTaskToConfigNodeRPCHandler( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + (Map) responseMap, + countDownLatch); + case TEST_CONNECTION: + default: + return new AsyncTSStatusRPCHandler2( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + (Map) responseMap, + countDownLatch); } + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java index fca7d67a594d..7519f6855c03 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java @@ -20,20 +20,15 @@ package org.apache.iotdb.confignode.client.async.handlers; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.thrift.async.AsyncMethodCallback; -import java.util.concurrent.ConcurrentHashMap; +import org.apache.thrift.async.AsyncMethodCallback; public class TestConnectionHandler implements AsyncMethodCallback { -// public TestConnectionHandler(ConcurrentHashMap) - - @Override - public void onComplete(TSStatus tsStatus) { - - } + // public TestConnectionHandler(ConcurrentHashMap) - @Override - public void onError(Exception e) { + @Override + public void onComplete(TSStatus tsStatus) {} - } + @Override + public void onError(Exception e) {} } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java index 50c984c342df..2c00e64873a7 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java @@ -29,57 +29,57 @@ public abstract class AbstractAsyncRPCHandler2 implements AsyncMethodCallback { - // Type of RPC request - protected final ConfigNodeRequestType requestType; - // Index of request - protected final int requestId; - // Target ConfigNode - protected final TConfigNodeLocation targetConfigNode; + // Type of RPC request + protected final ConfigNodeRequestType requestType; + // Index of request + protected final int requestId; + // Target ConfigNode + protected final TConfigNodeLocation targetConfigNode; - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target ConfigNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap only - * if its corresponding RPC request success - */ - protected final Map configNodeLocationMap; + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap + * only if its corresponding RPC request success + */ + protected final Map configNodeLocationMap; - /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - protected final Map responseMap; + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + protected final Map responseMap; - // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished - protected final CountDownLatch countDownLatch; + // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished + protected final CountDownLatch countDownLatch; - protected final String formattedTargetLocation; + protected final String formattedTargetLocation; - protected AbstractAsyncRPCHandler2( - ConfigNodeRequestType requestType, - int requestId, - TConfigNodeLocation targetConfigNode, - Map configNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - this.requestType = requestType; - this.requestId = requestId; - this.targetConfigNode = targetConfigNode; - this.formattedTargetLocation = - "{id=" - + targetConfigNode.getConfigNodeId() - + ", internalEndPoint=" - + targetConfigNode.getInternalEndPoint() - + "}"; + protected AbstractAsyncRPCHandler2( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + this.requestType = requestType; + this.requestId = requestId; + this.targetConfigNode = targetConfigNode; + this.formattedTargetLocation = + "{id=" + + targetConfigNode.getConfigNodeId() + + ", internalEndPoint=" + + targetConfigNode.getInternalEndPoint() + + "}"; - this.configNodeLocationMap = configNodeLocationMap; - this.responseMap = responseMap; - this.countDownLatch = countDownLatch; - } + this.configNodeLocationMap = configNodeLocationMap; + this.responseMap = responseMap; + this.countDownLatch = countDownLatch; + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java index 34f32d7120bd..007ec209db8b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java @@ -34,56 +34,62 @@ /** General RPC handler for TSStatus response type. */ public class AsyncTSStatusRPCHandler2 extends AbstractAsyncRPCHandler2 { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); - public AsyncTSStatusRPCHandler2( - ConfigNodeRequestType requestType, - int requestId, - TConfigNodeLocation targetConfigNode, - Map configNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - super(requestType, requestId, targetConfigNode, configNodeLocationMap, responseMap, countDownLatch); - } - - @Override - public void onComplete(TSStatus response) { - // Put response - responseMap.put(requestId, response); + public AsyncTSStatusRPCHandler2( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + super( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + responseMap, + countDownLatch); + } - if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - // Remove only if success - configNodeLocationMap.remove(requestId); - LOGGER.info("Successfully {} on ConfigNode: {}", requestType, formattedTargetLocation); - } else { - LOGGER.error( - "Failed to {} on ConfigNode: {}, response: {}", - requestType, - formattedTargetLocation, - response); - } + @Override + public void onComplete(TSStatus response) { + // Put response + responseMap.put(requestId, response); - // Always CountDown - countDownLatch.countDown(); + if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + // Remove only if success + configNodeLocationMap.remove(requestId); + LOGGER.info("Successfully {} on ConfigNode: {}", requestType, formattedTargetLocation); + } else { + LOGGER.error( + "Failed to {} on ConfigNode: {}, response: {}", + requestType, + formattedTargetLocation, + response); } - @Override - public void onError(Exception e) { - String errorMsg = - "Failed to " - + requestType - + " on ConfigNode: " - + formattedTargetLocation - + ", exception: " - + e.getMessage(); - LOGGER.error(errorMsg); + // Always CountDown + countDownLatch.countDown(); + } - responseMap.put( - requestId, - new TSStatus( - RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(), errorMsg))); + @Override + public void onError(Exception e) { + String errorMsg = + "Failed to " + + requestType + + " on ConfigNode: " + + formattedTargetLocation + + ", exception: " + + e.getMessage(); + LOGGER.error(errorMsg); - // Always CountDown - countDownLatch.countDown(); - } + responseMap.put( + requestId, + new TSStatus( + RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(), errorMsg))); + + // Always CountDown + countDownLatch.countDown(); + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index 86d7f1ae7474..e162ce349ae3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -22,15 +22,18 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.DataNodeRequestType; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Map; import java.util.concurrent.CountDownLatch; -public class SubmitTestConnectionTaskRPCHandler extends AbstractAsyncRPCHandler { +public class SubmitTestConnectionTaskRPCHandler + extends AbstractAsyncRPCHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskRPCHandler.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(SubmitTestConnectionTaskRPCHandler.class); public SubmitTestConnectionTaskRPCHandler( DataNodeRequestType requestType, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index 106b1fb73e37..6d469ab12622 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -24,24 +24,33 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.rpc.TSStatusCode; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Map; import java.util.concurrent.CountDownLatch; -public class SubmitTestConnectionTaskToConfigNodeRPCHandler extends AbstractAsyncRPCHandler2 { +public class SubmitTestConnectionTaskToConfigNodeRPCHandler + extends AbstractAsyncRPCHandler2 { - private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskToConfigNodeRPCHandler.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(SubmitTestConnectionTaskToConfigNodeRPCHandler.class); public SubmitTestConnectionTaskToConfigNodeRPCHandler( - ConfigNodeRequestType requestType, - int requestId, - TConfigNodeLocation targetConfigNode, - Map configNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - super(requestType, requestId, targetConfigNode, configNodeLocationMap, responseMap, countDownLatch); + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + super( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + responseMap, + countDownLatch); } @Override diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index e87cc1919c1b..edeed260258f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -33,24 +33,20 @@ import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncConfigNodeClientPool; -import org.apache.iotdb.confignode.client.async.AsyncConfigNodeHeartbeatClientPool; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; -import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; import org.apache.iotdb.confignode.persistence.ClusterInfo; import org.apache.iotdb.consensus.exception.ConsensusException; -import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; import org.apache.iotdb.rpc.TSStatusCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.UUID; @@ -117,33 +113,46 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { .map(TDataNodeConfiguration::getLocation) .collect(Collectors.toList())); Map configNodeLocationMap = - configManager.getNodeManager().getRegisteredConfigNodes().stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + configManager.getNodeManager().getRegisteredConfigNodes().stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); AsyncConfigNodeClientHandler configNodeClientHandler = - new AsyncConfigNodeClientHandler<>(ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); + new AsyncConfigNodeClientHandler<>( + ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + nodeLocations, + configNodeLocationMap); AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNode(configNodeClientHandler); - configNodeClientHandler.getResponseMap().values().forEach(configNodeResp -> { - if (configNodeResp.isSetResultList()) { - merge(resp, configNodeResp); - } else { - // TODO: 展示错误 - LOGGER.warn("Some problem"); - } - }); + configNodeClientHandler + .getResponseMap() + .values() + .forEach( + configNodeResp -> { + if (configNodeResp.isSetResultList()) { + merge(resp, configNodeResp); + } else { + // TODO: 展示错误 + LOGGER.warn("Some problem"); + } + }); Map dataNodeLocationMap = - configManager.getNodeManager().getRegisteredDataNodes().stream().map(TDataNodeConfiguration::getLocation) - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + configManager.getNodeManager().getRegisteredDataNodes().stream() + .map(TDataNodeConfiguration::getLocation) + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); AsyncClientHandler dataNodeClientHandler = - new AsyncClientHandler<>(DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); + new AsyncClientHandler<>( + DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNode(dataNodeClientHandler); - dataNodeClientHandler.getResponseMap().values().forEach(dataNodeResp -> { - if (dataNodeResp.isSetResultList()) { - merge(resp, dataNodeResp); - } else { - // TODO: 展示错误 - LOGGER.warn("Some problem"); - } - }); + dataNodeClientHandler + .getResponseMap() + .values() + .forEach( + dataNodeResp -> { + if (dataNodeResp.isSetResultList()) { + merge(resp, dataNodeResp); + } else { + // TODO: 展示错误 + LOGGER.warn("Some problem"); + } + }); return resp; } @@ -165,7 +174,8 @@ private void submitTestConnectionTaskToAllDataNode() { private void submitTestConnectionTaskToAllConfigNode() {} public List doConnectionTest(TNodeLocations nodeLocations) { - List configNodeResult = testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); + List configNodeResult = + testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); List dataNodeResult = testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); configNodeResult.addAll(dataNodeResult); @@ -208,39 +218,41 @@ private List testConfigNodeConnection( } private List testAllConfigNodeConnection( - List configNodeLocations) { + List configNodeLocations) { final TSender sender = - new TSender() - .setConfigNodeLocation( - ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); + new TSender() + .setConfigNodeLocation( + ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); Map configNodeLocationMap = - configNodeLocations.stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + configNodeLocations.stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); AsyncConfigNodeClientHandler clientHandler = - new AsyncConfigNodeClientHandler<>(ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); + new AsyncConfigNodeClientHandler<>( + ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNodeWithRetry(clientHandler); Map anotherConfigNodeLocationMap = - configNodeLocations.stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + configNodeLocations.stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); List results = new ArrayList<>(); clientHandler - .getResponseMap() - .forEach( - (configNodeId, status) -> { - TEndPoint endPoint = anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); + .getResponseMap() + .forEach( + (configNodeId, status) -> { + TEndPoint endPoint = + anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); return results; } @@ -254,11 +266,12 @@ private List testAllDataNodeConnection( dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + new AsyncClientHandler<>( + DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); List results = new ArrayList<>(); clientHandler .getResponseMap() diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java index 4043f2fd9a4b..4085fdd7b1d9 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java @@ -3917,13 +3917,16 @@ public void setInnerCompactionTaskSelectionDiskRedundancy( } public TDataNodeLocation generateLocalDataNodeLocation() { - TDataNodeLocation result = new TDataNodeLocation(); - result.setDataNodeId(getDataNodeId()); - result.setClientRpcEndPoint(new TEndPoint(getInternalAddress(), getRpcPort())); - result.setInternalEndPoint(new TEndPoint(getInternalAddress(), getInternalPort())); - result.setMPPDataExchangeEndPoint(new TEndPoint(getInternalAddress(), getMppDataExchangePort())); - result.setDataRegionConsensusEndPoint(new TEndPoint(getInternalAddress(), getDataRegionConsensusPort())); - result.setSchemaRegionConsensusEndPoint(new TEndPoint(getInternalAddress(), getSchemaRegionConsensusPort())); - return result; + TDataNodeLocation result = new TDataNodeLocation(); + result.setDataNodeId(getDataNodeId()); + result.setClientRpcEndPoint(new TEndPoint(getInternalAddress(), getRpcPort())); + result.setInternalEndPoint(new TEndPoint(getInternalAddress(), getInternalPort())); + result.setMPPDataExchangeEndPoint( + new TEndPoint(getInternalAddress(), getMppDataExchangePort())); + result.setDataRegionConsensusEndPoint( + new TEndPoint(getInternalAddress(), getDataRegionConsensusPort())); + result.setSchemaRegionConsensusEndPoint( + new TEndPoint(getInternalAddress(), getSchemaRegionConsensusPort())); + return result; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java index 8ae66a2f679d..4992d3ee620d 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java @@ -20,6 +20,7 @@ package org.apache.iotdb.db.protocol.client.cn; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; + import org.apache.thrift.async.AsyncMethodCallback; import java.util.Map; @@ -27,57 +28,57 @@ public abstract class AbstractAsyncRPCHandler2 implements AsyncMethodCallback { - // Type of RPC request - protected final ConfigNodeRequestType requestType; - // Index of request - protected final int requestId; - // Target ConfigNode - protected final TConfigNodeLocation targetConfigNode; + // Type of RPC request + protected final ConfigNodeRequestType requestType; + // Index of request + protected final int requestId; + // Target ConfigNode + protected final TConfigNodeLocation targetConfigNode; - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target ConfigNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap only - * if its corresponding RPC request success - */ - protected final Map configNodeLocationMap; + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap + * only if its corresponding RPC request success + */ + protected final Map configNodeLocationMap; - /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - protected final Map responseMap; + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + protected final Map responseMap; - // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished - protected final CountDownLatch countDownLatch; + // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished + protected final CountDownLatch countDownLatch; - protected final String formattedTargetLocation; + protected final String formattedTargetLocation; - protected AbstractAsyncRPCHandler2( - ConfigNodeRequestType requestType, - int requestId, - TConfigNodeLocation targetConfigNode, - Map configNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - this.requestType = requestType; - this.requestId = requestId; - this.targetConfigNode = targetConfigNode; - this.formattedTargetLocation = - "{id=" - + targetConfigNode.getConfigNodeId() - + ", internalEndPoint=" - + targetConfigNode.getInternalEndPoint() - + "}"; + protected AbstractAsyncRPCHandler2( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + this.requestType = requestType; + this.requestId = requestId; + this.targetConfigNode = targetConfigNode; + this.formattedTargetLocation = + "{id=" + + targetConfigNode.getConfigNodeId() + + ", internalEndPoint=" + + targetConfigNode.getInternalEndPoint() + + "}"; - this.configNodeLocationMap = configNodeLocationMap; - this.responseMap = responseMap; - this.countDownLatch = countDownLatch; - } + this.configNodeLocationMap = configNodeLocationMap; + this.responseMap = responseMap; + this.countDownLatch = countDownLatch; + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java index b45fd19064c7..833a65c8e0ff 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java @@ -36,126 +36,126 @@ */ public class AsyncConfigNodeClientHandler { - // Type of RPC request - protected final ConfigNodeRequestType requestType; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The corresponding RPC request - */ - private final Map requestMap; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target ConfigNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap only - * if its corresponding RPC request success - */ - private final Map configNodeLocationMap; - - /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - private final Map responseMap; - - private CountDownLatch countDownLatch; - - /** Custom constructor. */ - public AsyncConfigNodeClientHandler(ConfigNodeRequestType requestType) { - this.requestType = requestType; - this.requestMap = new ConcurrentHashMap<>(); - this.configNodeLocationMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - public void putRequest(int requestId, Q request) { - requestMap.put(requestId, request); - } - - public void putConfigNodeLocation(int requestId, TConfigNodeLocation configNodeLocation) { - configNodeLocationMap.put(requestId, configNodeLocation); - } - - /** Constructor for null requests. */ - public AsyncConfigNodeClientHandler( - ConfigNodeRequestType requestType, Map configNodeLocationMap) { - this.requestType = requestType; - this.configNodeLocationMap = configNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - /** Constructor for unique request. */ - public AsyncConfigNodeClientHandler( - ConfigNodeRequestType requestType, - Q request, - Map configNodeLocationMap) { - this.requestType = requestType; - this.configNodeLocationMap = configNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.configNodeLocationMap - .keySet() - .forEach(configNodeId -> this.requestMap.put(configNodeId, request)); - - this.responseMap = new ConcurrentHashMap<>(); - } - - public ConfigNodeRequestType getRequestType() { - return requestType; - } - - public List getRequestIndices() { - return new ArrayList<>(configNodeLocationMap.keySet()); - } - - public Q getRequest(int requestId) { - return requestMap.get(requestId); - } - - public TConfigNodeLocation getConfigNodeLocation(int requestId) { - return configNodeLocationMap.get(requestId); - } - - public List getResponseList() { - return new ArrayList<>(responseMap.values()); - } - - public Map getResponseMap() { - return responseMap; - } - - /** Always reset CountDownLatch before retry. */ - public void resetCountDownLatch() { - countDownLatch = new CountDownLatch(configNodeLocationMap.size()); - } - - public CountDownLatch getCountDownLatch() { - return countDownLatch; - } - - public AbstractAsyncRPCHandler2 createAsyncRPCHandler( - int requestId, TConfigNodeLocation targetConfigNode) { - switch (requestType) { - case SUBMIT_TEST_CONNECTION_TASK: - case TEST_CONNECTION: - default: - return new AsyncTSStatusRPCHandler2( - requestType, - requestId, - targetConfigNode, - configNodeLocationMap, - (Map) responseMap, - countDownLatch); - } + // Type of RPC request + protected final ConfigNodeRequestType requestType; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The corresponding RPC request + */ + private final Map requestMap; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap + * only if its corresponding RPC request success + */ + private final Map configNodeLocationMap; + + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + private final Map responseMap; + + private CountDownLatch countDownLatch; + + /** Custom constructor. */ + public AsyncConfigNodeClientHandler(ConfigNodeRequestType requestType) { + this.requestType = requestType; + this.requestMap = new ConcurrentHashMap<>(); + this.configNodeLocationMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + public void putRequest(int requestId, Q request) { + requestMap.put(requestId, request); + } + + public void putConfigNodeLocation(int requestId, TConfigNodeLocation configNodeLocation) { + configNodeLocationMap.put(requestId, configNodeLocation); + } + + /** Constructor for null requests. */ + public AsyncConfigNodeClientHandler( + ConfigNodeRequestType requestType, Map configNodeLocationMap) { + this.requestType = requestType; + this.configNodeLocationMap = configNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + /** Constructor for unique request. */ + public AsyncConfigNodeClientHandler( + ConfigNodeRequestType requestType, + Q request, + Map configNodeLocationMap) { + this.requestType = requestType; + this.configNodeLocationMap = configNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.configNodeLocationMap + .keySet() + .forEach(configNodeId -> this.requestMap.put(configNodeId, request)); + + this.responseMap = new ConcurrentHashMap<>(); + } + + public ConfigNodeRequestType getRequestType() { + return requestType; + } + + public List getRequestIndices() { + return new ArrayList<>(configNodeLocationMap.keySet()); + } + + public Q getRequest(int requestId) { + return requestMap.get(requestId); + } + + public TConfigNodeLocation getConfigNodeLocation(int requestId) { + return configNodeLocationMap.get(requestId); + } + + public List getResponseList() { + return new ArrayList<>(responseMap.values()); + } + + public Map getResponseMap() { + return responseMap; + } + + /** Always reset CountDownLatch before retry. */ + public void resetCountDownLatch() { + countDownLatch = new CountDownLatch(configNodeLocationMap.size()); + } + + public CountDownLatch getCountDownLatch() { + return countDownLatch; + } + + public AbstractAsyncRPCHandler2 createAsyncRPCHandler( + int requestId, TConfigNodeLocation targetConfigNode) { + switch (requestType) { + case SUBMIT_TEST_CONNECTION_TASK: + case TEST_CONNECTION: + default: + return new AsyncTSStatusRPCHandler2( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + (Map) responseMap, + countDownLatch); } + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java index 054f5fd6d1af..f3440b66cf2a 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java @@ -21,11 +21,11 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; import org.apache.iotdb.commons.client.exception.ClientManagerException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,156 +34,157 @@ /** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ public class AsyncConfigNodeClientPool { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); - - private final IClientManager clientManager; - - private static final int MAX_RETRY_NUM = 6; - - private AsyncConfigNodeClientPool() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncConfigNodeIServiceClientPoolFactory()); - } - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - * @param timeoutInMs timeout in milliseconds - */ - public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( - AsyncConfigNodeClientHandler clientHandler, long timeoutInMs) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); + + private final IClientManager clientManager; + + private static final int MAX_RETRY_NUM = 6; + + private AsyncConfigNodeClientPool() { + clientManager = + new IClientManager.Factory() + .createClientManager(new ClientPoolFactory.AsyncConfigNodeIServiceClientPoolFactory()); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + * @param timeoutInMs timeout in milliseconds + */ + public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( + AsyncConfigNodeClientHandler clientHandler, long timeoutInMs) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + */ + public void sendAsyncRequestToConfigNodeWithRetry( + AsyncConfigNodeClientHandler clientHandler) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); + } + + public void sendAsyncRequestToConfigNode(AsyncConfigNodeClientHandler clientHandler) { + sendAsyncRequest(clientHandler, 1, null); + } + + private void sendAsyncRequest( + AsyncConfigNodeClientHandler clientHandler, int retryNum, Long timeoutInMs) { + if (clientHandler.getRequestIndices().isEmpty()) { + return; } - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - */ - public void sendAsyncRequestToConfigNodeWithRetry(AsyncConfigNodeClientHandler clientHandler) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); - } - - public void sendAsyncRequestToConfigNode(AsyncConfigNodeClientHandler clientHandler) { - sendAsyncRequest(clientHandler, 1, null); - } - - private void sendAsyncRequest( - AsyncConfigNodeClientHandler clientHandler, int retryNum, Long timeoutInMs) { - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - - ConfigNodeRequestType requestType = clientHandler.getRequestType(); - for (int retry = 0; retry < retryNum; retry++) { - // Always Reset CountDownLatch first - clientHandler.resetCountDownLatch(); - - // Send requests to all targetConfigNodes - for (int requestId : clientHandler.getRequestIndices()) { - TConfigNodeLocation targetConfigNode = clientHandler.getConfigNodeLocation(requestId); - sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); - } - - // Wait for this batch of asynchronous RPC requests finish - try { - if (timeoutInMs == null) { - clientHandler.getCountDownLatch().await(); - } else { - if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { - LOGGER.warn( - "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - } - } - } catch (InterruptedException e) { - LOGGER.error( - "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - Thread.currentThread().interrupt(); - } - - // Check if there is a ConfigNode that fails to execute the request, and retry if there exists - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - } - - if (!clientHandler.getRequestIndices().isEmpty()) { + ConfigNodeRequestType requestType = clientHandler.getRequestType(); + for (int retry = 0; retry < retryNum; retry++) { + // Always Reset CountDownLatch first + clientHandler.resetCountDownLatch(); + + // Send requests to all targetConfigNodes + for (int requestId : clientHandler.getRequestIndices()) { + TConfigNodeLocation targetConfigNode = clientHandler.getConfigNodeLocation(requestId); + sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); + } + + // Wait for this batch of asynchronous RPC requests finish + try { + if (timeoutInMs == null) { + clientHandler.getCountDownLatch().await(); + } else { + if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { LOGGER.warn( - "Failed to {} on ConfigNode after {} retries, requestIndices: {}", - requestType, - retryNum, - clientHandler.getRequestIndices()); + "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + } } + } catch (InterruptedException e) { + LOGGER.error( + "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + Thread.currentThread().interrupt(); + } + + // Check if there is a ConfigNode that fails to execute the request, and retry if there exists + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } } - private void sendAsyncRequestToConfigNode( - AsyncConfigNodeClientHandler clientHandler, - int requestId, - TConfigNodeLocation targetConfigNode, - int retryCount) { - - try { - AsyncConfigNodeIServiceClient client; - client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler2 handler = - clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); - AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; - - switch (clientHandler.getRequestType()) { -// case SUBMIT_TEST_CONNECTION_TASK: -// client.submitTestConnectionTask((TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); -// break; - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", - clientHandler.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on ConfigNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetConfigNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } + if (!clientHandler.getRequestIndices().isEmpty()) { + LOGGER.warn( + "Failed to {} on ConfigNode after {} retries, requestIndices: {}", + requestType, + retryNum, + clientHandler.getRequestIndices()); } - - /** - * Always call this interface when a ConfigNode is restarted or removed. - * - * @param endPoint The specific ConfigNode - */ - public void resetClient(TEndPoint endPoint) { - clientManager.clear(endPoint); + } + + private void sendAsyncRequestToConfigNode( + AsyncConfigNodeClientHandler clientHandler, + int requestId, + TConfigNodeLocation targetConfigNode, + int retryCount) { + + try { + AsyncConfigNodeIServiceClient client; + client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler2 handler = + clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); + AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; + + switch (clientHandler.getRequestType()) { + // case SUBMIT_TEST_CONNECTION_TASK: + // client.submitTestConnectionTask((TNodeLocations) req, + // (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); + // break; + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on ConfigNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetConfigNode.getInternalEndPoint(), + e.getMessage(), + retryCount); } + } - public AsyncConfigNodeIServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) - throws ClientManagerException { - return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - } + /** + * Always call this interface when a ConfigNode is restarted or removed. + * + * @param endPoint The specific ConfigNode + */ + public void resetClient(TEndPoint endPoint) { + clientManager.clear(endPoint); + } - // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { + public AsyncConfigNodeIServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) + throws ClientManagerException { + return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + } - private static final AsyncConfigNodeClientPool INSTANCE = new AsyncConfigNodeClientPool(); + // TODO: Is the ClientPool must be a singleton? + private static class ClientPoolHolder { - private ClientPoolHolder() { - // Empty constructor - } - } + private static final AsyncConfigNodeClientPool INSTANCE = new AsyncConfigNodeClientPool(); - public static AsyncConfigNodeClientPool getInstance() { - return ClientPoolHolder.INSTANCE; + private ClientPoolHolder() { + // Empty constructor } + } + + public static AsyncConfigNodeClientPool getInstance() { + return ClientPoolHolder.INSTANCE; + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java index 2b2ae721ce6b..68a9ad8f9035 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java @@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,56 +33,62 @@ /** General RPC handler for TSStatus response type. */ public class AsyncTSStatusRPCHandler2 extends AbstractAsyncRPCHandler2 { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); - - public AsyncTSStatusRPCHandler2( - ConfigNodeRequestType requestType, - int requestId, - TConfigNodeLocation targetConfigNode, - Map configNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - super(requestType, requestId, targetConfigNode, configNodeLocationMap, responseMap, countDownLatch); - } + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); - @Override - public void onComplete(TSStatus response) { - // Put response - responseMap.put(requestId, response); + public AsyncTSStatusRPCHandler2( + ConfigNodeRequestType requestType, + int requestId, + TConfigNodeLocation targetConfigNode, + Map configNodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + super( + requestType, + requestId, + targetConfigNode, + configNodeLocationMap, + responseMap, + countDownLatch); + } - if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - // Remove only if success - configNodeLocationMap.remove(requestId); - LOGGER.info("Successfully {} on ConfigNode: {}", requestType, formattedTargetLocation); - } else { - LOGGER.error( - "Failed to {} on ConfigNode: {}, response: {}", - requestType, - formattedTargetLocation, - response); - } + @Override + public void onComplete(TSStatus response) { + // Put response + responseMap.put(requestId, response); - // Always CountDown - countDownLatch.countDown(); + if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + // Remove only if success + configNodeLocationMap.remove(requestId); + LOGGER.info("Successfully {} on ConfigNode: {}", requestType, formattedTargetLocation); + } else { + LOGGER.error( + "Failed to {} on ConfigNode: {}, response: {}", + requestType, + formattedTargetLocation, + response); } - @Override - public void onError(Exception e) { - String errorMsg = - "Failed to " - + requestType - + " on ConfigNode: " - + formattedTargetLocation - + ", exception: " - + e.getMessage(); - LOGGER.error(errorMsg); + // Always CountDown + countDownLatch.countDown(); + } - responseMap.put( - requestId, - new TSStatus( - RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(), errorMsg))); + @Override + public void onError(Exception e) { + String errorMsg = + "Failed to " + + requestType + + " on ConfigNode: " + + formattedTargetLocation + + ", exception: " + + e.getMessage(); + LOGGER.error(errorMsg); - // Always CountDown - countDownLatch.countDown(); - } + responseMap.put( + requestId, + new TSStatus( + RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(), errorMsg))); + + // Always CountDown + countDownLatch.countDown(); + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java index 8c2e726afd6e..1ba9f4099a3c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java @@ -20,6 +20,7 @@ package org.apache.iotdb.db.protocol.client.dn; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; + import org.apache.thrift.async.AsyncMethodCallback; import java.util.Map; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java index 2be827163fe6..9de2c6349dbf 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java @@ -21,30 +21,24 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.client.exception.ClientManagerException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.concurrent.TimeUnit; /** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ -public class AsyncDataNodeClientPool { +public abstract class AsyncDataNodeClientPool { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeClientPool.class); - private final IClientManager clientManager; + IClientManager clientManager; private static final int MAX_RETRY_NUM = 6; - private AsyncDataNodeClientPool() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); - } + AsyncDataNodeClientPool() {} /** * Send asynchronous requests to the specified DataNodes with default retry num @@ -122,38 +116,11 @@ private void sendAsyncRequest( } } - private void sendAsyncRequestToDataNode( + abstract void sendAsyncRequestToDataNode( AsyncClientHandler clientHandler, int requestId, TDataNodeLocation targetDataNode, - int retryCount) { - - try { - AsyncDataNodeInternalServiceClient client; - client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler handler = - clientHandler.createAsyncRPCHandler(requestId, targetDataNode); - AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; - - switch (clientHandler.getRequestType()) { - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - clientHandler.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetDataNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } - } + int retryCount); /** * Always call this interface when a DataNode is restarted or removed. @@ -164,22 +131,9 @@ public void resetClient(TEndPoint endPoint) { clientManager.clear(endPoint); } - public AsyncDataNodeInternalServiceClient getAsyncClient(TDataNodeLocation targetDataNode) - throws ClientManagerException { + public ClientType getAsyncClient(TDataNodeLocation targetDataNode) throws ClientManagerException { return clientManager.borrowClient(targetDataNode.getInternalEndPoint()); } // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { - - private static final AsyncDataNodeClientPool INSTANCE = new AsyncDataNodeClientPool(); - - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncDataNodeClientPool getInstance() { - return ClientPoolHolder.INSTANCE; - } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java new file mode 100644 index 000000000000..db9cb29fe10c --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java @@ -0,0 +1,88 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; +import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AsyncDataNodeExternalServiceClientPool extends AsyncDataNodeClientPool { + + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncDataNodeExternalServiceClientPool.class); + + public AsyncDataNodeExternalServiceClientPool() { + super(); + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeExternalServiceClientPoolFactory()); + } + + @Override + void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { + { + try { + AsyncDataNodeExternalServiceClient client; + client = clientManager.borrowClient(targetDataNode.getClientRpcEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler handler = + clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; + + switch (clientHandler.getRequestType()) { + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on DataNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetDataNode.getClientRpcEndPoint(), + e.getMessage(), + retryCount); + } + } + } + + private static class ClientPoolHolder { + + private static final AsyncDataNodeExternalServiceClientPool INSTANCE = + new AsyncDataNodeExternalServiceClientPool(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncDataNodeExternalServiceClientPool getInstance() { + return AsyncDataNodeExternalServiceClientPool.ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java new file mode 100644 index 000000000000..1e1e4525773c --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java @@ -0,0 +1,90 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AsyncDataNodeInternalServiceClientPool + extends AsyncDataNodeClientPool { + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncDataNodeInternalServiceClientPool.class); + + public AsyncDataNodeInternalServiceClientPool() { + super(); + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); + } + + @Override + void sendAsyncRequestToDataNode( + AsyncClientHandler clientHandler, + int requestId, + TDataNodeLocation targetDataNode, + int retryCount) { + try { + AsyncDataNodeInternalServiceClient client; + client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler handler = + clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; + + switch (clientHandler.getRequestType()) { + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on DataNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetDataNode.getInternalEndPoint(), + e.getMessage(), + retryCount); + } + } + + private static class ClientPoolHolder { + + private static final AsyncDataNodeInternalServiceClientPool INSTANCE = + new AsyncDataNodeInternalServiceClientPool(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncDataNodeInternalServiceClientPool getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java new file mode 100644 index 000000000000..41dfedae4c23 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java @@ -0,0 +1,89 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncDataNodeMPPDataExchangeServiceClient; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AsyncDataNodeMPPServiceClientPool + extends AsyncDataNodeClientPool { + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncDataNodeMPPServiceClientPool.class); + + public AsyncDataNodeMPPServiceClientPool() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeMPPDataExchangeServiceClientPoolFactory()); + } + + @Override + void sendAsyncRequestToDataNode( + AsyncClientHandler clientHandler, + int requestId, + TDataNodeLocation targetDataNode, + int retryCount) { + try { + AsyncDataNodeMPPDataExchangeServiceClient client; + client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler handler = + clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; + + switch (clientHandler.getRequestType()) { + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on DataNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetDataNode.getInternalEndPoint(), + e.getMessage(), + retryCount); + } + } + + private static class ClientPoolHolder { + + private static final AsyncDataNodeMPPServiceClientPool INSTANCE = + new AsyncDataNodeMPPServiceClientPool(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncDataNodeMPPServiceClientPool getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java index d05ac9e9af90..6ec902825d5c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java @@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 1dbe1458446b..bf6a7192ce3e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -35,11 +35,6 @@ import org.apache.iotdb.common.rpc.thrift.TSettleReq; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; -import org.apache.iotdb.commons.client.ClientPoolFactory; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; -import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; -import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.commons.conf.CommonConfig; import org.apache.iotdb.commons.conf.CommonDescriptor; @@ -82,7 +77,9 @@ import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientPool; import org.apache.iotdb.db.protocol.client.cn.ConfigNodeRequestType; import org.apache.iotdb.db.protocol.client.dn.AsyncClientHandler; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeClientPool; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeExternalServiceClientPool; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeInternalServiceClientPool; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeMPPServiceClientPool; import org.apache.iotdb.db.protocol.client.dn.DataNodeRequestType; import org.apache.iotdb.db.protocol.session.IClientSession; import org.apache.iotdb.db.protocol.session.InternalClientSession; @@ -1428,52 +1425,139 @@ public TFetchFragmentInstanceStatisticsResp fetchFragmentInstanceStatistics( } @Override - public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) throws TException { - List configNodeResult = testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); + public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) + throws TException { + List configNodeResult = + testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); List dataNodeResult = - testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); + testAllDataNodeInternalServiceConnection(nodeLocations.getDataNodeLocations()); + List mppResult = + testAllDataNodeMPPServiceConnection(nodeLocations.getDataNodeLocations()); + List clientResult = testAllDataNodeExternalServiceConnection(nodeLocations.getDataNodeLocations()); configNodeResult.addAll(dataNodeResult); + configNodeResult.addAll(mppResult); + configNodeResult.addAll(clientResult); return new TTestConnectionResp(configNodeResult); } private List testAllConfigNodeConnection( - List configNodeLocations) { + List configNodeLocations) { final TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); Map configNodeLocationMap = - configNodeLocations.stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + configNodeLocations.stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); AsyncConfigNodeClientHandler clientHandler = - new AsyncConfigNodeClientHandler<>(ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); + new AsyncConfigNodeClientHandler<>( + ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNodeWithRetry(clientHandler); Map anotherConfigNodeLocationMap = - configNodeLocations.stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + configNodeLocations.stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); List results = new ArrayList<>(); clientHandler - .getResponseMap() - .forEach( - (configNodeId, status) -> { - TEndPoint endPoint = anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); + .getResponseMap() + .forEach( + (configNodeId, status) -> { + TEndPoint endPoint = + anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); return results; } - private List testAllDataNodeConnection( + private List testAllDataNodeInternalServiceConnection( + List dataNodeLocations) { + final TSender sender = + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + Map dataNodeLocationMap = + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + AsyncClientHandler clientHandler = + new AsyncClientHandler<>( + DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + AsyncDataNodeInternalServiceClientPool.getInstance() + .sendAsyncRequestToDataNodeWithRetry(clientHandler); + Map anotherDataNodeLocationMap = + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + List results = new ArrayList<>(); + clientHandler + .getResponseMap() + .forEach( + (dataNodeId, status) -> { + TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); + return results; + } + + private List testAllDataNodeMPPServiceConnection( + List dataNodeLocations) { + final TSender sender = + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + Map dataNodeLocationMap = + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + AsyncClientHandler clientHandler = + new AsyncClientHandler<>( + DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + AsyncDataNodeMPPServiceClientPool.getInstance() + .sendAsyncRequestToDataNodeWithRetry(clientHandler); + Map anotherDataNodeLocationMap = + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + List results = new ArrayList<>(); + clientHandler + .getResponseMap() + .forEach( + (dataNodeId, status) -> { + TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeMPPService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); + return results; + } + + private List testAllDataNodeExternalServiceConnection( List dataNodeLocations) { final TSender sender = new TSender() @@ -1483,8 +1567,10 @@ private List testAllDataNodeConnection( dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncClientHandler<>( + DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + AsyncDataNodeExternalServiceClientPool.getInstance() + .sendAsyncRequestToDataNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); @@ -1493,9 +1579,9 @@ private List testAllDataNodeConnection( .getResponseMap() .forEach( (dataNodeId, status) -> { - TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); + TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getClientRpcEndPoint(); TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); + new TServiceProvider(endPoint, TServiceType.DataNodeExternalService); TTestConnectionResult result = new TTestConnectionResult(); result.setSender(sender); result.setServiceProvider(serviceProvider); @@ -1510,38 +1596,6 @@ private List testAllDataNodeConnection( return results; } - // @Override - public TTestConnectionResp submitTestConnectionTask1(TNodeLocations nodeLocations) - throws TException { - TTestConnectionResp resp = new TTestConnectionResp(); - IClientManager - dataNodeInternalServiceClientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); - IClientManager - configNodeInternalServiceClientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncConfigNodeHeartbeatServiceClientPoolFactory()); - try { - for (TDataNodeLocation dataNodeLocation : nodeLocations.dataNodeLocations) { - dataNodeInternalServiceClientManager - .borrowClient(dataNodeLocation.getInternalEndPoint()) - .testConnection(null); - } - for (TConfigNodeLocation configNodeLocation : nodeLocations.configNodeLocations) { - configNodeInternalServiceClientManager - .borrowClient(configNodeLocation.getInternalEndPoint()) - .testConnection(null); - } - } catch (ClientManagerException e) { - throw new RuntimeException(e); - } - throw new UnsupportedOperationException(); - // TODO: 其它service - } - @Override public TSStatus testConnection() throws TException { return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index 01b2f2ffcd67..58349a8d6c58 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -20,6 +20,7 @@ package org.apache.iotdb.db.queryengine.plan.execution.config.sys; import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TServiceProvider; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.db.queryengine.common.header.ColumnHeader; @@ -37,8 +38,8 @@ import org.apache.tsfile.read.common.block.TsBlockBuilder; import org.apache.tsfile.utils.Binary; +import java.util.Comparator; import java.util.List; -import java.util.function.Function; import java.util.stream.Collectors; public class TestConnectionTask implements IConfigTask { @@ -57,33 +58,33 @@ public static void buildTSBlock( .collect(Collectors.toList()); TsBlockBuilder builder = new TsBlockBuilder(outputDataTypes); sortTestConnectionResp(resp); - // ServiceProvider column + int maxLen = calculateServiceProviderMaxLen(resp); for (TTestConnectionResult result : resp.getResultList()) { + // ServiceProvider column builder.getTimeColumnBuilder().writeLong(0); - String serviceStr = endPointToString(result.getServiceProvider().getEndPoint()); - serviceStr += " (" + result.getServiceProvider().getServiceType() + ")"; - builder - .getColumnBuilder(0) - .writeBinary( - new Binary(serviceStr, TSFileConfig.STRING_CHARSET)); + StringBuilder serviceStr = new StringBuilder(serviceProviderToString(result.getServiceProvider())); + while (serviceStr.length() < maxLen) { + serviceStr.append(" "); + } + builder.getColumnBuilder(0).writeBinary(new Binary(serviceStr.toString(), TSFileConfig.STRING_CHARSET)); // Sender column String senderStr; if (result.getSender().isSetConfigNodeLocation()) { - senderStr = endPointToString(result.getSender().getConfigNodeLocation().getInternalEndPoint()); + senderStr = + endPointToString(result.getSender().getConfigNodeLocation().getInternalEndPoint()); senderStr += " (ConfigNode)"; } else { - senderStr = endPointToString(result.getSender().getDataNodeLocation().getInternalEndPoint()); + senderStr = + endPointToString(result.getSender().getDataNodeLocation().getInternalEndPoint()); senderStr += " (DataNode)"; } - builder - .getColumnBuilder(1) - .writeBinary(new Binary(senderStr, TSFileConfig.STRING_CHARSET)); + builder.getColumnBuilder(1).writeBinary(new Binary(senderStr, TSFileConfig.STRING_CHARSET)); // Connection column String connectionStatus; if (result.isSuccess()) { connectionStatus = "up"; } else { -// connectionStatus = addLineBreak("down" + " (" + result.getReason() + ")", 60); + // connectionStatus = addLineBreak("down" + " (" + result.getReason() + ")", 60); connectionStatus = "down" + " (" + result.getReason() + ")"; } builder @@ -99,29 +100,46 @@ public static void buildTSBlock( DatasetHeaderFactory.getTestConnectionHeader())); } + private static String serviceProviderToString(TServiceProvider provider) { + String serviceStr = endPointToString(provider.getEndPoint()); + serviceStr += " (" + provider.getServiceType() + ")"; + return serviceStr; + } + private static String endPointToString(TEndPoint endPoint) { return endPoint.getIp() + ":" + endPoint.getPort(); } private static void sortTestConnectionResp(TTestConnectionResp origin) { - origin.getResultList().sort((o1, o2) -> { - if (!o1.getServiceProvider().equals(o2.getServiceProvider())) { - return endPointToString(o1.getServiceProvider().getEndPoint()).compareTo(endPointToString(o2.getServiceProvider().getEndPoint())); - } - TEndPoint sender1; - if (o1.getSender().isSetConfigNodeLocation()) { - sender1 = o1.getSender().getConfigNodeLocation().getInternalEndPoint(); - } else { - sender1 = o1.getSender().getDataNodeLocation().getInternalEndPoint(); - } - TEndPoint sender2; - if (o2.getSender().isSetConfigNodeLocation()) { - sender2 = o2.getSender().getConfigNodeLocation().getInternalEndPoint(); - } else { - sender2 = o2.getSender().getDataNodeLocation().getInternalEndPoint(); - } - return endPointToString(sender1).compareTo(endPointToString(sender2)); - }); + origin + .getResultList() + .sort( + (o1, o2) -> { + if (!o1.getServiceProvider().equals(o2.getServiceProvider())) { + return endPointToString(o1.getServiceProvider().getEndPoint()) + .compareTo(endPointToString(o2.getServiceProvider().getEndPoint())); + } + TEndPoint sender1; + if (o1.getSender().isSetConfigNodeLocation()) { + sender1 = o1.getSender().getConfigNodeLocation().getInternalEndPoint(); + } else { + sender1 = o1.getSender().getDataNodeLocation().getInternalEndPoint(); + } + TEndPoint sender2; + if (o2.getSender().isSetConfigNodeLocation()) { + sender2 = o2.getSender().getConfigNodeLocation().getInternalEndPoint(); + } else { + sender2 = o2.getSender().getDataNodeLocation().getInternalEndPoint(); + } + return endPointToString(sender1).compareTo(endPointToString(sender2)); + }); + } + + private static int calculateServiceProviderMaxLen(TTestConnectionResp origin) { + return origin.getResultList().stream() + .map(TTestConnectionResult::getServiceProvider) + .map(TestConnectionTask::serviceProviderToString) + .max(Comparator.comparingInt(String::length)).get().length(); } private static String addLineBreak(String origin, int interval) { @@ -131,7 +149,7 @@ private static String addLineBreak(String origin, int interval) { StringBuilder builder = new StringBuilder(origin.substring(0, interval)); for (int i = interval; i < origin.length(); i += interval) { builder.append("\n"); - builder.append(origin, i, Math.min(origin.length(), i+interval)); + builder.append(origin, i, Math.min(origin.length(), i + interval)); } return builder.toString(); } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java index 44ef38949891..3347708b9ab6 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java @@ -21,6 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; +import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.client.async.AsyncDataNodeMPPDataExchangeServiceClient; import org.apache.iotdb.commons.client.async.AsyncPipeDataTransferServiceClient; @@ -134,6 +135,31 @@ public KeyedObjectPool createClie } } + public static class AsyncDataNodeExternalServiceClientPoolFactory + implements IClientPoolFactory { + + @Override + public KeyedObjectPool createClientPool( + ClientManager manager) { + GenericKeyedObjectPool clientPool = + new GenericKeyedObjectPool<>( + new AsyncDataNodeExternalServiceClient.Factory( + manager, + new ThriftClientProperty.Builder() + .setConnectionTimeoutMs(conf.getConnectionTimeoutInMS()) + .setRpcThriftCompressionEnabled(conf.isRpcThriftCompressionEnabled()) + .setSelectorNumOfAsyncClientManager(conf.getSelectorNumOfClientManager()) + .build(), + ThreadName.ASYNC_DATANODE_CLIENT_POOL.getName()), + new ClientPoolProperty.Builder() + .build() + .getConfig()); + ClientManagerMetrics.getInstance() + .registerClientManager(this.getClass().getSimpleName(), clientPool); + return clientPool; + } + } + public static class AsyncConfigNodeHeartbeatServiceClientPoolFactory implements IClientPoolFactory { diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncDataNodeExternalServiceClient.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncDataNodeExternalServiceClient.java new file mode 100644 index 000000000000..eb1954d72613 --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncDataNodeExternalServiceClient.java @@ -0,0 +1,173 @@ +/* + * 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.commons.client.async; + +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.commons.pool2.PooledObject; +import org.apache.commons.pool2.impl.DefaultPooledObject; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientManager; +import org.apache.iotdb.commons.client.ThriftClient; +import org.apache.iotdb.commons.client.factory.AsyncThriftClientFactory; +import org.apache.iotdb.commons.client.property.ThriftClientProperty; +import org.apache.iotdb.commons.utils.TestOnly; +import org.apache.iotdb.mpp.rpc.thrift.IDataNodeRPCService; +import org.apache.iotdb.rpc.TNonblockingSocketWrapper; +import org.apache.thrift.async.TAsyncClientManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; + +public class AsyncDataNodeExternalServiceClient extends IDataNodeRPCService.AsyncClient + implements ThriftClient { + + private static final Logger logger = + LoggerFactory.getLogger(AsyncDataNodeExternalServiceClient.class); + + private final boolean printLogWhenEncounterException; + + private final TEndPoint endpoint; + private final ClientManager clientManager; + + public AsyncDataNodeExternalServiceClient( + ThriftClientProperty property, + TEndPoint endpoint, + TAsyncClientManager tClientManager, + ClientManager clientManager) + throws IOException { + super( + property.getProtocolFactory(), + tClientManager, + TNonblockingSocketWrapper.wrap( + endpoint.getIp(), endpoint.getPort(), property.getConnectionTimeoutMs())); + setTimeout(property.getConnectionTimeoutMs()); + this.printLogWhenEncounterException = property.isPrintLogWhenEncounterException(); + this.endpoint = endpoint; + this.clientManager = clientManager; + } + + @TestOnly + public TEndPoint getTEndpoint() { + return endpoint; + } + + @TestOnly + public ClientManager getClientManager() { + return clientManager; + } + + @Override + public void onComplete() { + super.onComplete(); + returnSelf(); + } + + @Override + public void onError(Exception e) { + super.onError(e); + ThriftClient.resolveException(e, this); + returnSelf(); + } + + @Override + public void invalidate() { + if (!hasError()) { + super.onError(new Exception("This client has been invalidated")); + } + } + + @Override + public void invalidateAll() { + clientManager.clear(endpoint); + } + + @Override + public boolean printLogWhenEncounterException() { + return printLogWhenEncounterException; + } + + /** + * return self, the method doesn't need to be called by the user and will be triggered after the + * RPC is finished. + */ + private void returnSelf() { + clientManager.returnClient(endpoint, this); + } + + private void close() { + ___transport.close(); + ___currentMethod = null; + } + + public boolean isReady() { + try { + checkReady(); + return true; + } catch (Exception e) { + if (printLogWhenEncounterException) { + logger.error( + "Unexpected exception occurs in {}, error msg is {}", + this, + ExceptionUtils.getRootCause(e).toString()); + } + return false; + } + } + + @Override + public String toString() { + return String.format("AsyncDataNodeInternalServiceClient{%s}", endpoint); + } + + public static class Factory + extends AsyncThriftClientFactory { + + public Factory( + ClientManager clientManager, + ThriftClientProperty thriftClientProperty, + String threadName) { + super(clientManager, thriftClientProperty, threadName); + } + + @Override + public void destroyObject( + TEndPoint endPoint, PooledObject pooledObject) { + pooledObject.getObject().close(); + } + + @Override + public PooledObject makeObject(TEndPoint endPoint) + throws Exception { + return new DefaultPooledObject<>( + new AsyncDataNodeExternalServiceClient( + thriftClientProperty, + endPoint, + tManagers[clientCnt.incrementAndGet() % tManagers.length], + clientManager)); + } + + @Override + public boolean validateObject( + TEndPoint endPoint, PooledObject pooledObject) { + return pooledObject.getObject().isReady(); + } + } +} diff --git a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift index 8663ed53fdc5..58be65e4805f 100644 --- a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift +++ b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift @@ -188,6 +188,8 @@ struct TLicense { enum TServiceType { ConfigNodeInternalService, DataNodeInternalService, + DataNodeMPPService, + DataNodeExternalService, } struct TServiceProvider { From 13e7713f62cb69ff0b709d396a761547a772f489 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 7 Jun 2024 11:56:10 +0800 Subject: [PATCH 15/52] bad refactor --- .../client/dn/AsyncClientHandler.java | 159 --------------- .../client/dn/AsyncDataNodeClientPool.java | 10 +- ...syncDataNodeExternalServiceClientPool.java | 3 +- ...syncDataNodeInternalServiceClientPool.java | 2 +- .../dn/AsyncDataNodeMPPServiceClientPool.java | 2 +- .../dn/AsyncDataNodeRequestContext.java | 61 ++++++ .../impl/DataNodeInternalRPCServiceImpl.java | 16 +- .../client/gg/AbstractAsyncRPCHandler.java | 79 ++++++++ .../commons/client/gg/AsyncClientPool.java | 191 ++++++++++++++++++ .../client/gg/AsyncRequestContext.java | 144 +++++++++++++ 10 files changed, 491 insertions(+), 176 deletions(-) delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncClientPool.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java deleted file mode 100644 index f13d5cb864a5..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java +++ /dev/null @@ -1,159 +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.iotdb.db.protocol.client.dn; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TSStatus; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public class AsyncClientHandler { - - // Type of RPC request - protected final DataNodeRequestType requestType; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The corresponding RPC request - */ - private final Map requestMap; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target DataNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetDataNode from the dataNodeLocationMap only - * if its corresponding RPC request success - */ - private final Map dataNodeLocationMap; - - /** - * Map key: The indices(targetDataNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - private final Map responseMap; - - private CountDownLatch countDownLatch; - - /** Custom constructor. */ - public AsyncClientHandler(DataNodeRequestType requestType) { - this.requestType = requestType; - this.requestMap = new ConcurrentHashMap<>(); - this.dataNodeLocationMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - public void putRequest(int requestId, Q request) { - requestMap.put(requestId, request); - } - - public void putDataNodeLocation(int requestId, TDataNodeLocation dataNodeLocation) { - dataNodeLocationMap.put(requestId, dataNodeLocation); - } - - /** Constructor for null requests. */ - public AsyncClientHandler( - DataNodeRequestType requestType, Map dataNodeLocationMap) { - this.requestType = requestType; - this.dataNodeLocationMap = dataNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - /** Constructor for unique request. */ - public AsyncClientHandler( - DataNodeRequestType requestType, - Q request, - Map dataNodeLocationMap) { - this.requestType = requestType; - this.dataNodeLocationMap = dataNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.dataNodeLocationMap - .keySet() - .forEach(dataNodeId -> this.requestMap.put(dataNodeId, request)); - - this.responseMap = new ConcurrentHashMap<>(); - } - - public DataNodeRequestType getRequestType() { - return requestType; - } - - public List getRequestIndices() { - return new ArrayList<>(dataNodeLocationMap.keySet()); - } - - public Q getRequest(int requestId) { - return requestMap.get(requestId); - } - - public TDataNodeLocation getDataNodeLocation(int requestId) { - return dataNodeLocationMap.get(requestId); - } - - public List getResponseList() { - return new ArrayList<>(responseMap.values()); - } - - public Map getResponseMap() { - return responseMap; - } - - /** Always reset CountDownLatch before retry. */ - public void resetCountDownLatch() { - countDownLatch = new CountDownLatch(dataNodeLocationMap.size()); - } - - public CountDownLatch getCountDownLatch() { - return countDownLatch; - } - - public AbstractAsyncRPCHandler createAsyncRPCHandler( - int requestId, TDataNodeLocation targetDataNode) { - switch (requestType) { - default: - return new AsyncTSStatusRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - } - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java index 9de2c6349dbf..af695c65c659 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java @@ -49,7 +49,7 @@ public abstract class AsyncDataNodeClientPool { * @param timeoutInMs timeout in milliseconds */ public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( - AsyncClientHandler clientHandler, long timeoutInMs) { + AsyncDataNodeRequestContext clientHandler, long timeoutInMs) { sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); } @@ -60,16 +60,16 @@ public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( * * @param clientHandler which will also contain the result */ - public void sendAsyncRequestToDataNodeWithRetry(AsyncClientHandler clientHandler) { + public void sendAsyncRequestToDataNodeWithRetry(AsyncDataNodeRequestContext clientHandler) { sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); } - public void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler) { + public void sendAsyncRequestToDataNode(AsyncDataNodeRequestContext clientHandler) { sendAsyncRequest(clientHandler, 1, null); } private void sendAsyncRequest( - AsyncClientHandler clientHandler, int retryNum, Long timeoutInMs) { + AsyncDataNodeRequestContext clientHandler, int retryNum, Long timeoutInMs) { if (clientHandler.getRequestIndices().isEmpty()) { return; } @@ -117,7 +117,7 @@ private void sendAsyncRequest( } abstract void sendAsyncRequestToDataNode( - AsyncClientHandler clientHandler, + AsyncDataNodeRequestContext clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java index db9cb29fe10c..208dd504dd3c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java @@ -24,7 +24,6 @@ import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; -import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +41,7 @@ public AsyncDataNodeExternalServiceClientPool() { } @Override - void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { + void sendAsyncRequestToDataNode(AsyncDataNodeRequestContext clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { { try { AsyncDataNodeExternalServiceClient client; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java index 1e1e4525773c..c8e8550d748b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java @@ -43,7 +43,7 @@ public AsyncDataNodeInternalServiceClientPool() { @Override void sendAsyncRequestToDataNode( - AsyncClientHandler clientHandler, + AsyncDataNodeRequestContext clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java index 41dfedae4c23..e96294f3c0fe 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java @@ -42,7 +42,7 @@ public AsyncDataNodeMPPServiceClientPool() { @Override void sendAsyncRequestToDataNode( - AsyncClientHandler clientHandler, + AsyncDataNodeRequestContext clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java new file mode 100644 index 000000000000..73b5e148c580 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java @@ -0,0 +1,61 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; + +import java.util.Map; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncDataNodeRequestContext extends AsyncRequestContext { + + public AsyncDataNodeRequestContext(DataNodeRequestType dataNodeRequestType) { + super(dataNodeRequestType); + } + + public AsyncDataNodeRequestContext(DataNodeRequestType dataNodeRequestType, Map configNodeLocationMap) { + super(dataNodeRequestType, configNodeLocationMap); + } + + public AsyncDataNodeRequestContext(DataNodeRequestType dataNodeRequestType, Request request, Map configNodeLocationMap) { + super(dataNodeRequestType, request, configNodeLocationMap); + } + + public AbstractAsyncRPCHandler createAsyncRPCHandler( + int requestId, TDataNodeLocation targetDataNode) { + switch (requestType) { + default: + return new AsyncTSStatusRPCHandler( + requestType, + requestId, + targetDataNode, + nodeLocationMap, + (Map) responseMap, // TODO: 研究一下能不能不强转 + countDownLatch); + } + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index bf6a7192ce3e..fb55fba4c19b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -76,7 +76,7 @@ import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientHandler; import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientPool; import org.apache.iotdb.db.protocol.client.cn.ConfigNodeRequestType; -import org.apache.iotdb.db.protocol.client.dn.AsyncClientHandler; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeRequestContext; import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeExternalServiceClientPool; import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeInternalServiceClientPool; import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeMPPServiceClientPool; @@ -1488,8 +1488,8 @@ private List testAllDataNodeInternalServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeInternalServiceClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetry(clientHandler); @@ -1501,7 +1501,7 @@ private List testAllDataNodeInternalServiceConnection( .getResponseMap() .forEach( (dataNodeId, status) -> { - TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); + TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); TTestConnectionResult result = new TTestConnectionResult(); @@ -1527,8 +1527,8 @@ private List testAllDataNodeMPPServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeMPPServiceClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetry(clientHandler); @@ -1566,8 +1566,8 @@ private List testAllDataNodeExternalServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeExternalServiceClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetry(clientHandler); diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java new file mode 100644 index 000000000000..8c50a0c145fb --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java @@ -0,0 +1,79 @@ +/* + * 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.commons.client.gg; + +import org.apache.thrift.async.AsyncMethodCallback; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { + + // Type of RPC request + protected final RequestType requestType; + // Index of request + protected final int requestId; + // Target ConfigNode + protected final Location targetConfigNode; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target ConfigNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap + * only if its corresponding RPC request success + */ + protected final Map nodeLocationMap; + + /** + * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + protected final Map responseMap; + + // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished + protected final CountDownLatch countDownLatch; + + protected final String formattedTargetLocation; + + abstract protected String locationToString(Location location); + + protected AbstractAsyncRPCHandler( + RequestType requestType, + int requestId, + Location target, + Map nodeLocationMap, + Map responseMap, + CountDownLatch countDownLatch) { + this.requestType = requestType; + this.requestId = requestId; + this.targetConfigNode = target; + this.formattedTargetLocation = locationToString(target); + + this.nodeLocationMap = nodeLocationMap; + this.responseMap = responseMap; + this.countDownLatch = countDownLatch; + } +} diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncClientPool.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncClientPool.java new file mode 100644 index 000000000000..3cabedfbe015 --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncClientPool.java @@ -0,0 +1,191 @@ +/* + * 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.commons.client.gg; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.IClientPoolFactory; +import org.apache.iotdb.commons.client.async.Client; +import org.apache.iotdb.commons.client.exception.ClientManagerException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ +public abstract class AsyncClientPool { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncClientPool.class); + + private final IClientManager clientManager; + + private static final int MAX_RETRY_NUM = 6; + + private AsyncClientPool() { + clientManager = + new IClientManager.Factory() + .createClientManager(getClientPoolFactory()); + } + + protected abstract IClientPoolFactory getClientPoolFactory(); + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + * @param timeoutInMs timeout in milliseconds + */ + public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( + AsyncRequestContext clientHandler, long timeoutInMs) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); + } + + /** + * Send asynchronous requests to the specified ConfigNodes with default retry num + * + *

Notice: The ConfigNodes that failed to receive the requests will be reconnected + * + * @param clientHandler which will also contain the result + */ + public void sendAsyncRequestToConfigNodeWithRetry( + AsyncRequestContext clientHandler) { + sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); + } + + public void sendAsyncRequestToConfigNode(AsyncRequestContext clientHandler) { + sendAsyncRequest(clientHandler, 1, null); + } + + private void sendAsyncRequest( + AsyncRequestContext clientHandler, int retryNum, Long timeoutInMs) { + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } + + RequestType requestType = clientHandler.getRequestType(); + for (int retry = 0; retry < retryNum; retry++) { + // Always Reset CountDownLatch first + clientHandler.resetCountDownLatch(); + + // Send requests to all targetConfigNodes + for (int requestId : clientHandler.getRequestIndices()) { + Location targetConfigNode = clientHandler.getNodeLocation(requestId); + sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); + } + + // Wait for this batch of asynchronous RPC requests finish + try { + if (timeoutInMs == null) { + clientHandler.getCountDownLatch().await(); + } else { + if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { + LOGGER.warn( + "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + } + } + } catch (InterruptedException e) { + LOGGER.error( + "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + Thread.currentThread().interrupt(); + } + + // Check if there is a ConfigNode that fails to execute the request, and retry if there exists + if (clientHandler.getRequestIndices().isEmpty()) { + return; + } + } + + if (!clientHandler.getRequestIndices().isEmpty()) { + LOGGER.warn( + "Failed to {} on ConfigNode after {} retries, requestIndices: {}", + requestType, + retryNum, + clientHandler.getRequestIndices()); + } + } + + private void sendAsyncRequestToConfigNode( + AsyncRequestContext clientHandler, + int requestId, + TConfigNodeLocation targetConfigNode, + int retryCount) { + + try { + Client client; + client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler2 handler = + clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); + AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; + + switch (clientHandler.getRequestType()) { + // case SUBMIT_TEST_CONNECTION_TASK: + // client.submitTestConnectionTask((TNodeLocations) req, + // (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); + // break; + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", + clientHandler.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on ConfigNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetConfigNode.getInternalEndPoint(), + e.getMessage(), + retryCount); + } + } + + /** + * Always call this interface when a ConfigNode is restarted or removed. + * + * @param endPoint The specific ConfigNode + */ + public void resetClient(TEndPoint endPoint) { + clientManager.clear(endPoint); + } + + public Client getAsyncClient(TConfigNodeLocation targetConfigNode) + throws ClientManagerException { + return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); + } + + // TODO: Is the ClientPool must be a singleton? + private static class ClientPoolHolder { + + private static final AsyncClientPool INSTANCE = new AsyncClientPool(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncClientPool getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java new file mode 100644 index 000000000000..72fb58b77e3c --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java @@ -0,0 +1,144 @@ +/* + * 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.commons.client.gg; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public abstract class AsyncRequestContext { + + // Type of RPC request + protected final RequestType requestType; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The corresponding RPC request + */ + private final Map requestMap; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target Nodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetNode from the nodeLocationMap + * only if its corresponding RPC request success + */ + protected final Map nodeLocationMap; + + /** + * Map key: The indices(targetNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + protected final Map responseMap; + + protected CountDownLatch countDownLatch; + + /** Custom constructor. */ + public AsyncRequestContext(RequestType requestType) { + this.requestType = requestType; + this.requestMap = new ConcurrentHashMap<>(); + this.nodeLocationMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + public void putRequest(int requestId, Request request) { + requestMap.put(requestId, request); + } + + public void putNodeLocation(int requestId, Location nodeLocation) { + nodeLocationMap.put(requestId, nodeLocation); + } + + /** Constructor for null requests. */ + public AsyncRequestContext( + RequestType requestType, Map nodeLocationMap) { + this.requestType = requestType; + this.nodeLocationMap = nodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + /** Constructor for unique request. */ + public AsyncRequestContext( + RequestType requestType, + Request request, + Map nodeLocationMap) { + this.requestType = requestType; + this.nodeLocationMap = nodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.nodeLocationMap + .keySet() + .forEach(nodeId -> this.requestMap.put(nodeId, request)); + + this.responseMap = new ConcurrentHashMap<>(); + } + + public RequestType getRequestType() { + return requestType; + } + + public List getRequestIndices() { + return new ArrayList<>(nodeLocationMap.keySet()); + } + + public Request getRequest(int requestId) { + return requestMap.get(requestId); + } + + public Location getNodeLocation(int requestId) { + return nodeLocationMap.get(requestId); + } + + public List getResponseList() { + return new ArrayList<>(responseMap.values()); + } + + public Map getResponseMap() { + return responseMap; + } + + /** Always reset CountDownLatch before retry. */ + public void resetCountDownLatch() { + countDownLatch = new CountDownLatch(nodeLocationMap.size()); + } + + public CountDownLatch getCountDownLatch() { + return countDownLatch; + } + + abstract public CallbackHandler createAsyncRPCHandler(int requestId, Location targetNode); +} From 856e7262507060fb7593edd60329b5b8e6cb6443 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 7 Jun 2024 15:01:47 +0800 Subject: [PATCH 16/52] Revert "bad refactor" This reverts commit 13e7713f62cb69ff0b709d396a761547a772f489. --- .../client/dn/AsyncClientHandler.java | 159 +++++++++++++++ .../client/dn/AsyncDataNodeClientPool.java | 10 +- ...syncDataNodeExternalServiceClientPool.java | 3 +- ...syncDataNodeInternalServiceClientPool.java | 2 +- .../dn/AsyncDataNodeMPPServiceClientPool.java | 2 +- .../dn/AsyncDataNodeRequestContext.java | 61 ------ .../impl/DataNodeInternalRPCServiceImpl.java | 16 +- .../client/gg/AbstractAsyncRPCHandler.java | 79 -------- .../commons/client/gg/AsyncClientPool.java | 191 ------------------ .../client/gg/AsyncRequestContext.java | 144 ------------- 10 files changed, 176 insertions(+), 491 deletions(-) create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java delete mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java delete mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncClientPool.java delete mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java new file mode 100644 index 000000000000..f13d5cb864a5 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java @@ -0,0 +1,159 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncClientHandler { + + // Type of RPC request + protected final DataNodeRequestType requestType; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The corresponding RPC request + */ + private final Map requestMap; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target DataNodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetDataNode from the dataNodeLocationMap only + * if its corresponding RPC request success + */ + private final Map dataNodeLocationMap; + + /** + * Map key: The indices(targetDataNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + private final Map responseMap; + + private CountDownLatch countDownLatch; + + /** Custom constructor. */ + public AsyncClientHandler(DataNodeRequestType requestType) { + this.requestType = requestType; + this.requestMap = new ConcurrentHashMap<>(); + this.dataNodeLocationMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + public void putRequest(int requestId, Q request) { + requestMap.put(requestId, request); + } + + public void putDataNodeLocation(int requestId, TDataNodeLocation dataNodeLocation) { + dataNodeLocationMap.put(requestId, dataNodeLocation); + } + + /** Constructor for null requests. */ + public AsyncClientHandler( + DataNodeRequestType requestType, Map dataNodeLocationMap) { + this.requestType = requestType; + this.dataNodeLocationMap = dataNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + /** Constructor for unique request. */ + public AsyncClientHandler( + DataNodeRequestType requestType, + Q request, + Map dataNodeLocationMap) { + this.requestType = requestType; + this.dataNodeLocationMap = dataNodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.dataNodeLocationMap + .keySet() + .forEach(dataNodeId -> this.requestMap.put(dataNodeId, request)); + + this.responseMap = new ConcurrentHashMap<>(); + } + + public DataNodeRequestType getRequestType() { + return requestType; + } + + public List getRequestIndices() { + return new ArrayList<>(dataNodeLocationMap.keySet()); + } + + public Q getRequest(int requestId) { + return requestMap.get(requestId); + } + + public TDataNodeLocation getDataNodeLocation(int requestId) { + return dataNodeLocationMap.get(requestId); + } + + public List getResponseList() { + return new ArrayList<>(responseMap.values()); + } + + public Map getResponseMap() { + return responseMap; + } + + /** Always reset CountDownLatch before retry. */ + public void resetCountDownLatch() { + countDownLatch = new CountDownLatch(dataNodeLocationMap.size()); + } + + public CountDownLatch getCountDownLatch() { + return countDownLatch; + } + + public AbstractAsyncRPCHandler createAsyncRPCHandler( + int requestId, TDataNodeLocation targetDataNode) { + switch (requestType) { + default: + return new AsyncTSStatusRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + } + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java index af695c65c659..9de2c6349dbf 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java @@ -49,7 +49,7 @@ public abstract class AsyncDataNodeClientPool { * @param timeoutInMs timeout in milliseconds */ public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( - AsyncDataNodeRequestContext clientHandler, long timeoutInMs) { + AsyncClientHandler clientHandler, long timeoutInMs) { sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); } @@ -60,16 +60,16 @@ public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( * * @param clientHandler which will also contain the result */ - public void sendAsyncRequestToDataNodeWithRetry(AsyncDataNodeRequestContext clientHandler) { + public void sendAsyncRequestToDataNodeWithRetry(AsyncClientHandler clientHandler) { sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); } - public void sendAsyncRequestToDataNode(AsyncDataNodeRequestContext clientHandler) { + public void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler) { sendAsyncRequest(clientHandler, 1, null); } private void sendAsyncRequest( - AsyncDataNodeRequestContext clientHandler, int retryNum, Long timeoutInMs) { + AsyncClientHandler clientHandler, int retryNum, Long timeoutInMs) { if (clientHandler.getRequestIndices().isEmpty()) { return; } @@ -117,7 +117,7 @@ private void sendAsyncRequest( } abstract void sendAsyncRequestToDataNode( - AsyncDataNodeRequestContext clientHandler, + AsyncClientHandler clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java index 208dd504dd3c..db9cb29fe10c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java @@ -24,6 +24,7 @@ import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; +import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +42,7 @@ public AsyncDataNodeExternalServiceClientPool() { } @Override - void sendAsyncRequestToDataNode(AsyncDataNodeRequestContext clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { + void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { { try { AsyncDataNodeExternalServiceClient client; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java index c8e8550d748b..1e1e4525773c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java @@ -43,7 +43,7 @@ public AsyncDataNodeInternalServiceClientPool() { @Override void sendAsyncRequestToDataNode( - AsyncDataNodeRequestContext clientHandler, + AsyncClientHandler clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java index e96294f3c0fe..41dfedae4c23 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java @@ -42,7 +42,7 @@ public AsyncDataNodeMPPServiceClientPool() { @Override void sendAsyncRequestToDataNode( - AsyncDataNodeRequestContext clientHandler, + AsyncClientHandler clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java deleted file mode 100644 index 73b5e148c580..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java +++ /dev/null @@ -1,61 +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.iotdb.db.protocol.client.dn; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; - -import java.util.Map; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public class AsyncDataNodeRequestContext extends AsyncRequestContext { - - public AsyncDataNodeRequestContext(DataNodeRequestType dataNodeRequestType) { - super(dataNodeRequestType); - } - - public AsyncDataNodeRequestContext(DataNodeRequestType dataNodeRequestType, Map configNodeLocationMap) { - super(dataNodeRequestType, configNodeLocationMap); - } - - public AsyncDataNodeRequestContext(DataNodeRequestType dataNodeRequestType, Request request, Map configNodeLocationMap) { - super(dataNodeRequestType, request, configNodeLocationMap); - } - - public AbstractAsyncRPCHandler createAsyncRPCHandler( - int requestId, TDataNodeLocation targetDataNode) { - switch (requestType) { - default: - return new AsyncTSStatusRPCHandler( - requestType, - requestId, - targetDataNode, - nodeLocationMap, - (Map) responseMap, // TODO: 研究一下能不能不强转 - countDownLatch); - } - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index fb55fba4c19b..bf6a7192ce3e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -76,7 +76,7 @@ import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientHandler; import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientPool; import org.apache.iotdb.db.protocol.client.cn.ConfigNodeRequestType; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeRequestContext; +import org.apache.iotdb.db.protocol.client.dn.AsyncClientHandler; import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeExternalServiceClientPool; import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeInternalServiceClientPool; import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeMPPServiceClientPool; @@ -1488,8 +1488,8 @@ private List testAllDataNodeInternalServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + AsyncClientHandler clientHandler = + new AsyncClientHandler<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeInternalServiceClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetry(clientHandler); @@ -1501,7 +1501,7 @@ private List testAllDataNodeInternalServiceConnection( .getResponseMap() .forEach( (dataNodeId, status) -> { - TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); + TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); TTestConnectionResult result = new TTestConnectionResult(); @@ -1527,8 +1527,8 @@ private List testAllDataNodeMPPServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + AsyncClientHandler clientHandler = + new AsyncClientHandler<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeMPPServiceClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetry(clientHandler); @@ -1566,8 +1566,8 @@ private List testAllDataNodeExternalServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + AsyncClientHandler clientHandler = + new AsyncClientHandler<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeExternalServiceClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetry(clientHandler); diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java deleted file mode 100644 index 8c50a0c145fb..000000000000 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java +++ /dev/null @@ -1,79 +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.iotdb.commons.client.gg; - -import org.apache.thrift.async.AsyncMethodCallback; - -import java.util.Map; -import java.util.concurrent.CountDownLatch; - -public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { - - // Type of RPC request - protected final RequestType requestType; - // Index of request - protected final int requestId; - // Target ConfigNode - protected final Location targetConfigNode; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target ConfigNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap - * only if its corresponding RPC request success - */ - protected final Map nodeLocationMap; - - /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - protected final Map responseMap; - - // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished - protected final CountDownLatch countDownLatch; - - protected final String formattedTargetLocation; - - abstract protected String locationToString(Location location); - - protected AbstractAsyncRPCHandler( - RequestType requestType, - int requestId, - Location target, - Map nodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - this.requestType = requestType; - this.requestId = requestId; - this.targetConfigNode = target; - this.formattedTargetLocation = locationToString(target); - - this.nodeLocationMap = nodeLocationMap; - this.responseMap = responseMap; - this.countDownLatch = countDownLatch; - } -} diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncClientPool.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncClientPool.java deleted file mode 100644 index 3cabedfbe015..000000000000 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncClientPool.java +++ /dev/null @@ -1,191 +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.iotdb.commons.client.gg; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.IClientPoolFactory; -import org.apache.iotdb.commons.client.async.Client; -import org.apache.iotdb.commons.client.exception.ClientManagerException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.TimeUnit; - -/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ -public abstract class AsyncClientPool { - - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncClientPool.class); - - private final IClientManager clientManager; - - private static final int MAX_RETRY_NUM = 6; - - private AsyncClientPool() { - clientManager = - new IClientManager.Factory() - .createClientManager(getClientPoolFactory()); - } - - protected abstract IClientPoolFactory getClientPoolFactory(); - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - * @param timeoutInMs timeout in milliseconds - */ - public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( - AsyncRequestContext clientHandler, long timeoutInMs) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); - } - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - */ - public void sendAsyncRequestToConfigNodeWithRetry( - AsyncRequestContext clientHandler) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); - } - - public void sendAsyncRequestToConfigNode(AsyncRequestContext clientHandler) { - sendAsyncRequest(clientHandler, 1, null); - } - - private void sendAsyncRequest( - AsyncRequestContext clientHandler, int retryNum, Long timeoutInMs) { - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - - RequestType requestType = clientHandler.getRequestType(); - for (int retry = 0; retry < retryNum; retry++) { - // Always Reset CountDownLatch first - clientHandler.resetCountDownLatch(); - - // Send requests to all targetConfigNodes - for (int requestId : clientHandler.getRequestIndices()) { - Location targetConfigNode = clientHandler.getNodeLocation(requestId); - sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); - } - - // Wait for this batch of asynchronous RPC requests finish - try { - if (timeoutInMs == null) { - clientHandler.getCountDownLatch().await(); - } else { - if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { - LOGGER.warn( - "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - } - } - } catch (InterruptedException e) { - LOGGER.error( - "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - Thread.currentThread().interrupt(); - } - - // Check if there is a ConfigNode that fails to execute the request, and retry if there exists - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - } - - if (!clientHandler.getRequestIndices().isEmpty()) { - LOGGER.warn( - "Failed to {} on ConfigNode after {} retries, requestIndices: {}", - requestType, - retryNum, - clientHandler.getRequestIndices()); - } - } - - private void sendAsyncRequestToConfigNode( - AsyncRequestContext clientHandler, - int requestId, - TConfigNodeLocation targetConfigNode, - int retryCount) { - - try { - Client client; - client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler2 handler = - clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); - AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; - - switch (clientHandler.getRequestType()) { - // case SUBMIT_TEST_CONNECTION_TASK: - // client.submitTestConnectionTask((TNodeLocations) req, - // (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); - // break; - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", - clientHandler.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on ConfigNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetConfigNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } - } - - /** - * Always call this interface when a ConfigNode is restarted or removed. - * - * @param endPoint The specific ConfigNode - */ - public void resetClient(TEndPoint endPoint) { - clientManager.clear(endPoint); - } - - public Client getAsyncClient(TConfigNodeLocation targetConfigNode) - throws ClientManagerException { - return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - } - - // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { - - private static final AsyncClientPool INSTANCE = new AsyncClientPool(); - - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncClientPool getInstance() { - return ClientPoolHolder.INSTANCE; - } -} diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java deleted file mode 100644 index 72fb58b77e3c..000000000000 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java +++ /dev/null @@ -1,144 +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.iotdb.commons.client.gg; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public abstract class AsyncRequestContext { - - // Type of RPC request - protected final RequestType requestType; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The corresponding RPC request - */ - private final Map requestMap; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target Nodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetNode from the nodeLocationMap - * only if its corresponding RPC request success - */ - protected final Map nodeLocationMap; - - /** - * Map key: The indices(targetNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - protected final Map responseMap; - - protected CountDownLatch countDownLatch; - - /** Custom constructor. */ - public AsyncRequestContext(RequestType requestType) { - this.requestType = requestType; - this.requestMap = new ConcurrentHashMap<>(); - this.nodeLocationMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - public void putRequest(int requestId, Request request) { - requestMap.put(requestId, request); - } - - public void putNodeLocation(int requestId, Location nodeLocation) { - nodeLocationMap.put(requestId, nodeLocation); - } - - /** Constructor for null requests. */ - public AsyncRequestContext( - RequestType requestType, Map nodeLocationMap) { - this.requestType = requestType; - this.nodeLocationMap = nodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - /** Constructor for unique request. */ - public AsyncRequestContext( - RequestType requestType, - Request request, - Map nodeLocationMap) { - this.requestType = requestType; - this.nodeLocationMap = nodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.nodeLocationMap - .keySet() - .forEach(nodeId -> this.requestMap.put(nodeId, request)); - - this.responseMap = new ConcurrentHashMap<>(); - } - - public RequestType getRequestType() { - return requestType; - } - - public List getRequestIndices() { - return new ArrayList<>(nodeLocationMap.keySet()); - } - - public Request getRequest(int requestId) { - return requestMap.get(requestId); - } - - public Location getNodeLocation(int requestId) { - return nodeLocationMap.get(requestId); - } - - public List getResponseList() { - return new ArrayList<>(responseMap.values()); - } - - public Map getResponseMap() { - return responseMap; - } - - /** Always reset CountDownLatch before retry. */ - public void resetCountDownLatch() { - countDownLatch = new CountDownLatch(nodeLocationMap.size()); - } - - public CountDownLatch getCountDownLatch() { - return countDownLatch; - } - - abstract public CallbackHandler createAsyncRPCHandler(int requestId, Location targetNode); -} From f3a2f8f10c36a0dbd88f004e27705171c9cf7312 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 7 Jun 2024 15:40:28 +0800 Subject: [PATCH 17/52] rename Handler to Context && move a function --- .../client/async/AsyncDataNodeClientPool.java | 38 +++-- ...tHandler.java => AsyncRequestContext.java} | 155 +---------------- .../handlers/rpc/AbstractAsyncRPCHandler.java | 160 ++++++++++++++++++ .../confignode/manager/ClusterManager.java | 14 +- .../manager/ClusterQuotaManager.java | 10 +- .../confignode/manager/TriggerManager.java | 6 +- .../iotdb/confignode/manager/UDFManager.java | 10 +- .../manager/load/balancer/RouteBalancer.java | 10 +- .../confignode/manager/node/NodeManager.java | 34 ++-- .../manager/partition/PartitionManager.java | 14 +- .../runtime/PipeHeartbeatScheduler.java | 6 +- .../manager/schema/ClusterSchemaManager.java | 10 +- .../procedure/env/ConfigNodeProcedureEnv.java | 92 +++++----- .../procedure/env/RegionMaintainHandler.java | 6 +- .../schema/AlterLogicalViewProcedure.java | 6 +- .../schema/DataNodeRegionTaskExecutor.java | 8 +- .../schema/DeactivateTemplateProcedure.java | 6 +- .../impl/schema/DeleteDatabaseProcedure.java | 6 +- .../schema/DeleteLogicalViewProcedure.java | 6 +- .../schema/DeleteTimeSeriesProcedure.java | 6 +- .../impl/schema/SetTemplateProcedure.java | 14 +- .../impl/schema/UnsetTemplateProcedure.java | 10 +- 22 files changed, 331 insertions(+), 296 deletions(-) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/{AsyncClientHandler.java => AsyncRequestContext.java} (55%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index 3d4df4160fba..367bca33cb43 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -24,15 +24,17 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.common.rpc.thrift.TFlushReq; import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; @@ -49,11 +51,14 @@ import org.apache.iotdb.mpp.rpc.thrift.TActiveTriggerInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TAlterViewReq; import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateResp; import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceReq; +import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceResp; import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListReq; import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListWithTemplateReq; import org.apache.iotdb.mpp.rpc.thrift.TConstructViewSchemaBlackListReq; import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateResp; import org.apache.iotdb.mpp.rpc.thrift.TCreateDataRegionReq; import org.apache.iotdb.mpp.rpc.thrift.TCreateFunctionInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TCreatePipePluginInstanceReq; @@ -67,18 +72,24 @@ import org.apache.iotdb.mpp.rpc.thrift.TDropPipePluginInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TDropTriggerInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListResp; import org.apache.iotdb.mpp.rpc.thrift.TInactiveTriggerInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TInvalidateMatchedSchemaCacheReq; import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatReq; +import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatResp; import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaResp; import org.apache.iotdb.mpp.rpc.thrift.TPushMultiPipeMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushMultiTopicMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaResp; import org.apache.iotdb.mpp.rpc.thrift.TPushSingleConsumerGroupMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushSinglePipeMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushSingleTopicMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeReq; +import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeResp; import org.apache.iotdb.mpp.rpc.thrift.TRegionRouteReq; import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListReq; @@ -90,6 +101,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ @@ -117,7 +130,7 @@ private AsyncDataNodeClientPool() { * @param timeoutInMs timeout in milliseconds */ public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( - AsyncClientHandler clientHandler, long timeoutInMs) { + AsyncRequestContext clientHandler, long timeoutInMs) { sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); } @@ -128,16 +141,16 @@ public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( * * @param clientHandler which will also contain the result */ - public void sendAsyncRequestToDataNodeWithRetry(AsyncClientHandler clientHandler) { + public void sendAsyncRequestToDataNodeWithRetry(AsyncRequestContext clientHandler) { sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); } - public void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler) { + public void sendAsyncRequestToDataNode(AsyncRequestContext clientHandler) { sendAsyncRequest(clientHandler, 1, null); } private void sendAsyncRequest( - AsyncClientHandler clientHandler, int retryNum, Long timeoutInMs) { + AsyncRequestContext clientHandler, int retryNum, Long timeoutInMs) { if (clientHandler.getRequestIndices().isEmpty()) { return; } @@ -185,7 +198,7 @@ private void sendAsyncRequest( } private void sendAsyncRequestToDataNode( - AsyncClientHandler clientHandler, + AsyncRequestContext requestContext, int requestId, TDataNodeLocation targetDataNode, int retryCount) { @@ -193,16 +206,15 @@ private void sendAsyncRequestToDataNode( try { AsyncDataNodeInternalServiceClient client; client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler handler = - clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + Object req = requestContext.getRequest(requestId); + AbstractAsyncRPCHandler handler = AbstractAsyncRPCHandler.create(requestContext, requestId, targetDataNode); AsyncTSStatusRPCHandler defaultHandler = null; if (handler instanceof AsyncTSStatusRPCHandler) { defaultHandler = (AsyncTSStatusRPCHandler) handler; } - switch (clientHandler.getRequestType()) { + switch (requestContext.getRequestType()) { case SET_TTL: client.setTTL((TSetTTLReq) req, defaultHandler); break; @@ -388,12 +400,12 @@ private void sendAsyncRequestToDataNode( default: LOGGER.error( "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - clientHandler.getRequestType()); + requestContext.getRequestType()); } } catch (Exception e) { LOGGER.warn( "{} failed on DataNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), + requestContext.getRequestType(), targetDataNode.getInternalEndPoint(), e.getMessage(), retryCount); @@ -409,6 +421,8 @@ public void resetClient(TEndPoint endPoint) { clientManager.clear(endPoint); } + + public AsyncDataNodeInternalServiceClient getAsyncClient(TDataNodeLocation targetDataNode) throws ClientManagerException { return clientManager.borrowClient(targetDataNode.getInternalEndPoint()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncRequestContext.java similarity index 55% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncRequestContext.java index 764a7cbddbaa..a9dcc6dee98c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncClientHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncRequestContext.java @@ -58,7 +58,7 @@ * @param ClassName of RPC request * @param ClassName of RPC response */ -public class AsyncClientHandler { +public class AsyncRequestContext { // Type of RPC request protected final DataNodeRequestType requestType; @@ -93,7 +93,7 @@ public class AsyncClientHandler { private CountDownLatch countDownLatch; /** Custom constructor. */ - public AsyncClientHandler(DataNodeRequestType requestType) { + public AsyncRequestContext(DataNodeRequestType requestType) { this.requestType = requestType; this.requestMap = new ConcurrentHashMap<>(); this.dataNodeLocationMap = new ConcurrentHashMap<>(); @@ -109,7 +109,7 @@ public void putDataNodeLocation(int requestId, TDataNodeLocation dataNodeLocatio } /** Constructor for null requests. */ - public AsyncClientHandler( + public AsyncRequestContext( DataNodeRequestType requestType, Map dataNodeLocationMap) { this.requestType = requestType; this.dataNodeLocationMap = dataNodeLocationMap; @@ -119,18 +119,16 @@ public AsyncClientHandler( } /** Constructor for unique request. */ - public AsyncClientHandler( + public AsyncRequestContext( DataNodeRequestType requestType, Q request, Map dataNodeLocationMap) { this.requestType = requestType; this.dataNodeLocationMap = dataNodeLocationMap; - this.requestMap = new ConcurrentHashMap<>(); this.dataNodeLocationMap .keySet() .forEach(dataNodeId -> this.requestMap.put(dataNodeId, request)); - this.responseMap = new ConcurrentHashMap<>(); } @@ -150,6 +148,10 @@ public TDataNodeLocation getDataNodeLocation(int requestId) { return dataNodeLocationMap.get(requestId); } + public Map getDataNodeLocationMap() { + return dataNodeLocationMap; + } + public List getResponseList() { return new ArrayList<>(responseMap.values()); } @@ -166,145 +168,4 @@ public void resetCountDownLatch() { public CountDownLatch getCountDownLatch() { return countDownLatch; } - - public AbstractAsyncRPCHandler createAsyncRPCHandler( - int requestId, TDataNodeLocation targetDataNode) { - switch (requestType) { - case CONSTRUCT_SCHEMA_BLACK_LIST: - case ROLLBACK_SCHEMA_BLACK_LIST: - case DELETE_DATA_FOR_DELETE_SCHEMA: - case DELETE_TIMESERIES: - case CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE: - case ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE: - case DEACTIVATE_TEMPLATE: - case CONSTRUCT_VIEW_SCHEMA_BLACK_LIST: - case ROLLBACK_VIEW_SCHEMA_BLACK_LIST: - case DELETE_VIEW: - case ALTER_VIEW: - return new SchemaUpdateRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case FETCH_SCHEMA_BLACK_LIST: - return new FetchSchemaBlackListRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case COUNT_PATHS_USING_TEMPLATE: - return new CountPathsUsingTemplateRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case CHECK_SCHEMA_REGION_USING_TEMPLATE: - return new CheckSchemaRegionUsingTemplateRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case CHECK_TIMESERIES_EXISTENCE: - return new CheckTimeSeriesExistenceRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case PIPE_HEARTBEAT: - return new PipeHeartbeatRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case PIPE_PUSH_ALL_META: - case PIPE_PUSH_SINGLE_META: - case PIPE_PUSH_MULTI_META: - return new PipePushMetaRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case TOPIC_PUSH_ALL_META: - case TOPIC_PUSH_SINGLE_META: - case TOPIC_PUSH_MULTI_META: - return new TopicPushMetaRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case CONSUMER_GROUP_PUSH_ALL_META: - case CONSUMER_GROUP_PUSH_SINGLE_META: - return new ConsumerGroupPushMetaRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case CHANGE_REGION_LEADER: - return new TransferLeaderRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case SUBMIT_TEST_CONNECTION_TASK: - return new SubmitTestConnectionTaskRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - case SET_TTL: - case CREATE_DATA_REGION: - case CREATE_SCHEMA_REGION: - case CREATE_FUNCTION: - case DROP_FUNCTION: - case CREATE_TRIGGER_INSTANCE: - case DROP_TRIGGER_INSTANCE: - case ACTIVE_TRIGGER_INSTANCE: - case INACTIVE_TRIGGER_INSTANCE: - case UPDATE_TRIGGER_LOCATION: - case MERGE: - case FULL_MERGE: - case FLUSH: - case CLEAR_CACHE: - case START_REPAIR_DATA: - case STOP_REPAIR_DATA: - case LOAD_CONFIGURATION: - case SET_SYSTEM_STATUS: - case UPDATE_REGION_ROUTE_MAP: - case INVALIDATE_MATCHED_SCHEMA_CACHE: - case UPDATE_TEMPLATE: - case KILL_QUERY_INSTANCE: - case RESET_PEER_LIST: - case TEST_CONNECTION: - default: - return new AsyncTSStatusRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - } - } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java index 387359d7ee29..c0ec7e69418c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java @@ -20,8 +20,23 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; +import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateResp; +import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceResp; +import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateResp; +import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListResp; +import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatResp; +import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaResp; +import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaResp; +import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; +import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeResp; import org.apache.thrift.async.AsyncMethodCallback; import java.util.Map; @@ -82,4 +97,149 @@ protected AbstractAsyncRPCHandler( this.responseMap = responseMap; this.countDownLatch = countDownLatch; } + + public static AbstractAsyncRPCHandler create(AsyncRequestContext context, + int requestId, TDataNodeLocation targetDataNode) { + DataNodeRequestType requestType = context.getRequestType(); + Map dataNodeLocationMap = context.getDataNodeLocationMap(); + Map responseMap = context.getResponseMap(); + CountDownLatch countDownLatch = context.getCountDownLatch(); + switch (requestType) { + case CONSTRUCT_SCHEMA_BLACK_LIST: + case ROLLBACK_SCHEMA_BLACK_LIST: + case DELETE_DATA_FOR_DELETE_SCHEMA: + case DELETE_TIMESERIES: + case CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE: + case ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE: + case DEACTIVATE_TEMPLATE: + case CONSTRUCT_VIEW_SCHEMA_BLACK_LIST: + case ROLLBACK_VIEW_SCHEMA_BLACK_LIST: + case DELETE_VIEW: + case ALTER_VIEW: + return new SchemaUpdateRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case FETCH_SCHEMA_BLACK_LIST: + return new FetchSchemaBlackListRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case COUNT_PATHS_USING_TEMPLATE: + return new CountPathsUsingTemplateRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case CHECK_SCHEMA_REGION_USING_TEMPLATE: + return new CheckSchemaRegionUsingTemplateRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case CHECK_TIMESERIES_EXISTENCE: + return new CheckTimeSeriesExistenceRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case PIPE_HEARTBEAT: + return new PipeHeartbeatRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case PIPE_PUSH_ALL_META: + case PIPE_PUSH_SINGLE_META: + case PIPE_PUSH_MULTI_META: + return new PipePushMetaRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case TOPIC_PUSH_ALL_META: + case TOPIC_PUSH_SINGLE_META: + case TOPIC_PUSH_MULTI_META: + return new TopicPushMetaRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case CONSUMER_GROUP_PUSH_ALL_META: + case CONSUMER_GROUP_PUSH_SINGLE_META: + return new ConsumerGroupPushMetaRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case CHANGE_REGION_LEADER: + return new TransferLeaderRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case SUBMIT_TEST_CONNECTION_TASK: + return new SubmitTestConnectionTaskRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + case SET_TTL: + case CREATE_DATA_REGION: + case CREATE_SCHEMA_REGION: + case CREATE_FUNCTION: + case DROP_FUNCTION: + case CREATE_TRIGGER_INSTANCE: + case DROP_TRIGGER_INSTANCE: + case ACTIVE_TRIGGER_INSTANCE: + case INACTIVE_TRIGGER_INSTANCE: + case UPDATE_TRIGGER_LOCATION: + case MERGE: + case FULL_MERGE: + case FLUSH: + case CLEAR_CACHE: + case START_REPAIR_DATA: + case STOP_REPAIR_DATA: + case LOAD_CONFIGURATION: + case SET_SYSTEM_STATUS: + case UPDATE_REGION_ROUTE_MAP: + case INVALIDATE_MATCHED_SCHEMA_CACHE: + case UPDATE_TEMPLATE: + case KILL_QUERY_INSTANCE: + case RESET_PEER_LIST: + case TEST_CONNECTION: + default: + return new AsyncTSStatusRPCHandler( + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); + } + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index edeed260258f..90d13b976fc4 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -34,7 +34,7 @@ import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -137,8 +137,8 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { configManager.getNodeManager().getRegisteredDataNodes().stream() .map(TDataNodeConfiguration::getLocation) .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler dataNodeClientHandler = - new AsyncClientHandler<>( + AsyncRequestContext dataNodeClientHandler = + new AsyncRequestContext<>( DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNode(dataNodeClientHandler); dataNodeClientHandler @@ -162,8 +162,8 @@ private static void merge(TTestConnectionResp resp1, TTestConnectionResp resp2) private void submitTestConnectionTaskToAllDataNode() { - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, new TNodeLocations(), configManager.getNodeManager().getRegisteredDataNodeLocations()); @@ -265,8 +265,8 @@ private List testAllDataNodeConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java index 0c00005fc1b3..1ef05ccc0f92 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.quota.SetSpaceQuotaPlan; import org.apache.iotdb.confignode.consensus.request.write.quota.SetThrottleQuotaPlan; import org.apache.iotdb.confignode.manager.partition.PartitionManager; @@ -87,8 +87,8 @@ public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } @@ -192,8 +192,8 @@ public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index 0b4bb73102f9..0ff1ab615fff 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -26,7 +26,7 @@ import org.apache.iotdb.commons.trigger.TriggerInformation; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTransferringTriggersPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerJarPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerLocationPlan; @@ -248,8 +248,8 @@ public List updateTriggerLocation( final TUpdateTriggerLocationReq request = new TUpdateTriggerLocationReq(triggerName, dataNodeLocation); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index a84eb8359ead..1eb69a9f0567 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -25,7 +25,7 @@ import org.apache.iotdb.commons.udf.UDFInformation; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.function.GetFunctionTablePlan; import org.apache.iotdb.confignode.consensus.request.read.function.GetUDFJarPlan; @@ -127,8 +127,8 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, configManager.getNodeManager().getRegisteredDataNodeLocations(); final TCreateFunctionInstanceReq req = new TCreateFunctionInstanceReq(udfInformation.serialize()).setJarFile(jarFile); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -160,8 +160,8 @@ private List dropFunctionOnDataNodes(String functionName) { final TDropFunctionInstanceReq request = new TDropFunctionInstanceReq(functionName, false); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index c97ceb34ce26..233add90b0f4 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -27,7 +27,7 @@ import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.IManager; @@ -163,8 +163,8 @@ private void balanceRegionLeader( // Transfer leader to the optimal distribution long currentTime = System.nanoTime(); AtomicInteger requestId = new AtomicInteger(0); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.CHANGE_REGION_LEADER); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.CHANGE_REGION_LEADER); Map successTransferMap = new TreeMap<>(); optimalLeaderMap.forEach( (regionGroupId, newLeaderId) -> { @@ -300,8 +300,8 @@ private void broadcastLatestRegionPriorityMap() { long broadcastTime = System.currentTimeMillis(); Map tmpPriorityMap = getRegionPriorityMap(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.UPDATE_REGION_ROUTE_MAP, new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index de4bb223c087..b05414d6e818 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -35,7 +35,7 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -700,8 +700,8 @@ private TSStatus transferLeader( public List merge() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.MERGE, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.MERGE, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -709,8 +709,8 @@ public List merge() { public List flush(TFlushReq req) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.FLUSH, req, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.FLUSH, req, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -718,8 +718,8 @@ public List flush(TFlushReq req) { public List clearCache() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -727,8 +727,8 @@ public List clearCache() { public List startRpairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -736,8 +736,8 @@ public List startRpairData() { public List stopRepairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -745,8 +745,8 @@ public List stopRepairData() { public List loadConfiguration() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -754,8 +754,8 @@ public List loadConfiguration() { public List setSystemStatus(String status) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); @@ -787,8 +787,8 @@ public TSStatus killQuery(String queryId, int dataNodeId) { private TSStatus killAllQueries() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index fcb354b1a228..80e380cb50f3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -36,7 +36,7 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; @@ -1255,9 +1255,9 @@ public void maintainRegionReplicas() { switch (selectedRegionMaintainTask.get(0).getRegionId().getType()) { case SchemaRegion: // create SchemaRegion - AsyncClientHandler + AsyncRequestContext createSchemaRegionHandler = - new AsyncClientHandler<>( + new AsyncRequestContext<>( DataNodeRequestType.CREATE_SCHEMA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask schemaRegionCreateTask = @@ -1291,9 +1291,9 @@ public void maintainRegionReplicas() { break; case DataRegion: // Create DataRegion - AsyncClientHandler + AsyncRequestContext createDataRegionHandler = - new AsyncClientHandler<>(DataNodeRequestType.CREATE_DATA_REGION); + new AsyncRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask dataRegionCreateTask = (RegionCreateTask) regionMaintainTask; @@ -1329,8 +1329,8 @@ public void maintainRegionReplicas() { break; case DELETE: // delete region - AsyncClientHandler deleteRegionHandler = - new AsyncClientHandler<>(DataNodeRequestType.DELETE_REGION); + AsyncRequestContext deleteRegionHandler = + new AsyncRequestContext<>(DataNodeRequestType.DELETE_REGION); Map regionIdMap = new HashMap<>(); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionDeleteTask regionDeleteTask = (RegionDeleteTask) regionMaintainTask; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java index 65217818e7d0..85875879990a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java @@ -26,7 +26,7 @@ import org.apache.iotdb.commons.pipe.config.PipeConfig; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.manager.pipe.agent.PipeConfigNodeAgent; @@ -96,8 +96,8 @@ private synchronized void heartbeat() { final TPipeHeartbeatReq request = new TPipeHeartbeatReq(System.currentTimeMillis()); LOGGER.info("Collecting pipe heartbeat {} from data nodes", request.heartbeatId); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 742e89dcf594..fda45af7c42c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -33,7 +33,7 @@ import org.apache.iotdb.commons.utils.StatusUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.database.CountDatabasePlan; @@ -438,8 +438,8 @@ public TSStatus setTTL(SetTTLPlan setTTLPlan, boolean isGeneratedByPipe) { } } - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.SET_TTL); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.SET_TTL); dnlToSgMap .keySet() .forEach( @@ -1099,8 +1099,8 @@ public synchronized TSStatus extendSchemaTemplate( Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, updateTemplateReq, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index 0f5b7f876219..1844506a6fa8 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -35,7 +35,7 @@ import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.consensus.request.write.confignode.RemoveConfigNodePlan; @@ -429,7 +429,7 @@ public Map doRegionCreation( TConsensusGroupType consensusGroupType, CreateRegionGroupsPlan createRegionGroupsPlan) { // Prepare clientHandler - AsyncClientHandler clientHandler; + AsyncRequestContext clientHandler; switch (consensusGroupType) { case SchemaRegion: clientHandler = getCreateSchemaRegionClientHandler(createRegionGroupsPlan); @@ -468,10 +468,10 @@ public Map doRegionCreation( return failedRegions; } - private AsyncClientHandler getCreateSchemaRegionClientHandler( + private AsyncRequestContext getCreateSchemaRegionClientHandler( CreateRegionGroupsPlan createRegionGroupsPlan) { - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.CREATE_SCHEMA_REGION); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.CREATE_SCHEMA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -491,11 +491,11 @@ private AsyncClientHandler getCreateSchemaRegi return clientHandler; } - private AsyncClientHandler getCreateDataRegionClientHandler( + private AsyncRequestContext getCreateDataRegionClientHandler( CreateRegionGroupsPlan createRegionGroupsPlan) { Map ttlMap = getTTLMap(createRegionGroupsPlan); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.CREATE_DATA_REGION); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -608,8 +608,8 @@ public List createTriggerOnDataNodes( request.setJarFile(ByteBuffer.wrap(jarFile.getValues())); } - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); @@ -622,8 +622,8 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD final TDropTriggerInstanceReq request = new TDropTriggerInstanceReq(triggerName, needToDeleteJarFile); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); @@ -635,8 +635,8 @@ public List activeTriggerOnDataNodes(String triggerName) { nodeManager.getRegisteredDataNodeLocations(); final TActiveTriggerInstanceReq request = new TActiveTriggerInstanceReq(triggerName); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); @@ -648,8 +648,8 @@ public List inactiveTriggerOnDataNodes(String triggerName) { nodeManager.getRegisteredDataNodeLocations(); final TInactiveTriggerInstanceReq request = new TInactiveTriggerInstanceReq(triggerName); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); @@ -662,8 +662,8 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, final TCreatePipePluginInstanceReq request = new TCreatePipePluginInstanceReq(pipePluginMeta.serialize(), ByteBuffer.wrap(jarFile)); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); @@ -676,8 +676,8 @@ public List dropPipePluginOnDataNodes( final TDropPipePluginInstanceReq request = new TDropPipePluginInstanceReq(pipePluginName, needToDeleteJarFile); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); @@ -689,8 +689,8 @@ public Map pushAllPipeMetaToDataNodes( configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushPipeMetaReq request = new TPushPipeMetaReq().setPipeMetas(pipeMetaBinaryList); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -704,8 +704,8 @@ public Map pushSinglePipeMetaToDataNodes(ByteBuffer configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushSinglePipeMetaReq request = new TPushSinglePipeMetaReq().setPipeMeta(pipeMetaBinary); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -720,8 +720,8 @@ public Map dropSinglePipeOnDataNodes(String pipeName final TPushSinglePipeMetaReq request = new TPushSinglePipeMetaReq().setPipeNameToDrop(pipeNameToDrop); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -737,8 +737,8 @@ public Map pushMultiPipeMetaToDataNodes( final TPushMultiPipeMetaReq request = new TPushMultiPipeMetaReq().setPipeMetas(pipeMetaBinaryList); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -753,8 +753,8 @@ public Map dropMultiPipeOnDataNodes(List pip final TPushMultiPipeMetaReq request = new TPushMultiPipeMetaReq().setPipeNamesToDrop(pipeNamesToDrop); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -769,8 +769,8 @@ public Map pushAllTopicMetaToDataNodes( configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushTopicMetaReq request = new TPushTopicMetaReq().setTopicMetas(topicMetaBinaryList); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -784,8 +784,8 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushSingleTopicMetaReq request = new TPushSingleTopicMetaReq().setTopicMeta(topicMeta); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() @@ -799,8 +799,8 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { final TPushSingleTopicMetaReq request = new TPushSingleTopicMetaReq().setTopicNameToDrop(topicNameToDrop); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() @@ -815,8 +815,8 @@ public Map pushMultiTopicMetaToDataNodes( final TPushMultiTopicMetaReq request = new TPushMultiTopicMetaReq().setTopicMetas(topicMetaBinaryList); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -831,8 +831,8 @@ public Map dropMultiTopicOnDataNodes(List t final TPushMultiTopicMetaReq request = new TPushMultiTopicMetaReq().setTopicNamesToDrop(topicNamesToDrop); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -848,8 +848,8 @@ public Map pushAllConsumerGroupMetaToDataNo final TPushConsumerGroupMetaReq request = new TPushConsumerGroupMetaReq().setConsumerGroupMetas(consumerGroupMetaBinaryList); - final AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + final AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( @@ -864,9 +864,9 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup final TPushSingleConsumerGroupMetaReq request = new TPushSingleConsumerGroupMetaReq().setConsumerGroupMeta(consumerGroupMeta); - final AsyncClientHandler + final AsyncRequestContext clientHandler = - new AsyncClientHandler<>( + new AsyncRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() @@ -880,9 +880,9 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName final TPushSingleConsumerGroupMetaReq request = new TPushSingleConsumerGroupMetaReq().setConsumerGroupNameToDrop(consumerGroupNameToDrop); - final AsyncClientHandler + final AsyncRequestContext clientHandler = - new AsyncClientHandler<>( + new AsyncRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index 4dac3f311cb2..7feecedeb09e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -36,7 +36,7 @@ import org.apache.iotdb.commons.utils.NodeUrlUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -370,8 +370,8 @@ public Map resetPeerList( TConsensusGroupId regionId, List correctDataNodeLocations, Map dataNodeLocationMap) { - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.RESET_PEER_LIST, new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index 66677129dab6..ee8f95cff205 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -32,7 +32,7 @@ import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; import org.apache.iotdb.confignode.procedure.exception.ProcedureSuspendedException; @@ -120,8 +120,8 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, AlterLogicalViewStat private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java index f5071e95327d..e56fa1e18ef4 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java @@ -24,7 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -86,7 +86,7 @@ void execute() { : getLeaderDataNodeRegionGroupMap( configManager.getLoadManager().getRegionLeaderMap(), targetSchemaRegionGroup); while (!dataNodeConsensusGroupIdMap.isEmpty()) { - AsyncClientHandler clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); + AsyncRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map> currentFailedDataNodeMap = checkDataNodeExecutionResult(clientHandler.getResponseMap(), dataNodeConsensusGroupIdMap); @@ -112,9 +112,9 @@ void execute() { } } - private AsyncClientHandler prepareRequestHandler( + private AsyncRequestContext prepareRequestHandler( Map> dataNodeConsensusGroupIdMap) { - AsyncClientHandler clientHandler = new AsyncClientHandler<>(dataNodeRequestType); + AsyncRequestContext clientHandler = new AsyncRequestContext<>(dataNodeRequestType); for (Map.Entry> entry : dataNodeConsensusGroupIdMap.entrySet()) { clientHandler.putDataNodeLocation(entry.getKey().getDataNodeId(), entry.getKey()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java index 194e23d14886..f3cb1c83c9da 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java @@ -30,7 +30,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeactivateTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -198,8 +198,8 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { if (!timeSeriesPatternTree.isEmpty()) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(timeSeriesPatternTreeBytes), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java index f03cc7619ef2..5a46196e514f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java @@ -29,7 +29,7 @@ import org.apache.iotdb.commons.utils.ThriftConfigNodeSerDeUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.database.PreDeleteDatabasePlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; import org.apache.iotdb.confignode.manager.partition.PartitionMetrics; @@ -155,8 +155,8 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt MetricService.getInstance(), deleteDatabaseSchema.getName()); // try sync delete schemaengine region - AsyncClientHandler asyncClientHandler = - new AsyncClientHandler<>(DataNodeRequestType.DELETE_REGION); + AsyncRequestContext asyncClientHandler = + new AsyncRequestContext<>(DataNodeRequestType.DELETE_REGION); Map schemaRegionDeleteTaskMap = new HashMap<>(); int requestIndex = 0; for (TRegionReplicaSet schemaRegionReplicaSet : schemaRegionReplicaSets) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index 1a566ae44046..44301f521bfd 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -184,8 +184,8 @@ protected List processResponseOfOneDataNode( private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index f49827f0895f..5922e8745012 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -190,8 +190,8 @@ protected List processResponseOfOneDataNode( private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index ab8ac167aee9..070426ddf6db 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -30,7 +30,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.read.template.CheckTemplateSettablePlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetSchemaTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -210,8 +210,8 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { @@ -382,8 +382,8 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + AsyncRequestContext clientHandler = + new AsyncRequestContext<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { @@ -486,8 +486,8 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { TemplateInternalRPCUtil.generateInvalidateTemplateSetInfoBytes( template.getId(), templateSetPath)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index e2d30f10bff7..0382250e2163 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; import org.apache.iotdb.confignode.procedure.exception.ProcedureSuspendedException; @@ -155,8 +155,8 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure invalidateTemplateSetInfoReq.setType( TemplateInternalRPCUpdateType.INVALIDATE_TEMPLATE_SET_INFO.toByte()); invalidateTemplateSetInfoReq.setTemplateInfo(getInvalidateTemplateSetInfo()); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); @@ -250,8 +250,8 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) rollbackTemplateSetInfoReq.setType( TemplateInternalRPCUpdateType.ADD_TEMPLATE_SET_INFO.toByte()); rollbackTemplateSetInfoReq.setTemplateInfo(getAddTemplateSetInfo()); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( + AsyncRequestContext clientHandler = + new AsyncRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, rollbackTemplateSetInfoReq, dataNodeLocationMap); AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); From ad24d6c263671d536894d493ee5206b34c6fcded Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 7 Jun 2024 15:58:25 +0800 Subject: [PATCH 18/52] move function && rename var --- .../client/async/AsyncDataNodeClientPool.java | 55 +++++++------------ .../handlers/rpc/AbstractAsyncRPCHandler.java | 10 ++-- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java index 367bca33cb43..2fff48fd48a0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java @@ -24,11 +24,9 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.common.rpc.thrift.TFlushReq; import org.apache.iotdb.common.rpc.thrift.TNodeLocations; -import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; -import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; @@ -51,14 +49,11 @@ import org.apache.iotdb.mpp.rpc.thrift.TActiveTriggerInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TAlterViewReq; import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateResp; import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceReq; -import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceResp; import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListReq; import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListWithTemplateReq; import org.apache.iotdb.mpp.rpc.thrift.TConstructViewSchemaBlackListReq; import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateResp; import org.apache.iotdb.mpp.rpc.thrift.TCreateDataRegionReq; import org.apache.iotdb.mpp.rpc.thrift.TCreateFunctionInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TCreatePipePluginInstanceReq; @@ -72,24 +67,18 @@ import org.apache.iotdb.mpp.rpc.thrift.TDropPipePluginInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TDropTriggerInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListResp; import org.apache.iotdb.mpp.rpc.thrift.TInactiveTriggerInstanceReq; import org.apache.iotdb.mpp.rpc.thrift.TInvalidateMatchedSchemaCacheReq; import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatReq; -import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatResp; import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaResp; import org.apache.iotdb.mpp.rpc.thrift.TPushMultiPipeMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushMultiTopicMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaResp; import org.apache.iotdb.mpp.rpc.thrift.TPushSingleConsumerGroupMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushSinglePipeMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushSingleTopicMetaReq; import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeReq; -import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeResp; import org.apache.iotdb.mpp.rpc.thrift.TRegionRouteReq; import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListReq; @@ -101,8 +90,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Map; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ @@ -126,12 +113,12 @@ private AsyncDataNodeClientPool() { * *

Notice: The DataNodes that failed to receive the requests will be reconnected * - * @param clientHandler which will also contain the result + * @param requestContext which will also contain the result * @param timeoutInMs timeout in milliseconds */ public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( - AsyncRequestContext clientHandler, long timeoutInMs) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); + AsyncRequestContext requestContext, long timeoutInMs) { + sendAsyncRequest(requestContext, MAX_RETRY_NUM, timeoutInMs); } /** @@ -139,39 +126,39 @@ public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( * *

Notice: The DataNodes that failed to receive the requests will be reconnected * - * @param clientHandler which will also contain the result + * @param requestContext which will also contain the result */ - public void sendAsyncRequestToDataNodeWithRetry(AsyncRequestContext clientHandler) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); + public void sendAsyncRequestToDataNodeWithRetry(AsyncRequestContext requestContext) { + sendAsyncRequest(requestContext, MAX_RETRY_NUM, null); } - public void sendAsyncRequestToDataNode(AsyncRequestContext clientHandler) { - sendAsyncRequest(clientHandler, 1, null); + public void sendAsyncRequestToDataNode(AsyncRequestContext requestContext) { + sendAsyncRequest(requestContext, 1, null); } private void sendAsyncRequest( - AsyncRequestContext clientHandler, int retryNum, Long timeoutInMs) { - if (clientHandler.getRequestIndices().isEmpty()) { + AsyncRequestContext requestContext, int retryNum, Long timeoutInMs) { + if (requestContext.getRequestIndices().isEmpty()) { return; } - DataNodeRequestType requestType = clientHandler.getRequestType(); + DataNodeRequestType requestType = requestContext.getRequestType(); for (int retry = 0; retry < retryNum; retry++) { // Always Reset CountDownLatch first - clientHandler.resetCountDownLatch(); + requestContext.resetCountDownLatch(); // Send requests to all targetDataNodes - for (int requestId : clientHandler.getRequestIndices()) { - TDataNodeLocation targetDataNode = clientHandler.getDataNodeLocation(requestId); - sendAsyncRequestToDataNode(clientHandler, requestId, targetDataNode, retry); + for (int requestId : requestContext.getRequestIndices()) { + TDataNodeLocation targetDataNode = requestContext.getDataNodeLocation(requestId); + sendAsyncRequestToDataNode(requestContext, requestId, targetDataNode, retry); } // Wait for this batch of asynchronous RPC requests finish try { if (timeoutInMs == null) { - clientHandler.getCountDownLatch().await(); + requestContext.getCountDownLatch().await(); } else { - if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { + if (!requestContext.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { LOGGER.warn( "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); } @@ -183,17 +170,17 @@ private void sendAsyncRequest( } // Check if there is a DataNode that fails to execute the request, and retry if there exists - if (clientHandler.getRequestIndices().isEmpty()) { + if (requestContext.getRequestIndices().isEmpty()) { return; } } - if (!clientHandler.getRequestIndices().isEmpty()) { + if (!requestContext.getRequestIndices().isEmpty()) { LOGGER.warn( "Failed to {} on ConfigNode after {} retries, requestIndices: {}", requestType, retryNum, - clientHandler.getRequestIndices()); + requestContext.getRequestIndices()); } } @@ -207,7 +194,7 @@ private void sendAsyncRequestToDataNode( AsyncDataNodeInternalServiceClient client; client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); Object req = requestContext.getRequest(requestId); - AbstractAsyncRPCHandler handler = AbstractAsyncRPCHandler.create(requestContext, requestId, targetDataNode); + AbstractAsyncRPCHandler handler = AbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetDataNode); AsyncTSStatusRPCHandler defaultHandler = null; if (handler instanceof AsyncTSStatusRPCHandler) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java index c0ec7e69418c..33297110f12f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java @@ -42,7 +42,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { +public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { // Type of RPC request protected final DataNodeRequestType requestType; @@ -69,7 +69,7 @@ public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback< *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC * request finished */ - protected final Map responseMap; + protected final Map responseMap; // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished protected final CountDownLatch countDownLatch; @@ -81,7 +81,7 @@ protected AbstractAsyncRPCHandler( int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, - Map responseMap, + Map responseMap, CountDownLatch countDownLatch) { this.requestType = requestType; this.requestId = requestId; @@ -98,8 +98,8 @@ protected AbstractAsyncRPCHandler( this.countDownLatch = countDownLatch; } - public static AbstractAsyncRPCHandler create(AsyncRequestContext context, - int requestId, TDataNodeLocation targetDataNode) { + public static AbstractAsyncRPCHandler buildHandler(AsyncRequestContext context, + int requestId, TDataNodeLocation targetDataNode) { DataNodeRequestType requestType = context.getRequestType(); Map dataNodeLocationMap = context.getDataNodeLocationMap(); Map responseMap = context.getResponseMap(); From f7f03bc5fcef36b8d898e9799ce357f3e20d3f6a Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 7 Jun 2024 17:08:35 +0800 Subject: [PATCH 19/52] refactoring... cn->dn seems done. --- ...DataNodeInternalServiceRequestSender.java} | 180 +++++------------ .../handlers/AsyncDataNodeRequestContext.java | 51 +++++ .../async/handlers/AsyncRequestContext.java | 171 ---------------- .../handlers/rpc/AbstractAsyncRPCHandler.java | 7 +- .../confignode/manager/ClusterManager.java | 22 +- .../manager/ClusterQuotaManager.java | 16 +- .../confignode/manager/TriggerManager.java | 10 +- .../iotdb/confignode/manager/UDFManager.java | 16 +- .../confignode/manager/cq/CQScheduleTask.java | 4 +- .../manager/load/balancer/RouteBalancer.java | 16 +- .../confignode/manager/node/NodeManager.java | 52 ++--- .../manager/partition/PartitionManager.java | 22 +- .../runtime/PipeHeartbeatScheduler.java | 10 +- .../manager/schema/ClusterSchemaManager.java | 16 +- .../procedure/env/ConfigNodeProcedureEnv.java | 134 ++++++------ .../procedure/env/RegionMaintainHandler.java | 10 +- .../schema/AlterLogicalViewProcedure.java | 10 +- .../schema/DataNodeRegionTaskExecutor.java | 12 +- .../schema/DeactivateTemplateProcedure.java | 10 +- .../impl/schema/DeleteDatabaseProcedure.java | 10 +- .../schema/DeleteLogicalViewProcedure.java | 10 +- .../schema/DeleteTimeSeriesProcedure.java | 10 +- .../impl/schema/SetTemplateProcedure.java | 22 +- .../impl/schema/UnsetTemplateProcedure.java | 16 +- .../client/gg/AsyncRequestContext.java | 144 +++++++++++++ .../commons/client/gg/AsyncRequestSender.java | 190 ++++++++++++++++++ 26 files changed, 651 insertions(+), 520 deletions(-) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/{AsyncDataNodeClientPool.java => AsyncDataNodeInternalServiceRequestSender.java} (68%) create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java delete mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncRequestContext.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestSender.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java similarity index 68% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java index 2fff48fd48a0..cb95f48e3c56 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java @@ -31,8 +31,9 @@ import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.client.exception.ClientManagerException; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestSender; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; @@ -90,111 +91,37 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.TimeUnit; - /** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ -public class AsyncDataNodeClientPool { - - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeClientPool.class); +public class AsyncDataNodeInternalServiceRequestSender extends AsyncRequestSender { - private final IClientManager clientManager; + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestSender.class); - private static final int MAX_RETRY_NUM = 6; - - private AsyncDataNodeClientPool() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); + public AsyncDataNodeInternalServiceRequestSender() { + super(); } - /** - * Send asynchronous requests to the specified DataNodes with default retry num - * - *

Notice: The DataNodes that failed to receive the requests will be reconnected - * - * @param requestContext which will also contain the result - * @param timeoutInMs timeout in milliseconds - */ - public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( - AsyncRequestContext requestContext, long timeoutInMs) { - sendAsyncRequest(requestContext, MAX_RETRY_NUM, timeoutInMs); - } - - /** - * Send asynchronous requests to the specified DataNodes with default retry num - * - *

Notice: The DataNodes that failed to receive the requests will be reconnected - * - * @param requestContext which will also contain the result - */ - public void sendAsyncRequestToDataNodeWithRetry(AsyncRequestContext requestContext) { - sendAsyncRequest(requestContext, MAX_RETRY_NUM, null); + @Override + protected void initClientManager() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); } - public void sendAsyncRequestToDataNode(AsyncRequestContext requestContext) { - sendAsyncRequest(requestContext, 1, null); + @Override + protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { + return dataNodeLocation.getInternalEndPoint(); } - private void sendAsyncRequest( - AsyncRequestContext requestContext, int retryNum, Long timeoutInMs) { - if (requestContext.getRequestIndices().isEmpty()) { - return; - } - - DataNodeRequestType requestType = requestContext.getRequestType(); - for (int retry = 0; retry < retryNum; retry++) { - // Always Reset CountDownLatch first - requestContext.resetCountDownLatch(); - - // Send requests to all targetDataNodes - for (int requestId : requestContext.getRequestIndices()) { - TDataNodeLocation targetDataNode = requestContext.getDataNodeLocation(requestId); - sendAsyncRequestToDataNode(requestContext, requestId, targetDataNode, retry); - } - - // Wait for this batch of asynchronous RPC requests finish - try { - if (timeoutInMs == null) { - requestContext.getCountDownLatch().await(); - } else { - if (!requestContext.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { - LOGGER.warn( - "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - } - } - } catch (InterruptedException e) { - LOGGER.error( - "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - Thread.currentThread().interrupt(); - } - - // Check if there is a DataNode that fails to execute the request, and retry if there exists - if (requestContext.getRequestIndices().isEmpty()) { - return; - } - } - - if (!requestContext.getRequestIndices().isEmpty()) { - LOGGER.warn( - "Failed to {} on ConfigNode after {} retries, requestIndices: {}", - requestType, - retryNum, - requestContext.getRequestIndices()); - } - } - - private void sendAsyncRequestToDataNode( - AsyncRequestContext requestContext, - int requestId, - TDataNodeLocation targetDataNode, - int retryCount) { + @Override + protected void sendAsyncRequestToNode( + AsyncRequestContext requestContext, int requestId, TDataNodeLocation targetNode, int retryCount) { try { AsyncDataNodeInternalServiceClient client; - client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); + client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); Object req = requestContext.getRequest(requestId); - AbstractAsyncRPCHandler handler = AbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetDataNode); + AbstractAsyncRPCHandler handler = AbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); AsyncTSStatusRPCHandler defaultHandler = null; if (handler instanceof AsyncTSStatusRPCHandler) { @@ -255,19 +182,19 @@ private void sendAsyncRequestToDataNode( break; case TOPIC_PUSH_SINGLE_META: client.pushSingleTopicMeta( - (TPushSingleTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); + (TPushSingleTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); break; case TOPIC_PUSH_MULTI_META: client.pushMultiTopicMeta( - (TPushMultiTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); + (TPushMultiTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); break; case CONSUMER_GROUP_PUSH_ALL_META: client.pushConsumerGroupMeta( - (TPushConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); + (TPushConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); break; case CONSUMER_GROUP_PUSH_SINGLE_META: client.pushSingleConsumerGroupMeta( - (TPushSingleConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); + (TPushSingleConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); break; case PIPE_HEARTBEAT: client.pipeHeartbeat((TPipeHeartbeatReq) req, (PipeHeartbeatRPCHandler) handler); @@ -299,38 +226,38 @@ private void sendAsyncRequestToDataNode( break; case CHANGE_REGION_LEADER: client.changeRegionLeader( - (TRegionLeaderChangeReq) req, (TransferLeaderRPCHandler) handler); + (TRegionLeaderChangeReq) req, (TransferLeaderRPCHandler) handler); break; case CONSTRUCT_SCHEMA_BLACK_LIST: client.constructSchemaBlackList( - (TConstructSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); + (TConstructSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_SCHEMA_BLACK_LIST: client.rollbackSchemaBlackList( - (TRollbackSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); + (TRollbackSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case FETCH_SCHEMA_BLACK_LIST: client.fetchSchemaBlackList( - (TFetchSchemaBlackListReq) req, (FetchSchemaBlackListRPCHandler) handler); + (TFetchSchemaBlackListReq) req, (FetchSchemaBlackListRPCHandler) handler); break; case INVALIDATE_MATCHED_SCHEMA_CACHE: client.invalidateMatchedSchemaCache( - (TInvalidateMatchedSchemaCacheReq) req, defaultHandler); + (TInvalidateMatchedSchemaCacheReq) req, defaultHandler); break; case DELETE_DATA_FOR_DELETE_SCHEMA: client.deleteDataForDeleteSchema( - (TDeleteDataForDeleteSchemaReq) req, (SchemaUpdateRPCHandler) handler); + (TDeleteDataForDeleteSchemaReq) req, (SchemaUpdateRPCHandler) handler); break; case DELETE_TIMESERIES: client.deleteTimeSeries((TDeleteTimeSeriesReq) req, (SchemaUpdateRPCHandler) handler); break; case CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE: client.constructSchemaBlackListWithTemplate( - (TConstructSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); + (TConstructSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE: client.rollbackSchemaBlackListWithTemplate( - (TRollbackSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); + (TRollbackSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); break; case DEACTIVATE_TEMPLATE: client.deactivateTemplate((TDeactivateTemplateReq) req, (SchemaUpdateRPCHandler) handler); @@ -340,24 +267,24 @@ private void sendAsyncRequestToDataNode( break; case COUNT_PATHS_USING_TEMPLATE: client.countPathsUsingTemplate( - (TCountPathsUsingTemplateReq) req, (CountPathsUsingTemplateRPCHandler) handler); + (TCountPathsUsingTemplateReq) req, (CountPathsUsingTemplateRPCHandler) handler); break; case CHECK_SCHEMA_REGION_USING_TEMPLATE: client.checkSchemaRegionUsingTemplate( - (TCheckSchemaRegionUsingTemplateReq) req, - (CheckSchemaRegionUsingTemplateRPCHandler) handler); + (TCheckSchemaRegionUsingTemplateReq) req, + (CheckSchemaRegionUsingTemplateRPCHandler) handler); break; case CHECK_TIMESERIES_EXISTENCE: client.checkTimeSeriesExistence( - (TCheckTimeSeriesExistenceReq) req, (CheckTimeSeriesExistenceRPCHandler) handler); + (TCheckTimeSeriesExistenceReq) req, (CheckTimeSeriesExistenceRPCHandler) handler); break; case CONSTRUCT_VIEW_SCHEMA_BLACK_LIST: client.constructViewSchemaBlackList( - (TConstructViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); + (TConstructViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_VIEW_SCHEMA_BLACK_LIST: client.rollbackViewSchemaBlackList( - (TRollbackViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); + (TRollbackViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case DELETE_VIEW: client.deleteViewSchema((TDeleteViewSchemaReq) req, (SchemaUpdateRPCHandler) handler); @@ -379,37 +306,26 @@ private void sendAsyncRequestToDataNode( break; case SUBMIT_TEST_CONNECTION_TASK: client.submitTestConnectionTask( - (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); + (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); break; case TEST_CONNECTION: client.testConnection(defaultHandler); break; default: LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - requestContext.getRequestType()); + "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", + requestContext.getRequestType()); } } catch (Exception e) { LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - requestContext.getRequestType(), - targetDataNode.getInternalEndPoint(), - e.getMessage(), - retryCount); + "{} failed on DataNode {}, because {}, retrying {}...", + requestContext.getRequestType(), + nodeLocationToEndPoint(targetNode), + e.getMessage(), + retryCount); } } - /** - * Always call this interface when a DataNode is restarted or removed. - * - * @param endPoint The specific DataNode - */ - public void resetClient(TEndPoint endPoint) { - clientManager.clear(endPoint); - } - - - public AsyncDataNodeInternalServiceClient getAsyncClient(TDataNodeLocation targetDataNode) throws ClientManagerException { return clientManager.borrowClient(targetDataNode.getInternalEndPoint()); @@ -418,14 +334,14 @@ public AsyncDataNodeInternalServiceClient getAsyncClient(TDataNodeLocation targe // TODO: Is the ClientPool must be a singleton? private static class ClientPoolHolder { - private static final AsyncDataNodeClientPool INSTANCE = new AsyncDataNodeClientPool(); + private static final AsyncDataNodeInternalServiceRequestSender INSTANCE = new AsyncDataNodeInternalServiceRequestSender(); private ClientPoolHolder() { // Empty constructor } } - public static AsyncDataNodeClientPool getInstance() { + public static AsyncDataNodeInternalServiceRequestSender getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java new file mode 100644 index 000000000000..a59da34289d9 --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java @@ -0,0 +1,51 @@ +/* + * 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.client.async.handlers; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.confignode.client.DataNodeRequestType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncDataNodeRequestContext extends AsyncRequestContext { + + public AsyncDataNodeRequestContext(DataNodeRequestType requestType) { + super(requestType); + } + + public AsyncDataNodeRequestContext(DataNodeRequestType requestType, Map dataNodeLocationMap) { + super(requestType, dataNodeLocationMap); + } + + public AsyncDataNodeRequestContext(DataNodeRequestType requestType, Q q, Map dataNodeLocationMap) { + super(requestType, q, dataNodeLocationMap); + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncRequestContext.java deleted file mode 100644 index a9dcc6dee98c..000000000000 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncRequestContext.java +++ /dev/null @@ -1,171 +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.iotdb.confignode.client.async.handlers; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.FetchSchemaBlackListRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.SchemaUpdateRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.TransferLeaderRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; -import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateResp; -import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceResp; -import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateResp; -import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListResp; -import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatResp; -import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaResp; -import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaResp; -import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; -import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeResp; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public class AsyncRequestContext { - - // Type of RPC request - protected final DataNodeRequestType requestType; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The corresponding RPC request - */ - private final Map requestMap; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target DataNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetDataNode from the dataNodeLocationMap only - * if its corresponding RPC request success - */ - private final Map dataNodeLocationMap; - - /** - * Map key: The indices(targetDataNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - private final Map responseMap; - - private CountDownLatch countDownLatch; - - /** Custom constructor. */ - public AsyncRequestContext(DataNodeRequestType requestType) { - this.requestType = requestType; - this.requestMap = new ConcurrentHashMap<>(); - this.dataNodeLocationMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - public void putRequest(int requestId, Q request) { - requestMap.put(requestId, request); - } - - public void putDataNodeLocation(int requestId, TDataNodeLocation dataNodeLocation) { - dataNodeLocationMap.put(requestId, dataNodeLocation); - } - - /** Constructor for null requests. */ - public AsyncRequestContext( - DataNodeRequestType requestType, Map dataNodeLocationMap) { - this.requestType = requestType; - this.dataNodeLocationMap = dataNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - /** Constructor for unique request. */ - public AsyncRequestContext( - DataNodeRequestType requestType, - Q request, - Map dataNodeLocationMap) { - this.requestType = requestType; - this.dataNodeLocationMap = dataNodeLocationMap; - this.requestMap = new ConcurrentHashMap<>(); - this.dataNodeLocationMap - .keySet() - .forEach(dataNodeId -> this.requestMap.put(dataNodeId, request)); - this.responseMap = new ConcurrentHashMap<>(); - } - - public DataNodeRequestType getRequestType() { - return requestType; - } - - public List getRequestIndices() { - return new ArrayList<>(dataNodeLocationMap.keySet()); - } - - public Q getRequest(int requestId) { - return requestMap.get(requestId); - } - - public TDataNodeLocation getDataNodeLocation(int requestId) { - return dataNodeLocationMap.get(requestId); - } - - public Map getDataNodeLocationMap() { - return dataNodeLocationMap; - } - - public List getResponseList() { - return new ArrayList<>(responseMap.values()); - } - - public Map getResponseMap() { - return responseMap; - } - - /** Always reset CountDownLatch before retry. */ - public void resetCountDownLatch() { - countDownLatch = new CountDownLatch(dataNodeLocationMap.size()); - } - - public CountDownLatch getCountDownLatch() { - return countDownLatch; - } -} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java index 33297110f12f..a7d957d52e7a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java @@ -22,9 +22,10 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; @@ -98,10 +99,10 @@ protected AbstractAsyncRPCHandler( this.countDownLatch = countDownLatch; } - public static AbstractAsyncRPCHandler buildHandler(AsyncRequestContext context, + public static AbstractAsyncRPCHandler buildHandler(AsyncRequestContext context, int requestId, TDataNodeLocation targetDataNode) { DataNodeRequestType requestType = context.getRequestType(); - Map dataNodeLocationMap = context.getDataNodeLocationMap(); + Map dataNodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); CountDownLatch countDownLatch = context.getCountDownLatch(); switch (requestType) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 90d13b976fc4..bbb721f30e58 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -33,8 +33,8 @@ import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncConfigNodeClientPool; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -137,10 +137,10 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { configManager.getNodeManager().getRegisteredDataNodes().stream() .map(TDataNodeConfiguration::getLocation) .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncRequestContext dataNodeClientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext dataNodeClientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNode(dataNodeClientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNode(dataNodeClientHandler); dataNodeClientHandler .getResponseMap() .values() @@ -162,12 +162,12 @@ private static void merge(TTestConnectionResp resp1, TTestConnectionResp resp2) private void submitTestConnectionTaskToAllDataNode() { - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, new TNodeLocations(), configManager.getNodeManager().getRegisteredDataNodeLocations()); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); clientHandler.getResponseMap(); } @@ -265,10 +265,10 @@ private List testAllDataNodeConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java index 1ef05ccc0f92..c0dde859bb1e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java @@ -27,8 +27,8 @@ import org.apache.iotdb.common.rpc.thrift.TThrottleQuota; import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.quota.SetSpaceQuotaPlan; import org.apache.iotdb.confignode.consensus.request.write.quota.SetThrottleQuotaPlan; import org.apache.iotdb.confignode.manager.partition.PartitionManager; @@ -87,9 +87,9 @@ public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } return response; @@ -192,10 +192,10 @@ public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } return response; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index 0ff1ab615fff..92fe7b45e9b3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -25,8 +25,8 @@ import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.trigger.TriggerInformation; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTransferringTriggersPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerJarPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerLocationPlan; @@ -248,10 +248,10 @@ public List updateTriggerLocation( final TUpdateTriggerLocationReq request = new TUpdateTriggerLocationReq(triggerName, dataNodeLocation); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index 1eb69a9f0567..c3452c6b2d2e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -24,8 +24,8 @@ import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.commons.udf.UDFInformation; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.function.GetFunctionTablePlan; import org.apache.iotdb.confignode.consensus.request.read.function.GetUDFJarPlan; @@ -127,9 +127,9 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, configManager.getNodeManager().getRegisteredDataNodeLocations(); final TCreateFunctionInstanceReq req = new TCreateFunctionInstanceReq(udfInformation.serialize()).setJarFile(jarFile); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -160,9 +160,9 @@ private List dropFunctionOnDataNodes(String functionName) { final TDropFunctionInstanceReq request = new TDropFunctionInstanceReq(functionName, false); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java index 9ccd02f12811..701bb758c0cb 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java @@ -24,7 +24,7 @@ import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.cq.TimeoutPolicy; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; import org.apache.iotdb.confignode.consensus.request.write.cq.UpdateCQLastExecTimePlan; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.persistence.cq.CQInfo; @@ -188,7 +188,7 @@ public void run() { new TExecuteCQ(queryBody, startTime, endTime, everyInterval, zoneId, cqId, username); try { AsyncDataNodeInternalServiceClient client = - AsyncDataNodeClientPool.getInstance().getAsyncClient(targetDataNode.get()); + AsyncDataNodeInternalServiceRequestSender.getInstance().getAsyncClient(targetDataNode.get()); client.executeCQ(executeCQReq, new AsyncExecuteCQCallback(startTime, endTime)); } catch (Exception t) { LOGGER.warn("Execute CQ {} failed", cqId, t); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index 233add90b0f4..e2c26c874c6f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -26,8 +26,8 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.IManager; @@ -163,8 +163,8 @@ private void balanceRegionLeader( // Transfer leader to the optimal distribution long currentTime = System.nanoTime(); AtomicInteger requestId = new AtomicInteger(0); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.CHANGE_REGION_LEADER); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.CHANGE_REGION_LEADER); Map successTransferMap = new TreeMap<>(); optimalLeaderMap.forEach( (regionGroupId, newLeaderId) -> { @@ -218,7 +218,7 @@ private void balanceRegionLeader( }); if (requestId.get() > 0) { // Don't retry ChangeLeader request - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNode(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNode(clientHandler); for (int i = 0; i < requestId.get(); i++) { if (clientHandler.getResponseMap().get(i).getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -300,12 +300,12 @@ private void broadcastLatestRegionPriorityMap() { long broadcastTime = System.currentTimeMillis(); Map tmpPriorityMap = getRegionPriorityMap(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_REGION_ROUTE_MAP, new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); } private void recordRegionPriorityMap( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index b05414d6e818..b7044fd0632b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -34,8 +34,8 @@ import org.apache.iotdb.commons.consensus.ConsensusGroupId; import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -700,64 +700,64 @@ private TSStatus transferLeader( public List merge() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.MERGE, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.MERGE, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } public List flush(TFlushReq req) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.FLUSH, req, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.FLUSH, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } public List clearCache() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } public List startRpairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } public List stopRepairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } public List loadConfiguration() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } public List setSystemStatus(String status) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -787,9 +787,9 @@ public TSStatus killQuery(String queryId, int dataNodeId) { private TSStatus killAllQueries() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index 80e380cb50f3..e984afa63391 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -35,8 +35,8 @@ import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; @@ -1255,9 +1255,9 @@ public void maintainRegionReplicas() { switch (selectedRegionMaintainTask.get(0).getRegionId().getType()) { case SchemaRegion: // create SchemaRegion - AsyncRequestContext + AsyncDataNodeRequestContext createSchemaRegionHandler = - new AsyncRequestContext<>( + new AsyncDataNodeRequestContext<>( DataNodeRequestType.CREATE_SCHEMA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask schemaRegionCreateTask = @@ -1276,7 +1276,7 @@ public void maintainRegionReplicas() { schemaRegionCreateTask.getTargetDataNode()); } - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetry(createSchemaRegionHandler); for (Map.Entry entry : @@ -1291,9 +1291,9 @@ public void maintainRegionReplicas() { break; case DataRegion: // Create DataRegion - AsyncRequestContext + AsyncDataNodeRequestContext createDataRegionHandler = - new AsyncRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); + new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask dataRegionCreateTask = (RegionCreateTask) regionMaintainTask; @@ -1312,7 +1312,7 @@ public void maintainRegionReplicas() { dataRegionCreateTask.getTargetDataNode()); } - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetry(createDataRegionHandler); for (Map.Entry entry : @@ -1329,8 +1329,8 @@ public void maintainRegionReplicas() { break; case DELETE: // delete region - AsyncRequestContext deleteRegionHandler = - new AsyncRequestContext<>(DataNodeRequestType.DELETE_REGION); + AsyncDataNodeRequestContext deleteRegionHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.DELETE_REGION); Map regionIdMap = new HashMap<>(); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionDeleteTask regionDeleteTask = (RegionDeleteTask) regionMaintainTask; @@ -1348,7 +1348,7 @@ public void maintainRegionReplicas() { } long startTime = System.currentTimeMillis(); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetry(deleteRegionHandler); LOGGER.info( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java index 85875879990a..4152d09c7aad 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java @@ -25,8 +25,8 @@ import org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil; import org.apache.iotdb.commons.pipe.config.PipeConfig; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.manager.pipe.agent.PipeConfigNodeAgent; @@ -96,9 +96,9 @@ private synchronized void heartbeat() { final TPipeHeartbeatReq request = new TPipeHeartbeatReq(System.currentTimeMillis()); LOGGER.info("Collecting pipe heartbeat {} from data nodes", request.heartbeatId); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeHeartbeatIntervalSecondsForCollectingPipeMeta() diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index fda45af7c42c..5da3702161c6 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -32,8 +32,8 @@ import org.apache.iotdb.commons.utils.PathUtils; import org.apache.iotdb.commons.utils.StatusUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.database.CountDatabasePlan; @@ -438,8 +438,8 @@ public TSStatus setTTL(SetTTLPlan setTTLPlan, boolean isGeneratedByPipe) { } } - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.SET_TTL); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.SET_TTL); dnlToSgMap .keySet() .forEach( @@ -450,7 +450,7 @@ public TSStatus setTTL(SetTTLPlan setTTLPlan, boolean isGeneratedByPipe) { clientHandler.putDataNodeLocation(dataNodeId, dataNodeLocationMap.get(dataNodeId)); }); // TODO: Check response - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); try { return getConsensusManager() @@ -1099,10 +1099,10 @@ public synchronized TSStatus extendSchemaTemplate( Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, updateTemplateReq, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index 1844506a6fa8..58cb0dec8057 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -34,8 +34,8 @@ import org.apache.iotdb.commons.trigger.TriggerInformation; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.consensus.request.write.confignode.RemoveConfigNodePlan; @@ -429,7 +429,7 @@ public Map doRegionCreation( TConsensusGroupType consensusGroupType, CreateRegionGroupsPlan createRegionGroupsPlan) { // Prepare clientHandler - AsyncRequestContext clientHandler; + AsyncDataNodeRequestContext clientHandler; switch (consensusGroupType) { case SchemaRegion: clientHandler = getCreateSchemaRegionClientHandler(createRegionGroupsPlan); @@ -444,7 +444,7 @@ public Map doRegionCreation( } // Send CreateRegion requests to DataNodes - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); // Filter RegionGroups that weren't created successfully int requestId = 0; @@ -468,10 +468,10 @@ public Map doRegionCreation( return failedRegions; } - private AsyncRequestContext getCreateSchemaRegionClientHandler( + private AsyncDataNodeRequestContext getCreateSchemaRegionClientHandler( CreateRegionGroupsPlan createRegionGroupsPlan) { - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.CREATE_SCHEMA_REGION); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_SCHEMA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -491,11 +491,11 @@ private AsyncRequestContext getCreateSchemaReg return clientHandler; } - private AsyncRequestContext getCreateDataRegionClientHandler( + private AsyncDataNodeRequestContext getCreateDataRegionClientHandler( CreateRegionGroupsPlan createRegionGroupsPlan) { Map ttlMap = getTTLMap(createRegionGroupsPlan); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -608,10 +608,10 @@ public List createTriggerOnDataNodes( request.setJarFile(ByteBuffer.wrap(jarFile.getValues())); } - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -622,10 +622,10 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD final TDropTriggerInstanceReq request = new TDropTriggerInstanceReq(triggerName, needToDeleteJarFile); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -635,10 +635,10 @@ public List activeTriggerOnDataNodes(String triggerName) { nodeManager.getRegisteredDataNodeLocations(); final TActiveTriggerInstanceReq request = new TActiveTriggerInstanceReq(triggerName); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -648,10 +648,10 @@ public List inactiveTriggerOnDataNodes(String triggerName) { nodeManager.getRegisteredDataNodeLocations(); final TInactiveTriggerInstanceReq request = new TInactiveTriggerInstanceReq(triggerName); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -662,10 +662,10 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, final TCreatePipePluginInstanceReq request = new TCreatePipePluginInstanceReq(pipePluginMeta.serialize(), ByteBuffer.wrap(jarFile)); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -676,10 +676,10 @@ public List dropPipePluginOnDataNodes( final TDropPipePluginInstanceReq request = new TDropPipePluginInstanceReq(pipePluginName, needToDeleteJarFile); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -689,10 +689,10 @@ public Map pushAllPipeMetaToDataNodes( configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushPipeMetaReq request = new TPushPipeMetaReq().setPipeMetas(pipeMetaBinaryList); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -704,10 +704,10 @@ public Map pushSinglePipeMetaToDataNodes(ByteBuffer configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushSinglePipeMetaReq request = new TPushSinglePipeMetaReq().setPipeMeta(pipeMetaBinary); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -720,10 +720,10 @@ public Map dropSinglePipeOnDataNodes(String pipeName final TPushSinglePipeMetaReq request = new TPushSinglePipeMetaReq().setPipeNameToDrop(pipeNameToDrop); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -737,10 +737,10 @@ public Map pushMultiPipeMetaToDataNodes( final TPushMultiPipeMetaReq request = new TPushMultiPipeMetaReq().setPipeMetas(pipeMetaBinaryList); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -753,10 +753,10 @@ public Map dropMultiPipeOnDataNodes(List pip final TPushMultiPipeMetaReq request = new TPushMultiPipeMetaReq().setPipeNamesToDrop(pipeNamesToDrop); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -769,10 +769,10 @@ public Map pushAllTopicMetaToDataNodes( configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushTopicMetaReq request = new TPushTopicMetaReq().setTopicMetas(topicMetaBinaryList); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -784,10 +784,10 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushSingleTopicMetaReq request = new TPushSingleTopicMetaReq().setTopicMeta(topicMeta); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) .collect(Collectors.toList()); @@ -799,10 +799,10 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { final TPushSingleTopicMetaReq request = new TPushSingleTopicMetaReq().setTopicNameToDrop(topicNameToDrop); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) .collect(Collectors.toList()); @@ -815,10 +815,10 @@ public Map pushMultiTopicMetaToDataNodes( final TPushMultiTopicMetaReq request = new TPushMultiTopicMetaReq().setTopicMetas(topicMetaBinaryList); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -831,10 +831,10 @@ public Map dropMultiTopicOnDataNodes(List t final TPushMultiTopicMetaReq request = new TPushMultiTopicMetaReq().setTopicNamesToDrop(topicNamesToDrop); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -848,10 +848,10 @@ public Map pushAllConsumerGroupMetaToDataNo final TPushConsumerGroupMetaReq request = new TPushConsumerGroupMetaReq().setConsumerGroupMetas(consumerGroupMetaBinaryList); - final AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + final AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -864,11 +864,11 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup final TPushSingleConsumerGroupMetaReq request = new TPushSingleConsumerGroupMetaReq().setConsumerGroupMeta(consumerGroupMeta); - final AsyncRequestContext + final AsyncDataNodeRequestContext clientHandler = - new AsyncRequestContext<>( + new AsyncDataNodeRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) .collect(Collectors.toList()); @@ -880,11 +880,11 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName final TPushSingleConsumerGroupMetaReq request = new TPushSingleConsumerGroupMetaReq().setConsumerGroupNameToDrop(consumerGroupNameToDrop); - final AsyncRequestContext + final AsyncDataNodeRequestContext clientHandler = - new AsyncRequestContext<>( + new AsyncDataNodeRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) .collect(Collectors.toList()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index 7feecedeb09e..867f0601451e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -35,8 +35,8 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.NodeUrlUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -370,12 +370,12 @@ public Map resetPeerList( TConsensusGroupId regionId, List correctDataNodeLocations, Map dataNodeLocationMap) { - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.RESET_PEER_LIST, new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); return clientHandler.getResponseMap(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index ee8f95cff205..20d5f7afe030 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -31,8 +31,8 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; import org.apache.iotdb.confignode.procedure.exception.ProcedureSuspendedException; @@ -120,12 +120,12 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, AlterLogicalViewStat private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java index e56fa1e18ef4..6dda355ad509 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java @@ -23,8 +23,8 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -86,8 +86,8 @@ void execute() { : getLeaderDataNodeRegionGroupMap( configManager.getLoadManager().getRegionLeaderMap(), targetSchemaRegionGroup); while (!dataNodeConsensusGroupIdMap.isEmpty()) { - AsyncRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map> currentFailedDataNodeMap = checkDataNodeExecutionResult(clientHandler.getResponseMap(), dataNodeConsensusGroupIdMap); @@ -112,9 +112,9 @@ void execute() { } } - private AsyncRequestContext prepareRequestHandler( + private AsyncDataNodeRequestContext prepareRequestHandler( Map> dataNodeConsensusGroupIdMap) { - AsyncRequestContext clientHandler = new AsyncRequestContext<>(dataNodeRequestType); + AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(dataNodeRequestType); for (Map.Entry> entry : dataNodeConsensusGroupIdMap.entrySet()) { clientHandler.putDataNodeLocation(entry.getKey().getDataNodeId(), entry.getKey()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java index f3cb1c83c9da..56d0e0991467 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java @@ -29,8 +29,8 @@ import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeactivateTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -198,12 +198,12 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { if (!timeSeriesPatternTree.isEmpty()) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(timeSeriesPatternTreeBytes), dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schema cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java index 5a46196e514f..4da91e7d863e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java @@ -28,8 +28,8 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.ThriftConfigNodeSerDeUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.database.PreDeleteDatabasePlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; import org.apache.iotdb.confignode.manager.partition.PartitionMetrics; @@ -155,8 +155,8 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt MetricService.getInstance(), deleteDatabaseSchema.getName()); // try sync delete schemaengine region - AsyncRequestContext asyncClientHandler = - new AsyncRequestContext<>(DataNodeRequestType.DELETE_REGION); + AsyncDataNodeRequestContext asyncClientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.DELETE_REGION); Map schemaRegionDeleteTaskMap = new HashMap<>(); int requestIndex = 0; for (TRegionReplicaSet schemaRegionReplicaSet : schemaRegionReplicaSets) { @@ -171,7 +171,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt } } if (!schemaRegionDeleteTaskMap.isEmpty()) { - AsyncDataNodeClientPool.getInstance() + AsyncDataNodeInternalServiceRequestSender.getInstance() .sendAsyncRequestToDataNodeWithRetry(asyncClientHandler); for (Map.Entry entry : asyncClientHandler.getResponseMap().entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index 44301f521bfd..bab26eea78bd 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -27,8 +27,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -184,12 +184,12 @@ protected List processResponseOfOneDataNode( private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index 5922e8745012..7b73515dff21 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -27,8 +27,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -190,12 +190,12 @@ protected List processResponseOfOneDataNode( private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaEngine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index 070426ddf6db..0fbfff8c34ad 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -29,8 +29,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.read.template.CheckTemplateSettablePlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetSchemaTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -210,9 +210,9 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -382,9 +382,9 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -486,10 +486,10 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { TemplateInternalRPCUtil.generateInvalidateTemplateSetInfoBytes( template.getId(), templateSetPath)); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { // all dataNodes must clear the related template cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index 0382250e2163..4ef4d4613a2b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -27,8 +27,8 @@ import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool; -import org.apache.iotdb.confignode.client.async.handlers.AsyncRequestContext; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; import org.apache.iotdb.confignode.procedure.exception.ProcedureSuspendedException; @@ -155,10 +155,10 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure invalidateTemplateSetInfoReq.setType( TemplateInternalRPCUpdateType.INVALIDATE_TEMPLATE_SET_INFO.toByte()); invalidateTemplateSetInfoReq.setTemplateInfo(getInvalidateTemplateSetInfo()); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related template cache @@ -250,10 +250,10 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) rollbackTemplateSetInfoReq.setType( TemplateInternalRPCUpdateType.ADD_TEMPLATE_SET_INFO.toByte()); rollbackTemplateSetInfoReq.setTemplateInfo(getAddTemplateSetInfo()); - AsyncRequestContext clientHandler = - new AsyncRequestContext<>( + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, rollbackTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related template cache diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java new file mode 100644 index 000000000000..cc236d78d2eb --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java @@ -0,0 +1,144 @@ +/* + * 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.commons.client.gg; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncRequestContext { + + // Type of RPC request + protected final RequestType requestType; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The corresponding RPC request + */ + private final Map requestMap; + + /** + * Map key: The indices of asynchronous RPC requests. + * + *

Map value: The target Nodes of corresponding indices + * + *

All kinds of AsyncHandler will remove its targetNode from the nodeLocationMap only + * if its corresponding RPC request success + */ + private final Map nodeLocationMap; + + /** + * Map key: The indices(targetNode's ID) of asynchronous RPC requests. + * + *

Map value: The response of corresponding indices + * + *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC + * request finished + */ + private final Map responseMap; + + private CountDownLatch countDownLatch; + + /** Custom constructor. */ + public AsyncRequestContext(RequestType requestType) { + this.requestType = requestType; + this.requestMap = new ConcurrentHashMap<>(); + this.nodeLocationMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + public void putRequest(int requestId, Request request) { + requestMap.put(requestId, request); + } + + public void putNodeLocation(int requestId, NodeLocation nodeLocation) { + nodeLocationMap.put(requestId, nodeLocation); + } + + /** Constructor for null requests. */ + public AsyncRequestContext( + RequestType requestType, Map nodeLocationMap) { + this.requestType = requestType; + this.nodeLocationMap = nodeLocationMap; + + this.requestMap = new ConcurrentHashMap<>(); + this.responseMap = new ConcurrentHashMap<>(); + } + + /** Constructor for unique request. */ + public AsyncRequestContext( + RequestType requestType, + Request request, + Map nodeLocationMap) { + this.requestType = requestType; + this.nodeLocationMap = nodeLocationMap; + this.requestMap = new ConcurrentHashMap<>(); + this.nodeLocationMap + .keySet() + .forEach(nodeId -> this.requestMap.put(nodeId, request)); + this.responseMap = new ConcurrentHashMap<>(); + } + + public RequestType getRequestType() { + return requestType; + } + + public List getRequestIndices() { + return new ArrayList<>(nodeLocationMap.keySet()); + } + + public Request getRequest(int requestId) { + return requestMap.get(requestId); + } + + public NodeLocation getNodeLocation(int requestId) { + return nodeLocationMap.get(requestId); + } + + public Map getNodeLocationMap() { + return nodeLocationMap; + } + + public List getResponseList() { + return new ArrayList<>(responseMap.values()); + } + + public Map getResponseMap() { + return responseMap; + } + + /** Always reset CountDownLatch before retry. */ + public void resetCountDownLatch() { + countDownLatch = new CountDownLatch(nodeLocationMap.size()); + } + + public CountDownLatch getCountDownLatch() { + return countDownLatch; + } +} diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestSender.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestSender.java new file mode 100644 index 000000000000..0301a393eec9 --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestSender.java @@ -0,0 +1,190 @@ +/* + * 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.commons.client.gg; + +import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TFlushReq; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; +import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; +import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.exception.ClientManagerException; +import org.apache.iotdb.mpp.rpc.thrift.TActiveTriggerInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TAlterViewReq; +import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceReq; +import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListWithTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TConstructViewSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreateDataRegionReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreateFunctionInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreatePipePluginInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreateSchemaRegionReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreateTriggerInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TDeactivateTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TDeleteDataForDeleteSchemaReq; +import org.apache.iotdb.mpp.rpc.thrift.TDeleteTimeSeriesReq; +import org.apache.iotdb.mpp.rpc.thrift.TDeleteViewSchemaReq; +import org.apache.iotdb.mpp.rpc.thrift.TDropFunctionInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TDropPipePluginInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TDropTriggerInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TInactiveTriggerInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TInvalidateMatchedSchemaCacheReq; +import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushMultiPipeMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushMultiTopicMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushSingleConsumerGroupMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushSinglePipeMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushSingleTopicMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeReq; +import org.apache.iotdb.mpp.rpc.thrift.TRegionRouteReq; +import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; +import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListWithTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TRollbackViewSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TUpdateTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TUpdateTriggerLocationReq; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +/** Asynchronously send RPC requests to Nodes. See queryengine.thrift for more details. */ +public abstract class AsyncRequestSender { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncRequestSender.class); + + protected IClientManager clientManager; + + private static final int MAX_RETRY_NUM = 6; + + protected AsyncRequestSender() { + initClientManager(); + } + + protected abstract void initClientManager(); + + /** + * Send asynchronous requests to the specified Nodes with default retry num + * + *

Notice: The Nodes that failed to receive the requests will be reconnected + * + * @param requestContext which will also contain the result + * @param timeoutInMs timeout in milliseconds + */ + public void sendAsyncRequestToNodeWithRetryAndTimeoutInMs( + AsyncRequestContext requestContext, long timeoutInMs) { + sendAsyncRequest(requestContext, MAX_RETRY_NUM, timeoutInMs); + } + + /** + * Send asynchronous requests to the specified Nodes with default retry num + * + *

Notice: The Nodes that failed to receive the requests will be reconnected + * + * @param requestContext which will also contain the result + */ + public final void sendAsyncRequestToNodeWithRetry(AsyncRequestContext requestContext) { + sendAsyncRequest(requestContext, MAX_RETRY_NUM, null); + } + + public final void sendAsyncRequestToNode(AsyncRequestContext requestContext) { + sendAsyncRequest(requestContext, 1, null); + } + + private final void sendAsyncRequest( + AsyncRequestContext requestContext, int retryNum, Long timeoutInMs) { + if (requestContext.getRequestIndices().isEmpty()) { + return; + } + + RequestType requestType = requestContext.getRequestType(); + for (int retry = 0; retry < retryNum; retry++) { + // Always Reset CountDownLatch first + requestContext.resetCountDownLatch(); + + // Send requests to all targetNodes + for (int requestId : requestContext.getRequestIndices()) { + NodeLocation targetNode = requestContext.getNodeLocation(requestId); + sendAsyncRequestToNode(requestContext, requestId, targetNode, retry); + } + + // Wait for this batch of asynchronous RPC requests finish + try { + if (timeoutInMs == null) { + requestContext.getCountDownLatch().await(); + } else { + if (!requestContext.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { + LOGGER.warn( + "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + } + } + } catch (InterruptedException e) { + LOGGER.error( + "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); + Thread.currentThread().interrupt(); + } + + // Check if there is a Node that fails to execute the request, and retry if there exists + if (requestContext.getRequestIndices().isEmpty()) { + return; + } + } + + if (!requestContext.getRequestIndices().isEmpty()) { + LOGGER.warn( + "Failed to {} on ConfigNode after {} retries, requestIndices: {}", + requestType, + retryNum, + requestContext.getRequestIndices()); + } + } + + protected abstract TEndPoint nodeLocationToEndPoint(NodeLocation location); + + abstract protected void sendAsyncRequestToNode( + AsyncRequestContext requestContext, + int requestId, + NodeLocation targetNode, + int retryCount); + + /** + * Always call this interface when a Node is restarted or removed. + * + * @param endPoint The specific Node + */ + public void resetClient(TEndPoint endPoint) { + clientManager.clear(endPoint); + } + + + public Client getAsyncClient(NodeLocation targetNode) + throws ClientManagerException { + return clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); + } +} From d3240e6582cbd465f246f6d3ac94c9f0b6ce9434 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 7 Jun 2024 19:26:54 +0800 Subject: [PATCH 20/52] refactoring... cn->cn... --- .../async/AsyncConfigNodeClientPool.java | 199 ------------------ .../AsyncConfigNodeHeartbeatClientPool.java | 6 +- ...onfigNodeInternalServiceRequestSender.java | 110 ++++++++++ ...cDataNodeInternalServiceRequestSender.java | 12 +- .../AsyncConfigNodeClientHandler.java | 173 --------------- .../AsyncConfigNodeRequestContext.java | 51 +++++ .../DataNodeInternalServiceRequester.java | 26 +++ .../handlers/rpc/AsyncTSStatusRPCHandler.java | 4 +- .../rpc/AsyncTSStatusRPCHandler2.java | 2 +- .../CheckTimeSeriesExistenceRPCHandler.java | 2 +- .../ConfigNodeAbstractAsyncRPCHandler.java | 75 +++++++ .../CountPathsUsingTemplateRPCHandler.java | 2 +- ...a => DataNodeAbstractAsyncRPCHandler.java} | 63 ++---- .../rpc/FetchSchemaBlackListRPCHandler.java | 2 +- .../handlers/rpc/PipeHeartbeatRPCHandler.java | 2 +- .../handlers/rpc/PipePushMetaRPCHandler.java | 2 +- .../SubmitTestConnectionTaskRPCHandler.java | 2 +- ...tConnectionTaskToConfigNodeRPCHandler.java | 2 +- .../rpc/TransferLeaderRPCHandler.java | 2 +- ...ckSchemaRegionUsingTemplateRPCHandler.java | 4 +- .../ConsumerGroupPushMetaRPCHandler.java | 4 +- .../subscription/TopicPushMetaRPCHandler.java | 4 +- .../confignode/manager/ClusterManager.java | 22 +- .../client/cn/AsyncConfigNodeClientPool.java | 12 +- .../commons/client/ClientPoolFactory.java | 28 +-- ...AsyncConfigNodeInternalServiceClient.java} | 22 +- .../client/gg/AbstractAsyncRPCHandler.java} | 48 ++--- 27 files changed, 360 insertions(+), 521 deletions(-) delete mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java delete mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/requesters/datanode/DataNodeInternalServiceRequester.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/{AbstractAsyncRPCHandler.java => DataNodeAbstractAsyncRPCHandler.java} (77%) rename iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/{AsyncConfigNodeIServiceClient.java => AsyncConfigNodeInternalServiceClient.java} (84%) rename iotdb-core/{confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java => node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java} (55%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java deleted file mode 100644 index 8ecf7a050340..000000000000 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeClientPool.java +++ /dev/null @@ -1,199 +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.iotdb.confignode.client.async; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.common.rpc.thrift.TNodeLocations; -import org.apache.iotdb.commons.client.ClientPoolFactory; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; -import org.apache.iotdb.commons.client.exception.ClientManagerException; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler2; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; -import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.TimeUnit; - -/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ -public class AsyncConfigNodeClientPool { - - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); - - private final IClientManager clientManager; - - private static final int MAX_RETRY_NUM = 6; - - private AsyncConfigNodeClientPool() { - clientManager = - new IClientManager.Factory() - .createClientManager(new ClientPoolFactory.AsyncConfigNodeIServiceClientPoolFactory()); - } - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - * @param timeoutInMs timeout in milliseconds - */ - public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( - AsyncConfigNodeClientHandler clientHandler, long timeoutInMs) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); - } - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - */ - public void sendAsyncRequestToConfigNodeWithRetry( - AsyncConfigNodeClientHandler clientHandler) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); - } - - public void sendAsyncRequestToConfigNode(AsyncConfigNodeClientHandler clientHandler) { - sendAsyncRequest(clientHandler, 1, null); - } - - private void sendAsyncRequest( - AsyncConfigNodeClientHandler clientHandler, int retryNum, Long timeoutInMs) { - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - - ConfigNodeRequestType requestType = clientHandler.getRequestType(); - for (int retry = 0; retry < retryNum; retry++) { - // Always Reset CountDownLatch first - clientHandler.resetCountDownLatch(); - - // Send requests to all targetConfigNodes - for (int requestId : clientHandler.getRequestIndices()) { - TConfigNodeLocation targetConfigNode = clientHandler.getConfigNodeLocation(requestId); - sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); - } - - // Wait for this batch of asynchronous RPC requests finish - try { - if (timeoutInMs == null) { - clientHandler.getCountDownLatch().await(); - } else { - if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { - LOGGER.warn( - "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - } - } - } catch (InterruptedException e) { - LOGGER.error( - "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - Thread.currentThread().interrupt(); - } - - // Check if there is a ConfigNode that fails to execute the request, and retry if there exists - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - } - - if (!clientHandler.getRequestIndices().isEmpty()) { - LOGGER.warn( - "Failed to {} on ConfigNode after {} retries, requestIndices: {}", - requestType, - retryNum, - clientHandler.getRequestIndices()); - } - } - - private void sendAsyncRequestToConfigNode( - AsyncConfigNodeClientHandler clientHandler, - int requestId, - TConfigNodeLocation targetConfigNode, - int retryCount) { - - try { - AsyncConfigNodeIServiceClient client; - client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler2 handler = - clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); - AsyncTSStatusRPCHandler2 defaultHandler = null; - if (handler instanceof AsyncTSStatusRPCHandler2) { - defaultHandler = (AsyncTSStatusRPCHandler2) handler; - } - - switch (clientHandler.getRequestType()) { - case SUBMIT_TEST_CONNECTION_TASK: - client.submitTestConnectionTask( - (TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); - break; - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", - clientHandler.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on ConfigNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetConfigNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } - } - - /** - * Always call this interface when a ConfigNode is restarted or removed. - * - * @param endPoint The specific ConfigNode - */ - public void resetClient(TEndPoint endPoint) { - clientManager.clear(endPoint); - } - - public AsyncConfigNodeIServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) - throws ClientManagerException { - return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - } - - // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { - - private static final AsyncConfigNodeClientPool INSTANCE = new AsyncConfigNodeClientPool(); - - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncConfigNodeClientPool getInstance() { - return ClientPoolHolder.INSTANCE; - } -} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java index fdcd3b0d1e29..1117cdbfd9ac 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java @@ -22,17 +22,17 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; import org.apache.iotdb.confignode.client.async.handlers.heartbeat.ConfigNodeHeartbeatHandler; import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeHeartbeatReq; public class AsyncConfigNodeHeartbeatClientPool { - private final IClientManager clientManager; + private final IClientManager clientManager; private AsyncConfigNodeHeartbeatClientPool() { clientManager = - new IClientManager.Factory() + new IClientManager.Factory() .createClientManager( new ClientPoolFactory.AsyncConfigNodeHeartbeatServiceClientPoolFactory()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java new file mode 100644 index 000000000000..2305e538b388 --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java @@ -0,0 +1,110 @@ +/* + * 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.client.async; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestSender; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; +import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ +public class AsyncConfigNodeInternalServiceRequestSender extends AsyncRequestSender { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestSender.class); + + private AsyncConfigNodeInternalServiceRequestSender() { + super(); + } + + @Override + protected void initClientManager() { + clientManager = + new IClientManager.Factory() + .createClientManager(new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); + } + + @Override + protected TEndPoint nodeLocationToEndPoint(TConfigNodeLocation configNodeLocation) { + return configNodeLocation.getInternalEndPoint(); + } + + @Override + protected void sendAsyncRequestToNode( + AsyncRequestContext requestContext, int requestId, TConfigNodeLocation targetNode, int retryCount) { + + + try { + AsyncConfigNodeInternalServiceClient client; + client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); + Object req = requestContext.getRequest(requestId); + ConfigNodeAbstractAsyncRPCHandler handler = + ConfigNodeAbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); + AsyncTSStatusRPCHandler2 defaultHandler = null; + if (handler instanceof AsyncTSStatusRPCHandler2) { + defaultHandler = (AsyncTSStatusRPCHandler2) handler; + } + switch (requestContext.getRequestType()) { + case SUBMIT_TEST_CONNECTION_TASK: + client.submitTestConnectionTask( + (TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); + break; + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", + requestContext.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on ConfigNode {}, because {}, retrying {}...", + requestContext.getRequestType(), + nodeLocationToEndPoint(targetNode), + e.getMessage(), + retryCount); + } + } + + // TODO: Is the ClientPool must be a singleton? + private static class ClientPoolHolder { + + private static final AsyncConfigNodeInternalServiceRequestSender INSTANCE = new AsyncConfigNodeInternalServiceRequestSender(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncConfigNodeInternalServiceRequestSender getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java index cb95f48e3c56..36bde787ece2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java @@ -30,11 +30,10 @@ import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; -import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestSender; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; @@ -96,7 +95,7 @@ public class AsyncDataNodeInternalServiceRequestSender extends AsyncRequestSende private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestSender.class); - public AsyncDataNodeInternalServiceRequestSender() { + private AsyncDataNodeInternalServiceRequestSender() { super(); } @@ -121,7 +120,7 @@ protected void sendAsyncRequestToNode( AsyncDataNodeInternalServiceClient client; client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); Object req = requestContext.getRequest(requestId); - AbstractAsyncRPCHandler handler = AbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); + DataNodeAbstractAsyncRPCHandler handler = DataNodeAbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); AsyncTSStatusRPCHandler defaultHandler = null; if (handler instanceof AsyncTSStatusRPCHandler) { @@ -326,11 +325,6 @@ protected void sendAsyncRequestToNode( } } - public AsyncDataNodeInternalServiceClient getAsyncClient(TDataNodeLocation targetDataNode) - throws ClientManagerException { - return clientManager.borrowClient(targetDataNode.getInternalEndPoint()); - } - // TODO: Is the ClientPool must be a singleton? private static class ClientPoolHolder { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java deleted file mode 100644 index e4ddd7581dbf..000000000000 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeClientHandler.java +++ /dev/null @@ -1,173 +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.iotdb.confignode.client.async.handlers; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler2; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; -import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public class AsyncConfigNodeClientHandler { - - // Type of RPC request - protected final ConfigNodeRequestType requestType; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The corresponding RPC request - */ - private final Map requestMap; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target ConfigNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap - * only if its corresponding RPC request success - */ - private final Map configNodeLocationMap; - - /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - private final Map responseMap; - - private CountDownLatch countDownLatch; - - /** Custom constructor. */ - public AsyncConfigNodeClientHandler(ConfigNodeRequestType requestType) { - this.requestType = requestType; - this.requestMap = new ConcurrentHashMap<>(); - this.configNodeLocationMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - public void putRequest(int requestId, Q request) { - requestMap.put(requestId, request); - } - - public void putConfigNodeLocation(int requestId, TConfigNodeLocation configNodeLocation) { - configNodeLocationMap.put(requestId, configNodeLocation); - } - - /** Constructor for null requests. */ - public AsyncConfigNodeClientHandler( - ConfigNodeRequestType requestType, Map configNodeLocationMap) { - this.requestType = requestType; - this.configNodeLocationMap = configNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - /** Constructor for unique request. */ - public AsyncConfigNodeClientHandler( - ConfigNodeRequestType requestType, - Q request, - Map configNodeLocationMap) { - this.requestType = requestType; - this.configNodeLocationMap = configNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.configNodeLocationMap - .keySet() - .forEach(configNodeId -> this.requestMap.put(configNodeId, request)); - - this.responseMap = new ConcurrentHashMap<>(); - } - - public ConfigNodeRequestType getRequestType() { - return requestType; - } - - public List getRequestIndices() { - return new ArrayList<>(configNodeLocationMap.keySet()); - } - - public Q getRequest(int requestId) { - return requestMap.get(requestId); - } - - public TConfigNodeLocation getConfigNodeLocation(int requestId) { - return configNodeLocationMap.get(requestId); - } - - public List getResponseList() { - return new ArrayList<>(responseMap.values()); - } - - public Map getResponseMap() { - return responseMap; - } - - /** Always reset CountDownLatch before retry. */ - public void resetCountDownLatch() { - countDownLatch = new CountDownLatch(configNodeLocationMap.size()); - } - - public CountDownLatch getCountDownLatch() { - return countDownLatch; - } - - public AbstractAsyncRPCHandler2 createAsyncRPCHandler( - int requestId, TConfigNodeLocation targetConfigNode) { - switch (requestType) { - case SUBMIT_TEST_CONNECTION_TASK: - return new SubmitTestConnectionTaskToConfigNodeRPCHandler( - requestType, - requestId, - targetConfigNode, - configNodeLocationMap, - (Map) responseMap, - countDownLatch); - case TEST_CONNECTION: - default: - return new AsyncTSStatusRPCHandler2( - requestType, - requestId, - targetConfigNode, - configNodeLocationMap, - (Map) responseMap, - countDownLatch); - } - } -} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java new file mode 100644 index 000000000000..f05c10be237c --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java @@ -0,0 +1,51 @@ +/* + * 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.client.async.handlers; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncConfigNodeRequestContext extends AsyncRequestContext { + + public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType) { + super(configNodeRequestType); + } + + public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType, Map integerTConfigNodeLocationMap) { + super(configNodeRequestType, integerTConfigNodeLocationMap); + } + + public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType, Q q, Map integerTConfigNodeLocationMap) { + super(configNodeRequestType, q, integerTConfigNodeLocationMap); + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/requesters/datanode/DataNodeInternalServiceRequester.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/requesters/datanode/DataNodeInternalServiceRequester.java new file mode 100644 index 000000000000..2e374f2dde3f --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/requesters/datanode/DataNodeInternalServiceRequester.java @@ -0,0 +1,26 @@ +/* + * 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.client.async.handlers.requesters.datanode; + +import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; +import org.apache.iotdb.confignode.client.async.handlers.requesters.Requester; + +public abstract class DataNodeInternalServiceRequester extends Requester { +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler.java index 1f61ee141a0b..fd101cdc2b3a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler.java @@ -32,7 +32,7 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncTSStatusRPCHandler extends AbstractAsyncRPCHandler { +public class AsyncTSStatusRPCHandler extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler.class); @@ -53,7 +53,7 @@ public void onComplete(TSStatus response) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { // Remove only if success - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.info("Successfully {} on DataNode: {}", requestType, formattedTargetLocation); } else { LOGGER.error( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java index 007ec209db8b..270bf09203e9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java @@ -32,7 +32,7 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncTSStatusRPCHandler2 extends AbstractAsyncRPCHandler2 { +public class AsyncTSStatusRPCHandler2 extends ConfigNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java index 150947f1b97b..b86aaab210fa 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java @@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch; public class CheckTimeSeriesExistenceRPCHandler - extends AbstractAsyncRPCHandler { + extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(CheckTimeSeriesExistenceRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java new file mode 100644 index 000000000000..a26713a4d03c --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java @@ -0,0 +1,75 @@ +/* + * 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.client.async.handlers.rpc; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; +import org.apache.iotdb.commons.client.gg.AbstractAsyncRPCHandler; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.DataNodeRequestType; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public abstract class ConfigNodeAbstractAsyncRPCHandler extends AbstractAsyncRPCHandler { + + protected ConfigNodeAbstractAsyncRPCHandler(ConfigNodeRequestType configNodeRequestType, int requestId, TConfigNodeLocation targetNode, Map integerTConfigNodeLocationMap, Map integerResponseMap, CountDownLatch countDownLatch) { + super(configNodeRequestType, requestId, targetNode, integerTConfigNodeLocationMap, integerResponseMap, countDownLatch); + } + + @Override + protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeLocation) { + return "{id=" + + targetNode.getConfigNodeId() + + ", internalEndPoint=" + + targetNode.getInternalEndPoint() + + "}"; + } + + public static ConfigNodeAbstractAsyncRPCHandler buildHandler(AsyncRequestContext context, + int requestId, TConfigNodeLocation targetConfigNode) { + ConfigNodeRequestType requestType = context.getRequestType(); + Map nodeLocationMap = context.getNodeLocationMap(); + Map responseMap = context.getResponseMap(); + CountDownLatch countDownLatch = context.getCountDownLatch(); + switch (requestType) { + case SUBMIT_TEST_CONNECTION_TASK: + return new SubmitTestConnectionTaskToConfigNodeRPCHandler( + requestType, + requestId, + targetConfigNode, + nodeLocationMap, + (Map) responseMap, + countDownLatch); + case TEST_CONNECTION: + default: + return new AsyncTSStatusRPCHandler2( + requestType, + requestId, + targetConfigNode, + nodeLocationMap, + (Map) responseMap, + countDownLatch); + } + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java index 168208d86b97..bf4baaf74f0d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java @@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch; public class CountPathsUsingTemplateRPCHandler - extends AbstractAsyncRPCHandler { + extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(CountPathsUsingTemplateRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java similarity index 77% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java index a7d957d52e7a..056bd6eb78eb 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java @@ -22,10 +22,10 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; +import org.apache.iotdb.commons.client.gg.AbstractAsyncRPCHandler; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; @@ -43,64 +43,25 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { +public abstract class DataNodeAbstractAsyncRPCHandler extends AbstractAsyncRPCHandler { - // Type of RPC request - protected final DataNodeRequestType requestType; - // Index of request - protected final int requestId; - // Target DataNode - protected final TDataNodeLocation targetDataNode; - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target DataNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetDataNode from the dataNodeLocationMap only - * if its corresponding RPC request success - */ - protected final Map dataNodeLocationMap; - - /** - * Map key: The indices(targetDataNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - protected final Map responseMap; - - // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished - protected final CountDownLatch countDownLatch; - - protected final String formattedTargetLocation; + protected DataNodeAbstractAsyncRPCHandler(DataNodeRequestType requestType, int requestId, TDataNodeLocation targetNode, Map dataNodeLocationMap, Map integerResponseMap, CountDownLatch countDownLatch) { + super(requestType, requestId, targetNode, dataNodeLocationMap, integerResponseMap, countDownLatch); + } - protected AbstractAsyncRPCHandler( - DataNodeRequestType requestType, - int requestId, - TDataNodeLocation targetDataNode, - Map dataNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - this.requestType = requestType; - this.requestId = requestId; - this.targetDataNode = targetDataNode; - this.formattedTargetLocation = - "{id=" - + targetDataNode.getDataNodeId() + @Override + protected String generateFormattedTargetLocation(TDataNodeLocation dataNodeLocation) { + return "{id=" + + targetNode.getDataNodeId() + ", internalEndPoint=" - + targetDataNode.getInternalEndPoint() + + targetNode.getInternalEndPoint() + "}"; - this.dataNodeLocationMap = dataNodeLocationMap; - this.responseMap = responseMap; - this.countDownLatch = countDownLatch; } - public static AbstractAsyncRPCHandler buildHandler(AsyncRequestContext context, - int requestId, TDataNodeLocation targetDataNode) { + public static DataNodeAbstractAsyncRPCHandler buildHandler(AsyncRequestContext context, + int requestId, TDataNodeLocation targetDataNode) { DataNodeRequestType requestType = context.getRequestType(); Map dataNodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java index e73e41322065..fc9a73f6085d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java @@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch; public class FetchSchemaBlackListRPCHandler - extends AbstractAsyncRPCHandler { + extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(FetchSchemaBlackListRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java index ff235a38bd08..f8b293c54ac3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java @@ -29,7 +29,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class PipeHeartbeatRPCHandler extends AbstractAsyncRPCHandler { +public class PipeHeartbeatRPCHandler extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(PipeHeartbeatRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java index 774e914de367..2cb34a2a7fc2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class PipePushMetaRPCHandler extends AbstractAsyncRPCHandler { +public class PipePushMetaRPCHandler extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(PipePushMetaRPCHandler.class); public PipePushMetaRPCHandler( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index e162ce349ae3..809e54271701 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -30,7 +30,7 @@ import java.util.concurrent.CountDownLatch; public class SubmitTestConnectionTaskRPCHandler - extends AbstractAsyncRPCHandler { + extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index 6d469ab12622..0a06ddafd349 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -32,7 +32,7 @@ import java.util.concurrent.CountDownLatch; public class SubmitTestConnectionTaskToConfigNodeRPCHandler - extends AbstractAsyncRPCHandler2 { + extends ConfigNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskToConfigNodeRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java index d5107e315cf1..7f1bc5720df0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class TransferLeaderRPCHandler extends AbstractAsyncRPCHandler { +public class TransferLeaderRPCHandler extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(TransferLeaderRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java index ad6951629921..75ad4aca33b9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java @@ -22,7 +22,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -34,7 +34,7 @@ import java.util.concurrent.CountDownLatch; public class CheckSchemaRegionUsingTemplateRPCHandler - extends AbstractAsyncRPCHandler { + extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(CheckSchemaRegionUsingTemplateRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java index 52f5063101f2..7f2dfb9fef96 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch; public class ConsumerGroupPushMetaRPCHandler - extends AbstractAsyncRPCHandler { + extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerGroupPushMetaRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java index 39cb9cd23e97..364b9797ff8e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -32,7 +32,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class TopicPushMetaRPCHandler extends AbstractAsyncRPCHandler { +public class TopicPushMetaRPCHandler extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(TopicPushMetaRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index bbb721f30e58..45bab39613fb 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -32,10 +32,10 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncConfigNodeClientPool; +import org.apache.iotdb.confignode.client.async.AsyncConfigNodeInternalServiceRequestSender; import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; -import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeClientHandler; +import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; @@ -115,12 +115,12 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { Map configNodeLocationMap = configManager.getNodeManager().getRegisteredConfigNodes().stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - AsyncConfigNodeClientHandler configNodeClientHandler = - new AsyncConfigNodeClientHandler<>( + AsyncConfigNodeRequestContext configNodeClientHandler = + new AsyncConfigNodeRequestContext<>( ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); - AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNode(configNodeClientHandler); + AsyncConfigNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNode(configNodeClientHandler); configNodeClientHandler .getResponseMap() .values() @@ -140,7 +140,7 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { AsyncDataNodeRequestContext dataNodeClientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNode(dataNodeClientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNode(dataNodeClientHandler); dataNodeClientHandler .getResponseMap() .values() @@ -167,7 +167,7 @@ private void submitTestConnectionTaskToAllDataNode() { DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, new TNodeLocations(), configManager.getNodeManager().getRegisteredDataNodeLocations()); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNodeWithRetry(clientHandler); clientHandler.getResponseMap(); } @@ -226,10 +226,10 @@ private List testAllConfigNodeConnection( Map configNodeLocationMap = configNodeLocations.stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - AsyncConfigNodeClientHandler clientHandler = - new AsyncConfigNodeClientHandler<>( + AsyncConfigNodeRequestContext clientHandler = + new AsyncConfigNodeRequestContext<>( ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); - AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNodeWithRetry(clientHandler); + AsyncConfigNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherConfigNodeLocationMap = configNodeLocations.stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); @@ -268,7 +268,7 @@ private List testAllDataNodeConnection( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java index f3440b66cf2a..1361f2bdbe07 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java @@ -23,7 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.slf4j.Logger; @@ -36,14 +36,14 @@ public class AsyncConfigNodeClientPool { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); - private final IClientManager clientManager; + private final IClientManager clientManager; private static final int MAX_RETRY_NUM = 6; private AsyncConfigNodeClientPool() { clientManager = - new IClientManager.Factory() - .createClientManager(new ClientPoolFactory.AsyncConfigNodeIServiceClientPoolFactory()); + new IClientManager.Factory() + .createClientManager(new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); } /** @@ -130,7 +130,7 @@ private void sendAsyncRequestToConfigNode( int retryCount) { try { - AsyncConfigNodeIServiceClient client; + AsyncConfigNodeInternalServiceClient client; client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); Object req = clientHandler.getRequest(requestId); AbstractAsyncRPCHandler2 handler = @@ -169,7 +169,7 @@ public void resetClient(TEndPoint endPoint) { clientManager.clear(endPoint); } - public AsyncConfigNodeIServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) + public AsyncConfigNodeInternalServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) throws ClientManagerException { return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java index 3347708b9ab6..846a7fa8303b 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java @@ -20,7 +20,7 @@ package org.apache.iotdb.commons.client; import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.commons.client.async.AsyncConfigNodeIServiceClient; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.client.async.AsyncDataNodeMPPDataExchangeServiceClient; @@ -64,15 +64,15 @@ public KeyedObjectPool createClientPool } } - public static class AsyncConfigNodeIServiceClientPoolFactory - implements IClientPoolFactory { + public static class AsyncConfigNodeInternalServiceClientPoolFactory + implements IClientPoolFactory { @Override - public KeyedObjectPool createClientPool( - ClientManager manager) { - GenericKeyedObjectPool clientPool = + public KeyedObjectPool createClientPool( + ClientManager manager) { + GenericKeyedObjectPool clientPool = new GenericKeyedObjectPool<>( - new AsyncConfigNodeIServiceClient.Factory( + new AsyncConfigNodeInternalServiceClient.Factory( manager, new ThriftClientProperty.Builder() .setConnectionTimeoutMs(conf.getConnectionTimeoutInMS()) @@ -80,7 +80,7 @@ public KeyedObjectPool createClientPoo .setSelectorNumOfAsyncClientManager(conf.getSelectorNumOfClientManager()) .build(), ThreadName.ASYNC_CONFIGNODE_CLIENT_POOL.getName()), - new ClientPoolProperty.Builder().build().getConfig()); + new ClientPoolProperty.Builder().build().getConfig()); ClientManagerMetrics.getInstance() .registerClientManager(this.getClass().getSimpleName(), clientPool); return clientPool; @@ -161,15 +161,15 @@ public KeyedObjectPool createClie } public static class AsyncConfigNodeHeartbeatServiceClientPoolFactory - implements IClientPoolFactory { + implements IClientPoolFactory { @Override - public KeyedObjectPool createClientPool( - ClientManager manager) { + public KeyedObjectPool createClientPool( + ClientManager manager) { - GenericKeyedObjectPool clientPool = + GenericKeyedObjectPool clientPool = new GenericKeyedObjectPool<>( - new AsyncConfigNodeIServiceClient.Factory( + new AsyncConfigNodeInternalServiceClient.Factory( manager, new ThriftClientProperty.Builder() .setConnectionTimeoutMs(conf.getConnectionTimeoutInMS()) @@ -178,7 +178,7 @@ public KeyedObjectPool createClientPoo .setPrintLogWhenEncounterException(false) .build(), ThreadName.ASYNC_CONFIGNODE_HEARTBEAT_CLIENT_POOL.getName()), - new ClientPoolProperty.Builder().build().getConfig()); + new ClientPoolProperty.Builder().build().getConfig()); ClientManagerMetrics.getInstance() .registerClientManager(this.getClass().getSimpleName(), clientPool); return clientPool; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeIServiceClient.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeInternalServiceClient.java similarity index 84% rename from iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeIServiceClient.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeInternalServiceClient.java index 36d273c7b782..6016bb235500 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeIServiceClient.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeInternalServiceClient.java @@ -36,20 +36,20 @@ import java.io.IOException; -public class AsyncConfigNodeIServiceClient extends IConfigNodeRPCService.AsyncClient +public class AsyncConfigNodeInternalServiceClient extends IConfigNodeRPCService.AsyncClient implements ThriftClient { - private static final Logger logger = LoggerFactory.getLogger(AsyncConfigNodeIServiceClient.class); + private static final Logger logger = LoggerFactory.getLogger(AsyncConfigNodeInternalServiceClient.class); private final boolean printLogWhenEncounterException; private final TEndPoint endpoint; - private final ClientManager clientManager; + private final ClientManager clientManager; - public AsyncConfigNodeIServiceClient( + public AsyncConfigNodeInternalServiceClient( ThriftClientProperty property, TEndPoint endpoint, TAsyncClientManager tClientManager, - ClientManager clientManager) + ClientManager clientManager) throws IOException { super( property.getProtocolFactory(), @@ -126,10 +126,10 @@ public String toString() { } public static class Factory - extends AsyncThriftClientFactory { + extends AsyncThriftClientFactory { public Factory( - ClientManager clientManager, + ClientManager clientManager, ThriftClientProperty thriftClientProperty, String threadName) { super(clientManager, thriftClientProperty, threadName); @@ -137,15 +137,15 @@ public Factory( @Override public void destroyObject( - TEndPoint endPoint, PooledObject pooledObject) { + TEndPoint endPoint, PooledObject pooledObject) { pooledObject.getObject().close(); } @Override - public PooledObject makeObject(TEndPoint endPoint) + public PooledObject makeObject(TEndPoint endPoint) throws Exception { return new DefaultPooledObject<>( - new AsyncConfigNodeIServiceClient( + new AsyncConfigNodeInternalServiceClient( thriftClientProperty, endPoint, tManagers[clientCnt.incrementAndGet() % tManagers.length], @@ -154,7 +154,7 @@ public PooledObject makeObject(TEndPoint endPoint @Override public boolean validateObject( - TEndPoint endPoint, PooledObject pooledObject) { + TEndPoint endPoint, PooledObject pooledObject) { return pooledObject.getObject().isReady(); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java similarity index 55% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java index 2c00e64873a7..d6eaeb65bc90 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AbstractAsyncRPCHandler2.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java @@ -17,69 +17,63 @@ * under the License. */ -package org.apache.iotdb.confignode.client.async.handlers.rpc; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +package org.apache.iotdb.commons.client.gg; import org.apache.thrift.async.AsyncMethodCallback; import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class AbstractAsyncRPCHandler2 implements AsyncMethodCallback { +public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { // Type of RPC request - protected final ConfigNodeRequestType requestType; + protected final RequestType requestType; // Index of request protected final int requestId; - // Target ConfigNode - protected final TConfigNodeLocation targetConfigNode; + // Target Node + protected final NodeLocation targetNode; /** * Map key: The indices of asynchronous RPC requests. * - *

Map value: The target ConfigNodes of corresponding indices + *

Map value: The target Nodes of corresponding indices * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap - * only if its corresponding RPC request success + *

All kinds of AsyncHandler will remove its targetNode from the nodeLocationMap only + * if its corresponding RPC request success */ - protected final Map configNodeLocationMap; + protected final Map nodeLocationMap; /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. + * Map key: The indices(targetNode's ID) of asynchronous RPC requests. * *

Map value: The response of corresponding indices * *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC * request finished */ - protected final Map responseMap; + protected final Map responseMap; // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished protected final CountDownLatch countDownLatch; protected final String formattedTargetLocation; - protected AbstractAsyncRPCHandler2( - ConfigNodeRequestType requestType, + protected AbstractAsyncRPCHandler( + RequestType requestType, int requestId, - TConfigNodeLocation targetConfigNode, - Map configNodeLocationMap, - Map responseMap, + NodeLocation targetNode, + Map nodeLocationMap, + Map responseMap, CountDownLatch countDownLatch) { this.requestType = requestType; this.requestId = requestId; - this.targetConfigNode = targetConfigNode; - this.formattedTargetLocation = - "{id=" - + targetConfigNode.getConfigNodeId() - + ", internalEndPoint=" - + targetConfigNode.getInternalEndPoint() - + "}"; + this.targetNode = targetNode; + this.formattedTargetLocation = generateFormattedTargetLocation(targetNode); - this.configNodeLocationMap = configNodeLocationMap; + this.nodeLocationMap = nodeLocationMap; this.responseMap = responseMap; this.countDownLatch = countDownLatch; } + + abstract protected String generateFormattedTargetLocation(NodeLocation location); } From 3527e50151d9a984145341b73e89212f4fe7e6d9 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 11 Jun 2024 10:29:59 +0800 Subject: [PATCH 21/52] Revert "ConfigNodeClient" This reverts commit f90770f9 --- .../db/protocol/client/ConfigNodeClient.java | 97 +++++-------------- 1 file changed, 26 insertions(+), 71 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java index 88192016bfcd..bd5d69a68707 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java @@ -176,11 +176,13 @@ public class ConfigNodeClient implements IConfigNodeRPCService.Iface, ThriftClie private TTransport transport; - private List configNodeEndPoints; + private TEndPoint configLeader; - private Cursor cursor; + private List configNodes; - private boolean needRediscoverLeader = false; + private TEndPoint configNode; + + private int cursor = 0; private boolean isFirstInitiated; @@ -195,11 +197,11 @@ public ConfigNodeClient( ThriftClientProperty property, ClientManager clientManager) throws TException { - this.configNodeEndPoints = configNodes; + this.configNodes = configNodes; this.property = property; this.clientManager = clientManager; // Set the first configNode as configLeader for a tentative connection - this.cursor = new Cursor(0); + this.configLeader = this.configNodes.get(0); this.isFirstInitiated = true; connectAndSync(); @@ -214,6 +216,7 @@ public void connect(TEndPoint endpoint) throws TException { if (!transport.isOpen()) { transport.open(); } + configNode = endpoint; } catch (TTransportException e) { throw new TException(e); } @@ -232,13 +235,13 @@ private void connectAndSync() throws TException { } private void tryToConnect() throws TException { - if (!needRediscoverLeader) { + if (configLeader != null) { try { - connect(currentConnection()); + connect(configLeader); return; } catch (TException ignore) { - logger.warn("The current node may have been down {},try next node", currentConnection()); - needRediscoverLeader = true; + logger.warn("The current node may have been down {},try next node", configLeader); + configLeader = null; } } else { try { @@ -254,9 +257,9 @@ private void tryToConnect() throws TException { transport.close(); } - for (int tryHostNum = 0; tryHostNum < configNodeEndPoints.size(); tryHostNum++) { - cursor.set((cursor.get() + 1) % configNodeEndPoints.size()); - TEndPoint tryEndpoint = configNodeEndPoints.get(cursor.get()); + for (int tryHostNum = 0; tryHostNum < configNodes.size(); tryHostNum++) { + cursor = (cursor + 1) % configNodes.size(); + TEndPoint tryEndpoint = configNodes.get(cursor); try { connect(tryEndpoint); @@ -269,25 +272,13 @@ private void tryToConnect() throws TException { throw new TException(MSG_RECONNECTION_FAIL); } - private TEndPoint currentConnection() { - return configNodeEndPoints.get(cursor.get()); - } - - public void manuallySelectConfigNode(TEndPoint endPoint) { - if (!configNodeEndPoints.contains(endPoint)) { - logger.warn("You cannot do this !"); - return; - } - cursor.setAndLock(configNodeEndPoints.indexOf(endPoint)); - } - public TTransport getTransport() { return transport; } public void syncLatestConfigNodeList() { - configNodeEndPoints = ConfigNodeInfo.getInstance().getLatestConfigNodes(); - cursor.set(0); + configNodes = ConfigNodeInfo.getInstance().getLatestConfigNodes(); + cursor = 0; } @Override @@ -314,19 +305,16 @@ private boolean updateConfigNodeLeader(TSStatus status) { try { if (status.getCode() == TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode()) { if (status.isSetRedirectNode()) { - if (!configNodeEndPoints.contains(status.getRedirectNode())) { - configNodeEndPoints.add(status.getRedirectNode()); - } - cursor.set(configNodeEndPoints.indexOf(status.getRedirectNode())); - needRediscoverLeader = false; + configLeader = + new TEndPoint(status.getRedirectNode().getIp(), status.getRedirectNode().getPort()); } else { - needRediscoverLeader = true; + configLeader = null; } if (!isFirstInitiated) { logger.info( "Failed to connect to ConfigNode {} from DataNode {}, because the current node is not " + "leader or not ready yet, will try again later", - currentConnection(), + configNode, config.getAddressAndPort()); } return true; @@ -358,11 +346,11 @@ private T executeRemoteCallWithRetry(final Operation call, final Predicat final String message = String.format( MSG_RECONNECTION_DATANODE_FAIL, - currentConnection(), + configNode, config.getAddressAndPort(), Thread.currentThread().getStackTrace()[2].getMethodName()); logger.warn(message, e); - needRediscoverLeader = true; + configLeader = null; } connectAndSync(); } @@ -401,16 +389,16 @@ public TDataNodeRegisterResp registerDataNode(TDataNodeRegisterReq req) throws T for (TConfigNodeLocation configNodeLocation : resp.getConfigNodeList()) { newConfigNodes.add(configNodeLocation.getInternalEndPoint()); } - configNodeEndPoints = newConfigNodes; + configNodes = newConfigNodes; } catch (TException e) { String message = String.format( MSG_RECONNECTION_DATANODE_FAIL, - currentConnection(), + configNode, config.getAddressAndPort(), Thread.currentThread().getStackTrace()[1].getMethodName()); logger.warn(message, e); - needRediscoverLeader = false; + configLeader = null; } connectAndSync(); } @@ -1145,37 +1133,4 @@ public boolean validateObject( .orElse(false); } } - - private class Cursor { - private int value; - private boolean locked = false; - - public Cursor(int value) { - this.value = value; - } - - public int get() { - return value; - } - - public void set(int value) { - if (!locked) { - this.value = value; - } else { - logger.warn( - "ConfigNodeClient cursor will keep {} and won't change to {}, because it has been locked.", - configNodeEndPoints.get(this.value), - configNodeEndPoints.get(value)); - } - } - - public void setAndLock(int value) { - set(value); - locked = true; - } - - public void unlock() { - locked = false; - } - } } From d86df016fd14b67e137994e6dd57091552d2babf Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 11 Jun 2024 11:13:13 +0800 Subject: [PATCH 22/52] fix compile problem, it's working now --- ...onfigNodeInternalServiceRequestSender.java | 27 ++- ...cDataNodeInternalServiceRequestSender.java | 80 ++++---- .../AsyncConfigNodeRequestContext.java | 16 +- .../handlers/AsyncDataNodeRequestContext.java | 13 +- .../DataNodeInternalServiceRequester.java | 26 --- .../rpc/AsyncTSStatusRPCHandler2.java | 2 +- .../CheckTimeSeriesExistenceRPCHandler.java | 16 +- .../ConfigNodeAbstractAsyncRPCHandler.java | 61 +++--- .../CountPathsUsingTemplateRPCHandler.java | 16 +- .../rpc/DataNodeAbstractAsyncRPCHandler.java | 183 ++++++++++-------- .../rpc/FetchSchemaBlackListRPCHandler.java | 14 +- .../handlers/rpc/PipeHeartbeatRPCHandler.java | 2 +- .../handlers/rpc/PipePushMetaRPCHandler.java | 2 +- .../handlers/rpc/SchemaUpdateRPCHandler.java | 8 +- .../SubmitTestConnectionTaskRPCHandler.java | 4 +- ...tConnectionTaskToConfigNodeRPCHandler.java | 4 +- .../rpc/TransferLeaderRPCHandler.java | 5 +- ...ckSchemaRegionUsingTemplateRPCHandler.java | 19 +- .../ConsumerGroupPushMetaRPCHandler.java | 2 +- .../subscription/TopicPushMetaRPCHandler.java | 2 +- .../confignode/manager/ClusterManager.java | 17 +- .../manager/ClusterQuotaManager.java | 9 +- .../confignode/manager/TriggerManager.java | 3 +- .../iotdb/confignode/manager/UDFManager.java | 12 +- .../confignode/manager/cq/CQScheduleTask.java | 3 +- .../manager/load/balancer/RouteBalancer.java | 7 +- .../confignode/manager/node/NodeManager.java | 36 ++-- .../manager/partition/PartitionManager.java | 15 +- .../runtime/PipeHeartbeatScheduler.java | 5 +- .../manager/schema/ClusterSchemaManager.java | 8 +- .../procedure/env/ConfigNodeProcedureEnv.java | 70 ++++--- .../procedure/env/RegionMaintainHandler.java | 3 +- .../schema/AlterLogicalViewProcedure.java | 3 +- .../schema/DataNodeRegionTaskExecutor.java | 11 +- .../schema/DeactivateTemplateProcedure.java | 3 +- .../impl/schema/DeleteDatabaseProcedure.java | 4 +- .../schema/DeleteLogicalViewProcedure.java | 3 +- .../schema/DeleteTimeSeriesProcedure.java | 3 +- .../impl/schema/SetTemplateProcedure.java | 15 +- .../impl/schema/UnsetTemplateProcedure.java | 6 +- .../client/cn/AsyncConfigNodeClientPool.java | 3 +- ...syncDataNodeExternalServiceClientPool.java | 99 +++++----- .../impl/DataNodeInternalRPCServiceImpl.java | 66 ++++--- .../config/sys/TestConnectionTask.java | 15 +- .../commons/client/ClientPoolFactory.java | 38 ++-- .../AsyncConfigNodeInternalServiceClient.java | 3 +- .../AsyncDataNodeExternalServiceClient.java | 7 +- .../client/gg/AsyncRequestContext.java | 15 +- ...stSender.java => AsyncRequestManager.java} | 76 ++------ ...ndler.java => AsyncRequestRPCHandler.java} | 11 +- 50 files changed, 554 insertions(+), 517 deletions(-) delete mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/requesters/datanode/DataNodeInternalServiceRequester.java rename iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/{AsyncRequestSender.java => AsyncRequestManager.java} (53%) rename iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/{AbstractAsyncRPCHandler.java => AsyncRequestRPCHandler.java} (89%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java index 2305e538b388..b0d72fd9f581 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java @@ -26,19 +26,22 @@ import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestSender; +import org.apache.iotdb.commons.client.gg.AsyncRequestManager; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; +import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ -public class AsyncConfigNodeInternalServiceRequestSender extends AsyncRequestSender { +public class AsyncConfigNodeInternalServiceRequestSender + extends AsyncRequestManager< + ConfigNodeRequestType, TConfigNodeLocation, AsyncConfigNodeInternalServiceClient> { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestSender.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestSender.class); private AsyncConfigNodeInternalServiceRequestSender() { super(); @@ -47,8 +50,9 @@ private AsyncConfigNodeInternalServiceRequestSender() { @Override protected void initClientManager() { clientManager = - new IClientManager.Factory() - .createClientManager(new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); } @Override @@ -58,15 +62,17 @@ protected TEndPoint nodeLocationToEndPoint(TConfigNodeLocation configNodeLocatio @Override protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, int requestId, TConfigNodeLocation targetNode, int retryCount) { - + AsyncRequestContext requestContext, + int requestId, + TConfigNodeLocation targetNode, + int retryCount) { try { AsyncConfigNodeInternalServiceClient client; client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); Object req = requestContext.getRequest(requestId); ConfigNodeAbstractAsyncRPCHandler handler = - ConfigNodeAbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); + ConfigNodeAbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); AsyncTSStatusRPCHandler2 defaultHandler = null; if (handler instanceof AsyncTSStatusRPCHandler2) { defaultHandler = (AsyncTSStatusRPCHandler2) handler; @@ -97,7 +103,8 @@ protected void sendAsyncRequestToNode( // TODO: Is the ClientPool must be a singleton? private static class ClientPoolHolder { - private static final AsyncConfigNodeInternalServiceRequestSender INSTANCE = new AsyncConfigNodeInternalServiceRequestSender(); + private static final AsyncConfigNodeInternalServiceRequestSender INSTANCE = + new AsyncConfigNodeInternalServiceRequestSender(); private ClientPoolHolder() { // Empty constructor diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java index 36bde787ece2..83e0ea9d6a30 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java @@ -31,12 +31,12 @@ import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestSender; +import org.apache.iotdb.commons.client.gg.AsyncRequestManager; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.FetchSchemaBlackListRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; @@ -91,9 +91,12 @@ import org.slf4j.LoggerFactory; /** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ -public class AsyncDataNodeInternalServiceRequestSender extends AsyncRequestSender { +public class AsyncDataNodeInternalServiceRequestSender + extends AsyncRequestManager< + DataNodeRequestType, TDataNodeLocation, AsyncDataNodeInternalServiceClient> { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestSender.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestSender.class); private AsyncDataNodeInternalServiceRequestSender() { super(); @@ -102,9 +105,9 @@ private AsyncDataNodeInternalServiceRequestSender() { @Override protected void initClientManager() { clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); } @Override @@ -114,13 +117,17 @@ protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { @Override protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, int requestId, TDataNodeLocation targetNode, int retryCount) { + AsyncRequestContext requestContext, + int requestId, + TDataNodeLocation targetNode, + int retryCount) { try { AsyncDataNodeInternalServiceClient client; client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); Object req = requestContext.getRequest(requestId); - DataNodeAbstractAsyncRPCHandler handler = DataNodeAbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); + DataNodeAbstractAsyncRPCHandler handler = + DataNodeAbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); AsyncTSStatusRPCHandler defaultHandler = null; if (handler instanceof AsyncTSStatusRPCHandler) { @@ -181,19 +188,19 @@ protected void sendAsyncRequestToNode( break; case TOPIC_PUSH_SINGLE_META: client.pushSingleTopicMeta( - (TPushSingleTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); + (TPushSingleTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); break; case TOPIC_PUSH_MULTI_META: client.pushMultiTopicMeta( - (TPushMultiTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); + (TPushMultiTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); break; case CONSUMER_GROUP_PUSH_ALL_META: client.pushConsumerGroupMeta( - (TPushConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); + (TPushConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); break; case CONSUMER_GROUP_PUSH_SINGLE_META: client.pushSingleConsumerGroupMeta( - (TPushSingleConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); + (TPushSingleConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); break; case PIPE_HEARTBEAT: client.pipeHeartbeat((TPipeHeartbeatReq) req, (PipeHeartbeatRPCHandler) handler); @@ -225,38 +232,38 @@ protected void sendAsyncRequestToNode( break; case CHANGE_REGION_LEADER: client.changeRegionLeader( - (TRegionLeaderChangeReq) req, (TransferLeaderRPCHandler) handler); + (TRegionLeaderChangeReq) req, (TransferLeaderRPCHandler) handler); break; case CONSTRUCT_SCHEMA_BLACK_LIST: client.constructSchemaBlackList( - (TConstructSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); + (TConstructSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_SCHEMA_BLACK_LIST: client.rollbackSchemaBlackList( - (TRollbackSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); + (TRollbackSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case FETCH_SCHEMA_BLACK_LIST: client.fetchSchemaBlackList( - (TFetchSchemaBlackListReq) req, (FetchSchemaBlackListRPCHandler) handler); + (TFetchSchemaBlackListReq) req, (FetchSchemaBlackListRPCHandler) handler); break; case INVALIDATE_MATCHED_SCHEMA_CACHE: client.invalidateMatchedSchemaCache( - (TInvalidateMatchedSchemaCacheReq) req, defaultHandler); + (TInvalidateMatchedSchemaCacheReq) req, defaultHandler); break; case DELETE_DATA_FOR_DELETE_SCHEMA: client.deleteDataForDeleteSchema( - (TDeleteDataForDeleteSchemaReq) req, (SchemaUpdateRPCHandler) handler); + (TDeleteDataForDeleteSchemaReq) req, (SchemaUpdateRPCHandler) handler); break; case DELETE_TIMESERIES: client.deleteTimeSeries((TDeleteTimeSeriesReq) req, (SchemaUpdateRPCHandler) handler); break; case CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE: client.constructSchemaBlackListWithTemplate( - (TConstructSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); + (TConstructSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE: client.rollbackSchemaBlackListWithTemplate( - (TRollbackSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); + (TRollbackSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); break; case DEACTIVATE_TEMPLATE: client.deactivateTemplate((TDeactivateTemplateReq) req, (SchemaUpdateRPCHandler) handler); @@ -266,24 +273,24 @@ protected void sendAsyncRequestToNode( break; case COUNT_PATHS_USING_TEMPLATE: client.countPathsUsingTemplate( - (TCountPathsUsingTemplateReq) req, (CountPathsUsingTemplateRPCHandler) handler); + (TCountPathsUsingTemplateReq) req, (CountPathsUsingTemplateRPCHandler) handler); break; case CHECK_SCHEMA_REGION_USING_TEMPLATE: client.checkSchemaRegionUsingTemplate( - (TCheckSchemaRegionUsingTemplateReq) req, - (CheckSchemaRegionUsingTemplateRPCHandler) handler); + (TCheckSchemaRegionUsingTemplateReq) req, + (CheckSchemaRegionUsingTemplateRPCHandler) handler); break; case CHECK_TIMESERIES_EXISTENCE: client.checkTimeSeriesExistence( - (TCheckTimeSeriesExistenceReq) req, (CheckTimeSeriesExistenceRPCHandler) handler); + (TCheckTimeSeriesExistenceReq) req, (CheckTimeSeriesExistenceRPCHandler) handler); break; case CONSTRUCT_VIEW_SCHEMA_BLACK_LIST: client.constructViewSchemaBlackList( - (TConstructViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); + (TConstructViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case ROLLBACK_VIEW_SCHEMA_BLACK_LIST: client.rollbackViewSchemaBlackList( - (TRollbackViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); + (TRollbackViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); break; case DELETE_VIEW: client.deleteViewSchema((TDeleteViewSchemaReq) req, (SchemaUpdateRPCHandler) handler); @@ -305,30 +312,31 @@ protected void sendAsyncRequestToNode( break; case SUBMIT_TEST_CONNECTION_TASK: client.submitTestConnectionTask( - (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); + (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); break; case TEST_CONNECTION: client.testConnection(defaultHandler); break; default: LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - requestContext.getRequestType()); + "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", + requestContext.getRequestType()); } } catch (Exception e) { LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - requestContext.getRequestType(), - nodeLocationToEndPoint(targetNode), - e.getMessage(), - retryCount); + "{} failed on DataNode {}, because {}, retrying {}...", + requestContext.getRequestType(), + nodeLocationToEndPoint(targetNode), + e.getMessage(), + retryCount); } } // TODO: Is the ClientPool must be a singleton? private static class ClientPoolHolder { - private static final AsyncDataNodeInternalServiceRequestSender INSTANCE = new AsyncDataNodeInternalServiceRequestSender(); + private static final AsyncDataNodeInternalServiceRequestSender INSTANCE = + new AsyncDataNodeInternalServiceRequestSender(); private ClientPoolHolder() { // Empty constructor diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java index f05c10be237c..e843f618c960 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java @@ -23,11 +23,7 @@ import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; /** * Asynchronous Client handler. @@ -35,17 +31,23 @@ * @param ClassName of RPC request * @param ClassName of RPC response */ -public class AsyncConfigNodeRequestContext extends AsyncRequestContext { +public class AsyncConfigNodeRequestContext + extends AsyncRequestContext { public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType) { super(configNodeRequestType); } - public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType, Map integerTConfigNodeLocationMap) { + public AsyncConfigNodeRequestContext( + ConfigNodeRequestType configNodeRequestType, + Map integerTConfigNodeLocationMap) { super(configNodeRequestType, integerTConfigNodeLocationMap); } - public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType, Q q, Map integerTConfigNodeLocationMap) { + public AsyncConfigNodeRequestContext( + ConfigNodeRequestType configNodeRequestType, + Q q, + Map integerTConfigNodeLocationMap) { super(configNodeRequestType, q, integerTConfigNodeLocationMap); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java index a59da34289d9..5a5051320a4a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java @@ -23,11 +23,7 @@ import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; /** * Asynchronous Client handler. @@ -35,17 +31,20 @@ * @param ClassName of RPC request * @param ClassName of RPC response */ -public class AsyncDataNodeRequestContext extends AsyncRequestContext { +public class AsyncDataNodeRequestContext + extends AsyncRequestContext { public AsyncDataNodeRequestContext(DataNodeRequestType requestType) { super(requestType); } - public AsyncDataNodeRequestContext(DataNodeRequestType requestType, Map dataNodeLocationMap) { + public AsyncDataNodeRequestContext( + DataNodeRequestType requestType, Map dataNodeLocationMap) { super(requestType, dataNodeLocationMap); } - public AsyncDataNodeRequestContext(DataNodeRequestType requestType, Q q, Map dataNodeLocationMap) { + public AsyncDataNodeRequestContext( + DataNodeRequestType requestType, Q q, Map dataNodeLocationMap) { super(requestType, q, dataNodeLocationMap); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/requesters/datanode/DataNodeInternalServiceRequester.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/requesters/datanode/DataNodeInternalServiceRequester.java deleted file mode 100644 index 2e374f2dde3f..000000000000 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/requesters/datanode/DataNodeInternalServiceRequester.java +++ /dev/null @@ -1,26 +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.iotdb.confignode.client.async.handlers.requesters.datanode; - -import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; -import org.apache.iotdb.confignode.client.async.handlers.requesters.Requester; - -public abstract class DataNodeInternalServiceRequester extends Requester { -} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java index 270bf09203e9..17451a818078 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java @@ -59,7 +59,7 @@ public void onComplete(TSStatus response) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { // Remove only if success - configNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.info("Successfully {} on ConfigNode: {}", requestType, formattedTargetLocation); } else { LOGGER.error( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java index b86aaab210fa..1d017cf4fce3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java @@ -53,15 +53,13 @@ public void onComplete(TCheckTimeSeriesExistenceResp response) { TSStatus tsStatus = response.getStatus(); responseMap.put(requestId, response); if (tsStatus.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - dataNodeLocationMap.remove(requestId); - LOGGER.info("Successfully check timeseries existence on DataNode: {}", targetDataNode); + nodeLocationMap.remove(requestId); + LOGGER.info("Successfully check timeseries existence on DataNode: {}", targetNode); } else if (tsStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) { - dataNodeLocationMap.remove(requestId); - LOGGER.error( - "Failed to check timeseries existence on DataNode {}, {}", targetDataNode, tsStatus); + nodeLocationMap.remove(requestId); + LOGGER.error("Failed to check timeseries existence on DataNode {}, {}", targetNode, tsStatus); } else { - LOGGER.error( - "Failed to check timeseries existence on DataNode {}, {}", targetDataNode, tsStatus); + LOGGER.error("Failed to check timeseries existence on DataNode {}, {}", targetNode, tsStatus); } countDownLatch.countDown(); } @@ -70,9 +68,9 @@ public void onComplete(TCheckTimeSeriesExistenceResp response) { public void onError(Exception e) { String errorMsg = "Check timeseries existence error on DataNode: {id=" - + targetDataNode.getDataNodeId() + + targetNode.getDataNodeId() + ", internalEndPoint=" - + targetDataNode.getInternalEndPoint() + + targetNode.getInternalEndPoint() + "}" + e.getMessage(); LOGGER.error(errorMsg); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java index a26713a4d03c..34cb22835778 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java @@ -20,34 +20,47 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.commons.client.gg.AbstractAsyncRPCHandler; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.DataNodeRequestType; import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class ConfigNodeAbstractAsyncRPCHandler extends AbstractAsyncRPCHandler { +public abstract class ConfigNodeAbstractAsyncRPCHandler + extends AsyncRequestRPCHandler { - protected ConfigNodeAbstractAsyncRPCHandler(ConfigNodeRequestType configNodeRequestType, int requestId, TConfigNodeLocation targetNode, Map integerTConfigNodeLocationMap, Map integerResponseMap, CountDownLatch countDownLatch) { - super(configNodeRequestType, requestId, targetNode, integerTConfigNodeLocationMap, integerResponseMap, countDownLatch); + protected ConfigNodeAbstractAsyncRPCHandler( + ConfigNodeRequestType configNodeRequestType, + int requestId, + TConfigNodeLocation targetNode, + Map integerTConfigNodeLocationMap, + Map integerResponseMap, + CountDownLatch countDownLatch) { + super( + configNodeRequestType, + requestId, + targetNode, + integerTConfigNodeLocationMap, + integerResponseMap, + countDownLatch); } @Override protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeLocation) { return "{id=" - + targetNode.getConfigNodeId() - + ", internalEndPoint=" - + targetNode.getInternalEndPoint() - + "}"; + + targetNode.getConfigNodeId() + + ", internalEndPoint=" + + targetNode.getInternalEndPoint() + + "}"; } - public static ConfigNodeAbstractAsyncRPCHandler buildHandler(AsyncRequestContext context, - int requestId, TConfigNodeLocation targetConfigNode) { + public static ConfigNodeAbstractAsyncRPCHandler buildHandler( + AsyncRequestContext context, + int requestId, + TConfigNodeLocation targetConfigNode) { ConfigNodeRequestType requestType = context.getRequestType(); Map nodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); @@ -55,21 +68,21 @@ public static ConfigNodeAbstractAsyncRPCHandler buildHandler(AsyncRequestCont switch (requestType) { case SUBMIT_TEST_CONNECTION_TASK: return new SubmitTestConnectionTaskToConfigNodeRPCHandler( - requestType, - requestId, - targetConfigNode, - nodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetConfigNode, + nodeLocationMap, + (Map) responseMap, + countDownLatch); case TEST_CONNECTION: default: return new AsyncTSStatusRPCHandler2( - requestType, - requestId, - targetConfigNode, - nodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetConfigNode, + nodeLocationMap, + (Map) responseMap, + countDownLatch); } } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java index bf4baaf74f0d..66c0cda43e9c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java @@ -53,15 +53,13 @@ public void onComplete(TCountPathsUsingTemplateResp response) { TSStatus tsStatus = response.getStatus(); responseMap.put(requestId, response); if (tsStatus.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - dataNodeLocationMap.remove(requestId); - LOGGER.info("Successfully count paths using template on DataNode: {}", targetDataNode); + nodeLocationMap.remove(requestId); + LOGGER.info("Successfully count paths using template on DataNode: {}", targetNode); } else if (tsStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) { - dataNodeLocationMap.remove(requestId); - LOGGER.error( - "Failed to count paths using template on DataNode {}, {}", targetDataNode, tsStatus); + nodeLocationMap.remove(requestId); + LOGGER.error("Failed to count paths using template on DataNode {}, {}", targetNode, tsStatus); } else { - LOGGER.error( - "Failed to count paths using template on DataNode {}, {}", targetDataNode, tsStatus); + LOGGER.error("Failed to count paths using template on DataNode {}, {}", targetNode, tsStatus); } countDownLatch.countDown(); } @@ -70,9 +68,9 @@ public void onComplete(TCountPathsUsingTemplateResp response) { public void onError(Exception e) { String errorMsg = "Count paths using template error on DataNode: {id=" - + targetDataNode.getDataNodeId() + + targetNode.getDataNodeId() + ", internalEndPoint=" - + targetDataNode.getInternalEndPoint() + + targetNode.getInternalEndPoint() + "}" + e.getMessage(); LOGGER.error(errorMsg); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java index 056bd6eb78eb..0e960b9ef95d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java @@ -22,10 +22,9 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.commons.client.gg.AbstractAsyncRPCHandler; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; import org.apache.iotdb.confignode.client.DataNodeRequestType; - import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; @@ -38,30 +37,42 @@ import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaResp; import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeResp; -import org.apache.thrift.async.AsyncMethodCallback; import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class DataNodeAbstractAsyncRPCHandler extends AbstractAsyncRPCHandler { - +public abstract class DataNodeAbstractAsyncRPCHandler + extends AsyncRequestRPCHandler { - protected DataNodeAbstractAsyncRPCHandler(DataNodeRequestType requestType, int requestId, TDataNodeLocation targetNode, Map dataNodeLocationMap, Map integerResponseMap, CountDownLatch countDownLatch) { - super(requestType, requestId, targetNode, dataNodeLocationMap, integerResponseMap, countDownLatch); + protected DataNodeAbstractAsyncRPCHandler( + DataNodeRequestType requestType, + int requestId, + TDataNodeLocation targetNode, + Map dataNodeLocationMap, + Map integerResponseMap, + CountDownLatch countDownLatch) { + super( + requestType, + requestId, + targetNode, + dataNodeLocationMap, + integerResponseMap, + countDownLatch); } @Override protected String generateFormattedTargetLocation(TDataNodeLocation dataNodeLocation) { return "{id=" - + targetNode.getDataNodeId() - + ", internalEndPoint=" - + targetNode.getInternalEndPoint() - + "}"; - + + targetNode.getDataNodeId() + + ", internalEndPoint=" + + targetNode.getInternalEndPoint() + + "}"; } - public static DataNodeAbstractAsyncRPCHandler buildHandler(AsyncRequestContext context, - int requestId, TDataNodeLocation targetDataNode) { + public static DataNodeAbstractAsyncRPCHandler buildHandler( + AsyncRequestContext context, + int requestId, + TDataNodeLocation targetDataNode) { DataNodeRequestType requestType = context.getRequestType(); Map dataNodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); @@ -79,97 +90,97 @@ public static DataNodeAbstractAsyncRPCHandler buildHandler(AsyncRequestContex case DELETE_VIEW: case ALTER_VIEW: return new SchemaUpdateRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case FETCH_SCHEMA_BLACK_LIST: return new FetchSchemaBlackListRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case COUNT_PATHS_USING_TEMPLATE: return new CountPathsUsingTemplateRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case CHECK_SCHEMA_REGION_USING_TEMPLATE: return new CheckSchemaRegionUsingTemplateRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case CHECK_TIMESERIES_EXISTENCE: return new CheckTimeSeriesExistenceRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case PIPE_HEARTBEAT: return new PipeHeartbeatRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case PIPE_PUSH_ALL_META: case PIPE_PUSH_SINGLE_META: case PIPE_PUSH_MULTI_META: return new PipePushMetaRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case TOPIC_PUSH_ALL_META: case TOPIC_PUSH_SINGLE_META: case TOPIC_PUSH_MULTI_META: return new TopicPushMetaRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case CONSUMER_GROUP_PUSH_ALL_META: case CONSUMER_GROUP_PUSH_SINGLE_META: return new ConsumerGroupPushMetaRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case CHANGE_REGION_LEADER: return new TransferLeaderRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case SUBMIT_TEST_CONNECTION_TASK: return new SubmitTestConnectionTaskRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); case SET_TTL: case CREATE_DATA_REGION: case CREATE_SCHEMA_REGION: @@ -196,12 +207,12 @@ public static DataNodeAbstractAsyncRPCHandler buildHandler(AsyncRequestContex case TEST_CONNECTION: default: return new AsyncTSStatusRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); + requestType, + requestId, + targetDataNode, + dataNodeLocationMap, + (Map) responseMap, + countDownLatch); } } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java index fc9a73f6085d..a25d35c40e6f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java @@ -53,15 +53,15 @@ public void onComplete(TFetchSchemaBlackListResp tFetchSchemaBlackListResp) { TSStatus tsStatus = tFetchSchemaBlackListResp.getStatus(); responseMap.put(requestId, tFetchSchemaBlackListResp); if (tsStatus.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - dataNodeLocationMap.remove(requestId); - LOGGER.info("Successfully fetch schemaengine black list on DataNode: {}", targetDataNode); + nodeLocationMap.remove(requestId); + LOGGER.info("Successfully fetch schemaengine black list on DataNode: {}", targetNode); } else if (tsStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) { - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.error( - "Failed to fetch schemaengine black list on DataNode {}, {}", targetDataNode, tsStatus); + "Failed to fetch schemaengine black list on DataNode {}, {}", targetNode, tsStatus); } else { LOGGER.error( - "Failed to fetch schemaengine black list on DataNode {}, {}", targetDataNode, tsStatus); + "Failed to fetch schemaengine black list on DataNode {}, {}", targetNode, tsStatus); } countDownLatch.countDown(); } @@ -70,9 +70,9 @@ public void onComplete(TFetchSchemaBlackListResp tFetchSchemaBlackListResp) { public void onError(Exception e) { String errorMsg = "Fetch schemaengine black list error on DataNode: {id=" - + targetDataNode.getDataNodeId() + + targetNode.getDataNodeId() + ", internalEndPoint=" - + targetDataNode.getInternalEndPoint() + + targetNode.getInternalEndPoint() + "}" + e.getMessage(); LOGGER.error(errorMsg); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java index f8b293c54ac3..6301d6ce5bd6 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java @@ -47,7 +47,7 @@ public PipeHeartbeatRPCHandler( public void onComplete(TPipeHeartbeatResp response) { // Put response responseMap.put(requestId, response); - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.info("Successfully {} on DataNode: {}", requestType, formattedTargetLocation); // Always CountDown diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java index 2cb34a2a7fc2..ba8769de74dd 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java @@ -60,7 +60,7 @@ public void onComplete(TPushPipeMetaResp response) { } // Always remove to avoid retrying - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); // Always CountDown countDownLatch.countDown(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java index 3980e6e0c1b5..7bd576ab7810 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java @@ -50,10 +50,10 @@ public void onComplete(TSStatus tsStatus) { responseMap.put(requestId, tsStatus); LOGGER.info("{} for {} receives: {}", requestType, requestId, tsStatus); if (tsStatus.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.info("Successfully {} on DataNode: {}", requestType, formattedTargetLocation); } else if (tsStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) { - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.warn( "Failed to {} on DataNode {}, {}", requestType, formattedTargetLocation, tsStatus); } else { @@ -68,9 +68,9 @@ public void onError(Exception e) { String errorMsg = requestType + " error on DataNode: {id=" - + targetDataNode.getDataNodeId() + + targetNode.getDataNodeId() + ", internalEndPoint=" - + targetDataNode.getInternalEndPoint() + + targetNode.getInternalEndPoint() + "}" + e.getMessage(); LOGGER.warn(errorMsg); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index 809e54271701..e523899c6e9e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -48,7 +48,7 @@ public SubmitTestConnectionTaskRPCHandler( @Override public void onComplete(TTestConnectionResp resp) { responseMap.put(requestId, resp); - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); countDownLatch.countDown(); } @@ -57,7 +57,7 @@ public void onComplete(TTestConnectionResp resp) { public void onError(Exception e) { LOGGER.error("gg", e); responseMap.put(requestId, new TTestConnectionResp()); - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); countDownLatch.countDown(); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index 0a06ddafd349..901eab920940 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -56,7 +56,7 @@ public SubmitTestConnectionTaskToConfigNodeRPCHandler( @Override public void onComplete(TTestConnectionResp resp) { responseMap.put(requestId, resp); - configNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); countDownLatch.countDown(); } @@ -67,7 +67,7 @@ public void onError(Exception e) { TTestConnectionResp resp = new TTestConnectionResp(); resp.setStatus(new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())); responseMap.put(requestId, new TTestConnectionResp()); - configNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); countDownLatch.countDown(); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java index 7f1bc5720df0..3ae3a1b69152 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java @@ -31,7 +31,8 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class TransferLeaderRPCHandler extends DataNodeAbstractAsyncRPCHandler { +public class TransferLeaderRPCHandler + extends DataNodeAbstractAsyncRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(TransferLeaderRPCHandler.class); @@ -52,7 +53,7 @@ public void onComplete(TRegionLeaderChangeResp response) { if (response.getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { // Remove only if success - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.info("Successfully {} on DataNode: {}", requestType, formattedTargetLocation); } else { LOGGER.error( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java index 75ad4aca33b9..944021eefdd4 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java @@ -54,20 +54,15 @@ public void onComplete(TCheckSchemaRegionUsingTemplateResp response) { TSStatus tsStatus = response.getStatus(); responseMap.put(requestId, response); if (tsStatus.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - dataNodeLocationMap.remove(requestId); - LOGGER.info( - "Successfully check schema region using template on DataNode: {}", targetDataNode); + nodeLocationMap.remove(requestId); + LOGGER.info("Successfully check schema region using template on DataNode: {}", targetNode); } else if (tsStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) { - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.error( - "Failed to check schema region using template on DataNode {}, {}", - targetDataNode, - tsStatus); + "Failed to check schema region using template on DataNode {}, {}", targetNode, tsStatus); } else { LOGGER.error( - "Failed to check schema region using template on DataNode {}, {}", - targetDataNode, - tsStatus); + "Failed to check schema region using template on DataNode {}, {}", targetNode, tsStatus); } countDownLatch.countDown(); } @@ -76,9 +71,9 @@ public void onComplete(TCheckSchemaRegionUsingTemplateResp response) { public void onError(Exception e) { String errorMsg = "Count paths using template error on DataNode: {id=" - + targetDataNode.getDataNodeId() + + targetNode.getDataNodeId() + ", internalEndPoint=" - + targetDataNode.getInternalEndPoint() + + targetNode.getInternalEndPoint() + "}" + e.getMessage(); LOGGER.error(errorMsg); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java index 7f2dfb9fef96..5a4bb07c5ef6 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java @@ -63,7 +63,7 @@ public void onComplete(TPushConsumerGroupMetaResp response) { } // Always remove to avoid retrying - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); // Always CountDown countDownLatch.countDown(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java index 364b9797ff8e..6fec30a28ea3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java @@ -62,7 +62,7 @@ public void onComplete(TPushTopicMetaResp response) { } // Always remove to avoid retrying - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); // Always CountDown countDownLatch.countDown(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 45bab39613fb..3ea324d4f115 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -34,8 +34,8 @@ import org.apache.iotdb.confignode.client.DataNodeRequestType; import org.apache.iotdb.confignode.client.async.AsyncConfigNodeInternalServiceRequestSender; import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; @@ -120,7 +120,8 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); - AsyncConfigNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNode(configNodeClientHandler); + AsyncConfigNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNode(configNodeClientHandler); configNodeClientHandler .getResponseMap() .values() @@ -140,7 +141,8 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { AsyncDataNodeRequestContext dataNodeClientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNode(dataNodeClientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNode(dataNodeClientHandler); dataNodeClientHandler .getResponseMap() .values() @@ -167,7 +169,8 @@ private void submitTestConnectionTaskToAllDataNode() { DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, new TNodeLocations(), configManager.getNodeManager().getRegisteredDataNodeLocations()); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); clientHandler.getResponseMap(); } @@ -229,7 +232,8 @@ private List testAllConfigNodeConnection( AsyncConfigNodeRequestContext clientHandler = new AsyncConfigNodeRequestContext<>( ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); - AsyncConfigNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNodeWithRetry(clientHandler); + AsyncConfigNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherConfigNodeLocationMap = configNodeLocations.stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); @@ -268,7 +272,8 @@ private List testAllDataNodeConnection( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java index c0dde859bb1e..7899be084692 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java @@ -88,8 +88,10 @@ public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } return response; @@ -195,7 +197,8 @@ public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } return response; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index 92fe7b45e9b3..7b02e08b1c89 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -251,7 +251,8 @@ public List updateTriggerLocation( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index c3452c6b2d2e..b5e894702d9d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -128,8 +128,10 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, final TCreateFunctionInstanceReq req = new TCreateFunctionInstanceReq(udfInformation.serialize()).setJarFile(jarFile); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -161,8 +163,10 @@ private List dropFunctionOnDataNodes(String functionName) { final TDropFunctionInstanceReq request = new TDropFunctionInstanceReq(functionName, false); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java index 701bb758c0cb..5a85eeec95d4 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java @@ -188,7 +188,8 @@ public void run() { new TExecuteCQ(queryBody, startTime, endTime, everyInterval, zoneId, cqId, username); try { AsyncDataNodeInternalServiceClient client = - AsyncDataNodeInternalServiceRequestSender.getInstance().getAsyncClient(targetDataNode.get()); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .getAsyncClient(targetDataNode.get()); client.executeCQ(executeCQReq, new AsyncExecuteCQCallback(startTime, endTime)); } catch (Exception t) { LOGGER.warn("Execute CQ {} failed", cqId, t); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index e2c26c874c6f..6a7cce36d199 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -210,7 +210,7 @@ private void balanceRegionLeader( new TRegionLeaderChangeReq(regionGroupId, newLeader); int requestIndex = requestId.getAndIncrement(); clientHandler.putRequest(requestIndex, regionLeaderChangeReq); - clientHandler.putDataNodeLocation(requestIndex, newLeader); + clientHandler.putNodeLocation(requestIndex, newLeader); } break; } @@ -218,7 +218,7 @@ private void balanceRegionLeader( }); if (requestId.get() > 0) { // Don't retry ChangeLeader request - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNode(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNode(clientHandler); for (int i = 0; i < requestId.get(); i++) { if (clientHandler.getResponseMap().get(i).getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -305,7 +305,8 @@ private void broadcastLatestRegionPriorityMap() { DataNodeRequestType.UPDATE_REGION_ROUTE_MAP, new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); } private void recordRegionPriorityMap( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index b7044fd0632b..011ff081277b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -702,7 +702,8 @@ public List merge() { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(DataNodeRequestType.MERGE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -711,7 +712,8 @@ public List flush(TFlushReq req) { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(DataNodeRequestType.FLUSH, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -720,7 +722,8 @@ public List clearCache() { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(DataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -728,8 +731,10 @@ public List startRpairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -737,8 +742,10 @@ public List stopRepairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -746,8 +753,10 @@ public List loadConfiguration() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -757,7 +766,8 @@ public List setSystemStatus(String status) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -788,8 +798,10 @@ private TSStatus killAllQueries() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index e984afa63391..8a3ca97a08b9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -1271,13 +1271,13 @@ public void maintainRegionReplicas() { new TCreateSchemaRegionReq( schemaRegionCreateTask.getRegionReplicaSet(), schemaRegionCreateTask.getStorageGroup())); - createSchemaRegionHandler.putDataNodeLocation( + createSchemaRegionHandler.putNodeLocation( schemaRegionCreateTask.getRegionId().getId(), schemaRegionCreateTask.getTargetDataNode()); } AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetry(createSchemaRegionHandler); + .sendAsyncRequestToNodeWithRetry(createSchemaRegionHandler); for (Map.Entry entry : createSchemaRegionHandler.getResponseMap().entrySet()) { @@ -1293,7 +1293,8 @@ public void maintainRegionReplicas() { // Create DataRegion AsyncDataNodeRequestContext createDataRegionHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.CREATE_DATA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask dataRegionCreateTask = (RegionCreateTask) regionMaintainTask; @@ -1307,13 +1308,13 @@ public void maintainRegionReplicas() { dataRegionCreateTask.getRegionReplicaSet(), dataRegionCreateTask.getStorageGroup()) .setTtl(dataRegionCreateTask.getTTL())); - createDataRegionHandler.putDataNodeLocation( + createDataRegionHandler.putNodeLocation( dataRegionCreateTask.getRegionId().getId(), dataRegionCreateTask.getTargetDataNode()); } AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetry(createDataRegionHandler); + .sendAsyncRequestToNodeWithRetry(createDataRegionHandler); for (Map.Entry entry : createDataRegionHandler.getResponseMap().entrySet()) { @@ -1340,7 +1341,7 @@ public void maintainRegionReplicas() { regionDeleteTask.getTargetDataNode()); deleteRegionHandler.putRequest( regionDeleteTask.getRegionId().getId(), regionDeleteTask.getRegionId()); - deleteRegionHandler.putDataNodeLocation( + deleteRegionHandler.putNodeLocation( regionDeleteTask.getRegionId().getId(), regionDeleteTask.getTargetDataNode()); regionIdMap.put( @@ -1349,7 +1350,7 @@ public void maintainRegionReplicas() { long startTime = System.currentTimeMillis(); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetry(deleteRegionHandler); + .sendAsyncRequestToNodeWithRetry(deleteRegionHandler); LOGGER.info( "Deleting regions costs {}ms", (System.currentTimeMillis() - startTime)); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java index 4152d09c7aad..e54bbebeb5fb 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java @@ -97,9 +97,10 @@ private synchronized void heartbeat() { LOGGER.info("Collecting pipe heartbeat {} from data nodes", request.heartbeatId); final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeHeartbeatIntervalSecondsForCollectingPipeMeta() * 1000L diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 5da3702161c6..3b3a8b5c71a5 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -447,10 +447,11 @@ public TSStatus setTTL(SetTTLPlan setTTLPlan, boolean isGeneratedByPipe) { TSetTTLReq setTTLReq = new TSetTTLReq(dnlToSgMap.get(dataNodeId), setTTLPlan.getTTL()); clientHandler.putRequest(dataNodeId, setTTLReq); - clientHandler.putDataNodeLocation(dataNodeId, dataNodeLocationMap.get(dataNodeId)); + clientHandler.putNodeLocation(dataNodeId, dataNodeLocationMap.get(dataNodeId)); }); // TODO: Check response - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); try { return getConsensusManager() @@ -1102,7 +1103,8 @@ public synchronized TSStatus extendSchemaTemplate( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, updateTemplateReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index 58cb0dec8057..53dbe2877d05 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -444,7 +444,8 @@ public Map doRegionCreation( } // Send CreateRegion requests to DataNodes - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); // Filter RegionGroups that weren't created successfully int requestId = 0; @@ -468,8 +469,8 @@ public Map doRegionCreation( return failedRegions; } - private AsyncDataNodeRequestContext getCreateSchemaRegionClientHandler( - CreateRegionGroupsPlan createRegionGroupsPlan) { + private AsyncDataNodeRequestContext + getCreateSchemaRegionClientHandler(CreateRegionGroupsPlan createRegionGroupsPlan) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_SCHEMA_REGION); @@ -482,7 +483,7 @@ private AsyncDataNodeRequestContext getCreateS for (TDataNodeLocation dataNodeLocation : regionReplicaSet.getDataNodeLocations()) { clientHandler.putRequest( requestId, genCreateSchemaRegionReq(storageGroup, regionReplicaSet)); - clientHandler.putDataNodeLocation(requestId, dataNodeLocation); + clientHandler.putNodeLocation(requestId, dataNodeLocation); requestId += 1; } } @@ -491,8 +492,8 @@ private AsyncDataNodeRequestContext getCreateS return clientHandler; } - private AsyncDataNodeRequestContext getCreateDataRegionClientHandler( - CreateRegionGroupsPlan createRegionGroupsPlan) { + private AsyncDataNodeRequestContext + getCreateDataRegionClientHandler(CreateRegionGroupsPlan createRegionGroupsPlan) { Map ttlMap = getTTLMap(createRegionGroupsPlan); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); @@ -507,7 +508,7 @@ private AsyncDataNodeRequestContext getCreateDat for (TDataNodeLocation dataNodeLocation : regionReplicaSet.getDataNodeLocations()) { clientHandler.putRequest( requestId, genCreateDataRegionReq(storageGroup, regionReplicaSet, ttl)); - clientHandler.putDataNodeLocation(requestId, dataNodeLocation); + clientHandler.putNodeLocation(requestId, dataNodeLocation); requestId += 1; } } @@ -611,7 +612,8 @@ public List createTriggerOnDataNodes( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -625,7 +627,8 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -638,7 +641,8 @@ public List activeTriggerOnDataNodes(String triggerName) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -651,7 +655,8 @@ public List inactiveTriggerOnDataNodes(String triggerName) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -665,7 +670,8 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -679,7 +685,8 @@ public List dropPipePluginOnDataNodes( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -693,7 +700,7 @@ public Map pushAllPipeMetaToDataNodes( new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -708,7 +715,7 @@ public Map pushSinglePipeMetaToDataNodes(ByteBuffer new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -724,7 +731,7 @@ public Map dropSinglePipeOnDataNodes(String pipeName new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -741,7 +748,7 @@ public Map pushMultiPipeMetaToDataNodes( new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -757,7 +764,7 @@ public Map dropMultiPipeOnDataNodes(List pip new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -773,7 +780,7 @@ public Map pushAllTopicMetaToDataNodes( new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -787,7 +794,8 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) .collect(Collectors.toList()); @@ -802,7 +810,8 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) .collect(Collectors.toList()); @@ -819,7 +828,7 @@ public Map pushMultiTopicMetaToDataNodes( new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -835,7 +844,7 @@ public Map dropMultiTopicOnDataNodes(List t new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -848,11 +857,12 @@ public Map pushAllConsumerGroupMetaToDataNo final TPushConsumerGroupMetaReq request = new TPushConsumerGroupMetaReq().setConsumerGroupMetas(consumerGroupMetaBinaryList); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); + final AsyncDataNodeRequestContext + clientHandler = + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( + .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); return clientHandler.getResponseMap(); @@ -868,7 +878,8 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) .collect(Collectors.toList()); @@ -884,7 +895,8 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) .collect(Collectors.toList()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index 867f0601451e..0e8377034764 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -375,7 +375,8 @@ public Map resetPeerList( DataNodeRequestType.RESET_PEER_LIST, new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseMap(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index 20d5f7afe030..01d140cc9af7 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -125,7 +125,8 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java index 6dda355ad509..43f45fc9a307 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java @@ -86,8 +86,10 @@ void execute() { : getLeaderDataNodeRegionGroupMap( configManager.getLoadManager().getRegionLeaderMap(), targetSchemaRegionGroup); while (!dataNodeConsensusGroupIdMap.isEmpty()) { - AsyncDataNodeRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + prepareRequestHandler(dataNodeConsensusGroupIdMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map> currentFailedDataNodeMap = checkDataNodeExecutionResult(clientHandler.getResponseMap(), dataNodeConsensusGroupIdMap); @@ -114,10 +116,11 @@ void execute() { private AsyncDataNodeRequestContext prepareRequestHandler( Map> dataNodeConsensusGroupIdMap) { - AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(dataNodeRequestType); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>(dataNodeRequestType); for (Map.Entry> entry : dataNodeConsensusGroupIdMap.entrySet()) { - clientHandler.putDataNodeLocation(entry.getKey().getDataNodeId(), entry.getKey()); + clientHandler.putNodeLocation(entry.getKey().getDataNodeId(), entry.getKey()); clientHandler.putRequest( entry.getKey().getDataNodeId(), dataNodeRequestGenerator.apply(entry.getKey(), entry.getValue())); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java index 56d0e0991467..fa96d909a344 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java @@ -203,7 +203,8 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(timeSeriesPatternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schema cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java index 4da91e7d863e..7369c3d8fb7e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java @@ -163,7 +163,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt for (TDataNodeLocation dataNodeLocation : schemaRegionReplicaSet.getDataNodeLocations()) { asyncClientHandler.putRequest(requestIndex, schemaRegionReplicaSet.getRegionId()); - asyncClientHandler.putDataNodeLocation(requestIndex, dataNodeLocation); + asyncClientHandler.putNodeLocation(requestIndex, dataNodeLocation); schemaRegionDeleteTaskMap.put( requestIndex, new RegionDeleteTask(dataNodeLocation, schemaRegionReplicaSet.getRegionId())); @@ -172,7 +172,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt } if (!schemaRegionDeleteTaskMap.isEmpty()) { AsyncDataNodeInternalServiceRequestSender.getInstance() - .sendAsyncRequestToDataNodeWithRetry(asyncClientHandler); + .sendAsyncRequestToNodeWithRetry(asyncClientHandler); for (Map.Entry entry : asyncClientHandler.getResponseMap().entrySet()) { if (entry.getValue().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index bab26eea78bd..b88077ae2790 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -189,7 +189,8 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index 7b73515dff21..c9cd211fe4d2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -195,7 +195,8 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaEngine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index 0fbfff8c34ad..02b82fec0605 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -211,8 +211,10 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -383,8 +385,10 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + new AsyncDataNodeRequestContext<>( + DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -489,7 +493,8 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { // all dataNodes must clear the related template cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index 4ef4d4613a2b..18c9befab981 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -158,7 +158,8 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related template cache @@ -253,7 +254,8 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, rollbackTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeInternalServiceRequestSender.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related template cache diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java index 1361f2bdbe07..19b75517d46b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java @@ -43,7 +43,8 @@ public class AsyncConfigNodeClientPool { private AsyncConfigNodeClientPool() { clientManager = new IClientManager.Factory() - .createClientManager(new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); + .createClientManager( + new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); } /** diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java index db9cb29fe10c..d33f760ee7db 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java @@ -24,65 +24,70 @@ import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; -import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AsyncDataNodeExternalServiceClientPool extends AsyncDataNodeClientPool { +public class AsyncDataNodeExternalServiceClientPool + extends AsyncDataNodeClientPool { - private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeExternalServiceClientPool.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncDataNodeExternalServiceClientPool.class); - public AsyncDataNodeExternalServiceClientPool() { - super(); - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncDataNodeExternalServiceClientPoolFactory()); - } + public AsyncDataNodeExternalServiceClientPool() { + super(); + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeExternalServiceClientPoolFactory()); + } - @Override - void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler, int requestId, TDataNodeLocation targetDataNode, int retryCount) { - { - try { - AsyncDataNodeExternalServiceClient client; - client = clientManager.borrowClient(targetDataNode.getClientRpcEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler handler = - clientHandler.createAsyncRPCHandler(requestId, targetDataNode); - AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; + @Override + void sendAsyncRequestToDataNode( + AsyncClientHandler clientHandler, + int requestId, + TDataNodeLocation targetDataNode, + int retryCount) { + { + try { + AsyncDataNodeExternalServiceClient client; + client = clientManager.borrowClient(targetDataNode.getClientRpcEndPoint()); + Object req = clientHandler.getRequest(requestId); + AbstractAsyncRPCHandler handler = + clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; - switch (clientHandler.getRequestType()) { - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - clientHandler.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetDataNode.getClientRpcEndPoint(), - e.getMessage(), - retryCount); - } + switch (clientHandler.getRequestType()) { + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", + clientHandler.getRequestType()); } + } catch (Exception e) { + LOGGER.warn( + "{} failed on DataNode {}, because {}, retrying {}...", + clientHandler.getRequestType(), + targetDataNode.getClientRpcEndPoint(), + e.getMessage(), + retryCount); + } } + } - private static class ClientPoolHolder { + private static class ClientPoolHolder { - private static final AsyncDataNodeExternalServiceClientPool INSTANCE = - new AsyncDataNodeExternalServiceClientPool(); + private static final AsyncDataNodeExternalServiceClientPool INSTANCE = + new AsyncDataNodeExternalServiceClientPool(); - private ClientPoolHolder() { - // Empty constructor - } + private ClientPoolHolder() { + // Empty constructor } + } - public static AsyncDataNodeExternalServiceClientPool getInstance() { - return AsyncDataNodeExternalServiceClientPool.ClientPoolHolder.INSTANCE; - } + public static AsyncDataNodeExternalServiceClientPool getInstance() { + return AsyncDataNodeExternalServiceClientPool.ClientPoolHolder.INSTANCE; + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index bf6a7192ce3e..19faf5dbf107 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -1433,7 +1433,8 @@ public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations testAllDataNodeInternalServiceConnection(nodeLocations.getDataNodeLocations()); List mppResult = testAllDataNodeMPPServiceConnection(nodeLocations.getDataNodeLocations()); - List clientResult = testAllDataNodeExternalServiceConnection(nodeLocations.getDataNodeLocations()); + List clientResult = + testAllDataNodeExternalServiceConnection(nodeLocations.getDataNodeLocations()); configNodeResult.addAll(dataNodeResult); configNodeResult.addAll(mppResult); configNodeResult.addAll(clientResult); @@ -1501,7 +1502,8 @@ private List testAllDataNodeInternalServiceConnection( .getResponseMap() .forEach( (dataNodeId, status) -> { - TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); + TEndPoint endPoint = + anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); TTestConnectionResult result = new TTestConnectionResult(); @@ -1540,7 +1542,8 @@ private List testAllDataNodeMPPServiceConnection( .getResponseMap() .forEach( (dataNodeId, status) -> { - TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); + TEndPoint endPoint = + anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.DataNodeMPPService); TTestConnectionResult result = new TTestConnectionResult(); @@ -1558,41 +1561,42 @@ private List testAllDataNodeMPPServiceConnection( } private List testAllDataNodeExternalServiceConnection( - List dataNodeLocations) { + List dataNodeLocations) { final TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); Map dataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); AsyncClientHandler clientHandler = - new AsyncClientHandler<>( - DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + new AsyncClientHandler<>( + DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeExternalServiceClientPool.getInstance() - .sendAsyncRequestToDataNodeWithRetry(clientHandler); + .sendAsyncRequestToDataNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + dataNodeLocations.stream() + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); List results = new ArrayList<>(); clientHandler - .getResponseMap() - .forEach( - (dataNodeId, status) -> { - TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getClientRpcEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.DataNodeExternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); + .getResponseMap() + .forEach( + (dataNodeId, status) -> { + TEndPoint endPoint = + anotherDataNodeLocationMap.get(dataNodeId).getClientRpcEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeExternalService); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); return results; } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index 58349a8d6c58..155a137d814f 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -62,11 +62,14 @@ public static void buildTSBlock( for (TTestConnectionResult result : resp.getResultList()) { // ServiceProvider column builder.getTimeColumnBuilder().writeLong(0); - StringBuilder serviceStr = new StringBuilder(serviceProviderToString(result.getServiceProvider())); + StringBuilder serviceStr = + new StringBuilder(serviceProviderToString(result.getServiceProvider())); while (serviceStr.length() < maxLen) { serviceStr.append(" "); } - builder.getColumnBuilder(0).writeBinary(new Binary(serviceStr.toString(), TSFileConfig.STRING_CHARSET)); + builder + .getColumnBuilder(0) + .writeBinary(new Binary(serviceStr.toString(), TSFileConfig.STRING_CHARSET)); // Sender column String senderStr; if (result.getSender().isSetConfigNodeLocation()) { @@ -137,9 +140,11 @@ private static void sortTestConnectionResp(TTestConnectionResp origin) { private static int calculateServiceProviderMaxLen(TTestConnectionResp origin) { return origin.getResultList().stream() - .map(TTestConnectionResult::getServiceProvider) - .map(TestConnectionTask::serviceProviderToString) - .max(Comparator.comparingInt(String::length)).get().length(); + .map(TTestConnectionResult::getServiceProvider) + .map(TestConnectionTask::serviceProviderToString) + .max(Comparator.comparingInt(String::length)) + .get() + .length(); } private static String addLineBreak(String origin, int interval) { diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java index 846a7fa8303b..8af0d556c4aa 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientPoolFactory.java @@ -80,7 +80,9 @@ public KeyedObjectPool createCl .setSelectorNumOfAsyncClientManager(conf.getSelectorNumOfClientManager()) .build(), ThreadName.ASYNC_CONFIGNODE_CLIENT_POOL.getName()), - new ClientPoolProperty.Builder().build().getConfig()); + new ClientPoolProperty.Builder() + .build() + .getConfig()); ClientManagerMetrics.getInstance() .registerClientManager(this.getClass().getSimpleName(), clientPool); return clientPool; @@ -136,26 +138,26 @@ public KeyedObjectPool createClie } public static class AsyncDataNodeExternalServiceClientPoolFactory - implements IClientPoolFactory { + implements IClientPoolFactory { @Override public KeyedObjectPool createClientPool( - ClientManager manager) { + ClientManager manager) { GenericKeyedObjectPool clientPool = - new GenericKeyedObjectPool<>( - new AsyncDataNodeExternalServiceClient.Factory( - manager, - new ThriftClientProperty.Builder() - .setConnectionTimeoutMs(conf.getConnectionTimeoutInMS()) - .setRpcThriftCompressionEnabled(conf.isRpcThriftCompressionEnabled()) - .setSelectorNumOfAsyncClientManager(conf.getSelectorNumOfClientManager()) - .build(), - ThreadName.ASYNC_DATANODE_CLIENT_POOL.getName()), - new ClientPoolProperty.Builder() - .build() - .getConfig()); + new GenericKeyedObjectPool<>( + new AsyncDataNodeExternalServiceClient.Factory( + manager, + new ThriftClientProperty.Builder() + .setConnectionTimeoutMs(conf.getConnectionTimeoutInMS()) + .setRpcThriftCompressionEnabled(conf.isRpcThriftCompressionEnabled()) + .setSelectorNumOfAsyncClientManager(conf.getSelectorNumOfClientManager()) + .build(), + ThreadName.ASYNC_DATANODE_CLIENT_POOL.getName()), + new ClientPoolProperty.Builder() + .build() + .getConfig()); ClientManagerMetrics.getInstance() - .registerClientManager(this.getClass().getSimpleName(), clientPool); + .registerClientManager(this.getClass().getSimpleName(), clientPool); return clientPool; } } @@ -178,7 +180,9 @@ public KeyedObjectPool createCl .setPrintLogWhenEncounterException(false) .build(), ThreadName.ASYNC_CONFIGNODE_HEARTBEAT_CLIENT_POOL.getName()), - new ClientPoolProperty.Builder().build().getConfig()); + new ClientPoolProperty.Builder() + .build() + .getConfig()); ClientManagerMetrics.getInstance() .registerClientManager(this.getClass().getSimpleName(), clientPool); return clientPool; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeInternalServiceClient.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeInternalServiceClient.java index 6016bb235500..b5adc9611360 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeInternalServiceClient.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncConfigNodeInternalServiceClient.java @@ -39,7 +39,8 @@ public class AsyncConfigNodeInternalServiceClient extends IConfigNodeRPCService.AsyncClient implements ThriftClient { - private static final Logger logger = LoggerFactory.getLogger(AsyncConfigNodeInternalServiceClient.class); + private static final Logger logger = + LoggerFactory.getLogger(AsyncConfigNodeInternalServiceClient.class); private final boolean printLogWhenEncounterException; private final TEndPoint endpoint; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncDataNodeExternalServiceClient.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncDataNodeExternalServiceClient.java index eb1954d72613..5de58b8eef14 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncDataNodeExternalServiceClient.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncDataNodeExternalServiceClient.java @@ -19,9 +19,6 @@ package org.apache.iotdb.commons.client.async; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.apache.commons.pool2.PooledObject; -import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.commons.client.ClientManager; import org.apache.iotdb.commons.client.ThriftClient; @@ -30,6 +27,10 @@ import org.apache.iotdb.commons.utils.TestOnly; import org.apache.iotdb.mpp.rpc.thrift.IDataNodeRPCService; import org.apache.iotdb.rpc.TNonblockingSocketWrapper; + +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.commons.pool2.PooledObject; +import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.thrift.async.TAsyncClientManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java index cc236d78d2eb..2d8fd5eeb697 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java @@ -48,8 +48,8 @@ public class AsyncRequestContext { * *

Map value: The target Nodes of corresponding indices * - *

All kinds of AsyncHandler will remove its targetNode from the nodeLocationMap only - * if its corresponding RPC request success + *

All kinds of AsyncHandler will remove its targetNode from the nodeLocationMap only if its + * corresponding RPC request success */ private final Map nodeLocationMap; @@ -82,8 +82,7 @@ public void putNodeLocation(int requestId, NodeLocation nodeLocation) { } /** Constructor for null requests. */ - public AsyncRequestContext( - RequestType requestType, Map nodeLocationMap) { + public AsyncRequestContext(RequestType requestType, Map nodeLocationMap) { this.requestType = requestType; this.nodeLocationMap = nodeLocationMap; @@ -93,15 +92,11 @@ public AsyncRequestContext( /** Constructor for unique request. */ public AsyncRequestContext( - RequestType requestType, - Request request, - Map nodeLocationMap) { + RequestType requestType, Request request, Map nodeLocationMap) { this.requestType = requestType; this.nodeLocationMap = nodeLocationMap; this.requestMap = new ConcurrentHashMap<>(); - this.nodeLocationMap - .keySet() - .forEach(nodeId -> this.requestMap.put(nodeId, request)); + this.nodeLocationMap.keySet().forEach(nodeId -> this.requestMap.put(nodeId, request)); this.responseMap = new ConcurrentHashMap<>(); } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestSender.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java similarity index 53% rename from iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestSender.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java index 0301a393eec9..3ac1fa84bea1 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestSender.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java @@ -19,71 +19,25 @@ package org.apache.iotdb.commons.client.gg; -import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.common.rpc.thrift.TFlushReq; -import org.apache.iotdb.common.rpc.thrift.TNodeLocations; -import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; -import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; -import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; -import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.exception.ClientManagerException; -import org.apache.iotdb.mpp.rpc.thrift.TActiveTriggerInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TAlterViewReq; -import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceReq; -import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListWithTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TConstructViewSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreateDataRegionReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreateFunctionInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreatePipePluginInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreateSchemaRegionReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreateTriggerInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TDeactivateTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TDeleteDataForDeleteSchemaReq; -import org.apache.iotdb.mpp.rpc.thrift.TDeleteTimeSeriesReq; -import org.apache.iotdb.mpp.rpc.thrift.TDeleteViewSchemaReq; -import org.apache.iotdb.mpp.rpc.thrift.TDropFunctionInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TDropPipePluginInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TDropTriggerInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TInactiveTriggerInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TInvalidateMatchedSchemaCacheReq; -import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushMultiPipeMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushMultiTopicMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushSingleConsumerGroupMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushSinglePipeMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushSingleTopicMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeReq; -import org.apache.iotdb.mpp.rpc.thrift.TRegionRouteReq; -import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; -import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListWithTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TRollbackViewSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TUpdateTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TUpdateTriggerLocationReq; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.concurrent.TimeUnit; /** Asynchronously send RPC requests to Nodes. See queryengine.thrift for more details. */ -public abstract class AsyncRequestSender { +public abstract class AsyncRequestManager { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncRequestSender.class); + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncRequestManager.class); protected IClientManager clientManager; private static final int MAX_RETRY_NUM = 6; - protected AsyncRequestSender() { + protected AsyncRequestManager() { initClientManager(); } @@ -98,7 +52,7 @@ protected AsyncRequestSender() { * @param timeoutInMs timeout in milliseconds */ public void sendAsyncRequestToNodeWithRetryAndTimeoutInMs( - AsyncRequestContext requestContext, long timeoutInMs) { + AsyncRequestContext requestContext, long timeoutInMs) { sendAsyncRequest(requestContext, MAX_RETRY_NUM, timeoutInMs); } @@ -109,16 +63,20 @@ public void sendAsyncRequestToNodeWithRetryAndTimeoutInMs( * * @param requestContext which will also contain the result */ - public final void sendAsyncRequestToNodeWithRetry(AsyncRequestContext requestContext) { + public final void sendAsyncRequestToNodeWithRetry( + AsyncRequestContext requestContext) { sendAsyncRequest(requestContext, MAX_RETRY_NUM, null); } - public final void sendAsyncRequestToNode(AsyncRequestContext requestContext) { + public final void sendAsyncRequestToNode( + AsyncRequestContext requestContext) { sendAsyncRequest(requestContext, 1, null); } private final void sendAsyncRequest( - AsyncRequestContext requestContext, int retryNum, Long timeoutInMs) { + AsyncRequestContext requestContext, + int retryNum, + Long timeoutInMs) { if (requestContext.getRequestIndices().isEmpty()) { return; } @@ -164,11 +122,11 @@ private final void sendAsyncRequest( requestContext.getRequestIndices()); } } - + protected abstract TEndPoint nodeLocationToEndPoint(NodeLocation location); - abstract protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, + protected abstract void sendAsyncRequestToNode( + AsyncRequestContext requestContext, int requestId, NodeLocation targetNode, int retryCount); @@ -181,10 +139,8 @@ abstract protected void sendAsyncRequestToNode( public void resetClient(TEndPoint endPoint) { clientManager.clear(endPoint); } - - public Client getAsyncClient(NodeLocation targetNode) - throws ClientManagerException { + public Client getAsyncClient(NodeLocation targetNode) throws ClientManagerException { return clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); } } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestRPCHandler.java similarity index 89% rename from iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestRPCHandler.java index d6eaeb65bc90..f369905d8857 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AbstractAsyncRPCHandler.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestRPCHandler.java @@ -24,7 +24,8 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { +public abstract class AsyncRequestRPCHandler + implements AsyncMethodCallback { // Type of RPC request protected final RequestType requestType; @@ -38,8 +39,8 @@ public abstract class AbstractAsyncRPCHandlerMap value: The target Nodes of corresponding indices * - *

All kinds of AsyncHandler will remove its targetNode from the nodeLocationMap only - * if its corresponding RPC request success + *

All kinds of AsyncHandler will remove its targetNode from the nodeLocationMap only if its + * corresponding RPC request success */ protected final Map nodeLocationMap; @@ -58,7 +59,7 @@ public abstract class AbstractAsyncRPCHandler Date: Tue, 11 Jun 2024 11:30:34 +0800 Subject: [PATCH 23/52] rename RequestSender to RequestManager --- ...figNodeInternalServiceRequestManager.java} | 12 +++--- ...ataNodeInternalServiceRequestManager.java} | 12 +++--- .../confignode/manager/ClusterManager.java | 14 +++---- .../manager/ClusterQuotaManager.java | 6 +-- .../confignode/manager/TriggerManager.java | 4 +- .../iotdb/confignode/manager/UDFManager.java | 6 +-- .../confignode/manager/cq/CQScheduleTask.java | 4 +- .../manager/load/balancer/RouteBalancer.java | 6 +-- .../confignode/manager/node/NodeManager.java | 18 ++++---- .../manager/partition/PartitionManager.java | 8 ++-- .../runtime/PipeHeartbeatScheduler.java | 4 +- .../manager/schema/ClusterSchemaManager.java | 6 +-- .../procedure/env/ConfigNodeProcedureEnv.java | 42 +++++++++---------- .../procedure/env/RegionMaintainHandler.java | 4 +- .../schema/AlterLogicalViewProcedure.java | 4 +- .../schema/DataNodeRegionTaskExecutor.java | 4 +- .../schema/DeactivateTemplateProcedure.java | 4 +- .../impl/schema/DeleteDatabaseProcedure.java | 4 +- .../schema/DeleteLogicalViewProcedure.java | 4 +- .../schema/DeleteTimeSeriesProcedure.java | 4 +- .../impl/schema/SetTemplateProcedure.java | 8 ++-- .../impl/schema/UnsetTemplateProcedure.java | 6 +-- 22 files changed, 92 insertions(+), 92 deletions(-) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/{AsyncConfigNodeInternalServiceRequestSender.java => AsyncConfigNodeInternalServiceRequestManager.java} (92%) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/{AsyncDataNodeInternalServiceRequestSender.java => AsyncDataNodeInternalServiceRequestManager.java} (97%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java similarity index 92% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java index b0d72fd9f581..a7fee8948804 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestSender.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java @@ -36,14 +36,14 @@ import org.slf4j.LoggerFactory; /** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ -public class AsyncConfigNodeInternalServiceRequestSender +public class AsyncConfigNodeInternalServiceRequestManager extends AsyncRequestManager< ConfigNodeRequestType, TConfigNodeLocation, AsyncConfigNodeInternalServiceClient> { private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestSender.class); + LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestManager.class); - private AsyncConfigNodeInternalServiceRequestSender() { + private AsyncConfigNodeInternalServiceRequestManager() { super(); } @@ -103,15 +103,15 @@ protected void sendAsyncRequestToNode( // TODO: Is the ClientPool must be a singleton? private static class ClientPoolHolder { - private static final AsyncConfigNodeInternalServiceRequestSender INSTANCE = - new AsyncConfigNodeInternalServiceRequestSender(); + private static final AsyncConfigNodeInternalServiceRequestManager INSTANCE = + new AsyncConfigNodeInternalServiceRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static AsyncConfigNodeInternalServiceRequestSender getInstance() { + public static AsyncConfigNodeInternalServiceRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java similarity index 97% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java index 83e0ea9d6a30..17c8b651e5f0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestSender.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java @@ -91,14 +91,14 @@ import org.slf4j.LoggerFactory; /** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ -public class AsyncDataNodeInternalServiceRequestSender +public class AsyncDataNodeInternalServiceRequestManager extends AsyncRequestManager< DataNodeRequestType, TDataNodeLocation, AsyncDataNodeInternalServiceClient> { private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestSender.class); + LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestManager.class); - private AsyncDataNodeInternalServiceRequestSender() { + private AsyncDataNodeInternalServiceRequestManager() { super(); } @@ -335,15 +335,15 @@ protected void sendAsyncRequestToNode( // TODO: Is the ClientPool must be a singleton? private static class ClientPoolHolder { - private static final AsyncDataNodeInternalServiceRequestSender INSTANCE = - new AsyncDataNodeInternalServiceRequestSender(); + private static final AsyncDataNodeInternalServiceRequestManager INSTANCE = + new AsyncDataNodeInternalServiceRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static AsyncDataNodeInternalServiceRequestSender getInstance() { + public static AsyncDataNodeInternalServiceRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 3ea324d4f115..c934fd477efe 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -32,8 +32,8 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncConfigNodeInternalServiceRequestSender; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncConfigNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeRequestContext; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; @@ -120,7 +120,7 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); - AsyncConfigNodeInternalServiceRequestSender.getInstance() + AsyncConfigNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNode(configNodeClientHandler); configNodeClientHandler .getResponseMap() @@ -141,7 +141,7 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { AsyncDataNodeRequestContext dataNodeClientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNode(dataNodeClientHandler); dataNodeClientHandler .getResponseMap() @@ -169,7 +169,7 @@ private void submitTestConnectionTaskToAllDataNode() { DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, new TNodeLocations(), configManager.getNodeManager().getRegisteredDataNodeLocations()); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); clientHandler.getResponseMap(); } @@ -232,7 +232,7 @@ private List testAllConfigNodeConnection( AsyncConfigNodeRequestContext clientHandler = new AsyncConfigNodeRequestContext<>( ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); - AsyncConfigNodeInternalServiceRequestSender.getInstance() + AsyncConfigNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherConfigNodeLocationMap = configNodeLocations.stream() @@ -272,7 +272,7 @@ private List testAllDataNodeConnection( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = dataNodeLocations.stream() diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java index 7899be084692..88a937e97faf 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java @@ -27,7 +27,7 @@ import org.apache.iotdb.common.rpc.thrift.TThrottleQuota; import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.quota.SetSpaceQuotaPlan; import org.apache.iotdb.confignode.consensus.request.write.quota.SetThrottleQuotaPlan; @@ -90,7 +90,7 @@ public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } @@ -197,7 +197,7 @@ public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index 7b02e08b1c89..c3b16e88cbf9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -25,7 +25,7 @@ import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.trigger.TriggerInformation; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTransferringTriggersPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerJarPlan; @@ -251,7 +251,7 @@ public List updateTriggerLocation( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index b5e894702d9d..62aa2f7e4417 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -24,7 +24,7 @@ import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.commons.udf.UDFInformation; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.function.GetFunctionTablePlan; @@ -130,7 +130,7 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -165,7 +165,7 @@ private List dropFunctionOnDataNodes(String functionName) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java index 5a85eeec95d4..0d2427bb707d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java @@ -24,7 +24,7 @@ import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.cq.TimeoutPolicy; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.consensus.request.write.cq.UpdateCQLastExecTimePlan; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.persistence.cq.CQInfo; @@ -188,7 +188,7 @@ public void run() { new TExecuteCQ(queryBody, startTime, endTime, everyInterval, zoneId, cqId, username); try { AsyncDataNodeInternalServiceClient client = - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .getAsyncClient(targetDataNode.get()); client.executeCQ(executeCQReq, new AsyncExecuteCQCallback(startTime, endTime)); } catch (Exception t) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index 6a7cce36d199..11ce6c6e7176 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -26,7 +26,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -218,7 +218,7 @@ private void balanceRegionLeader( }); if (requestId.get() > 0) { // Don't retry ChangeLeader request - AsyncDataNodeInternalServiceRequestSender.getInstance().sendAsyncRequestToNode(clientHandler); + AsyncDataNodeInternalServiceRequestManager.getInstance().sendAsyncRequestToNode(clientHandler); for (int i = 0; i < requestId.get(); i++) { if (clientHandler.getResponseMap().get(i).getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -305,7 +305,7 @@ private void broadcastLatestRegionPriorityMap() { DataNodeRequestType.UPDATE_REGION_ROUTE_MAP, new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index 011ff081277b..576d399c5ed2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -34,7 +34,7 @@ import org.apache.iotdb.commons.consensus.ConsensusGroupId; import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; @@ -702,7 +702,7 @@ public List merge() { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(DataNodeRequestType.MERGE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -712,7 +712,7 @@ public List flush(TFlushReq req) { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(DataNodeRequestType.FLUSH, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -722,7 +722,7 @@ public List clearCache() { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>(DataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -733,7 +733,7 @@ public List startRpairData() { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -744,7 +744,7 @@ public List stopRepairData() { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -755,7 +755,7 @@ public List loadConfiguration() { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -766,7 +766,7 @@ public List setSystemStatus(String status) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -800,7 +800,7 @@ private TSStatus killAllQueries() { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index 8a3ca97a08b9..5a233adb9a09 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -35,7 +35,7 @@ import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -1276,7 +1276,7 @@ public void maintainRegionReplicas() { schemaRegionCreateTask.getTargetDataNode()); } - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(createSchemaRegionHandler); for (Map.Entry entry : @@ -1313,7 +1313,7 @@ public void maintainRegionReplicas() { dataRegionCreateTask.getTargetDataNode()); } - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(createDataRegionHandler); for (Map.Entry entry : @@ -1349,7 +1349,7 @@ public void maintainRegionReplicas() { } long startTime = System.currentTimeMillis(); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(deleteRegionHandler); LOGGER.info( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java index e54bbebeb5fb..712f77c4e696 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java @@ -25,7 +25,7 @@ import org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil; import org.apache.iotdb.commons.pipe.config.PipeConfig; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.ConfigManager; @@ -99,7 +99,7 @@ private synchronized void heartbeat() { final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeHeartbeatIntervalSecondsForCollectingPipeMeta() diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 3b3a8b5c71a5..6a4ff84ed597 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -32,7 +32,7 @@ import org.apache.iotdb.commons.utils.PathUtils; import org.apache.iotdb.commons.utils.StatusUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -450,7 +450,7 @@ public TSStatus setTTL(SetTTLPlan setTTLPlan, boolean isGeneratedByPipe) { clientHandler.putNodeLocation(dataNodeId, dataNodeLocationMap.get(dataNodeId)); }); // TODO: Check response - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); try { @@ -1103,7 +1103,7 @@ public synchronized TSStatus extendSchemaTemplate( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, updateTemplateReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index 53dbe2877d05..977a7b525d70 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -34,7 +34,7 @@ import org.apache.iotdb.commons.trigger.TriggerInformation; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; @@ -444,7 +444,7 @@ public Map doRegionCreation( } // Send CreateRegion requests to DataNodes - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); // Filter RegionGroups that weren't created successfully @@ -612,7 +612,7 @@ public List createTriggerOnDataNodes( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -627,7 +627,7 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -641,7 +641,7 @@ public List activeTriggerOnDataNodes(String triggerName) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -655,7 +655,7 @@ public List inactiveTriggerOnDataNodes(String triggerName) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -670,7 +670,7 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -685,7 +685,7 @@ public List dropPipePluginOnDataNodes( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -699,7 +699,7 @@ public Map pushAllPipeMetaToDataNodes( final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -714,7 +714,7 @@ public Map pushSinglePipeMetaToDataNodes(ByteBuffer final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -730,7 +730,7 @@ public Map dropSinglePipeOnDataNodes(String pipeName final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -747,7 +747,7 @@ public Map pushMultiPipeMetaToDataNodes( final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -763,7 +763,7 @@ public Map dropMultiPipeOnDataNodes(List pip final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -779,7 +779,7 @@ public Map pushAllTopicMetaToDataNodes( final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -794,7 +794,7 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) @@ -810,7 +810,7 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) @@ -827,7 +827,7 @@ public Map pushMultiTopicMetaToDataNodes( final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -843,7 +843,7 @@ public Map dropMultiTopicOnDataNodes(List t final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -861,7 +861,7 @@ public Map pushAllConsumerGroupMetaToDataNo clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -878,7 +878,7 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) @@ -895,7 +895,7 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index 0e8377034764..9f511c5ce43d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -35,7 +35,7 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.NodeUrlUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; @@ -375,7 +375,7 @@ public Map resetPeerList( DataNodeRequestType.RESET_PEER_LIST, new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseMap(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index 01d140cc9af7..1587739d60ae 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -31,7 +31,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; @@ -125,7 +125,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java index 43f45fc9a307..533c99e34164 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java @@ -23,7 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -88,7 +88,7 @@ void execute() { while (!dataNodeConsensusGroupIdMap.isEmpty()) { AsyncDataNodeRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map> currentFailedDataNodeMap = checkDataNodeExecutionResult(clientHandler.getResponseMap(), dataNodeConsensusGroupIdMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java index fa96d909a344..9845d2cd7eef 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java @@ -29,7 +29,7 @@ import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeactivateTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -203,7 +203,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(timeSeriesPatternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java index 7369c3d8fb7e..d99f509ba1db 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.ThriftConfigNodeSerDeUtils; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.database.PreDeleteDatabasePlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; @@ -171,7 +171,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt } } if (!schemaRegionDeleteTaskMap.isEmpty()) { - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(asyncClientHandler); for (Map.Entry entry : asyncClientHandler.getResponseMap().entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index b88077ae2790..2bf5b9c345cc 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -27,7 +27,7 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -189,7 +189,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index c9cd211fe4d2..e6e49264338a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -27,7 +27,7 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -195,7 +195,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index 02b82fec0605..10e318e51f34 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -29,7 +29,7 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.read.template.CheckTemplateSettablePlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetSchemaTemplatePlan; @@ -213,7 +213,7 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { @@ -387,7 +387,7 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { @@ -493,7 +493,7 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index 18c9befab981..a90c4b1c0051 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -27,7 +27,7 @@ import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestSender; +import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; @@ -158,7 +158,7 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -254,7 +254,7 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( DataNodeRequestType.UPDATE_TEMPLATE, rollbackTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestSender.getInstance() + AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { From 25053c6bfa86b380a6b00265e260e9dc12e6f387 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 11 Jun 2024 11:41:54 +0800 Subject: [PATCH 24/52] rename AbstractAsyncRPCHandler to AsyncRequestRPCHandler --- ...yncConfigNodeInternalServiceRequestManager.java | 14 +++++++------- ...AsyncDataNodeInternalServiceRequestManager.java | 14 +++++++------- .../rpc/CheckTimeSeriesExistenceRPCHandler.java | 2 +- ....java => ConfigNodeAsyncRequestRPCHandler.java} | 8 ++++---- ...ler2.java => ConfigNodeTSStatusRPCHandler.java} | 6 +++--- .../rpc/CountPathsUsingTemplateRPCHandler.java | 2 +- ...er.java => DataNodeAsyncRequestRPCHandler.java} | 8 ++++---- ...andler.java => DataNodeTSStatusRPCHandler.java} | 6 +++--- .../rpc/FetchSchemaBlackListRPCHandler.java | 2 +- .../handlers/rpc/PipeHeartbeatRPCHandler.java | 2 +- .../async/handlers/rpc/PipePushMetaRPCHandler.java | 2 +- .../async/handlers/rpc/SchemaUpdateRPCHandler.java | 2 +- .../rpc/SubmitTestConnectionTaskRPCHandler.java | 2 +- ...itTestConnectionTaskToConfigNodeRPCHandler.java | 2 +- .../handlers/rpc/TransferLeaderRPCHandler.java | 2 +- .../CheckSchemaRegionUsingTemplateRPCHandler.java | 4 ++-- .../ConsumerGroupPushMetaRPCHandler.java | 4 ++-- .../rpc/subscription/TopicPushMetaRPCHandler.java | 4 ++-- 18 files changed, 43 insertions(+), 43 deletions(-) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/{ConfigNodeAbstractAsyncRPCHandler.java => ConfigNodeAsyncRequestRPCHandler.java} (93%) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/{AsyncTSStatusRPCHandler2.java => ConfigNodeTSStatusRPCHandler.java} (92%) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/{DataNodeAbstractAsyncRPCHandler.java => DataNodeAsyncRequestRPCHandler.java} (97%) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/{AsyncTSStatusRPCHandler.java => DataNodeTSStatusRPCHandler.java} (92%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java index a7fee8948804..00aed352a624 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java @@ -28,8 +28,8 @@ import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestManager; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler2; -import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeTSStatusRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAsyncRequestRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; import org.slf4j.Logger; @@ -71,11 +71,11 @@ protected void sendAsyncRequestToNode( AsyncConfigNodeInternalServiceClient client; client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); Object req = requestContext.getRequest(requestId); - ConfigNodeAbstractAsyncRPCHandler handler = - ConfigNodeAbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); - AsyncTSStatusRPCHandler2 defaultHandler = null; - if (handler instanceof AsyncTSStatusRPCHandler2) { - defaultHandler = (AsyncTSStatusRPCHandler2) handler; + ConfigNodeAsyncRequestRPCHandler handler = + ConfigNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); + ConfigNodeTSStatusRPCHandler defaultHandler = null; + if (handler instanceof ConfigNodeTSStatusRPCHandler) { + defaultHandler = (ConfigNodeTSStatusRPCHandler) handler; } switch (requestContext.getRequestType()) { case SUBMIT_TEST_CONNECTION_TASK: diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java index 17c8b651e5f0..ef80fe0a394e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java @@ -33,10 +33,10 @@ import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestManager; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.AsyncTSStatusRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.FetchSchemaBlackListRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; @@ -126,12 +126,12 @@ protected void sendAsyncRequestToNode( AsyncDataNodeInternalServiceClient client; client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); Object req = requestContext.getRequest(requestId); - DataNodeAbstractAsyncRPCHandler handler = - DataNodeAbstractAsyncRPCHandler.buildHandler(requestContext, requestId, targetNode); + DataNodeAsyncRequestRPCHandler handler = + DataNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); - AsyncTSStatusRPCHandler defaultHandler = null; - if (handler instanceof AsyncTSStatusRPCHandler) { - defaultHandler = (AsyncTSStatusRPCHandler) handler; + DataNodeTSStatusRPCHandler defaultHandler = null; + if (handler instanceof DataNodeTSStatusRPCHandler) { + defaultHandler = (DataNodeTSStatusRPCHandler) handler; } switch (requestContext.getRequestType()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java index 1d017cf4fce3..ee4c534be3f3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java @@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch; public class CheckTimeSeriesExistenceRPCHandler - extends DataNodeAbstractAsyncRPCHandler { + extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(CheckTimeSeriesExistenceRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java similarity index 93% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java index 34cb22835778..6f623071518e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAbstractAsyncRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java @@ -29,10 +29,10 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class ConfigNodeAbstractAsyncRPCHandler +public abstract class ConfigNodeAsyncRequestRPCHandler extends AsyncRequestRPCHandler { - protected ConfigNodeAbstractAsyncRPCHandler( + protected ConfigNodeAsyncRequestRPCHandler( ConfigNodeRequestType configNodeRequestType, int requestId, TConfigNodeLocation targetNode, @@ -57,7 +57,7 @@ protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeL + "}"; } - public static ConfigNodeAbstractAsyncRPCHandler buildHandler( + public static ConfigNodeAsyncRequestRPCHandler buildHandler( AsyncRequestContext context, int requestId, TConfigNodeLocation targetConfigNode) { @@ -76,7 +76,7 @@ public static ConfigNodeAbstractAsyncRPCHandler buildHandler( countDownLatch); case TEST_CONNECTION: default: - return new AsyncTSStatusRPCHandler2( + return new ConfigNodeTSStatusRPCHandler( requestType, requestId, targetConfigNode, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java similarity index 92% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java index 17451a818078..ece8c6be9c68 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler2.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java @@ -32,11 +32,11 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncTSStatusRPCHandler2 extends ConfigNodeAbstractAsyncRPCHandler { +public class ConfigNodeTSStatusRPCHandler extends ConfigNodeAsyncRequestRPCHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNodeTSStatusRPCHandler.class); - public AsyncTSStatusRPCHandler2( + public ConfigNodeTSStatusRPCHandler( ConfigNodeRequestType requestType, int requestId, TConfigNodeLocation targetConfigNode, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java index 66c0cda43e9c..313fb0761194 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java @@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch; public class CountPathsUsingTemplateRPCHandler - extends DataNodeAbstractAsyncRPCHandler { + extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(CountPathsUsingTemplateRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java similarity index 97% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java index 0e960b9ef95d..bb4a587a7fb5 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAbstractAsyncRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java @@ -41,10 +41,10 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class DataNodeAbstractAsyncRPCHandler +public abstract class DataNodeAsyncRequestRPCHandler extends AsyncRequestRPCHandler { - protected DataNodeAbstractAsyncRPCHandler( + protected DataNodeAsyncRequestRPCHandler( DataNodeRequestType requestType, int requestId, TDataNodeLocation targetNode, @@ -69,7 +69,7 @@ protected String generateFormattedTargetLocation(TDataNodeLocation dataNodeLocat + "}"; } - public static DataNodeAbstractAsyncRPCHandler buildHandler( + public static DataNodeAsyncRequestRPCHandler buildHandler( AsyncRequestContext context, int requestId, TDataNodeLocation targetDataNode) { @@ -206,7 +206,7 @@ public static DataNodeAbstractAsyncRPCHandler buildHandler( case RESET_PEER_LIST: case TEST_CONNECTION: default: - return new AsyncTSStatusRPCHandler( + return new DataNodeTSStatusRPCHandler( requestType, requestId, targetDataNode, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java similarity index 92% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java index fd101cdc2b3a..72599af2dd1d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/AsyncTSStatusRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java @@ -32,11 +32,11 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncTSStatusRPCHandler extends DataNodeAbstractAsyncRPCHandler { +public class DataNodeTSStatusRPCHandler extends DataNodeAsyncRequestRPCHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeTSStatusRPCHandler.class); - public AsyncTSStatusRPCHandler( + public DataNodeTSStatusRPCHandler( DataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java index a25d35c40e6f..6f907d390548 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java @@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch; public class FetchSchemaBlackListRPCHandler - extends DataNodeAbstractAsyncRPCHandler { + extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(FetchSchemaBlackListRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java index 6301d6ce5bd6..a2abed14d059 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java @@ -29,7 +29,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class PipeHeartbeatRPCHandler extends DataNodeAbstractAsyncRPCHandler { +public class PipeHeartbeatRPCHandler extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(PipeHeartbeatRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java index ba8769de74dd..a6114a8c0236 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class PipePushMetaRPCHandler extends DataNodeAbstractAsyncRPCHandler { +public class PipePushMetaRPCHandler extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(PipePushMetaRPCHandler.class); public PipePushMetaRPCHandler( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java index 7bd576ab7810..f073233e8325 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class SchemaUpdateRPCHandler extends AsyncTSStatusRPCHandler { +public class SchemaUpdateRPCHandler extends DataNodeTSStatusRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(SchemaUpdateRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index e523899c6e9e..0f43381c8098 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -30,7 +30,7 @@ import java.util.concurrent.CountDownLatch; public class SubmitTestConnectionTaskRPCHandler - extends DataNodeAbstractAsyncRPCHandler { + extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index 901eab920940..be1bb8016932 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -32,7 +32,7 @@ import java.util.concurrent.CountDownLatch; public class SubmitTestConnectionTaskToConfigNodeRPCHandler - extends ConfigNodeAbstractAsyncRPCHandler { + extends ConfigNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(SubmitTestConnectionTaskToConfigNodeRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java index 3ae3a1b69152..b67fa4d03757 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java @@ -32,7 +32,7 @@ import java.util.concurrent.CountDownLatch; public class TransferLeaderRPCHandler - extends DataNodeAbstractAsyncRPCHandler { + extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(TransferLeaderRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java index 944021eefdd4..b112457f0fa9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java @@ -22,7 +22,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -34,7 +34,7 @@ import java.util.concurrent.CountDownLatch; public class CheckSchemaRegionUsingTemplateRPCHandler - extends DataNodeAbstractAsyncRPCHandler { + extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(CheckSchemaRegionUsingTemplateRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java index 5a4bb07c5ef6..bc8bfd0b6d78 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch; public class ConsumerGroupPushMetaRPCHandler - extends DataNodeAbstractAsyncRPCHandler { + extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerGroupPushMetaRPCHandler.class); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java index 6fec30a28ea3..9bbdc1625e96 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAbstractAsyncRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -32,7 +32,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public class TopicPushMetaRPCHandler extends DataNodeAbstractAsyncRPCHandler { +public class TopicPushMetaRPCHandler extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(TopicPushMetaRPCHandler.class); From 37e72aecb3948e4d18ba95c4e9600a904e9009f2 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 11 Jun 2024 12:21:24 +0800 Subject: [PATCH 25/52] dn -> cn --- ...nfigNodeInternalServiceRequestManager.java | 2 +- ...DataNodeInternalServiceRequestManager.java | 2 +- .../manager/load/balancer/RouteBalancer.java | 3 +- .../client/cn/AbstractAsyncRPCHandler2.java | 84 -------- .../cn/AsyncConfigNodeClientHandler.java | 161 --------------- .../client/cn/AsyncConfigNodeClientPool.java | 191 ------------------ ...nfigNodeInternalServiceRequestManager.java | 99 +++++++++ .../cn/AsyncConfigNodeRequestContext.java | 52 +++++ .../client/cn/AsyncTSStatusRPCHandler2.java | 4 +- .../cn/ConfigNodeAsyncRequestRPCHandler.java | 80 ++++++++ .../impl/DataNodeInternalRPCServiceImpl.java | 11 +- 11 files changed, 243 insertions(+), 446 deletions(-) delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java index 00aed352a624..fb85001c9425 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java @@ -28,8 +28,8 @@ import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestManager; import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAsyncRequestRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; import org.slf4j.Logger; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java index ef80fe0a394e..1544a07d8f2e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java @@ -33,10 +33,10 @@ import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestManager; import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.FetchSchemaBlackListRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index 11ce6c6e7176..396cce0d0e18 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -218,7 +218,8 @@ private void balanceRegionLeader( }); if (requestId.get() > 0) { // Don't retry ChangeLeader request - AsyncDataNodeInternalServiceRequestManager.getInstance().sendAsyncRequestToNode(clientHandler); + AsyncDataNodeInternalServiceRequestManager.getInstance() + .sendAsyncRequestToNode(clientHandler); for (int i = 0; i < requestId.get(); i++) { if (clientHandler.getResponseMap().get(i).getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java deleted file mode 100644 index 4992d3ee620d..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AbstractAsyncRPCHandler2.java +++ /dev/null @@ -1,84 +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.iotdb.db.protocol.client.cn; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; - -import org.apache.thrift.async.AsyncMethodCallback; - -import java.util.Map; -import java.util.concurrent.CountDownLatch; - -public abstract class AbstractAsyncRPCHandler2 implements AsyncMethodCallback { - - // Type of RPC request - protected final ConfigNodeRequestType requestType; - // Index of request - protected final int requestId; - // Target ConfigNode - protected final TConfigNodeLocation targetConfigNode; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target ConfigNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap - * only if its corresponding RPC request success - */ - protected final Map configNodeLocationMap; - - /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - protected final Map responseMap; - - // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished - protected final CountDownLatch countDownLatch; - - protected final String formattedTargetLocation; - - protected AbstractAsyncRPCHandler2( - ConfigNodeRequestType requestType, - int requestId, - TConfigNodeLocation targetConfigNode, - Map configNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - this.requestType = requestType; - this.requestId = requestId; - this.targetConfigNode = targetConfigNode; - this.formattedTargetLocation = - "{id=" - + targetConfigNode.getConfigNodeId() - + ", internalEndPoint=" - + targetConfigNode.getInternalEndPoint() - + "}"; - - this.configNodeLocationMap = configNodeLocationMap; - this.responseMap = responseMap; - this.countDownLatch = countDownLatch; - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java deleted file mode 100644 index 833a65c8e0ff..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientHandler.java +++ /dev/null @@ -1,161 +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.iotdb.db.protocol.client.cn; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TSStatus; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public class AsyncConfigNodeClientHandler { - - // Type of RPC request - protected final ConfigNodeRequestType requestType; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The corresponding RPC request - */ - private final Map requestMap; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target ConfigNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetConfigNode from the configNodeLocationMap - * only if its corresponding RPC request success - */ - private final Map configNodeLocationMap; - - /** - * Map key: The indices(targetConfigNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - private final Map responseMap; - - private CountDownLatch countDownLatch; - - /** Custom constructor. */ - public AsyncConfigNodeClientHandler(ConfigNodeRequestType requestType) { - this.requestType = requestType; - this.requestMap = new ConcurrentHashMap<>(); - this.configNodeLocationMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - public void putRequest(int requestId, Q request) { - requestMap.put(requestId, request); - } - - public void putConfigNodeLocation(int requestId, TConfigNodeLocation configNodeLocation) { - configNodeLocationMap.put(requestId, configNodeLocation); - } - - /** Constructor for null requests. */ - public AsyncConfigNodeClientHandler( - ConfigNodeRequestType requestType, Map configNodeLocationMap) { - this.requestType = requestType; - this.configNodeLocationMap = configNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - /** Constructor for unique request. */ - public AsyncConfigNodeClientHandler( - ConfigNodeRequestType requestType, - Q request, - Map configNodeLocationMap) { - this.requestType = requestType; - this.configNodeLocationMap = configNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.configNodeLocationMap - .keySet() - .forEach(configNodeId -> this.requestMap.put(configNodeId, request)); - - this.responseMap = new ConcurrentHashMap<>(); - } - - public ConfigNodeRequestType getRequestType() { - return requestType; - } - - public List getRequestIndices() { - return new ArrayList<>(configNodeLocationMap.keySet()); - } - - public Q getRequest(int requestId) { - return requestMap.get(requestId); - } - - public TConfigNodeLocation getConfigNodeLocation(int requestId) { - return configNodeLocationMap.get(requestId); - } - - public List getResponseList() { - return new ArrayList<>(responseMap.values()); - } - - public Map getResponseMap() { - return responseMap; - } - - /** Always reset CountDownLatch before retry. */ - public void resetCountDownLatch() { - countDownLatch = new CountDownLatch(configNodeLocationMap.size()); - } - - public CountDownLatch getCountDownLatch() { - return countDownLatch; - } - - public AbstractAsyncRPCHandler2 createAsyncRPCHandler( - int requestId, TConfigNodeLocation targetConfigNode) { - switch (requestType) { - case SUBMIT_TEST_CONNECTION_TASK: - case TEST_CONNECTION: - default: - return new AsyncTSStatusRPCHandler2( - requestType, - requestId, - targetConfigNode, - configNodeLocationMap, - (Map) responseMap, - countDownLatch); - } - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java deleted file mode 100644 index 19b75517d46b..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeClientPool.java +++ /dev/null @@ -1,191 +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.iotdb.db.protocol.client.cn; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.commons.client.ClientPoolFactory; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; -import org.apache.iotdb.commons.client.exception.ClientManagerException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.TimeUnit; - -/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ -public class AsyncConfigNodeClientPool { - - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeClientPool.class); - - private final IClientManager clientManager; - - private static final int MAX_RETRY_NUM = 6; - - private AsyncConfigNodeClientPool() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); - } - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - * @param timeoutInMs timeout in milliseconds - */ - public void sendAsyncRequestToConfigNodeWithRetryAndTimeoutInMs( - AsyncConfigNodeClientHandler clientHandler, long timeoutInMs) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); - } - - /** - * Send asynchronous requests to the specified ConfigNodes with default retry num - * - *

Notice: The ConfigNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - */ - public void sendAsyncRequestToConfigNodeWithRetry( - AsyncConfigNodeClientHandler clientHandler) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); - } - - public void sendAsyncRequestToConfigNode(AsyncConfigNodeClientHandler clientHandler) { - sendAsyncRequest(clientHandler, 1, null); - } - - private void sendAsyncRequest( - AsyncConfigNodeClientHandler clientHandler, int retryNum, Long timeoutInMs) { - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - - ConfigNodeRequestType requestType = clientHandler.getRequestType(); - for (int retry = 0; retry < retryNum; retry++) { - // Always Reset CountDownLatch first - clientHandler.resetCountDownLatch(); - - // Send requests to all targetConfigNodes - for (int requestId : clientHandler.getRequestIndices()) { - TConfigNodeLocation targetConfigNode = clientHandler.getConfigNodeLocation(requestId); - sendAsyncRequestToConfigNode(clientHandler, requestId, targetConfigNode, retry); - } - - // Wait for this batch of asynchronous RPC requests finish - try { - if (timeoutInMs == null) { - clientHandler.getCountDownLatch().await(); - } else { - if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { - LOGGER.warn( - "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - } - } - } catch (InterruptedException e) { - LOGGER.error( - "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - Thread.currentThread().interrupt(); - } - - // Check if there is a ConfigNode that fails to execute the request, and retry if there exists - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - } - - if (!clientHandler.getRequestIndices().isEmpty()) { - LOGGER.warn( - "Failed to {} on ConfigNode after {} retries, requestIndices: {}", - requestType, - retryNum, - clientHandler.getRequestIndices()); - } - } - - private void sendAsyncRequestToConfigNode( - AsyncConfigNodeClientHandler clientHandler, - int requestId, - TConfigNodeLocation targetConfigNode, - int retryCount) { - - try { - AsyncConfigNodeInternalServiceClient client; - client = clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler2 handler = - clientHandler.createAsyncRPCHandler(requestId, targetConfigNode); - AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; - - switch (clientHandler.getRequestType()) { - // case SUBMIT_TEST_CONNECTION_TASK: - // client.submitTestConnectionTask((TNodeLocations) req, - // (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); - // break; - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", - clientHandler.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on ConfigNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetConfigNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } - } - - /** - * Always call this interface when a ConfigNode is restarted or removed. - * - * @param endPoint The specific ConfigNode - */ - public void resetClient(TEndPoint endPoint) { - clientManager.clear(endPoint); - } - - public AsyncConfigNodeInternalServiceClient getAsyncClient(TConfigNodeLocation targetConfigNode) - throws ClientManagerException { - return clientManager.borrowClient(targetConfigNode.getInternalEndPoint()); - } - - // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { - - private static final AsyncConfigNodeClientPool INSTANCE = new AsyncConfigNodeClientPool(); - - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncConfigNodeClientPool getInstance() { - return ClientPoolHolder.INSTANCE; - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java new file mode 100644 index 000000000000..00accc500aa6 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java @@ -0,0 +1,99 @@ +/* + * 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.db.protocol.client.cn; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestManager; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ +public class AsyncConfigNodeInternalServiceRequestManager + extends AsyncRequestManager< + ConfigNodeRequestType, TConfigNodeLocation, AsyncConfigNodeInternalServiceClient> { + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestManager.class); + + @Override + protected void initClientManager() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); + } + + @Override + protected TEndPoint nodeLocationToEndPoint(TConfigNodeLocation configNodeLocation) { + return configNodeLocation.getInternalEndPoint(); + } + + @Override + protected void sendAsyncRequestToNode( + AsyncRequestContext requestContext, + int requestId, + TConfigNodeLocation targetNode, + int retryCount) { + try { + AsyncConfigNodeInternalServiceClient client; + client = clientManager.borrowClient(targetNode.getInternalEndPoint()); + Object req = requestContext.getRequest(requestId); + ConfigNodeAsyncRequestRPCHandler handler = + ConfigNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); + AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; + + switch (requestContext.getRequestType()) { + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", + requestContext.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on ConfigNode {}, because {}, retrying {}...", + requestContext.getRequestType(), + targetNode.getInternalEndPoint(), + e.getMessage(), + retryCount); + } + } + + private static class ClientPoolHolder { + + private static final AsyncConfigNodeInternalServiceRequestManager INSTANCE = + new AsyncConfigNodeInternalServiceRequestManager(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncConfigNodeInternalServiceRequestManager getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java new file mode 100644 index 000000000000..2ab98d2b6c34 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java @@ -0,0 +1,52 @@ +/* + * 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.db.protocol.client.cn; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; + +import java.util.Map; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncConfigNodeRequestContext + extends AsyncRequestContext { + + public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType) { + super(configNodeRequestType); + } + + public AsyncConfigNodeRequestContext( + ConfigNodeRequestType configNodeRequestType, + Map integerTConfigNodeLocationMap) { + super(configNodeRequestType, integerTConfigNodeLocationMap); + } + + public AsyncConfigNodeRequestContext( + ConfigNodeRequestType configNodeRequestType, + Q q, + Map integerTConfigNodeLocationMap) { + super(configNodeRequestType, q, integerTConfigNodeLocationMap); + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java index 68a9ad8f9035..16543ee1f4a9 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java @@ -31,7 +31,7 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncTSStatusRPCHandler2 extends AbstractAsyncRPCHandler2 { +public class AsyncTSStatusRPCHandler2 extends ConfigNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); @@ -58,7 +58,7 @@ public void onComplete(TSStatus response) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { // Remove only if success - configNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.info("Successfully {} on ConfigNode: {}", requestType, formattedTargetLocation); } else { LOGGER.error( diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java new file mode 100644 index 000000000000..bda48e4e4dc0 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java @@ -0,0 +1,80 @@ +/* + * 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.db.protocol.client.cn; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +// TODO: ConfigNodeRequestType可抽 +public abstract class ConfigNodeAsyncRequestRPCHandler + extends AsyncRequestRPCHandler { + + protected ConfigNodeAsyncRequestRPCHandler( + ConfigNodeRequestType configNodeRequestType, + int requestId, + TConfigNodeLocation targetNode, + Map integerTConfigNodeLocationMap, + Map integerResponseMap, + CountDownLatch countDownLatch) { + super( + configNodeRequestType, + requestId, + targetNode, + integerTConfigNodeLocationMap, + integerResponseMap, + countDownLatch); + } + + @Override + protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeLocation) { + return "{id=" + + targetNode.getConfigNodeId() + + ", internalEndPoint=" + + targetNode.getInternalEndPoint() + + "}"; + } + + public static ConfigNodeAsyncRequestRPCHandler buildHandler( + AsyncRequestContext context, + int requestId, + TConfigNodeLocation targetConfigNode) { + ConfigNodeRequestType requestType = context.getRequestType(); + Map nodeLocationMap = context.getNodeLocationMap(); + Map responseMap = context.getResponseMap(); + CountDownLatch countDownLatch = context.getCountDownLatch(); + switch (requestType) { + case SUBMIT_TEST_CONNECTION_TASK: + case TEST_CONNECTION: + default: + return new AsyncTSStatusRPCHandler2( + requestType, + requestId, + targetConfigNode, + nodeLocationMap, + (Map) responseMap, + countDownLatch); + } + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 19faf5dbf107..53a2f620638e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -73,8 +73,8 @@ import org.apache.iotdb.db.exception.StorageEngineException; import org.apache.iotdb.db.pipe.agent.PipeAgent; import org.apache.iotdb.db.protocol.client.ConfigNodeInfo; -import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientHandler; -import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeClientPool; +import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeInternalServiceRequestManager; +import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeRequestContext; import org.apache.iotdb.db.protocol.client.cn.ConfigNodeRequestType; import org.apache.iotdb.db.protocol.client.dn.AsyncClientHandler; import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeExternalServiceClientPool; @@ -1450,10 +1450,11 @@ private List testAllConfigNodeConnection( Map configNodeLocationMap = configNodeLocations.stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - AsyncConfigNodeClientHandler clientHandler = - new AsyncConfigNodeClientHandler<>( + AsyncConfigNodeRequestContext clientHandler = + new AsyncConfigNodeRequestContext<>( ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); - AsyncConfigNodeClientPool.getInstance().sendAsyncRequestToConfigNodeWithRetry(clientHandler); + AsyncConfigNodeInternalServiceRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherConfigNodeLocationMap = configNodeLocations.stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); From 8481693760749a41fc146571f8dfaa6427700406 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 11 Jun 2024 12:26:58 +0800 Subject: [PATCH 26/52] remove comment --- .../client/async/AsyncConfigNodeHeartbeatClientPool.java | 3 +-- .../async/AsyncConfigNodeInternalServiceRequestManager.java | 3 +-- .../async/AsyncDataNodeInternalServiceRequestManager.java | 3 +-- .../iotdb/confignode/client/sync/SyncConfigNodeClientPool.java | 3 +-- .../iotdb/confignode/client/sync/SyncDataNodeClientPool.java | 3 +-- .../iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java index 1117cdbfd9ac..c745bdbe0b6e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java @@ -53,8 +53,7 @@ public void getConfigNodeHeartBeat( } } - // TODO: Is the ClientPool must be a singleton? - private static class AsyncConfigNodeHeartbeatClientPoolHolder { + private static class AsyncConfigNodeHeartbeatClientPoolHolder { private static final AsyncConfigNodeHeartbeatClientPool INSTANCE = new AsyncConfigNodeHeartbeatClientPool(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java index fb85001c9425..c6b0e4dee38e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java @@ -100,8 +100,7 @@ protected void sendAsyncRequestToNode( } } - // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { + private static class ClientPoolHolder { private static final AsyncConfigNodeInternalServiceRequestManager INSTANCE = new AsyncConfigNodeInternalServiceRequestManager(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java index 1544a07d8f2e..b4fc2523b20e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java @@ -332,8 +332,7 @@ protected void sendAsyncRequestToNode( } } - // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { + private static class ClientPoolHolder { private static final AsyncDataNodeInternalServiceRequestManager INSTANCE = new AsyncDataNodeInternalServiceRequestManager(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java index 730fec57f19a..7605d007bd73 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java @@ -147,8 +147,7 @@ private void doRetryWait(int retryNum) { } } - // TODO: Is the ClientPool must be a singleton? - private static class SyncConfigNodeClientPoolHolder { + private static class SyncConfigNodeClientPoolHolder { private static final SyncConfigNodeClientPool INSTANCE = new SyncConfigNodeClientPool(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java index 1d0e564e43cd..c1cc15477d90 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java @@ -187,8 +187,7 @@ public TRegionLeaderChangeResp changeRegionLeader( return new TRegionLeaderChangeResp(status, -1L); } - // TODO: Is the ClientPool must be a singleton? - private static class ClientPoolHolder { + private static class ClientPoolHolder { private static final SyncDataNodeClientPool INSTANCE = new SyncDataNodeClientPool(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java index 9de2c6349dbf..1ec873e4cee9 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java @@ -135,5 +135,4 @@ public ClientType getAsyncClient(TDataNodeLocation targetDataNode) throws Client return clientManager.borrowClient(targetDataNode.getInternalEndPoint()); } - // TODO: Is the ClientPool must be a singleton? -} + } From 1e7ae4b5add0862ddc6eef78e6668c5666db419a Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 11 Jun 2024 15:51:58 +0800 Subject: [PATCH 27/52] dn -> dn done, refactor done --- .../AsyncConfigNodeHeartbeatClientPool.java | 2 +- ...nfigNodeInternalServiceRequestManager.java | 2 +- ...DataNodeInternalServiceRequestManager.java | 2 +- .../client/sync/SyncConfigNodeClientPool.java | 2 +- .../client/sync/SyncDataNodeClientPool.java | 2 +- ...nfigNodeInternalServiceRequestManager.java | 14 +- .../cn/AsyncConfigNodeRequestContext.java | 8 +- ... => AsyncConfigNodeRequestRPCHandler.java} | 16 +- ...=> AsyncConfigNodeTSStatusRPCHandler.java} | 9 +- ...a => DataNodeToConfigNodeRequestType.java} | 10 +- .../client/dn/AbstractAsyncRPCHandler.java | 84 --------- .../client/dn/AsyncClientHandler.java | 159 ------------------ .../client/dn/AsyncDataNodeClientPool.java | 138 --------------- ...syncDataNodeExternalServiceClientPool.java | 93 ---------- ...DataNodeExternalServiceRequestManager.java | 103 ++++++++++++ ...ataNodeInternalServiceRequestManager.java} | 52 +++--- ...syncDataNodeMPPServiceRequestManager.java} | 54 +++--- .../client/dn/AsyncDataNodeRPCHandler.java | 83 +++++++++ .../dn/AsyncDataNodeRequestContext.java | 52 ++++++ .../client/dn/AsyncTSStatusRPCHandler.java | 6 +- .../client/dn/DataNodeRequestType.java | 122 -------------- .../dn/DataNodeToDataNodeRequestType.java | 24 +++ .../impl/DataNodeInternalRPCServiceImpl.java | 47 +++--- .../executor/ClusterConfigTaskExecutor.java | 4 +- .../config/sys/TestConnectionTask.java | 33 ++-- 25 files changed, 405 insertions(+), 716 deletions(-) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/{ConfigNodeAsyncRequestRPCHandler.java => AsyncConfigNodeRequestRPCHandler.java} (81%) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/{AsyncTSStatusRPCHandler2.java => AsyncConfigNodeTSStatusRPCHandler.java} (89%) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/{ConfigNodeRequestType.java => DataNodeToConfigNodeRequestType.java} (79%) delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceRequestManager.java rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/{AsyncDataNodeInternalServiceClientPool.java => AsyncDataNodeInternalServiceRequestManager.java} (57%) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/{AsyncDataNodeMPPServiceClientPool.java => AsyncDataNodeMPPServiceRequestManager.java} (57%) create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeRequestType.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeRequestType.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java index c745bdbe0b6e..7b6bca5d0d9e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeHeartbeatClientPool.java @@ -53,7 +53,7 @@ public void getConfigNodeHeartBeat( } } - private static class AsyncConfigNodeHeartbeatClientPoolHolder { + private static class AsyncConfigNodeHeartbeatClientPoolHolder { private static final AsyncConfigNodeHeartbeatClientPool INSTANCE = new AsyncConfigNodeHeartbeatClientPool(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java index c6b0e4dee38e..494839d88dcd 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java @@ -100,7 +100,7 @@ protected void sendAsyncRequestToNode( } } - private static class ClientPoolHolder { + private static class ClientPoolHolder { private static final AsyncConfigNodeInternalServiceRequestManager INSTANCE = new AsyncConfigNodeInternalServiceRequestManager(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java index b4fc2523b20e..b06325fb1367 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java @@ -332,7 +332,7 @@ protected void sendAsyncRequestToNode( } } - private static class ClientPoolHolder { + private static class ClientPoolHolder { private static final AsyncDataNodeInternalServiceRequestManager INSTANCE = new AsyncDataNodeInternalServiceRequestManager(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java index 7605d007bd73..2ae8a3b56b38 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java @@ -147,7 +147,7 @@ private void doRetryWait(int retryNum) { } } - private static class SyncConfigNodeClientPoolHolder { + private static class SyncConfigNodeClientPoolHolder { private static final SyncConfigNodeClientPool INSTANCE = new SyncConfigNodeClientPool(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java index c1cc15477d90..a969266744be 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java @@ -187,7 +187,7 @@ public TRegionLeaderChangeResp changeRegionLeader( return new TRegionLeaderChangeResp(status, -1L); } - private static class ClientPoolHolder { + private static class ClientPoolHolder { private static final SyncDataNodeClientPool INSTANCE = new SyncDataNodeClientPool(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java index 00accc500aa6..774de763f61e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java @@ -33,7 +33,9 @@ /** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ public class AsyncConfigNodeInternalServiceRequestManager extends AsyncRequestManager< - ConfigNodeRequestType, TConfigNodeLocation, AsyncConfigNodeInternalServiceClient> { + DataNodeToConfigNodeRequestType, + TConfigNodeLocation, + AsyncConfigNodeInternalServiceClient> { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestManager.class); @@ -52,7 +54,8 @@ protected TEndPoint nodeLocationToEndPoint(TConfigNodeLocation configNodeLocatio @Override protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, + AsyncRequestContext + requestContext, int requestId, TConfigNodeLocation targetNode, int retryCount) { @@ -60,9 +63,10 @@ protected void sendAsyncRequestToNode( AsyncConfigNodeInternalServiceClient client; client = clientManager.borrowClient(targetNode.getInternalEndPoint()); Object req = requestContext.getRequest(requestId); - ConfigNodeAsyncRequestRPCHandler handler = - ConfigNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); - AsyncTSStatusRPCHandler2 defaultHandler = (AsyncTSStatusRPCHandler2) handler; + AsyncConfigNodeRequestRPCHandler handler = + AsyncConfigNodeRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); + AsyncConfigNodeTSStatusRPCHandler defaultHandler = + (AsyncConfigNodeTSStatusRPCHandler) handler; switch (requestContext.getRequestType()) { case TEST_CONNECTION: diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java index 2ab98d2b6c34..f36adf1a70ab 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java @@ -31,20 +31,20 @@ * @param ClassName of RPC response */ public class AsyncConfigNodeRequestContext - extends AsyncRequestContext { + extends AsyncRequestContext { - public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType) { + public AsyncConfigNodeRequestContext(DataNodeToConfigNodeRequestType configNodeRequestType) { super(configNodeRequestType); } public AsyncConfigNodeRequestContext( - ConfigNodeRequestType configNodeRequestType, + DataNodeToConfigNodeRequestType configNodeRequestType, Map integerTConfigNodeLocationMap) { super(configNodeRequestType, integerTConfigNodeLocationMap); } public AsyncConfigNodeRequestContext( - ConfigNodeRequestType configNodeRequestType, + DataNodeToConfigNodeRequestType configNodeRequestType, Q q, Map integerTConfigNodeLocationMap) { super(configNodeRequestType, q, integerTConfigNodeLocationMap); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java similarity index 81% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java index bda48e4e4dc0..bc49a73420f6 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java @@ -28,11 +28,11 @@ import java.util.concurrent.CountDownLatch; // TODO: ConfigNodeRequestType可抽 -public abstract class ConfigNodeAsyncRequestRPCHandler - extends AsyncRequestRPCHandler { +public abstract class AsyncConfigNodeRequestRPCHandler + extends AsyncRequestRPCHandler { - protected ConfigNodeAsyncRequestRPCHandler( - ConfigNodeRequestType configNodeRequestType, + protected AsyncConfigNodeRequestRPCHandler( + DataNodeToConfigNodeRequestType configNodeRequestType, int requestId, TConfigNodeLocation targetNode, Map integerTConfigNodeLocationMap, @@ -56,11 +56,11 @@ protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeL + "}"; } - public static ConfigNodeAsyncRequestRPCHandler buildHandler( - AsyncRequestContext context, + public static AsyncConfigNodeRequestRPCHandler buildHandler( + AsyncRequestContext context, int requestId, TConfigNodeLocation targetConfigNode) { - ConfigNodeRequestType requestType = context.getRequestType(); + DataNodeToConfigNodeRequestType requestType = context.getRequestType(); Map nodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); CountDownLatch countDownLatch = context.getCountDownLatch(); @@ -68,7 +68,7 @@ public static ConfigNodeAsyncRequestRPCHandler buildHandler( case SUBMIT_TEST_CONNECTION_TASK: case TEST_CONNECTION: default: - return new AsyncTSStatusRPCHandler2( + return new AsyncConfigNodeTSStatusRPCHandler( requestType, requestId, targetConfigNode, diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java similarity index 89% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java index 16543ee1f4a9..063b35c1c125 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncTSStatusRPCHandler2.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java @@ -31,12 +31,13 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncTSStatusRPCHandler2 extends ConfigNodeAsyncRequestRPCHandler { +public class AsyncConfigNodeTSStatusRPCHandler extends AsyncConfigNodeRequestRPCHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler2.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncConfigNodeTSStatusRPCHandler.class); - public AsyncTSStatusRPCHandler2( - ConfigNodeRequestType requestType, + public AsyncConfigNodeTSStatusRPCHandler( + DataNodeToConfigNodeRequestType requestType, int requestId, TConfigNodeLocation targetConfigNode, Map configNodeLocationMap, diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeRequestType.java similarity index 79% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeRequestType.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeRequestType.java index adaa83889fff..5adf0406ca35 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeRequestType.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeRequestType.java @@ -19,15 +19,7 @@ package org.apache.iotdb.db.protocol.client.cn; -public enum ConfigNodeRequestType { - ADD_CONSENSUS_GROUP, - NOTIFY_REGISTER_SUCCESS, - REGISTER_CONFIG_NODE, - RESTART_CONFIG_NODE, - REMOVE_CONFIG_NODE, - DELETE_CONFIG_NODE_PEER, - REPORT_CONFIG_NODE_SHUTDOWN, - STOP_CONFIG_NODE, +public enum DataNodeToConfigNodeRequestType { SUBMIT_TEST_CONNECTION_TASK, TEST_CONNECTION, } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java deleted file mode 100644 index 1ba9f4099a3c..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AbstractAsyncRPCHandler.java +++ /dev/null @@ -1,84 +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.iotdb.db.protocol.client.dn; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; - -import org.apache.thrift.async.AsyncMethodCallback; - -import java.util.Map; -import java.util.concurrent.CountDownLatch; - -public abstract class AbstractAsyncRPCHandler implements AsyncMethodCallback { - - // Type of RPC request - protected final DataNodeRequestType requestType; - // Index of request - protected final int requestId; - // Target DataNode - protected final TDataNodeLocation targetDataNode; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target DataNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetDataNode from the dataNodeLocationMap only - * if its corresponding RPC request success - */ - protected final Map dataNodeLocationMap; - - /** - * Map key: The indices(targetDataNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - protected final Map responseMap; - - // All kinds of AsyncHandler will invoke countDown after its corresponding RPC request finished - protected final CountDownLatch countDownLatch; - - protected final String formattedTargetLocation; - - protected AbstractAsyncRPCHandler( - DataNodeRequestType requestType, - int requestId, - TDataNodeLocation targetDataNode, - Map dataNodeLocationMap, - Map responseMap, - CountDownLatch countDownLatch) { - this.requestType = requestType; - this.requestId = requestId; - this.targetDataNode = targetDataNode; - this.formattedTargetLocation = - "{id=" - + targetDataNode.getDataNodeId() - + ", internalEndPoint=" - + targetDataNode.getInternalEndPoint() - + "}"; - - this.dataNodeLocationMap = dataNodeLocationMap; - this.responseMap = responseMap; - this.countDownLatch = countDownLatch; - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java deleted file mode 100644 index f13d5cb864a5..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncClientHandler.java +++ /dev/null @@ -1,159 +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.iotdb.db.protocol.client.dn; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TSStatus; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public class AsyncClientHandler { - - // Type of RPC request - protected final DataNodeRequestType requestType; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The corresponding RPC request - */ - private final Map requestMap; - - /** - * Map key: The indices of asynchronous RPC requests. - * - *

Map value: The target DataNodes of corresponding indices - * - *

All kinds of AsyncHandler will remove its targetDataNode from the dataNodeLocationMap only - * if its corresponding RPC request success - */ - private final Map dataNodeLocationMap; - - /** - * Map key: The indices(targetDataNode's ID) of asynchronous RPC requests. - * - *

Map value: The response of corresponding indices - * - *

All kinds of AsyncHandler will add response to the responseMap after its corresponding RPC - * request finished - */ - private final Map responseMap; - - private CountDownLatch countDownLatch; - - /** Custom constructor. */ - public AsyncClientHandler(DataNodeRequestType requestType) { - this.requestType = requestType; - this.requestMap = new ConcurrentHashMap<>(); - this.dataNodeLocationMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - public void putRequest(int requestId, Q request) { - requestMap.put(requestId, request); - } - - public void putDataNodeLocation(int requestId, TDataNodeLocation dataNodeLocation) { - dataNodeLocationMap.put(requestId, dataNodeLocation); - } - - /** Constructor for null requests. */ - public AsyncClientHandler( - DataNodeRequestType requestType, Map dataNodeLocationMap) { - this.requestType = requestType; - this.dataNodeLocationMap = dataNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.responseMap = new ConcurrentHashMap<>(); - } - - /** Constructor for unique request. */ - public AsyncClientHandler( - DataNodeRequestType requestType, - Q request, - Map dataNodeLocationMap) { - this.requestType = requestType; - this.dataNodeLocationMap = dataNodeLocationMap; - - this.requestMap = new ConcurrentHashMap<>(); - this.dataNodeLocationMap - .keySet() - .forEach(dataNodeId -> this.requestMap.put(dataNodeId, request)); - - this.responseMap = new ConcurrentHashMap<>(); - } - - public DataNodeRequestType getRequestType() { - return requestType; - } - - public List getRequestIndices() { - return new ArrayList<>(dataNodeLocationMap.keySet()); - } - - public Q getRequest(int requestId) { - return requestMap.get(requestId); - } - - public TDataNodeLocation getDataNodeLocation(int requestId) { - return dataNodeLocationMap.get(requestId); - } - - public List getResponseList() { - return new ArrayList<>(responseMap.values()); - } - - public Map getResponseMap() { - return responseMap; - } - - /** Always reset CountDownLatch before retry. */ - public void resetCountDownLatch() { - countDownLatch = new CountDownLatch(dataNodeLocationMap.size()); - } - - public CountDownLatch getCountDownLatch() { - return countDownLatch; - } - - public AbstractAsyncRPCHandler createAsyncRPCHandler( - int requestId, TDataNodeLocation targetDataNode) { - switch (requestType) { - default: - return new AsyncTSStatusRPCHandler( - requestType, - requestId, - targetDataNode, - dataNodeLocationMap, - (Map) responseMap, - countDownLatch); - } - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java deleted file mode 100644 index 1ec873e4cee9..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeClientPool.java +++ /dev/null @@ -1,138 +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.iotdb.db.protocol.client.dn; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.exception.ClientManagerException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.TimeUnit; - -/** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ -public abstract class AsyncDataNodeClientPool { - - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeClientPool.class); - - IClientManager clientManager; - - private static final int MAX_RETRY_NUM = 6; - - AsyncDataNodeClientPool() {} - - /** - * Send asynchronous requests to the specified DataNodes with default retry num - * - *

Notice: The DataNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - * @param timeoutInMs timeout in milliseconds - */ - public void sendAsyncRequestToDataNodeWithRetryAndTimeoutInMs( - AsyncClientHandler clientHandler, long timeoutInMs) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, timeoutInMs); - } - - /** - * Send asynchronous requests to the specified DataNodes with default retry num - * - *

Notice: The DataNodes that failed to receive the requests will be reconnected - * - * @param clientHandler which will also contain the result - */ - public void sendAsyncRequestToDataNodeWithRetry(AsyncClientHandler clientHandler) { - sendAsyncRequest(clientHandler, MAX_RETRY_NUM, null); - } - - public void sendAsyncRequestToDataNode(AsyncClientHandler clientHandler) { - sendAsyncRequest(clientHandler, 1, null); - } - - private void sendAsyncRequest( - AsyncClientHandler clientHandler, int retryNum, Long timeoutInMs) { - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - - DataNodeRequestType requestType = clientHandler.getRequestType(); - for (int retry = 0; retry < retryNum; retry++) { - // Always Reset CountDownLatch first - clientHandler.resetCountDownLatch(); - - // Send requests to all targetDataNodes - for (int requestId : clientHandler.getRequestIndices()) { - TDataNodeLocation targetDataNode = clientHandler.getDataNodeLocation(requestId); - sendAsyncRequestToDataNode(clientHandler, requestId, targetDataNode, retry); - } - - // Wait for this batch of asynchronous RPC requests finish - try { - if (timeoutInMs == null) { - clientHandler.getCountDownLatch().await(); - } else { - if (!clientHandler.getCountDownLatch().await(timeoutInMs, TimeUnit.MILLISECONDS)) { - LOGGER.warn( - "Timeout during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - } - } - } catch (InterruptedException e) { - LOGGER.error( - "Interrupted during {} on ConfigNode. Retry: {}/{}", requestType, retry, retryNum); - Thread.currentThread().interrupt(); - } - - // Check if there is a DataNode that fails to execute the request, and retry if there exists - if (clientHandler.getRequestIndices().isEmpty()) { - return; - } - } - - if (!clientHandler.getRequestIndices().isEmpty()) { - LOGGER.warn( - "Failed to {} on ConfigNode after {} retries, requestIndices: {}", - requestType, - retryNum, - clientHandler.getRequestIndices()); - } - } - - abstract void sendAsyncRequestToDataNode( - AsyncClientHandler clientHandler, - int requestId, - TDataNodeLocation targetDataNode, - int retryCount); - - /** - * Always call this interface when a DataNode is restarted or removed. - * - * @param endPoint The specific DataNode - */ - public void resetClient(TEndPoint endPoint) { - clientManager.clear(endPoint); - } - - public ClientType getAsyncClient(TDataNodeLocation targetDataNode) throws ClientManagerException { - return clientManager.borrowClient(targetDataNode.getInternalEndPoint()); - } - - } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.java deleted file mode 100644 index d33f760ee7db..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceClientPool.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.iotdb.db.protocol.client.dn; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.commons.client.ClientPoolFactory; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsyncDataNodeExternalServiceClientPool - extends AsyncDataNodeClientPool { - - private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeExternalServiceClientPool.class); - - public AsyncDataNodeExternalServiceClientPool() { - super(); - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncDataNodeExternalServiceClientPoolFactory()); - } - - @Override - void sendAsyncRequestToDataNode( - AsyncClientHandler clientHandler, - int requestId, - TDataNodeLocation targetDataNode, - int retryCount) { - { - try { - AsyncDataNodeExternalServiceClient client; - client = clientManager.borrowClient(targetDataNode.getClientRpcEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler handler = - clientHandler.createAsyncRPCHandler(requestId, targetDataNode); - AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; - - switch (clientHandler.getRequestType()) { - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - clientHandler.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetDataNode.getClientRpcEndPoint(), - e.getMessage(), - retryCount); - } - } - } - - private static class ClientPoolHolder { - - private static final AsyncDataNodeExternalServiceClientPool INSTANCE = - new AsyncDataNodeExternalServiceClientPool(); - - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncDataNodeExternalServiceClientPool getInstance() { - return AsyncDataNodeExternalServiceClientPool.ClientPoolHolder.INSTANCE; - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceRequestManager.java new file mode 100644 index 000000000000..f1e0c2db5f24 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceRequestManager.java @@ -0,0 +1,103 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestManager; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AsyncDataNodeExternalServiceRequestManager + extends AsyncRequestManager< + DataNodeToDataNodeRequestType, TDataNodeLocation, AsyncDataNodeExternalServiceClient> { + + private static final Logger LOGGER = + LoggerFactory.getLogger(AsyncDataNodeExternalServiceRequestManager.class); + + public AsyncDataNodeExternalServiceRequestManager() { + super(); + } + + @Override + protected void initClientManager() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeExternalServiceClientPoolFactory()); + } + + @Override + protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { + return dataNodeLocation.getClientRpcEndPoint(); + } + + @Override + protected void sendAsyncRequestToNode( + AsyncRequestContext requestContext, + int requestId, + TDataNodeLocation targetNode, + int retryCount) { + try { + AsyncDataNodeExternalServiceClient client = + clientManager.borrowClient(targetNode.getClientRpcEndPoint()); + Object req = requestContext.getRequest(requestId); + AsyncDataNodeRPCHandler handler = + AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); + AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; + + switch (requestContext.getRequestType()) { + case TEST_CONNECTION: + client.testConnection(defaultHandler); + break; + default: + LOGGER.error( + "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", + requestContext.getRequestType()); + } + } catch (Exception e) { + LOGGER.warn( + "{} failed on DataNode {}, because {}, retrying {}...", + requestContext.getRequestType(), + targetNode.getClientRpcEndPoint(), + e.getMessage(), + retryCount); + } + } + + private static class ClientPoolHolder { + + private static final AsyncDataNodeExternalServiceRequestManager INSTANCE = + new AsyncDataNodeExternalServiceRequestManager(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static AsyncDataNodeExternalServiceRequestManager getInstance() { + return AsyncDataNodeExternalServiceRequestManager.ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceRequestManager.java similarity index 57% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceRequestManager.java index 1e1e4525773c..4bd325003549 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceRequestManager.java @@ -24,17 +24,24 @@ import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AsyncDataNodeInternalServiceClientPool - extends AsyncDataNodeClientPool { +public class AsyncDataNodeInternalServiceRequestManager + extends AsyncRequestManager< + DataNodeToDataNodeRequestType, TDataNodeLocation, AsyncDataNodeInternalServiceClient> { private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeInternalServiceClientPool.class); + LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestManager.class); - public AsyncDataNodeInternalServiceClientPool() { + public AsyncDataNodeInternalServiceRequestManager() { super(); + } + + @Override + protected void initClientManager() { clientManager = new IClientManager.Factory() .createClientManager( @@ -42,33 +49,36 @@ public AsyncDataNodeInternalServiceClientPool() { } @Override - void sendAsyncRequestToDataNode( - AsyncClientHandler clientHandler, + protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { + return dataNodeLocation.getInternalEndPoint(); + } + + @Override + protected void sendAsyncRequestToNode( + AsyncRequestContext requestContext, int requestId, - TDataNodeLocation targetDataNode, + TDataNodeLocation targetNode, int retryCount) { try { AsyncDataNodeInternalServiceClient client; - client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler handler = - clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + client = clientManager.borrowClient(targetNode.getInternalEndPoint()); + Object req = requestContext.getRequest(requestId); + AsyncDataNodeRPCHandler handler = + AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; - - switch (clientHandler.getRequestType()) { + switch (requestContext.getRequestType()) { case TEST_CONNECTION: client.testConnection(defaultHandler); break; default: - LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - clientHandler.getRequestType()); + throw new UnsupportedOperationException( + "unsupported request type: " + requestContext.getRequestType()); } } catch (Exception e) { LOGGER.warn( "{} failed on DataNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetDataNode.getInternalEndPoint(), + requestContext.getRequestType(), + targetNode.getInternalEndPoint(), e.getMessage(), retryCount); } @@ -76,15 +86,15 @@ void sendAsyncRequestToDataNode( private static class ClientPoolHolder { - private static final AsyncDataNodeInternalServiceClientPool INSTANCE = - new AsyncDataNodeInternalServiceClientPool(); + private static final AsyncDataNodeInternalServiceRequestManager INSTANCE = + new AsyncDataNodeInternalServiceRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static AsyncDataNodeInternalServiceClientPool getInstance() { + public static AsyncDataNodeInternalServiceRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceRequestManager.java similarity index 57% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceRequestManager.java index 41dfedae4c23..80b76f575a00 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceClientPool.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceRequestManager.java @@ -24,16 +24,26 @@ import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeMPPDataExchangeServiceClient; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AsyncDataNodeMPPServiceClientPool - extends AsyncDataNodeClientPool { +import static org.apache.iotdb.db.protocol.client.dn.DataNodeToDataNodeRequestType.TEST_CONNECTION; + +public class AsyncDataNodeMPPServiceRequestManager + extends AsyncRequestManager< + DataNodeToDataNodeRequestType, + TDataNodeLocation, + AsyncDataNodeMPPDataExchangeServiceClient> { private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeMPPServiceClientPool.class); + LoggerFactory.getLogger(AsyncDataNodeMPPServiceRequestManager.class); + + public AsyncDataNodeMPPServiceRequestManager() {} - public AsyncDataNodeMPPServiceClientPool() { + @Override + protected void initClientManager() { clientManager = new IClientManager.Factory() .createClientManager( @@ -41,33 +51,37 @@ public AsyncDataNodeMPPServiceClientPool() { } @Override - void sendAsyncRequestToDataNode( - AsyncClientHandler clientHandler, + protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { + return null; + } + + @Override + protected void sendAsyncRequestToNode( + AsyncRequestContext requestContext, int requestId, - TDataNodeLocation targetDataNode, + TDataNodeLocation targetNode, int retryCount) { try { AsyncDataNodeMPPDataExchangeServiceClient client; - client = clientManager.borrowClient(targetDataNode.getInternalEndPoint()); - Object req = clientHandler.getRequest(requestId); - AbstractAsyncRPCHandler handler = - clientHandler.createAsyncRPCHandler(requestId, targetDataNode); + client = clientManager.borrowClient(targetNode.getInternalEndPoint()); + Object req = requestContext.getRequest(requestId); + AsyncDataNodeRPCHandler handler = + AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; - switch (clientHandler.getRequestType()) { + switch (requestContext.getRequestType()) { case TEST_CONNECTION: client.testConnection(defaultHandler); break; default: - LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - clientHandler.getRequestType()); + throw new UnsupportedOperationException( + "unsupported request type: " + requestContext.getRequestType()); } } catch (Exception e) { LOGGER.warn( "{} failed on DataNode {}, because {}, retrying {}...", - clientHandler.getRequestType(), - targetDataNode.getInternalEndPoint(), + requestContext.getRequestType(), + targetNode.getInternalEndPoint(), e.getMessage(), retryCount); } @@ -75,15 +89,15 @@ void sendAsyncRequestToDataNode( private static class ClientPoolHolder { - private static final AsyncDataNodeMPPServiceClientPool INSTANCE = - new AsyncDataNodeMPPServiceClientPool(); + private static final AsyncDataNodeMPPServiceRequestManager INSTANCE = + new AsyncDataNodeMPPServiceRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static AsyncDataNodeMPPServiceClientPool getInstance() { + public static AsyncDataNodeMPPServiceRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java new file mode 100644 index 000000000000..40a7fc26777f --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java @@ -0,0 +1,83 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public abstract class AsyncDataNodeRPCHandler + extends AsyncRequestRPCHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeRPCHandler.class); + + protected AsyncDataNodeRPCHandler( + DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType, + int requestId, + TDataNodeLocation targetNode, + Map dataNodeLocationMap, + Map integerResponseMap, + CountDownLatch countDownLatch) { + super( + dataNodeToDataNodeRequestType, + requestId, + targetNode, + dataNodeLocationMap, + integerResponseMap, + countDownLatch); + } + + @Override + protected String generateFormattedTargetLocation(TDataNodeLocation dataNodeLocation) { + return "{id=" + + targetNode.getDataNodeId() + + ", internalEndPoint=" + + targetNode.getInternalEndPoint() + + "}"; + } + + public static AsyncDataNodeRPCHandler createAsyncRPCHandler( + AsyncRequestContext context, + int requestId, + TDataNodeLocation targetDataNode) { + DataNodeToDataNodeRequestType requestType = context.getRequestType(); + Map nodeLocationMap = context.getNodeLocationMap(); + Map responseMap = context.getResponseMap(); + CountDownLatch countDownLatch = context.getCountDownLatch(); + switch (requestType) { + case TEST_CONNECTION: + return new AsyncTSStatusRPCHandler( + requestType, + requestId, + targetDataNode, + nodeLocationMap, + (Map) responseMap, + countDownLatch); + default: + throw new UnsupportedOperationException("request type is not supported: " + requestType); + } + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java new file mode 100644 index 000000000000..4e3c75d6d7d2 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java @@ -0,0 +1,52 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; + +import java.util.Map; + +/** + * Asynchronous Client handler. + * + * @param ClassName of RPC request + * @param ClassName of RPC response + */ +public class AsyncDataNodeRequestContext + extends AsyncRequestContext { + + public AsyncDataNodeRequestContext(DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType) { + super(dataNodeToDataNodeRequestType); + } + + public AsyncDataNodeRequestContext( + DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType, + Map dataNodeLocationMap) { + super(dataNodeToDataNodeRequestType, dataNodeLocationMap); + } + + public AsyncDataNodeRequestContext( + DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType, + Q q, + Map dataNodeLocationMap) { + super(dataNodeToDataNodeRequestType, q, dataNodeLocationMap); + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java index 6ec902825d5c..a453df0b1724 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java @@ -31,12 +31,12 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncTSStatusRPCHandler extends AbstractAsyncRPCHandler { +public class AsyncTSStatusRPCHandler extends AsyncDataNodeRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler.class); public AsyncTSStatusRPCHandler( - DataNodeRequestType requestType, + DataNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, @@ -52,7 +52,7 @@ public void onComplete(TSStatus response) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { // Remove only if success - dataNodeLocationMap.remove(requestId); + nodeLocationMap.remove(requestId); LOGGER.info("Successfully {} on DataNode: {}", requestType, formattedTargetLocation); } else { LOGGER.error( diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeRequestType.java deleted file mode 100644 index 41f371677cb5..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeRequestType.java +++ /dev/null @@ -1,122 +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.iotdb.db.protocol.client.dn; - -public enum DataNodeRequestType { - - // Node Maintenance - DISABLE_DATA_NODE, - STOP_DATA_NODE, - - FLUSH, - MERGE, - FULL_MERGE, - START_REPAIR_DATA, - STOP_REPAIR_DATA, - LOAD_CONFIGURATION, - SET_SYSTEM_STATUS, - - SUBMIT_TEST_CONNECTION_TASK, - TEST_CONNECTION, - - // Region Maintenance - CREATE_DATA_REGION, - CREATE_SCHEMA_REGION, - DELETE_REGION, - - CREATE_NEW_REGION_PEER, - ADD_REGION_PEER, - REMOVE_REGION_PEER, - DELETE_OLD_REGION_PEER, - RESET_PEER_LIST, - - UPDATE_REGION_ROUTE_MAP, - CHANGE_REGION_LEADER, - - // PartitionCache - INVALIDATE_PARTITION_CACHE, - INVALIDATE_PERMISSION_CACHE, - INVALIDATE_SCHEMA_CACHE, - CLEAR_CACHE, - - // Function - CREATE_FUNCTION, - DROP_FUNCTION, - - // Trigger - CREATE_TRIGGER_INSTANCE, - DROP_TRIGGER_INSTANCE, - ACTIVE_TRIGGER_INSTANCE, - INACTIVE_TRIGGER_INSTANCE, - UPDATE_TRIGGER_LOCATION, - - // Pipe Plugin - CREATE_PIPE_PLUGIN, - DROP_PIPE_PLUGIN, - - // Pipe Task - PIPE_PUSH_ALL_META, - PIPE_PUSH_SINGLE_META, - PIPE_PUSH_MULTI_META, - PIPE_HEARTBEAT, - - // Subscription - TOPIC_PUSH_ALL_META, - TOPIC_PUSH_SINGLE_META, - TOPIC_PUSH_MULTI_META, - CONSUMER_GROUP_PUSH_ALL_META, - CONSUMER_GROUP_PUSH_SINGLE_META, - - // CQ - EXECUTE_CQ, - - // TEMPLATE - UPDATE_TEMPLATE, - - // Schema - SET_TTL, - - CONSTRUCT_SCHEMA_BLACK_LIST, - ROLLBACK_SCHEMA_BLACK_LIST, - FETCH_SCHEMA_BLACK_LIST, - INVALIDATE_MATCHED_SCHEMA_CACHE, - DELETE_DATA_FOR_DELETE_SCHEMA, - DELETE_TIMESERIES, - - CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, - ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, - DEACTIVATE_TEMPLATE, - COUNT_PATHS_USING_TEMPLATE, - CHECK_SCHEMA_REGION_USING_TEMPLATE, - CHECK_TIMESERIES_EXISTENCE, - - CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, - ROLLBACK_VIEW_SCHEMA_BLACK_LIST, - DELETE_VIEW, - - ALTER_VIEW, - - // TODO Need to migrate to Node Maintenance - KILL_QUERY_INSTANCE, - - // Quota - SET_SPACE_QUOTA, - SET_THROTTLE_QUOTA, -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeRequestType.java new file mode 100644 index 000000000000..20b023062c29 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeRequestType.java @@ -0,0 +1,24 @@ +/* + * 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.db.protocol.client.dn; + +public enum DataNodeToDataNodeRequestType { + TEST_CONNECTION, +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 53a2f620638e..6e482b4c52fa 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -75,12 +75,12 @@ import org.apache.iotdb.db.protocol.client.ConfigNodeInfo; import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeInternalServiceRequestManager; import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeRequestContext; -import org.apache.iotdb.db.protocol.client.cn.ConfigNodeRequestType; -import org.apache.iotdb.db.protocol.client.dn.AsyncClientHandler; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeExternalServiceClientPool; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeInternalServiceClientPool; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeMPPServiceClientPool; -import org.apache.iotdb.db.protocol.client.dn.DataNodeRequestType; +import org.apache.iotdb.db.protocol.client.cn.DataNodeToConfigNodeRequestType; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeExternalServiceRequestManager; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeMPPServiceRequestManager; +import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeRequestContext; +import org.apache.iotdb.db.protocol.client.dn.DataNodeToDataNodeRequestType; import org.apache.iotdb.db.protocol.session.IClientSession; import org.apache.iotdb.db.protocol.session.InternalClientSession; import org.apache.iotdb.db.protocol.session.SessionManager; @@ -1452,7 +1452,7 @@ private List testAllConfigNodeConnection( .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); AsyncConfigNodeRequestContext clientHandler = new AsyncConfigNodeRequestContext<>( - ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); + DataNodeToConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); AsyncConfigNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherConfigNodeLocationMap = @@ -1490,11 +1490,11 @@ private List testAllDataNodeInternalServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( - DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeInternalServiceClientPool.getInstance() - .sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( + DataNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + AsyncDataNodeInternalServiceRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); @@ -1503,8 +1503,7 @@ private List testAllDataNodeInternalServiceConnection( .getResponseMap() .forEach( (dataNodeId, status) -> { - TEndPoint endPoint = - anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); + TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); TTestConnectionResult result = new TTestConnectionResult(); @@ -1530,11 +1529,11 @@ private List testAllDataNodeMPPServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( - DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeMPPServiceClientPool.getInstance() - .sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( + DataNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + AsyncDataNodeMPPServiceRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); @@ -1570,11 +1569,11 @@ private List testAllDataNodeExternalServiceConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncClientHandler clientHandler = - new AsyncClientHandler<>( - DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeExternalServiceClientPool.getInstance() - .sendAsyncRequestToDataNodeWithRetry(clientHandler); + AsyncDataNodeRequestContext clientHandler = + new AsyncDataNodeRequestContext<>( + DataNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + AsyncDataNodeExternalServiceRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(clientHandler); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java index 987f86f7d8ed..f9bd05e23e14 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java @@ -1252,7 +1252,9 @@ public SettableFuture testConnection() { CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { // TODO: now sync, maybe async in future TTestConnectionResp result = client.submitTestConnectionTaskToLeader(); - TestConnectionTask.buildTSBlock(result, future); + int configNodeNum = client.showConfigNodes().getConfigNodesInfoListSize(); + int dataNodeNum = client.showDataNodes().getDataNodesInfoListSize(); + TestConnectionTask.buildTSBlock(result, configNodeNum, dataNodeNum, future); } catch (Exception e) { future.setException(e); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index 155a137d814f..13be48cb6b1a 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -51,7 +51,10 @@ public ListenableFuture execute(IConfigTaskExecutor configTask } public static void buildTSBlock( - TTestConnectionResp resp, SettableFuture future) { + TTestConnectionResp resp, + int configNodeNum, + int dataNodeNum, + SettableFuture future) { List outputDataTypes = ColumnHeaderConstant.testConnectionColumnHeaders.stream() .map(ColumnHeader::getColumnType) @@ -118,23 +121,21 @@ private static void sortTestConnectionResp(TTestConnectionResp origin) { .getResultList() .sort( (o1, o2) -> { - if (!o1.getServiceProvider().equals(o2.getServiceProvider())) { - return endPointToString(o1.getServiceProvider().getEndPoint()) - .compareTo(endPointToString(o2.getServiceProvider().getEndPoint())); + { + String serviceIp1 = o1.getServiceProvider().getEndPoint().getIp(); + String serviceIp2 = o2.getServiceProvider().getEndPoint().getIp(); + if (!serviceIp1.equals(serviceIp2)) { + return serviceIp1.compareTo(serviceIp2); + } } - TEndPoint sender1; - if (o1.getSender().isSetConfigNodeLocation()) { - sender1 = o1.getSender().getConfigNodeLocation().getInternalEndPoint(); - } else { - sender1 = o1.getSender().getDataNodeLocation().getInternalEndPoint(); + { + int servicePort1 = o1.getServiceProvider().getEndPoint().getPort(); + int servicePort2 = o2.getServiceProvider().getEndPoint().getPort(); + if (servicePort1 != servicePort2) { + return Integer.compare(servicePort1, servicePort2); + } } - TEndPoint sender2; - if (o2.getSender().isSetConfigNodeLocation()) { - sender2 = o2.getSender().getConfigNodeLocation().getInternalEndPoint(); - } else { - sender2 = o2.getSender().getDataNodeLocation().getInternalEndPoint(); - } - return endPointToString(sender1).compareTo(endPointToString(sender2)); + return 0; }); } From 3e70cb73a4df3c1ac3ca1b59b06e6aefac11fc82 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Tue, 11 Jun 2024 19:34:38 +0800 Subject: [PATCH 28/52] refactor something --- .../async/handlers/TestConnectionHandler.java | 34 --- .../confignode/manager/ClusterManager.java | 154 +++++------- ...nfigNodeInternalServiceRequestManager.java | 2 - .../impl/DataNodeInternalRPCServiceImpl.java | 229 +++++++----------- 4 files changed, 148 insertions(+), 271 deletions(-) delete mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java deleted file mode 100644 index 7519f6855c03..000000000000 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/TestConnectionHandler.java +++ /dev/null @@ -1,34 +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.iotdb.confignode.client.async.handlers; - -import org.apache.iotdb.common.rpc.thrift.TSStatus; - -import org.apache.thrift.async.AsyncMethodCallback; - -public class TestConnectionHandler implements AsyncMethodCallback { - // public TestConnectionHandler(ConcurrentHashMap) - - @Override - public void onComplete(TSStatus tsStatus) {} - - @Override - public void onError(Exception e) {} -} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index c934fd477efe..83dffd01f5f2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -36,7 +36,6 @@ import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeRequestContext; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; -import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; import org.apache.iotdb.confignode.persistence.ClusterInfo; @@ -122,16 +121,17 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { configNodeLocationMap); AsyncConfigNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNode(configNodeClientHandler); + Map anotherConfigNodeLocationMap = + configManager.getNodeManager().getRegisteredConfigNodes().stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); configNodeClientHandler .getResponseMap() - .values() .forEach( - configNodeResp -> { + (nodeId,configNodeResp) -> { if (configNodeResp.isSetResultList()) { - merge(resp, configNodeResp); + resp.getResultList().addAll(configNodeResp.getResultList()); } else { - // TODO: 展示错误 - LOGGER.warn("Some problem"); + resp.getResultList().addAll(buildAllDownConfigNodeConnectionResult(anotherConfigNodeLocationMap.get(nodeId), nodeLocations)); } }); Map dataNodeLocationMap = @@ -143,39 +143,22 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); AsyncDataNodeInternalServiceRequestManager.getInstance() .sendAsyncRequestToNode(dataNodeClientHandler); + Map anotherDataNodeLocationMap = + configManager.getNodeManager().getRegisteredDataNodes().stream() + .map(TDataNodeConfiguration::getLocation).collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location));; dataNodeClientHandler .getResponseMap() - .values() .forEach( - dataNodeResp -> { + (nodeId, dataNodeResp) -> { if (dataNodeResp.isSetResultList()) { - merge(resp, dataNodeResp); + resp.getResultList().addAll(dataNodeResp.getResultList()); } else { - // TODO: 展示错误 - LOGGER.warn("Some problem"); + resp.getResultList().addAll(buildAllDownDataNodeConnectionResult(anotherDataNodeLocationMap.get(nodeId), nodeLocations)); } }); return resp; } - private static void merge(TTestConnectionResp resp1, TTestConnectionResp resp2) { - resp1.resultList.addAll(resp2.getResultList()); - } - - private void submitTestConnectionTaskToAllDataNode() { - - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( - DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, - new TNodeLocations(), - configManager.getNodeManager().getRegisteredDataNodeLocations()); - AsyncDataNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); - clientHandler.getResponseMap(); - } - - private void submitTestConnectionTaskToAllConfigNode() {} - public List doConnectionTest(TNodeLocations nodeLocations) { List configNodeResult = testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); @@ -185,41 +168,6 @@ public List doConnectionTest(TNodeLocations nodeLocations return configNodeResult; } - private List testConfigNodeConnection( - TConfigNodeLocation configNodeLocation) { - final TSender sender = - new TSender() - .setConfigNodeLocation( - ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); - final TTestConnectionResult result = new TTestConnectionResult(); - result.setServiceProvider( - new TServiceProvider( - configNodeLocation.getInternalEndPoint(), TServiceType.ConfigNodeInternalService)); - result.setSender(sender); - List results = new ArrayList<>(); - try { - TSStatus status = - (TSStatus) - SyncConfigNodeClientPool.getInstance() - .sendSyncRequestToConfigNodeWithRetry( - configNodeLocation.getInternalEndPoint(), - null, - ConfigNodeRequestType.TEST_CONNECTION); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason("unknown"); - } - } catch (Exception e) { - LOGGER.error("Test connection fail", e); - result.setSuccess(false); - result.setReason(e.getMessage()); - } - results.add(result); - return results; - } - private List testAllConfigNodeConnection( List configNodeLocations) { final TSender sender = @@ -229,16 +177,16 @@ private List testAllConfigNodeConnection( Map configNodeLocationMap = configNodeLocations.stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - AsyncConfigNodeRequestContext clientHandler = + AsyncConfigNodeRequestContext requestContext = new AsyncConfigNodeRequestContext<>( ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); AsyncConfigNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestToNodeWithRetry(requestContext); Map anotherConfigNodeLocationMap = configNodeLocations.stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); List results = new ArrayList<>(); - clientHandler + requestContext .getResponseMap() .forEach( (configNodeId, status) -> { @@ -246,20 +194,16 @@ private List testAllConfigNodeConnection( anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); + collectResult(sender, results, status, serviceProvider); }); return results; } + private List buildAllDownConfigNodeConnectionResult(TConfigNodeLocation sourceConfigNode, TNodeLocations nodeLocations) { + final TSender sender = new TSender().setConfigNodeLocation(sourceConfigNode); + return buildAllDownNodeConnectionResult(nodeLocations, sender); + } + private List testAllDataNodeConnection( List dataNodeLocations) { final TSender sender = @@ -269,33 +213,63 @@ private List testAllDataNodeConnection( Map dataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext clientHandler = + AsyncDataNodeRequestContext requestContext = new AsyncDataNodeRequestContext<>( DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); AsyncDataNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestToNodeWithRetry(requestContext); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); List results = new ArrayList<>(); - clientHandler + requestContext .getResponseMap() .forEach( (dataNodeId, status) -> { TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); + collectResult(sender, results, status, serviceProvider); }); return results; } + + private List buildAllDownDataNodeConnectionResult(TDataNodeLocation sourceDataNode, TNodeLocations nodeLocations) { + final TSender sender = new TSender().setDataNodeLocation(sourceDataNode); + return buildAllDownNodeConnectionResult(nodeLocations, sender); + } + + private List buildAllDownNodeConnectionResult(TNodeLocations nodeLocations, TSender sender) { + List results = new ArrayList<>(); + nodeLocations.getConfigNodeLocations().forEach(location -> { + TEndPoint endPoint = location.getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult().setServiceProvider(serviceProvider).setSender(sender); + result.setSuccess(false).setReason("Cannot get verification result"); + results.add(result); + }); + nodeLocations.getDataNodeLocations().forEach(location -> { + TEndPoint endPoint = location.getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); + TTestConnectionResult result = new TTestConnectionResult().setServiceProvider(serviceProvider).setSender(sender); + result.setSuccess(false).setReason("Cannot get verification result"); + results.add(result); + }); + return results; + } + + private void collectResult(TSender sender, List results, TSStatus status, TServiceProvider serviceProvider) { + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java index 774de763f61e..1863c775fb38 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java @@ -88,10 +88,8 @@ protected void sendAsyncRequestToNode( } private static class ClientPoolHolder { - private static final AsyncConfigNodeInternalServiceRequestManager INSTANCE = new AsyncConfigNodeInternalServiceRequestManager(); - private ClientPoolHolder() { // Empty constructor } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 6e482b4c52fa..8a7b1deba7d4 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -35,6 +35,7 @@ import org.apache.iotdb.common.rpc.thrift.TSettleReq; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.commons.conf.CommonConfig; import org.apache.iotdb.commons.conf.CommonDescriptor; @@ -273,6 +274,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReadWriteLock; +import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; @@ -1441,163 +1443,100 @@ public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations return new TTestConnectionResp(configNodeResult); } - private List testAllConfigNodeConnection( - List configNodeLocations) { + private List testAllConnections( + List nodeLocations, + Function getId, + Function getEndPoint, + TServiceType serviceType, + RequestType requestType, + Consumer> sendRequest + ) { final TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); - Map configNodeLocationMap = - configNodeLocations.stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - AsyncConfigNodeRequestContext clientHandler = - new AsyncConfigNodeRequestContext<>( - DataNodeToConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); - AsyncConfigNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); - Map anotherConfigNodeLocationMap = - configNodeLocations.stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + Map nodeLocationMap = + nodeLocations.stream() + .collect(Collectors.toMap(getId, location -> location)); + AsyncRequestContext requestContext = + new AsyncRequestContext<>( + requestType, new Object(), nodeLocationMap); + sendRequest.accept(requestContext); + Map anotherNodeLocationMap = + nodeLocations.stream() + .collect(Collectors.toMap(getId, location -> location)); List results = new ArrayList<>(); - clientHandler - .getResponseMap() - .forEach( - (configNodeId, status) -> { - TEndPoint endPoint = - anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); + requestContext + .getResponseMap() + .forEach( + (nodeId, status) -> { + TEndPoint endPoint = getEndPoint.apply(anotherNodeLocationMap.get(nodeId)); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, serviceType); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); return results; } + private List testAllConfigNodeConnection( + List configNodeLocations) { + return testAllConnections( + configNodeLocations, + TConfigNodeLocation::getConfigNodeId, + TConfigNodeLocation::getInternalEndPoint, + TServiceType.ConfigNodeInternalService, + DataNodeToConfigNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> AsyncConfigNodeInternalServiceRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(handler) + ); + } + private List testAllDataNodeInternalServiceConnection( - List dataNodeLocations) { - final TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); - Map dataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( - DataNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); - Map anotherDataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - List results = new ArrayList<>(); - clientHandler - .getResponseMap() - .forEach( - (dataNodeId, status) -> { - TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); - return results; + List dataNodeLocations) { + return testAllConnections( + dataNodeLocations, + TDataNodeLocation::getDataNodeId, + TDataNodeLocation::getInternalEndPoint, + TServiceType.DataNodeInternalService, + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> AsyncDataNodeInternalServiceRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(handler) + ); } private List testAllDataNodeMPPServiceConnection( - List dataNodeLocations) { - final TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); - Map dataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( - DataNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeMPPServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); - Map anotherDataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - List results = new ArrayList<>(); - clientHandler - .getResponseMap() - .forEach( - (dataNodeId, status) -> { - TEndPoint endPoint = - anotherDataNodeLocationMap.get(dataNodeId).getMPPDataExchangeEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.DataNodeMPPService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); - return results; + List dataNodeLocations) { + return testAllConnections( + dataNodeLocations, + TDataNodeLocation::getDataNodeId, + TDataNodeLocation::getMPPDataExchangeEndPoint, + TServiceType.DataNodeMPPService, + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> AsyncDataNodeInternalServiceRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(handler) + ); } private List testAllDataNodeExternalServiceConnection( - List dataNodeLocations) { - final TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); - Map dataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( - DataNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeExternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); - Map anotherDataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - List results = new ArrayList<>(); - clientHandler - .getResponseMap() - .forEach( - (dataNodeId, status) -> { - TEndPoint endPoint = - anotherDataNodeLocationMap.get(dataNodeId).getClientRpcEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.DataNodeExternalService); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); - return results; + List dataNodeLocations) { + return testAllConnections( + dataNodeLocations, + TDataNodeLocation::getDataNodeId, + TDataNodeLocation::getClientRpcEndPoint, + TServiceType.DataNodeExternalService, + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> AsyncDataNodeInternalServiceRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(handler) + ); } @Override From 94347f6698ab2610aab372f368587be4b3629715 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 11:05:36 +0800 Subject: [PATCH 29/52] refactor AsyncRequestManager --- ...=> ConfigNodeToConfigNodeRequestType.java} | 2 +- ...a => ConfigNodeToDataNodeRequestType.java} | 2 +- ...nfigNodeInternalServiceRequestManager.java | 116 ------ ...DataNodeInternalServiceRequestManager.java | 348 ---------------- ...odeInternalServiceAsyncRequestManager.java | 76 ++++ ...odeInternalServiceAsyncRequestManager.java | 371 ++++++++++++++++++ .../AsyncConfigNodeRequestContext.java | 10 +- .../handlers/AsyncDataNodeRequestContext.java | 13 +- .../CheckTimeSeriesExistenceRPCHandler.java | 4 +- .../rpc/ConfigNodeAsyncRequestRPCHandler.java | 11 +- .../rpc/ConfigNodeTSStatusRPCHandler.java | 4 +- .../CountPathsUsingTemplateRPCHandler.java | 4 +- .../rpc/DataNodeAsyncRequestRPCHandler.java | 10 +- .../rpc/DataNodeTSStatusRPCHandler.java | 4 +- .../rpc/FetchSchemaBlackListRPCHandler.java | 4 +- .../handlers/rpc/PipeHeartbeatRPCHandler.java | 4 +- .../handlers/rpc/PipePushMetaRPCHandler.java | 4 +- .../handlers/rpc/SchemaUpdateRPCHandler.java | 4 +- .../SubmitTestConnectionTaskRPCHandler.java | 4 +- ...tConnectionTaskToConfigNodeRPCHandler.java | 4 +- .../rpc/TransferLeaderRPCHandler.java | 4 +- ...ckSchemaRegionUsingTemplateRPCHandler.java | 4 +- .../ConsumerGroupPushMetaRPCHandler.java | 4 +- .../subscription/TopicPushMetaRPCHandler.java | 4 +- .../client/sync/SyncConfigNodeClientPool.java | 4 +- .../client/sync/SyncDataNodeClientPool.java | 10 +- .../conf/ConfigNodeRemoveCheck.java | 4 +- .../confignode/manager/ClusterManager.java | 149 ++++--- .../manager/ClusterQuotaManager.java | 12 +- .../confignode/manager/TriggerManager.java | 8 +- .../iotdb/confignode/manager/UDFManager.java | 12 +- .../confignode/manager/cq/CQScheduleTask.java | 4 +- .../manager/load/balancer/RouteBalancer.java | 12 +- .../confignode/manager/node/NodeManager.java | 43 +- .../manager/partition/PartitionManager.java | 17 +- .../runtime/PipeHeartbeatScheduler.java | 8 +- .../manager/schema/ClusterSchemaManager.java | 14 +- .../procedure/env/ConfigNodeProcedureEnv.java | 112 +++--- .../procedure/env/RegionMaintainHandler.java | 25 +- .../schema/AlterLogicalViewProcedure.java | 12 +- .../schema/DataNodeRegionTaskExecutor.java | 12 +- .../schema/DeactivateTemplateProcedure.java | 20 +- .../impl/schema/DeleteDatabaseProcedure.java | 8 +- .../schema/DeleteLogicalViewProcedure.java | 16 +- .../schema/DeleteTimeSeriesProcedure.java | 20 +- .../procedure/impl/schema/SchemaUtils.java | 6 +- .../impl/schema/SetTemplateProcedure.java | 20 +- .../impl/schema/UnsetTemplateProcedure.java | 16 +- .../impl/sync/AuthOperationProcedure.java | 4 +- .../iotdb/confignode/service/ConfigNode.java | 4 +- .../service/ConfigNodeShutdownHook.java | 4 +- ...nfigNodeInternalServiceRequestManager.java | 101 ----- ...odeInternalServiceAsyncRequestManager.java | 67 ++++ ...DataNodeInternalServiceRequestManager.java | 100 ----- ...deExternalServiceAsyncRequestManager.java} | 61 +-- ...ataNodeMPPServiceAsyncRequestManager.java} | 58 +-- ...odeInternalServiceAsyncRequestManager.java | 69 ++++ .../impl/DataNodeInternalRPCServiceImpl.java | 151 ++++--- .../client/gg/AsyncRequestManager.java | 51 ++- ...odeInternalServiceAsyncRequestManager.java | 43 ++ ...DataNodeInternalServiceRequestManager.java | 43 ++ .../utils/function/CheckedTriConsumer.java | 25 ++ 62 files changed, 1225 insertions(+), 1135 deletions(-) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/{ConfigNodeRequestType.java => ConfigNodeToConfigNodeRequestType.java} (95%) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/{DataNodeRequestType.java => ConfigNodeToDataNodeRequestType.java} (98%) delete mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java delete mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java create mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceRequestManager.java rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/{AsyncDataNodeExternalServiceRequestManager.java => DataNodeExternalServiceAsyncRequestManager.java} (56%) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/{AsyncDataNodeMPPServiceRequestManager.java => DataNodeMPPServiceAsyncRequestManager.java} (56%) create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/ConfigNodeInternalServiceAsyncRequestManager.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/DataNodeInternalServiceRequestManager.java create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/function/CheckedTriConsumer.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToConfigNodeRequestType.java similarity index 95% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToConfigNodeRequestType.java index f8f78d411693..62f457afa608 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToConfigNodeRequestType.java @@ -19,7 +19,7 @@ package org.apache.iotdb.confignode.client; -public enum ConfigNodeRequestType { +public enum ConfigNodeToConfigNodeRequestType { ADD_CONSENSUS_GROUP, NOTIFY_REGISTER_SUCCESS, REGISTER_CONFIG_NODE, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToDataNodeRequestType.java similarity index 98% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToDataNodeRequestType.java index 428fcdbf719d..7ebaa5934184 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToDataNodeRequestType.java @@ -19,7 +19,7 @@ package org.apache.iotdb.confignode.client; -public enum DataNodeRequestType { +public enum ConfigNodeToDataNodeRequestType { // Node Maintenance DISABLE_DATA_NODE, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java deleted file mode 100644 index 494839d88dcd..000000000000 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncConfigNodeInternalServiceRequestManager.java +++ /dev/null @@ -1,116 +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.iotdb.confignode.client.async; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.common.rpc.thrift.TNodeLocations; -import org.apache.iotdb.commons.client.ClientPoolFactory; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestManager; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAsyncRequestRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeTSStatusRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ -public class AsyncConfigNodeInternalServiceRequestManager - extends AsyncRequestManager< - ConfigNodeRequestType, TConfigNodeLocation, AsyncConfigNodeInternalServiceClient> { - - private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestManager.class); - - private AsyncConfigNodeInternalServiceRequestManager() { - super(); - } - - @Override - protected void initClientManager() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); - } - - @Override - protected TEndPoint nodeLocationToEndPoint(TConfigNodeLocation configNodeLocation) { - return configNodeLocation.getInternalEndPoint(); - } - - @Override - protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, - int requestId, - TConfigNodeLocation targetNode, - int retryCount) { - - try { - AsyncConfigNodeInternalServiceClient client; - client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); - Object req = requestContext.getRequest(requestId); - ConfigNodeAsyncRequestRPCHandler handler = - ConfigNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); - ConfigNodeTSStatusRPCHandler defaultHandler = null; - if (handler instanceof ConfigNodeTSStatusRPCHandler) { - defaultHandler = (ConfigNodeTSStatusRPCHandler) handler; - } - switch (requestContext.getRequestType()) { - case SUBMIT_TEST_CONNECTION_TASK: - client.submitTestConnectionTask( - (TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler); - break; - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", - requestContext.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on ConfigNode {}, because {}, retrying {}...", - requestContext.getRequestType(), - nodeLocationToEndPoint(targetNode), - e.getMessage(), - retryCount); - } - } - - private static class ClientPoolHolder { - - private static final AsyncConfigNodeInternalServiceRequestManager INSTANCE = - new AsyncConfigNodeInternalServiceRequestManager(); - - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncConfigNodeInternalServiceRequestManager getInstance() { - return ClientPoolHolder.INSTANCE; - } -} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java deleted file mode 100644 index b06325fb1367..000000000000 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeInternalServiceRequestManager.java +++ /dev/null @@ -1,348 +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.iotdb.confignode.client.async; - -import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.common.rpc.thrift.TFlushReq; -import org.apache.iotdb.common.rpc.thrift.TNodeLocations; -import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; -import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; -import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; -import org.apache.iotdb.commons.client.ClientPoolFactory; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestManager; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeTSStatusRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.FetchSchemaBlackListRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.SchemaUpdateRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.TransferLeaderRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; -import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; -import org.apache.iotdb.mpp.rpc.thrift.TActiveTriggerInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TAlterViewReq; -import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceReq; -import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListWithTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TConstructViewSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreateDataRegionReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreateFunctionInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreatePipePluginInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreateSchemaRegionReq; -import org.apache.iotdb.mpp.rpc.thrift.TCreateTriggerInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TDeactivateTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TDeleteDataForDeleteSchemaReq; -import org.apache.iotdb.mpp.rpc.thrift.TDeleteTimeSeriesReq; -import org.apache.iotdb.mpp.rpc.thrift.TDeleteViewSchemaReq; -import org.apache.iotdb.mpp.rpc.thrift.TDropFunctionInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TDropPipePluginInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TDropTriggerInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TInactiveTriggerInstanceReq; -import org.apache.iotdb.mpp.rpc.thrift.TInvalidateMatchedSchemaCacheReq; -import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushMultiPipeMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushMultiTopicMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushSingleConsumerGroupMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushSinglePipeMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushSingleTopicMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaReq; -import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeReq; -import org.apache.iotdb.mpp.rpc.thrift.TRegionRouteReq; -import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; -import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListWithTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TRollbackViewSchemaBlackListReq; -import org.apache.iotdb.mpp.rpc.thrift.TUpdateTemplateReq; -import org.apache.iotdb.mpp.rpc.thrift.TUpdateTriggerLocationReq; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ -public class AsyncDataNodeInternalServiceRequestManager - extends AsyncRequestManager< - DataNodeRequestType, TDataNodeLocation, AsyncDataNodeInternalServiceClient> { - - private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestManager.class); - - private AsyncDataNodeInternalServiceRequestManager() { - super(); - } - - @Override - protected void initClientManager() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); - } - - @Override - protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { - return dataNodeLocation.getInternalEndPoint(); - } - - @Override - protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, - int requestId, - TDataNodeLocation targetNode, - int retryCount) { - - try { - AsyncDataNodeInternalServiceClient client; - client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); - Object req = requestContext.getRequest(requestId); - DataNodeAsyncRequestRPCHandler handler = - DataNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); - - DataNodeTSStatusRPCHandler defaultHandler = null; - if (handler instanceof DataNodeTSStatusRPCHandler) { - defaultHandler = (DataNodeTSStatusRPCHandler) handler; - } - - switch (requestContext.getRequestType()) { - case SET_TTL: - client.setTTL((TSetTTLReq) req, defaultHandler); - break; - case CREATE_DATA_REGION: - client.createDataRegion((TCreateDataRegionReq) req, defaultHandler); - break; - case DELETE_REGION: - client.deleteRegion((TConsensusGroupId) req, defaultHandler); - break; - case CREATE_SCHEMA_REGION: - client.createSchemaRegion((TCreateSchemaRegionReq) req, defaultHandler); - break; - case CREATE_FUNCTION: - client.createFunction((TCreateFunctionInstanceReq) req, defaultHandler); - break; - case DROP_FUNCTION: - client.dropFunction((TDropFunctionInstanceReq) req, defaultHandler); - break; - case CREATE_TRIGGER_INSTANCE: - client.createTriggerInstance((TCreateTriggerInstanceReq) req, defaultHandler); - break; - case DROP_TRIGGER_INSTANCE: - client.dropTriggerInstance((TDropTriggerInstanceReq) req, defaultHandler); - break; - case ACTIVE_TRIGGER_INSTANCE: - client.activeTriggerInstance((TActiveTriggerInstanceReq) req, defaultHandler); - break; - case INACTIVE_TRIGGER_INSTANCE: - client.inactiveTriggerInstance((TInactiveTriggerInstanceReq) req, defaultHandler); - break; - case UPDATE_TRIGGER_LOCATION: - client.updateTriggerLocation((TUpdateTriggerLocationReq) req, defaultHandler); - break; - case CREATE_PIPE_PLUGIN: - client.createPipePlugin((TCreatePipePluginInstanceReq) req, defaultHandler); - break; - case DROP_PIPE_PLUGIN: - client.dropPipePlugin((TDropPipePluginInstanceReq) req, defaultHandler); - break; - case PIPE_PUSH_ALL_META: - client.pushPipeMeta((TPushPipeMetaReq) req, (PipePushMetaRPCHandler) handler); - break; - case PIPE_PUSH_SINGLE_META: - client.pushSinglePipeMeta((TPushSinglePipeMetaReq) req, (PipePushMetaRPCHandler) handler); - break; - case PIPE_PUSH_MULTI_META: - client.pushMultiPipeMeta((TPushMultiPipeMetaReq) req, (PipePushMetaRPCHandler) handler); - break; - case TOPIC_PUSH_ALL_META: - client.pushTopicMeta((TPushTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); - break; - case TOPIC_PUSH_SINGLE_META: - client.pushSingleTopicMeta( - (TPushSingleTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); - break; - case TOPIC_PUSH_MULTI_META: - client.pushMultiTopicMeta( - (TPushMultiTopicMetaReq) req, (TopicPushMetaRPCHandler) handler); - break; - case CONSUMER_GROUP_PUSH_ALL_META: - client.pushConsumerGroupMeta( - (TPushConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); - break; - case CONSUMER_GROUP_PUSH_SINGLE_META: - client.pushSingleConsumerGroupMeta( - (TPushSingleConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler); - break; - case PIPE_HEARTBEAT: - client.pipeHeartbeat((TPipeHeartbeatReq) req, (PipeHeartbeatRPCHandler) handler); - break; - case MERGE: - case FULL_MERGE: - client.merge(defaultHandler); - break; - case FLUSH: - client.flush((TFlushReq) req, defaultHandler); - break; - case CLEAR_CACHE: - client.clearCache(defaultHandler); - break; - case START_REPAIR_DATA: - client.startRepairData(defaultHandler); - break; - case STOP_REPAIR_DATA: - client.stopRepairData(defaultHandler); - break; - case LOAD_CONFIGURATION: - client.loadConfiguration(defaultHandler); - break; - case SET_SYSTEM_STATUS: - client.setSystemStatus((String) req, defaultHandler); - break; - case UPDATE_REGION_ROUTE_MAP: - client.updateRegionCache((TRegionRouteReq) req, defaultHandler); - break; - case CHANGE_REGION_LEADER: - client.changeRegionLeader( - (TRegionLeaderChangeReq) req, (TransferLeaderRPCHandler) handler); - break; - case CONSTRUCT_SCHEMA_BLACK_LIST: - client.constructSchemaBlackList( - (TConstructSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); - break; - case ROLLBACK_SCHEMA_BLACK_LIST: - client.rollbackSchemaBlackList( - (TRollbackSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); - break; - case FETCH_SCHEMA_BLACK_LIST: - client.fetchSchemaBlackList( - (TFetchSchemaBlackListReq) req, (FetchSchemaBlackListRPCHandler) handler); - break; - case INVALIDATE_MATCHED_SCHEMA_CACHE: - client.invalidateMatchedSchemaCache( - (TInvalidateMatchedSchemaCacheReq) req, defaultHandler); - break; - case DELETE_DATA_FOR_DELETE_SCHEMA: - client.deleteDataForDeleteSchema( - (TDeleteDataForDeleteSchemaReq) req, (SchemaUpdateRPCHandler) handler); - break; - case DELETE_TIMESERIES: - client.deleteTimeSeries((TDeleteTimeSeriesReq) req, (SchemaUpdateRPCHandler) handler); - break; - case CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE: - client.constructSchemaBlackListWithTemplate( - (TConstructSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); - break; - case ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE: - client.rollbackSchemaBlackListWithTemplate( - (TRollbackSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler); - break; - case DEACTIVATE_TEMPLATE: - client.deactivateTemplate((TDeactivateTemplateReq) req, (SchemaUpdateRPCHandler) handler); - break; - case UPDATE_TEMPLATE: - client.updateTemplate((TUpdateTemplateReq) req, defaultHandler); - break; - case COUNT_PATHS_USING_TEMPLATE: - client.countPathsUsingTemplate( - (TCountPathsUsingTemplateReq) req, (CountPathsUsingTemplateRPCHandler) handler); - break; - case CHECK_SCHEMA_REGION_USING_TEMPLATE: - client.checkSchemaRegionUsingTemplate( - (TCheckSchemaRegionUsingTemplateReq) req, - (CheckSchemaRegionUsingTemplateRPCHandler) handler); - break; - case CHECK_TIMESERIES_EXISTENCE: - client.checkTimeSeriesExistence( - (TCheckTimeSeriesExistenceReq) req, (CheckTimeSeriesExistenceRPCHandler) handler); - break; - case CONSTRUCT_VIEW_SCHEMA_BLACK_LIST: - client.constructViewSchemaBlackList( - (TConstructViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); - break; - case ROLLBACK_VIEW_SCHEMA_BLACK_LIST: - client.rollbackViewSchemaBlackList( - (TRollbackViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler); - break; - case DELETE_VIEW: - client.deleteViewSchema((TDeleteViewSchemaReq) req, (SchemaUpdateRPCHandler) handler); - break; - case ALTER_VIEW: - client.alterView((TAlterViewReq) req, (SchemaUpdateRPCHandler) handler); - break; - case KILL_QUERY_INSTANCE: - client.killQueryInstance((String) req, defaultHandler); - break; - case SET_SPACE_QUOTA: - client.setSpaceQuota((TSetSpaceQuotaReq) req, defaultHandler); - break; - case SET_THROTTLE_QUOTA: - client.setThrottleQuota((TSetThrottleQuotaReq) req, defaultHandler); - break; - case RESET_PEER_LIST: - client.resetPeerList((TResetPeerListReq) req, defaultHandler); - break; - case SUBMIT_TEST_CONNECTION_TASK: - client.submitTestConnectionTask( - (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler); - break; - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - requestContext.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - requestContext.getRequestType(), - nodeLocationToEndPoint(targetNode), - e.getMessage(), - retryCount); - } - } - - private static class ClientPoolHolder { - - private static final AsyncDataNodeInternalServiceRequestManager INSTANCE = - new AsyncDataNodeInternalServiceRequestManager(); - - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncDataNodeInternalServiceRequestManager getInstance() { - return ClientPoolHolder.INSTANCE; - } -} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java new file mode 100644 index 000000000000..bb95ddb281aa --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java @@ -0,0 +1,76 @@ +/* + * 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.client.async; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.gg.ConfigNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAsyncRequestRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeTSStatusRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ +public class ConfigNodeToConfigNodeInternalServiceAsyncRequestManager + extends ConfigNodeInternalServiceAsyncRequestManager { + + private static final Logger LOGGER = + LoggerFactory.getLogger(ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.class); + + @Override + protected void initActionMapBuilder() { + actionMapBuilder.put( + ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + (req, client, handler) -> + client.submitTestConnectionTask( + (TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, + (req, client, handler) -> client.testConnection((ConfigNodeTSStatusRPCHandler) handler)); + } + + @Override + protected AsyncRequestRPCHandler + buildHandler( + AsyncRequestContext + requestContext, + int requestId, + TConfigNodeLocation targetNode) { + return ConfigNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); + } + + private static class ClientPoolHolder { + private static final ConfigNodeToConfigNodeInternalServiceAsyncRequestManager INSTANCE = + new ConfigNodeToConfigNodeInternalServiceAsyncRequestManager(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static ConfigNodeToConfigNodeInternalServiceAsyncRequestManager getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java new file mode 100644 index 000000000000..2250640086ff --- /dev/null +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java @@ -0,0 +1,371 @@ +/* + * 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.client.async; + +import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TFlushReq; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; +import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; +import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; +import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.gg.DataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeTSStatusRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.FetchSchemaBlackListRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.PipeHeartbeatRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.PipePushMetaRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.SchemaUpdateRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.TransferLeaderRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; +import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; +import org.apache.iotdb.mpp.rpc.thrift.TActiveTriggerInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TAlterViewReq; +import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceReq; +import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TConstructSchemaBlackListWithTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TConstructViewSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreateDataRegionReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreateFunctionInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreatePipePluginInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreateSchemaRegionReq; +import org.apache.iotdb.mpp.rpc.thrift.TCreateTriggerInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TDeactivateTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TDeleteDataForDeleteSchemaReq; +import org.apache.iotdb.mpp.rpc.thrift.TDeleteTimeSeriesReq; +import org.apache.iotdb.mpp.rpc.thrift.TDeleteViewSchemaReq; +import org.apache.iotdb.mpp.rpc.thrift.TDropFunctionInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TDropPipePluginInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TDropTriggerInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TInactiveTriggerInstanceReq; +import org.apache.iotdb.mpp.rpc.thrift.TInvalidateMatchedSchemaCacheReq; +import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushMultiPipeMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushMultiTopicMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushSingleConsumerGroupMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushSinglePipeMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushSingleTopicMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaReq; +import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeReq; +import org.apache.iotdb.mpp.rpc.thrift.TRegionRouteReq; +import org.apache.iotdb.mpp.rpc.thrift.TResetPeerListReq; +import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TRollbackSchemaBlackListWithTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TRollbackViewSchemaBlackListReq; +import org.apache.iotdb.mpp.rpc.thrift.TUpdateTemplateReq; +import org.apache.iotdb.mpp.rpc.thrift.TUpdateTriggerLocationReq; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ +public class ConfigNodeToDataNodeInternalServiceAsyncRequestManager + extends DataNodeInternalServiceRequestManager { + + private static final Logger LOGGER = + LoggerFactory.getLogger(ConfigNodeToDataNodeInternalServiceAsyncRequestManager.class); + + @Override + protected void initActionMapBuilder() { + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.SET_TTL, + (req, client, handler) -> + client.setTTL((TSetTTLReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION, + (req, client, handler) -> + client.createDataRegion( + (TCreateDataRegionReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.DELETE_REGION, + (req, client, handler) -> + client.deleteRegion((TConsensusGroupId) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION, + (req, client, handler) -> + client.createSchemaRegion( + (TCreateSchemaRegionReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CREATE_FUNCTION, + (req, client, handler) -> + client.createFunction( + (TCreateFunctionInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.DROP_FUNCTION, + (req, client, handler) -> + client.dropFunction( + (TDropFunctionInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CREATE_TRIGGER_INSTANCE, + (req, client, handler) -> + client.createTriggerInstance( + (TCreateTriggerInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.DROP_TRIGGER_INSTANCE, + (req, client, handler) -> + client.dropTriggerInstance( + (TDropTriggerInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, + (req, client, handler) -> + client.activeTriggerInstance( + (TActiveTriggerInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, + (req, client, handler) -> + client.inactiveTriggerInstance( + (TInactiveTriggerInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.UPDATE_TRIGGER_LOCATION, + (req, client, handler) -> + client.updateTriggerLocation( + (TUpdateTriggerLocationReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CREATE_PIPE_PLUGIN, + (req, client, handler) -> + client.createPipePlugin( + (TCreatePipePluginInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.DROP_PIPE_PLUGIN, + (req, client, handler) -> + client.dropPipePlugin( + (TDropPipePluginInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.PIPE_PUSH_ALL_META, + (req, client, handler) -> + client.pushPipeMeta((TPushPipeMetaReq) req, (PipePushMetaRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.PIPE_PUSH_SINGLE_META, + (req, client, handler) -> + client.pushSinglePipeMeta( + (TPushSinglePipeMetaReq) req, (PipePushMetaRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.PIPE_PUSH_MULTI_META, + (req, client, handler) -> + client.pushMultiPipeMeta( + (TPushMultiPipeMetaReq) req, (PipePushMetaRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.TOPIC_PUSH_ALL_META, + (req, client, handler) -> + client.pushTopicMeta((TPushTopicMetaReq) req, (TopicPushMetaRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, + (req, client, handler) -> + client.pushSingleTopicMeta( + (TPushSingleTopicMetaReq) req, (TopicPushMetaRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.TOPIC_PUSH_MULTI_META, + (req, client, handler) -> + client.pushMultiTopicMeta( + (TPushMultiTopicMetaReq) req, (TopicPushMetaRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, + (req, client, handler) -> + client.pushConsumerGroupMeta( + (TPushConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, + (req, client, handler) -> + client.pushSingleConsumerGroupMeta( + (TPushSingleConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.PIPE_HEARTBEAT, + (req, client, handler) -> + client.pipeHeartbeat((TPipeHeartbeatReq) req, (PipeHeartbeatRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.MERGE, + (req, client, handler) -> client.merge((DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.FULL_MERGE, + (req, client, handler) -> client.merge((DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.FLUSH, + (req, client, handler) -> + client.flush((TFlushReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CLEAR_CACHE, + (req, client, handler) -> client.clearCache((DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.START_REPAIR_DATA, + (req, client, handler) -> client.startRepairData((DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.STOP_REPAIR_DATA, + (req, client, handler) -> client.stopRepairData((DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.LOAD_CONFIGURATION, + (req, client, handler) -> client.loadConfiguration((DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS, + (req, client, handler) -> + client.setSystemStatus((String) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.UPDATE_REGION_ROUTE_MAP, + (req, client, handler) -> + client.updateRegionCache((TRegionRouteReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CHANGE_REGION_LEADER, + (req, client, handler) -> + client.changeRegionLeader( + (TRegionLeaderChangeReq) req, (TransferLeaderRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST, + (req, client, handler) -> + client.constructSchemaBlackList( + (TConstructSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST, + (req, client, handler) -> + client.rollbackSchemaBlackList( + (TRollbackSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.FETCH_SCHEMA_BLACK_LIST, + (req, client, handler) -> + client.fetchSchemaBlackList( + (TFetchSchemaBlackListReq) req, (FetchSchemaBlackListRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + (req, client, handler) -> + client.invalidateMatchedSchemaCache( + (TInvalidateMatchedSchemaCacheReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, + (req, client, handler) -> + client.deleteDataForDeleteSchema( + (TDeleteDataForDeleteSchemaReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.DELETE_TIMESERIES, + (req, client, handler) -> + client.deleteTimeSeries((TDeleteTimeSeriesReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + (req, client, handler) -> + client.constructSchemaBlackListWithTemplate( + (TConstructSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + (req, client, handler) -> + client.rollbackSchemaBlackListWithTemplate( + (TRollbackSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.DEACTIVATE_TEMPLATE, + (req, client, handler) -> + client.deactivateTemplate( + (TDeactivateTemplateReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + (req, client, handler) -> + client.updateTemplate((TUpdateTemplateReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.COUNT_PATHS_USING_TEMPLATE, + (req, client, handler) -> + client.countPathsUsingTemplate( + (TCountPathsUsingTemplateReq) req, (CountPathsUsingTemplateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CHECK_SCHEMA_REGION_USING_TEMPLATE, + (req, client, handler) -> + client.checkSchemaRegionUsingTemplate( + (TCheckSchemaRegionUsingTemplateReq) req, + (CheckSchemaRegionUsingTemplateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CHECK_TIMESERIES_EXISTENCE, + (req, client, handler) -> + client.checkTimeSeriesExistence( + (TCheckTimeSeriesExistenceReq) req, (CheckTimeSeriesExistenceRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, + (req, client, handler) -> + client.constructViewSchemaBlackList( + (TConstructViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.ROLLBACK_VIEW_SCHEMA_BLACK_LIST, + (req, client, handler) -> + client.rollbackViewSchemaBlackList( + (TRollbackViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.DELETE_VIEW, + (req, client, handler) -> + client.deleteViewSchema((TDeleteViewSchemaReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.ALTER_VIEW, + (req, client, handler) -> + client.alterView((TAlterViewReq) req, (SchemaUpdateRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.KILL_QUERY_INSTANCE, + (req, client, handler) -> + client.killQueryInstance((String) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.SET_SPACE_QUOTA, + (req, client, handler) -> + client.setSpaceQuota((TSetSpaceQuotaReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.SET_THROTTLE_QUOTA, + (req, client, handler) -> + client.setThrottleQuota( + (TSetThrottleQuotaReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.RESET_PEER_LIST, + (req, client, handler) -> + client.resetPeerList((TResetPeerListReq) req, (DataNodeTSStatusRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + (req, client, handler) -> + client.submitTestConnectionTask( + (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler)); + actionMapBuilder.put( + ConfigNodeToDataNodeRequestType.TEST_CONNECTION, + (req, client, handler) -> client.testConnection((DataNodeTSStatusRPCHandler) handler)); + } + + @Override + protected AsyncRequestRPCHandler + buildHandler( + AsyncRequestContext + requestContext, + int requestId, + TDataNodeLocation targetNode) { + return DataNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); + } + + private static class ClientPoolHolder { + + private static final ConfigNodeToDataNodeInternalServiceAsyncRequestManager INSTANCE = + new ConfigNodeToDataNodeInternalServiceAsyncRequestManager(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static ConfigNodeToDataNodeInternalServiceAsyncRequestManager getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java index e843f618c960..f79e3eb9338b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import java.util.Map; @@ -32,20 +32,20 @@ * @param ClassName of RPC response */ public class AsyncConfigNodeRequestContext - extends AsyncRequestContext { + extends AsyncRequestContext { - public AsyncConfigNodeRequestContext(ConfigNodeRequestType configNodeRequestType) { + public AsyncConfigNodeRequestContext(ConfigNodeToConfigNodeRequestType configNodeRequestType) { super(configNodeRequestType); } public AsyncConfigNodeRequestContext( - ConfigNodeRequestType configNodeRequestType, + ConfigNodeToConfigNodeRequestType configNodeRequestType, Map integerTConfigNodeLocationMap) { super(configNodeRequestType, integerTConfigNodeLocationMap); } public AsyncConfigNodeRequestContext( - ConfigNodeRequestType configNodeRequestType, + ConfigNodeToConfigNodeRequestType configNodeRequestType, Q q, Map integerTConfigNodeLocationMap) { super(configNodeRequestType, q, integerTConfigNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java index 5a5051320a4a..5abf76dc80f3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import java.util.Map; @@ -32,19 +32,22 @@ * @param ClassName of RPC response */ public class AsyncDataNodeRequestContext - extends AsyncRequestContext { + extends AsyncRequestContext { - public AsyncDataNodeRequestContext(DataNodeRequestType requestType) { + public AsyncDataNodeRequestContext(ConfigNodeToDataNodeRequestType requestType) { super(requestType); } public AsyncDataNodeRequestContext( - DataNodeRequestType requestType, Map dataNodeLocationMap) { + ConfigNodeToDataNodeRequestType requestType, + Map dataNodeLocationMap) { super(requestType, dataNodeLocationMap); } public AsyncDataNodeRequestContext( - DataNodeRequestType requestType, Q q, Map dataNodeLocationMap) { + ConfigNodeToDataNodeRequestType requestType, + Q q, + Map dataNodeLocationMap) { super(requestType, q, dataNodeLocationMap); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java index ee4c534be3f3..23a71dc6f855 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -39,7 +39,7 @@ public class CheckTimeSeriesExistenceRPCHandler LoggerFactory.getLogger(CheckTimeSeriesExistenceRPCHandler.class); public CheckTimeSeriesExistenceRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java index 6f623071518e..b9c40d217d04 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java @@ -24,16 +24,17 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import java.util.Map; import java.util.concurrent.CountDownLatch; public abstract class ConfigNodeAsyncRequestRPCHandler - extends AsyncRequestRPCHandler { + extends AsyncRequestRPCHandler< + Response, ConfigNodeToConfigNodeRequestType, TConfigNodeLocation> { protected ConfigNodeAsyncRequestRPCHandler( - ConfigNodeRequestType configNodeRequestType, + ConfigNodeToConfigNodeRequestType configNodeRequestType, int requestId, TConfigNodeLocation targetNode, Map integerTConfigNodeLocationMap, @@ -58,10 +59,10 @@ protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeL } public static ConfigNodeAsyncRequestRPCHandler buildHandler( - AsyncRequestContext context, + AsyncRequestContext context, int requestId, TConfigNodeLocation targetConfigNode) { - ConfigNodeRequestType requestType = context.getRequestType(); + ConfigNodeToConfigNodeRequestType requestType = context.getRequestType(); Map nodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); CountDownLatch countDownLatch = context.getCountDownLatch(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java index ece8c6be9c68..4ade8a14ce1f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -37,7 +37,7 @@ public class ConfigNodeTSStatusRPCHandler extends ConfigNodeAsyncRequestRPCHandl private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNodeTSStatusRPCHandler.class); public ConfigNodeTSStatusRPCHandler( - ConfigNodeRequestType requestType, + ConfigNodeToConfigNodeRequestType requestType, int requestId, TConfigNodeLocation targetConfigNode, Map configNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java index 313fb0761194..b24466d36149 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -39,7 +39,7 @@ public class CountPathsUsingTemplateRPCHandler LoggerFactory.getLogger(CountPathsUsingTemplateRPCHandler.class); public CountPathsUsingTemplateRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java index bb4a587a7fb5..7e056ae1b8e6 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java @@ -24,7 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; @@ -42,10 +42,10 @@ import java.util.concurrent.CountDownLatch; public abstract class DataNodeAsyncRequestRPCHandler - extends AsyncRequestRPCHandler { + extends AsyncRequestRPCHandler { protected DataNodeAsyncRequestRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetNode, Map dataNodeLocationMap, @@ -70,10 +70,10 @@ protected String generateFormattedTargetLocation(TDataNodeLocation dataNodeLocat } public static DataNodeAsyncRequestRPCHandler buildHandler( - AsyncRequestContext context, + AsyncRequestContext context, int requestId, TDataNodeLocation targetDataNode) { - DataNodeRequestType requestType = context.getRequestType(); + ConfigNodeToDataNodeRequestType requestType = context.getRequestType(); Map dataNodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); CountDownLatch countDownLatch = context.getCountDownLatch(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java index 72599af2dd1d..1833ff4d2df0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -37,7 +37,7 @@ public class DataNodeTSStatusRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java index 6f907d390548..dad755f0bfe9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -39,7 +39,7 @@ public class FetchSchemaBlackListRPCHandler LoggerFactory.getLogger(FetchSchemaBlackListRPCHandler.class); public FetchSchemaBlackListRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java index a2abed14d059..08ab10b4b469 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatResp; import org.slf4j.Logger; @@ -34,7 +34,7 @@ public class PipeHeartbeatRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java index a6114a8c0236..6a9dc819bf90 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -35,7 +35,7 @@ public class PipePushMetaRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java index f073233e8325..5f1d7ca8ea2a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -36,7 +36,7 @@ public class SchemaUpdateRPCHandler extends DataNodeTSStatusRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(SchemaUpdateRPCHandler.class); public SchemaUpdateRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index 0f43381c8098..e862e89b0b32 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +36,7 @@ public class SubmitTestConnectionTaskRPCHandler LoggerFactory.getLogger(SubmitTestConnectionTaskRPCHandler.class); public SubmitTestConnectionTaskRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index be1bb8016932..81ea8cb1c896 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -22,7 +22,7 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.rpc.TSStatusCode; import org.slf4j.Logger; @@ -38,7 +38,7 @@ public class SubmitTestConnectionTaskToConfigNodeRPCHandler LoggerFactory.getLogger(SubmitTestConnectionTaskToConfigNodeRPCHandler.class); public SubmitTestConnectionTaskToConfigNodeRPCHandler( - ConfigNodeRequestType requestType, + ConfigNodeToConfigNodeRequestType requestType, int requestId, TConfigNodeLocation targetConfigNode, Map configNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java index b67fa4d03757..1a24808801f6 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -37,7 +37,7 @@ public class TransferLeaderRPCHandler private static final Logger LOGGER = LoggerFactory.getLogger(TransferLeaderRPCHandler.class); public TransferLeaderRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java index b112457f0fa9..a7110692ed08 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateResp; import org.apache.iotdb.rpc.RpcUtils; @@ -40,7 +40,7 @@ public class CheckSchemaRegionUsingTemplateRPCHandler LoggerFactory.getLogger(CheckSchemaRegionUsingTemplateRPCHandler.class); public CheckSchemaRegionUsingTemplateRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java index bc8bfd0b6d78..2afa394ae58c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc.subscription; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaResp; import org.apache.iotdb.rpc.RpcUtils; @@ -38,7 +38,7 @@ public class ConsumerGroupPushMetaRPCHandler LoggerFactory.getLogger(ConsumerGroupPushMetaRPCHandler.class); public ConsumerGroupPushMetaRPCHandler( - DataNodeRequestType requestType, + ConfigNodeToDataNodeRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java index 9bbdc1625e96..df0febc7abdd 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc.subscription; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; import org.apache.iotdb.rpc.RpcUtils; @@ -37,7 +37,7 @@ public class TopicPushMetaRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java index 2ae8a3b56b38..292fab52f35e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java @@ -27,7 +27,7 @@ import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.confignode.rpc.thrift.TAddConsensusGroupReq; import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterReq; import org.apache.iotdb.rpc.RpcUtils; @@ -66,7 +66,7 @@ private void updateConfigNodeLeader(TSStatus status) { } public Object sendSyncRequestToConfigNodeWithRetry( - TEndPoint endPoint, Object req, ConfigNodeRequestType requestType) { + TEndPoint endPoint, Object req, ConfigNodeToConfigNodeRequestType requestType) { Throwable lastException = null; for (int retry = 0; retry < MAX_RETRY_NUM; retry++) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java index a969266744be..f3f4916132f1 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java @@ -27,7 +27,7 @@ import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.commons.client.sync.SyncDataNodeInternalServiceClient; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.mpp.rpc.thrift.TCreateDataRegionReq; import org.apache.iotdb.mpp.rpc.thrift.TCreatePeerReq; import org.apache.iotdb.mpp.rpc.thrift.TCreateSchemaRegionReq; @@ -65,7 +65,7 @@ private SyncDataNodeClientPool() { } public TSStatus sendSyncRequestToDataNodeWithRetry( - TEndPoint endPoint, Object req, DataNodeRequestType requestType) { + TEndPoint endPoint, Object req, ConfigNodeToDataNodeRequestType requestType) { Throwable lastException = new TException(); for (int retry = 0; retry < DEFAULT_RETRY_NUM; retry++) { try (SyncDataNodeInternalServiceClient client = clientManager.borrowClient(endPoint)) { @@ -84,7 +84,7 @@ public TSStatus sendSyncRequestToDataNodeWithRetry( } public TSStatus sendSyncRequestToDataNodeWithGivenRetry( - TEndPoint endPoint, Object req, DataNodeRequestType requestType, int retryNum) { + TEndPoint endPoint, Object req, ConfigNodeToDataNodeRequestType requestType, int retryNum) { Throwable lastException = new TException(); for (int retry = 0; retry < retryNum; retry++) { try (SyncDataNodeInternalServiceClient client = clientManager.borrowClient(endPoint)) { @@ -103,7 +103,9 @@ public TSStatus sendSyncRequestToDataNodeWithGivenRetry( } private TSStatus executeSyncRequest( - DataNodeRequestType requestType, SyncDataNodeInternalServiceClient client, Object req) + ConfigNodeToDataNodeRequestType requestType, + SyncDataNodeInternalServiceClient client, + Object req) throws TException { switch (requestType) { case INVALIDATE_PARTITION_CACHE: diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java index bdbbdc43c7a9..d2b658987fda 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java @@ -25,7 +25,7 @@ import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.commons.exception.BadNodeUrlException; import org.apache.iotdb.commons.utils.NodeUrlUtils; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.rpc.TSStatusCode; @@ -112,7 +112,7 @@ public void removeConfigNode(TConfigNodeLocation removedNode) .sendSyncRequestToConfigNodeWithRetry( configNodeLocation.getInternalEndPoint(), removedNode, - ConfigNodeRequestType.REMOVE_CONFIG_NODE); + ConfigNodeToConfigNodeRequestType.REMOVE_CONFIG_NODE); if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { break; } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 83dffd01f5f2..6e92e8d5574a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -30,10 +30,10 @@ import org.apache.iotdb.common.rpc.thrift.TServiceType; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncConfigNodeInternalServiceRequestManager; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToConfigNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeRequestContext; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -116,22 +116,25 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); AsyncConfigNodeRequestContext configNodeClientHandler = new AsyncConfigNodeRequestContext<>( - ConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); - AsyncConfigNodeInternalServiceRequestManager.getInstance() + ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNode(configNodeClientHandler); - Map anotherConfigNodeLocationMap = - configManager.getNodeManager().getRegisteredConfigNodes().stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); + Map anotherConfigNodeLocationMap = + configManager.getNodeManager().getRegisteredConfigNodes().stream() + .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); configNodeClientHandler .getResponseMap() .forEach( - (nodeId,configNodeResp) -> { + (nodeId, configNodeResp) -> { if (configNodeResp.isSetResultList()) { resp.getResultList().addAll(configNodeResp.getResultList()); } else { - resp.getResultList().addAll(buildAllDownConfigNodeConnectionResult(anotherConfigNodeLocationMap.get(nodeId), nodeLocations)); + resp.getResultList() + .addAll( + buildAllDownConfigNodeConnectionResult( + anotherConfigNodeLocationMap.get(nodeId), nodeLocations)); } }); Map dataNodeLocationMap = @@ -140,20 +143,27 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); AsyncDataNodeRequestContext dataNodeClientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + nodeLocations, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNode(dataNodeClientHandler); - Map anotherDataNodeLocationMap = - configManager.getNodeManager().getRegisteredDataNodes().stream() - .map(TDataNodeConfiguration::getLocation).collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location));; + Map anotherDataNodeLocationMap = + configManager.getNodeManager().getRegisteredDataNodes().stream() + .map(TDataNodeConfiguration::getLocation) + .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); + ; dataNodeClientHandler .getResponseMap() .forEach( - (nodeId, dataNodeResp) -> { + (nodeId, dataNodeResp) -> { if (dataNodeResp.isSetResultList()) { resp.getResultList().addAll(dataNodeResp.getResultList()); } else { - resp.getResultList().addAll(buildAllDownDataNodeConnectionResult(anotherDataNodeLocationMap.get(nodeId), nodeLocations)); + resp.getResultList() + .addAll( + buildAllDownDataNodeConnectionResult( + anotherDataNodeLocationMap.get(nodeId), nodeLocations)); } }); return resp; @@ -179,8 +189,8 @@ private List testAllConfigNodeConnection( .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); AsyncConfigNodeRequestContext requestContext = new AsyncConfigNodeRequestContext<>( - ConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); - AsyncConfigNodeInternalServiceRequestManager.getInstance() + ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); + ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(requestContext); Map anotherConfigNodeLocationMap = configNodeLocations.stream() @@ -194,15 +204,16 @@ private List testAllConfigNodeConnection( anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); TServiceProvider serviceProvider = new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); - collectResult(sender, results, status, serviceProvider); + collectResult(sender, results, status, serviceProvider); }); return results; } - private List buildAllDownConfigNodeConnectionResult(TConfigNodeLocation sourceConfigNode, TNodeLocations nodeLocations) { - final TSender sender = new TSender().setConfigNodeLocation(sourceConfigNode); - return buildAllDownNodeConnectionResult(nodeLocations, sender); - } + private List buildAllDownConfigNodeConnectionResult( + TConfigNodeLocation sourceConfigNode, TNodeLocations nodeLocations) { + final TSender sender = new TSender().setConfigNodeLocation(sourceConfigNode); + return buildAllDownNodeConnectionResult(nodeLocations, sender); + } private List testAllDataNodeConnection( List dataNodeLocations) { @@ -215,8 +226,8 @@ private List testAllDataNodeConnection( .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); AsyncDataNodeRequestContext requestContext = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(requestContext); Map anotherDataNodeLocationMap = dataNodeLocations.stream() @@ -234,42 +245,56 @@ private List testAllDataNodeConnection( return results; } - private List buildAllDownDataNodeConnectionResult(TDataNodeLocation sourceDataNode, TNodeLocations nodeLocations) { - final TSender sender = new TSender().setDataNodeLocation(sourceDataNode); - return buildAllDownNodeConnectionResult(nodeLocations, sender); - } + private List buildAllDownDataNodeConnectionResult( + TDataNodeLocation sourceDataNode, TNodeLocations nodeLocations) { + final TSender sender = new TSender().setDataNodeLocation(sourceDataNode); + return buildAllDownNodeConnectionResult(nodeLocations, sender); + } - private List buildAllDownNodeConnectionResult(TNodeLocations nodeLocations, TSender sender) { - List results = new ArrayList<>(); - nodeLocations.getConfigNodeLocations().forEach(location -> { - TEndPoint endPoint = location.getInternalEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult().setServiceProvider(serviceProvider).setSender(sender); - result.setSuccess(false).setReason("Cannot get verification result"); - results.add(result); - }); - nodeLocations.getDataNodeLocations().forEach(location -> { - TEndPoint endPoint = location.getInternalEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); - TTestConnectionResult result = new TTestConnectionResult().setServiceProvider(serviceProvider).setSender(sender); - result.setSuccess(false).setReason("Cannot get verification result"); - results.add(result); - }); - return results; - } + private List buildAllDownNodeConnectionResult( + TNodeLocations nodeLocations, TSender sender) { + List results = new ArrayList<>(); + nodeLocations + .getConfigNodeLocations() + .forEach( + location -> { + TEndPoint endPoint = location.getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); + TTestConnectionResult result = + new TTestConnectionResult().setServiceProvider(serviceProvider).setSender(sender); + result.setSuccess(false).setReason("Cannot get verification result"); + results.add(result); + }); + nodeLocations + .getDataNodeLocations() + .forEach( + location -> { + TEndPoint endPoint = location.getInternalEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); + TTestConnectionResult result = + new TTestConnectionResult().setServiceProvider(serviceProvider).setSender(sender); + result.setSuccess(false).setReason("Cannot get verification result"); + results.add(result); + }); + return results; + } - private void collectResult(TSender sender, List results, TSStatus status, TServiceProvider serviceProvider) { - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); + private void collectResult( + TSender sender, + List results, + TSStatus status, + TServiceProvider serviceProvider) { + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); } + results.add(result); + } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java index 88a937e97faf..50a65a0e6b43 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java @@ -26,8 +26,8 @@ import org.apache.iotdb.common.rpc.thrift.TSpaceQuota; import org.apache.iotdb.common.rpc.thrift.TThrottleQuota; import org.apache.iotdb.commons.conf.IoTDBConstant; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.quota.SetSpaceQuotaPlan; import org.apache.iotdb.confignode.consensus.request.write.quota.SetThrottleQuotaPlan; @@ -89,8 +89,8 @@ public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } @@ -196,8 +196,8 @@ public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index c3b16e88cbf9..aa25adde4036 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -24,8 +24,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.trigger.TriggerInformation; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTransferringTriggersPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerJarPlan; @@ -250,8 +250,8 @@ public List updateTriggerLocation( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index 62aa2f7e4417..d2e5d9afa816 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -23,8 +23,8 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.commons.udf.UDFInformation; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.function.GetFunctionTablePlan; @@ -129,8 +129,8 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, new TCreateFunctionInstanceReq(udfInformation.serialize()).setJarFile(jarFile); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -164,8 +164,8 @@ private List dropFunctionOnDataNodes(String functionName) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java index 0d2427bb707d..89b33ecb4dd5 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java @@ -24,7 +24,7 @@ import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.cq.TimeoutPolicy; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.consensus.request.write.cq.UpdateCQLastExecTimePlan; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.persistence.cq.CQInfo; @@ -188,7 +188,7 @@ public void run() { new TExecuteCQ(queryBody, startTime, endTime, everyInterval, zoneId, cqId, username); try { AsyncDataNodeInternalServiceClient client = - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .getAsyncClient(targetDataNode.get()); client.executeCQ(executeCQReq, new AsyncExecuteCQCallback(startTime, endTime)); } catch (Exception t) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index 396cce0d0e18..50c055883838 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -25,8 +25,8 @@ import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.cluster.NodeStatus; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -164,7 +164,7 @@ private void balanceRegionLeader( long currentTime = System.nanoTime(); AtomicInteger requestId = new AtomicInteger(0); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.CHANGE_REGION_LEADER); + new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.CHANGE_REGION_LEADER); Map successTransferMap = new TreeMap<>(); optimalLeaderMap.forEach( (regionGroupId, newLeaderId) -> { @@ -218,7 +218,7 @@ private void balanceRegionLeader( }); if (requestId.get() > 0) { // Don't retry ChangeLeader request - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNode(clientHandler); for (int i = 0; i < requestId.get(); i++) { if (clientHandler.getResponseMap().get(i).getStatus().getCode() @@ -303,10 +303,10 @@ private void broadcastLatestRegionPriorityMap() { Map tmpPriorityMap = getRegionPriorityMap(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.UPDATE_REGION_ROUTE_MAP, + ConfigNodeToDataNodeRequestType.UPDATE_REGION_ROUTE_MAP, new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index 576d399c5ed2..ba18d21a6308 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -33,8 +33,8 @@ import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.consensus.ConsensusGroupId; import org.apache.iotdb.commons.service.metric.MetricService; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; @@ -701,8 +701,9 @@ public List merge() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.MERGE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + new AsyncDataNodeRequestContext<>( + ConfigNodeToDataNodeRequestType.MERGE, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -711,8 +712,9 @@ public List flush(TFlushReq req) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.FLUSH, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + new AsyncDataNodeRequestContext<>( + ConfigNodeToDataNodeRequestType.FLUSH, req, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -721,8 +723,9 @@ public List clearCache() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + new AsyncDataNodeRequestContext<>( + ConfigNodeToDataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -732,8 +735,8 @@ public List startRpairData() { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -743,8 +746,8 @@ public List stopRepairData() { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -754,8 +757,8 @@ public List loadConfiguration() { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -765,8 +768,8 @@ public List setSystemStatus(String status) { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -776,7 +779,7 @@ public TSStatus setDataNodeStatus(TSetDataNodeStatusReq setDataNodeStatusReq) { .sendSyncRequestToDataNodeWithRetry( setDataNodeStatusReq.getTargetDataNode().getInternalEndPoint(), setDataNodeStatusReq.getStatus(), - DataNodeRequestType.SET_SYSTEM_STATUS); + ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS); } /** @@ -799,8 +802,8 @@ private TSStatus killAllQueries() { configManager.getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } @@ -815,7 +818,7 @@ private TSStatus killSpecificQuery(String queryId, TDataNodeLocation dataNodeLoc .sendSyncRequestToDataNodeWithRetry( dataNodeLocation.getInternalEndPoint(), queryId, - DataNodeRequestType.KILL_QUERY_INSTANCE); + ConfigNodeToDataNodeRequestType.KILL_QUERY_INSTANCE); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index 5a233adb9a09..c7a520a2f5a1 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -34,8 +34,8 @@ import org.apache.iotdb.commons.partition.SchemaPartitionTable; import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor; import org.apache.iotdb.commons.path.PartialPath; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -1258,7 +1258,7 @@ public void maintainRegionReplicas() { AsyncDataNodeRequestContext createSchemaRegionHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CREATE_SCHEMA_REGION); + ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask schemaRegionCreateTask = (RegionCreateTask) regionMaintainTask; @@ -1276,7 +1276,7 @@ public void maintainRegionReplicas() { schemaRegionCreateTask.getTargetDataNode()); } - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(createSchemaRegionHandler); for (Map.Entry entry : @@ -1294,7 +1294,7 @@ public void maintainRegionReplicas() { AsyncDataNodeRequestContext createDataRegionHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CREATE_DATA_REGION); + ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask dataRegionCreateTask = (RegionCreateTask) regionMaintainTask; @@ -1313,7 +1313,7 @@ public void maintainRegionReplicas() { dataRegionCreateTask.getTargetDataNode()); } - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(createDataRegionHandler); for (Map.Entry entry : @@ -1331,7 +1331,8 @@ public void maintainRegionReplicas() { case DELETE: // delete region AsyncDataNodeRequestContext deleteRegionHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.DELETE_REGION); + new AsyncDataNodeRequestContext<>( + ConfigNodeToDataNodeRequestType.DELETE_REGION); Map regionIdMap = new HashMap<>(); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionDeleteTask regionDeleteTask = (RegionDeleteTask) regionMaintainTask; @@ -1349,7 +1350,7 @@ public void maintainRegionReplicas() { } long startTime = System.currentTimeMillis(); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(deleteRegionHandler); LOGGER.info( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java index 712f77c4e696..20f53dae0ad4 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/PipeHeartbeatScheduler.java @@ -24,8 +24,8 @@ import org.apache.iotdb.commons.concurrent.ThreadName; import org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil; import org.apache.iotdb.commons.pipe.config.PipeConfig; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.ConfigManager; @@ -98,8 +98,8 @@ private synchronized void heartbeat() { final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeHeartbeatIntervalSecondsForCollectingPipeMeta() diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 6a4ff84ed597..6c8c299ca76a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -31,8 +31,8 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.PathUtils; import org.apache.iotdb.commons.utils.StatusUtils; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -439,7 +439,7 @@ public TSStatus setTTL(SetTTLPlan setTTLPlan, boolean isGeneratedByPipe) { } AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.SET_TTL); + new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.SET_TTL); dnlToSgMap .keySet() .forEach( @@ -450,7 +450,7 @@ public TSStatus setTTL(SetTTLPlan setTTLPlan, boolean isGeneratedByPipe) { clientHandler.putNodeLocation(dataNodeId, dataNodeLocationMap.get(dataNodeId)); }); // TODO: Check response - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); try { @@ -1102,8 +1102,10 @@ public synchronized TSStatus extendSchemaTemplate( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.UPDATE_TEMPLATE, updateTemplateReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + updateTemplateReq, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index 977a7b525d70..3c813b11fb6a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -32,9 +32,9 @@ import org.apache.iotdb.commons.pipe.config.PipeConfig; import org.apache.iotdb.commons.pipe.plugin.meta.PipePluginMeta; import org.apache.iotdb.commons.trigger.TriggerInformation; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; @@ -186,14 +186,14 @@ public boolean invalidateCache(String storageGroupName) throws IOException, TExc .sendSyncRequestToDataNodeWithRetry( dataNodeConfiguration.getLocation().getInternalEndPoint(), invalidateCacheReq, - DataNodeRequestType.INVALIDATE_PARTITION_CACHE); + ConfigNodeToDataNodeRequestType.INVALIDATE_PARTITION_CACHE); final TSStatus invalidateSchemaStatus = SyncDataNodeClientPool.getInstance() .sendSyncRequestToDataNodeWithRetry( dataNodeConfiguration.getLocation().getInternalEndPoint(), invalidateCacheReq, - DataNodeRequestType.INVALIDATE_SCHEMA_CACHE); + ConfigNodeToDataNodeRequestType.INVALIDATE_SCHEMA_CACHE); if (!verifySucceed(invalidatePartitionStatus, invalidateSchemaStatus)) { LOG.error( @@ -250,7 +250,7 @@ public void addConsensusGroup(TConfigNodeLocation tConfigNodeLocation) .sendSyncRequestToConfigNodeWithRetry( tConfigNodeLocation.getInternalEndPoint(), new TAddConsensusGroupReq(configNodeLocations), - ConfigNodeRequestType.ADD_CONSENSUS_GROUP); + ConfigNodeToConfigNodeRequestType.ADD_CONSENSUS_GROUP); if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { throw new AddConsensusGroupException(tConfigNodeLocation); } @@ -314,7 +314,7 @@ public void deleteConfigNodePeer(TConfigNodeLocation removedConfigNode) .sendSyncRequestToConfigNodeWithRetry( removedConfigNode.getInternalEndPoint(), removedConfigNode, - ConfigNodeRequestType.DELETE_CONFIG_NODE_PEER); + ConfigNodeToConfigNodeRequestType.DELETE_CONFIG_NODE_PEER); if (tsStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { throw new ProcedureException(tsStatus.getMessage()); } @@ -333,7 +333,7 @@ public void stopConfigNode(TConfigNodeLocation tConfigNodeLocation) throws Proce .sendSyncRequestToConfigNodeWithRetry( tConfigNodeLocation.getInternalEndPoint(), tConfigNodeLocation, - ConfigNodeRequestType.STOP_CONFIG_NODE); + ConfigNodeToConfigNodeRequestType.STOP_CONFIG_NODE); if (tsStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { throw new ProcedureException(tsStatus.getMessage()); @@ -363,7 +363,7 @@ public void notifyRegisterSuccess(TConfigNodeLocation configNodeLocation) { .sendSyncRequestToConfigNodeWithRetry( configNodeLocation.getInternalEndPoint(), null, - ConfigNodeRequestType.NOTIFY_REGISTER_SUCCESS); + ConfigNodeToConfigNodeRequestType.NOTIFY_REGISTER_SUCCESS); } /** @@ -388,14 +388,14 @@ public void markDataNodeAsRemovingAndBroadcast(TDataNodeLocation dataNodeLocatio .sendSyncRequestToDataNodeWithGivenRetry( dataNodeLocation.getInternalEndPoint(), NodeStatus.Removing.getStatus(), - DataNodeRequestType.SET_SYSTEM_STATUS, + ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS, 1); } else { SyncDataNodeClientPool.getInstance() .sendSyncRequestToDataNodeWithRetry( dataNodeLocation.getInternalEndPoint(), NodeStatus.Removing.getStatus(), - DataNodeRequestType.SET_SYSTEM_STATUS); + ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS); } long currentTime = System.nanoTime(); @@ -444,7 +444,7 @@ public Map doRegionCreation( } // Send CreateRegion requests to DataNodes - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); // Filter RegionGroups that weren't created successfully @@ -472,7 +472,7 @@ public Map doRegionCreation( private AsyncDataNodeRequestContext getCreateSchemaRegionClientHandler(CreateRegionGroupsPlan createRegionGroupsPlan) { AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_SCHEMA_REGION); + new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -496,7 +496,7 @@ public Map doRegionCreation( getCreateDataRegionClientHandler(CreateRegionGroupsPlan createRegionGroupsPlan) { Map ttlMap = getTTLMap(createRegionGroupsPlan); AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.CREATE_DATA_REGION); + new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -611,8 +611,8 @@ public List createTriggerOnDataNodes( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -626,8 +626,8 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -640,8 +640,8 @@ public List activeTriggerOnDataNodes(String triggerName) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -654,8 +654,10 @@ public List inactiveTriggerOnDataNodes(String triggerName) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, + request, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -669,8 +671,8 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -684,8 +686,8 @@ public List dropPipePluginOnDataNodes( AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -698,8 +700,8 @@ public Map pushAllPipeMetaToDataNodes( final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -713,8 +715,8 @@ public Map pushSinglePipeMetaToDataNodes(ByteBuffer final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -729,8 +731,8 @@ public Map dropSinglePipeOnDataNodes(String pipeName final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -746,8 +748,8 @@ public Map pushMultiPipeMetaToDataNodes( final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -762,8 +764,8 @@ public Map dropMultiPipeOnDataNodes(List pip final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -778,8 +780,8 @@ public Map pushAllTopicMetaToDataNodes( final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -793,8 +795,8 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) @@ -809,8 +811,8 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) @@ -826,8 +828,8 @@ public Map pushMultiTopicMetaToDataNodes( final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -842,8 +844,8 @@ public Map dropMultiTopicOnDataNodes(List t final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -860,8 +862,10 @@ public Map pushAllConsumerGroupMetaToDataNo final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, + request, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -877,8 +881,10 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, + request, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) @@ -894,8 +900,10 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName final AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, + request, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index 9f511c5ce43d..327e1a0e299c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -34,8 +34,8 @@ import org.apache.iotdb.commons.cluster.RegionStatus; import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.NodeUrlUtils; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; @@ -144,7 +144,7 @@ public void broadcastDisableDataNode(TDataNodeLocation disabledDataNode) { .sendSyncRequestToDataNodeWithRetry( node.getLocation().getInternalEndPoint(), disableReq, - DataNodeRequestType.DISABLE_DATA_NODE); + ConfigNodeToDataNodeRequestType.DISABLE_DATA_NODE); if (!isSucceed(status)) { LOGGER.error( "{}, BroadcastDisableDataNode meets error, disabledDataNode: {}, error: {}", @@ -237,7 +237,7 @@ public TSStatus createNewRegionPeer(TConsensusGroupId regionId, TDataNodeLocatio .sendSyncRequestToDataNodeWithRetry( destDataNode.getInternalEndPoint(), req, - DataNodeRequestType.CREATE_NEW_REGION_PEER); + ConfigNodeToDataNodeRequestType.CREATE_NEW_REGION_PEER); if (isSucceed(status)) { LOGGER.info( @@ -282,7 +282,7 @@ public TSStatus submitAddRegionPeerTask( .sendSyncRequestToDataNodeWithRetry( coordinator.getInternalEndPoint(), maintainPeerReq, - DataNodeRequestType.ADD_REGION_PEER); + ConfigNodeToDataNodeRequestType.ADD_REGION_PEER); LOGGER.info( "{}, Send action addRegionPeer finished, regionId: {}, rpcDataNode: {}, destDataNode: {}, status: {}", REGION_MIGRATE_PROCESS, @@ -318,7 +318,7 @@ public TSStatus submitRemoveRegionPeerTask( .sendSyncRequestToDataNodeWithRetry( coordinator.getInternalEndPoint(), maintainPeerReq, - DataNodeRequestType.REMOVE_REGION_PEER); + ConfigNodeToDataNodeRequestType.REMOVE_REGION_PEER); LOGGER.info( "{}, Send action removeRegionPeer finished, regionId: {}, rpcDataNode: {}", REGION_MIGRATE_PROCESS, @@ -351,13 +351,13 @@ public TSStatus submitDeleteOldRegionPeerTask( .sendSyncRequestToDataNodeWithGivenRetry( originalDataNode.getInternalEndPoint(), maintainPeerReq, - DataNodeRequestType.DELETE_OLD_REGION_PEER, + ConfigNodeToDataNodeRequestType.DELETE_OLD_REGION_PEER, 1) : SyncDataNodeClientPool.getInstance() .sendSyncRequestToDataNodeWithRetry( originalDataNode.getInternalEndPoint(), maintainPeerReq, - DataNodeRequestType.DELETE_OLD_REGION_PEER); + ConfigNodeToDataNodeRequestType.DELETE_OLD_REGION_PEER); LOGGER.info( "{}, Send action deleteOldRegionPeer finished, regionId: {}, dataNodeId: {}", REGION_MIGRATE_PROCESS, @@ -372,10 +372,10 @@ public Map resetPeerList( Map dataNodeLocationMap) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.RESET_PEER_LIST, + ConfigNodeToDataNodeRequestType.RESET_PEER_LIST, new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); return clientHandler.getResponseMap(); } @@ -503,7 +503,10 @@ public void stopDataNode(TDataNodeLocation dataNode) { TSStatus status = SyncDataNodeClientPool.getInstance() .sendSyncRequestToDataNodeWithGivenRetry( - dataNode.getInternalEndPoint(), dataNode, DataNodeRequestType.STOP_DATA_NODE, 2); + dataNode.getInternalEndPoint(), + dataNode, + ConfigNodeToDataNodeRequestType.STOP_DATA_NODE, + 2); configManager.getLoadManager().removeNodeCache(dataNode.getDataNodeId()); LOGGER.info( "{}, Stop Data Node result: {}, stoppedDataNode: {}", diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index 1587739d60ae..f673cc3e982e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -30,8 +30,8 @@ import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; @@ -122,10 +122,10 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -156,7 +156,7 @@ private void alterLogicalView(ConfigNodeProcedureEnv env) throws ProcedureExcept "Alter view", env, targetSchemaRegionGroup, - DataNodeRequestType.ALTER_VIEW, + ConfigNodeToDataNodeRequestType.ALTER_VIEW, (dataNodeLocation, consensusGroupIdList) -> { TAlterViewReq req = new TAlterViewReq().setIsGeneratedByPipe(isGeneratedByPipe); req.setSchemaRegionIdList(consensusGroupIdList); @@ -324,7 +324,7 @@ private class AlterLogicalViewRegionTaskExecutor String taskName, ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, - DataNodeRequestType dataNodeRequestType, + ConfigNodeToDataNodeRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super(env, targetSchemaRegionGroup, false, dataNodeRequestType, dataNodeRequestGenerator); this.taskName = taskName; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java index 533c99e34164..fe37d09ff56b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java @@ -22,8 +22,8 @@ import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -45,7 +45,7 @@ public abstract class DataNodeRegionTaskExecutor { protected final Map targetSchemaRegionGroup; protected final boolean executeOnAllReplicaset; - protected final DataNodeRequestType dataNodeRequestType; + protected final ConfigNodeToDataNodeRequestType dataNodeRequestType; protected final BiFunction, Q> dataNodeRequestGenerator; @@ -55,7 +55,7 @@ protected DataNodeRegionTaskExecutor( ConfigManager configManager, Map targetSchemaRegionGroup, boolean executeOnAllReplicaset, - DataNodeRequestType dataNodeRequestType, + ConfigNodeToDataNodeRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { this.configManager = configManager; this.targetSchemaRegionGroup = targetSchemaRegionGroup; @@ -68,7 +68,7 @@ protected DataNodeRegionTaskExecutor( ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, boolean executeOnAllReplicaset, - DataNodeRequestType dataNodeRequestType, + ConfigNodeToDataNodeRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { this.configManager = env.getConfigManager(); this.targetSchemaRegionGroup = targetSchemaRegionGroup; @@ -88,7 +88,7 @@ void execute() { while (!dataNodeConsensusGroupIdMap.isEmpty()) { AsyncDataNodeRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map> currentFailedDataNodeMap = checkDataNodeExecutionResult(clientHandler.getResponseMap(), dataNodeConsensusGroupIdMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java index 9845d2cd7eef..bf3f22056d5c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java @@ -28,8 +28,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeactivateTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -152,7 +152,7 @@ private long constructBlackList(ConfigNodeProcedureEnv env) { "construct schema black list", env, targetSchemaRegionGroup, - DataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + ConfigNodeToDataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TConstructSchemaBlackListWithTemplateReq( consensusGroupIdList, dataNodeRequest))) { @@ -200,10 +200,10 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(timeSeriesPatternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -233,7 +233,7 @@ private void deleteData(ConfigNodeProcedureEnv env) { env, relatedDataRegionGroup, true, - DataNodeRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, + ConfigNodeToDataNodeRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, ((dataNodeLocation, consensusGroupIdList) -> new TDeleteDataForDeleteSchemaReq( new ArrayList<>(consensusGroupIdList), timeSeriesPatternTreeBytes))); @@ -248,7 +248,7 @@ private void deactivateTemplate(ConfigNodeProcedureEnv env) { "deactivate template schema", env, env.getConfigManager().getRelatedSchemaRegionGroup(timeSeriesPatternTree), - DataNodeRequestType.DEACTIVATE_TEMPLATE, + ConfigNodeToDataNodeRequestType.DEACTIVATE_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TDeactivateTemplateReq(consensusGroupIdList, dataNodeRequest) .setIsGeneratedByPipe(isGeneratedByPipe))); @@ -286,7 +286,7 @@ protected void rollbackState( "roll back schema black list", env, env.getConfigManager().getRelatedSchemaRegionGroup(timeSeriesPatternTree), - DataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + ConfigNodeToDataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TRollbackSchemaBlackListWithTemplateReq( consensusGroupIdList, dataNodeRequest))); @@ -439,7 +439,7 @@ private class DeactivateTemplateRegionTaskExecutor String taskName, ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, - DataNodeRequestType dataNodeRequestType, + ConfigNodeToDataNodeRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super(env, targetSchemaRegionGroup, false, dataNodeRequestType, dataNodeRequestGenerator); this.taskName = taskName; @@ -450,7 +450,7 @@ private class DeactivateTemplateRegionTaskExecutor ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, boolean executeOnAllReplicaset, - DataNodeRequestType dataNodeRequestType, + ConfigNodeToDataNodeRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super( env, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java index d99f509ba1db..966d736d684e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java @@ -27,8 +27,8 @@ import org.apache.iotdb.commons.exception.runtime.ThriftSerDeException; import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.ThriftConfigNodeSerDeUtils; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.database.PreDeleteDatabasePlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; @@ -156,7 +156,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt // try sync delete schemaengine region AsyncDataNodeRequestContext asyncClientHandler = - new AsyncDataNodeRequestContext<>(DataNodeRequestType.DELETE_REGION); + new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.DELETE_REGION); Map schemaRegionDeleteTaskMap = new HashMap<>(); int requestIndex = 0; for (TRegionReplicaSet schemaRegionReplicaSet : schemaRegionReplicaSets) { @@ -171,7 +171,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt } } if (!schemaRegionDeleteTaskMap.isEmpty()) { - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(asyncClientHandler); for (Map.Entry entry : asyncClientHandler.getResponseMap().entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index 2bf5b9c345cc..6249efeb9258 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -26,8 +26,8 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -142,7 +142,7 @@ private long constructBlackList(ConfigNodeProcedureEnv env) { "construct view schemaengine black list", env, targetSchemaRegionGroup, - DataNodeRequestType.CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, + ConfigNodeToDataNodeRequestType.CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, ((dataNodeLocation, consensusGroupIdList) -> new TConstructViewSchemaBlackListReq(consensusGroupIdList, patternTreeBytes))) { @Override @@ -186,10 +186,10 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -212,7 +212,7 @@ private void deleteViewSchema(ConfigNodeProcedureEnv env) { "delete view schemaengine", env, env.getConfigManager().getRelatedSchemaRegionGroup(patternTree), - DataNodeRequestType.DELETE_VIEW, + ConfigNodeToDataNodeRequestType.DELETE_VIEW, ((dataNodeLocation, consensusGroupIdList) -> new TDeleteViewSchemaReq(consensusGroupIdList, patternTreeBytes) .setIsGeneratedByPipe(isGeneratedByPipe))); @@ -248,7 +248,7 @@ protected void rollbackState( "roll back view schemaengine black list", env, env.getConfigManager().getRelatedSchemaRegionGroup(patternTree), - DataNodeRequestType.ROLLBACK_VIEW_SCHEMA_BLACK_LIST, + ConfigNodeToDataNodeRequestType.ROLLBACK_VIEW_SCHEMA_BLACK_LIST, (dataNodeLocation, consensusGroupIdList) -> new TRollbackViewSchemaBlackListReq(consensusGroupIdList, patternTreeBytes)); rollbackStateTask.execute(); @@ -344,7 +344,7 @@ private class DeleteLogicalViewRegionTaskExecutor String taskName, ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, - DataNodeRequestType dataNodeRequestType, + ConfigNodeToDataNodeRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super(env, targetSchemaRegionGroup, false, dataNodeRequestType, dataNodeRequestGenerator); this.taskName = taskName; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index e6e49264338a..0c5998265585 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -26,8 +26,8 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -148,7 +148,7 @@ private long constructBlackList(ConfigNodeProcedureEnv env) { "construct schemaengine black list", env, targetSchemaRegionGroup, - DataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST, + ConfigNodeToDataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST, ((dataNodeLocation, consensusGroupIdList) -> new TConstructSchemaBlackListReq(consensusGroupIdList, patternTreeBytes))) { @Override @@ -192,10 +192,10 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -238,7 +238,7 @@ private void executeDeleteData(ConfigNodeProcedureEnv env, PathPatternTree patte env, relatedDataRegionGroup, true, - DataNodeRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, + ConfigNodeToDataNodeRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, ((dataNodeLocation, consensusGroupIdList) -> new TDeleteDataForDeleteSchemaReq( new ArrayList<>(consensusGroupIdList), @@ -253,7 +253,7 @@ private void deleteTimeSeriesSchema(ConfigNodeProcedureEnv env) { "delete timeseries schemaengine", env, env.getConfigManager().getRelatedSchemaRegionGroup(patternTree), - DataNodeRequestType.DELETE_TIMESERIES, + ConfigNodeToDataNodeRequestType.DELETE_TIMESERIES, ((dataNodeLocation, consensusGroupIdList) -> new TDeleteTimeSeriesReq(consensusGroupIdList, patternTreeBytes) .setIsGeneratedByPipe(isGeneratedByPipe))); @@ -290,7 +290,7 @@ protected void rollbackState( "roll back schemaengine black list", env, env.getConfigManager().getRelatedSchemaRegionGroup(patternTree), - DataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST, + ConfigNodeToDataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST, (dataNodeLocation, consensusGroupIdList) -> new TRollbackSchemaBlackListReq(consensusGroupIdList, patternTreeBytes)); rollbackStateTask.execute(); @@ -387,7 +387,7 @@ private class DeleteTimeSeriesRegionTaskExecutor String taskName, ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, - DataNodeRequestType dataNodeRequestType, + ConfigNodeToDataNodeRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super(env, targetSchemaRegionGroup, false, dataNodeRequestType, dataNodeRequestGenerator); this.taskName = taskName; @@ -398,7 +398,7 @@ private class DeleteTimeSeriesRegionTaskExecutor ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, boolean executeOnAllReplicaset, - DataNodeRequestType dataNodeRequestType, + ConfigNodeToDataNodeRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super( env, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SchemaUtils.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SchemaUtils.java index 1dc978cc4040..b5e3417c18c0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SchemaUtils.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SchemaUtils.java @@ -26,7 +26,7 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.db.exception.metadata.PathNotExistException; import org.apache.iotdb.db.schemaengine.template.Template; @@ -76,7 +76,7 @@ public static boolean checkDataNodeTemplateActivation( configManager, relatedSchemaRegionGroup, false, - DataNodeRequestType.COUNT_PATHS_USING_TEMPLATE, + ConfigNodeToDataNodeRequestType.COUNT_PATHS_USING_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TCountPathsUsingTemplateReq( template.getId(), patternTreeBytes, consensusGroupIdList))) { @@ -155,7 +155,7 @@ public static void checkSchemaRegionUsingTemplate( configManager, relatedSchemaRegionGroup, false, - DataNodeRequestType.CHECK_SCHEMA_REGION_USING_TEMPLATE, + ConfigNodeToDataNodeRequestType.CHECK_SCHEMA_REGION_USING_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TCheckSchemaRegionUsingTemplateReq(consensusGroupIdList))) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index 10e318e51f34..df3547fd7cf1 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -28,8 +28,8 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.consensus.request.read.template.CheckTemplateSettablePlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetSchemaTemplatePlan; @@ -212,8 +212,8 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { @@ -283,7 +283,7 @@ private void validateTimeSeriesExistence(ConfigNodeProcedureEnv env) { env, relatedSchemaRegionGroup, false, - DataNodeRequestType.CHECK_TIMESERIES_EXISTENCE, + ConfigNodeToDataNodeRequestType.CHECK_TIMESERIES_EXISTENCE, ((dataNodeLocation, consensusGroupIdList) -> new TCheckTimeSeriesExistenceReq(patternTreeBytes, consensusGroupIdList))) { @@ -386,8 +386,8 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { @@ -492,8 +492,10 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + invalidateTemplateSetInfoReq, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index a90c4b1c0051..c0c0df562b24 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -26,8 +26,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.DataNodeRequestType; -import org.apache.iotdb.confignode.client.async.AsyncDataNodeInternalServiceRequestManager; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; @@ -157,8 +157,10 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure invalidateTemplateSetInfoReq.setTemplateInfo(getInvalidateTemplateSetInfo()); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + invalidateTemplateSetInfoReq, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -253,8 +255,10 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) rollbackTemplateSetInfoReq.setTemplateInfo(getAddTemplateSetInfo()); AsyncDataNodeRequestContext clientHandler = new AsyncDataNodeRequestContext<>( - DataNodeRequestType.UPDATE_TEMPLATE, rollbackTemplateSetInfoReq, dataNodeLocationMap); - AsyncDataNodeInternalServiceRequestManager.getInstance() + ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + rollbackTemplateSetInfoReq, + dataNodeLocationMap); + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java index b3f10181c201..0dad4438c9bf 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java @@ -25,7 +25,7 @@ import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.exception.IoTDBException; import org.apache.iotdb.commons.utils.ThriftCommonsSerDeUtils; -import org.apache.iotdb.confignode.client.DataNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; import org.apache.iotdb.confignode.consensus.request.auth.AuthorPlan; @@ -111,7 +111,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, AuthOperationProcedu .sendSyncRequestToDataNodeWithRetry( pair.getLeft().getLocation().getInternalEndPoint(), req, - DataNodeRequestType.INVALIDATE_PERMISSION_CACHE); + ConfigNodeToDataNodeRequestType.INVALIDATE_PERMISSION_CACHE); if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { it.remove(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java index df95895658f8..9dc4376466bc 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java @@ -37,7 +37,7 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.service.metric.cpu.CpuUsageMetrics; import org.apache.iotdb.commons.utils.TestOnly; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeConstant; @@ -338,7 +338,7 @@ private void sendRegisterConfigNodeRequest() throws StartupException, IOExceptio Object obj = SyncConfigNodeClientPool.getInstance() .sendSyncRequestToConfigNodeWithRetry( - seedConfigNode, req, ConfigNodeRequestType.REGISTER_CONFIG_NODE); + seedConfigNode, req, ConfigNodeToConfigNodeRequestType.REGISTER_CONFIG_NODE); if (obj instanceof TConfigNodeRegisterResp) { resp = (TConfigNodeRegisterResp) obj; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeShutdownHook.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeShutdownHook.java index 369c6c96af84..4c0cc21a905f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeShutdownHook.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeShutdownHook.java @@ -24,7 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.commons.conf.CommonDescriptor; -import org.apache.iotdb.confignode.client.ConfigNodeRequestType; +import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeConstant; @@ -71,7 +71,7 @@ public void run() { CONF.getConfigNodeId(), new TEndPoint(CONF.getInternalAddress(), CONF.getInternalPort()), new TEndPoint(CONF.getInternalAddress(), CONF.getConsensusPort())), - ConfigNodeRequestType.REPORT_CONFIG_NODE_SHUTDOWN); + ConfigNodeToConfigNodeRequestType.REPORT_CONFIG_NODE_SHUTDOWN); if (result.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { // Report success diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java deleted file mode 100644 index 1863c775fb38..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeInternalServiceRequestManager.java +++ /dev/null @@ -1,101 +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.iotdb.db.protocol.client.cn; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.commons.client.ClientPoolFactory; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestManager; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ -public class AsyncConfigNodeInternalServiceRequestManager - extends AsyncRequestManager< - DataNodeToConfigNodeRequestType, - TConfigNodeLocation, - AsyncConfigNodeInternalServiceClient> { - private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncConfigNodeInternalServiceRequestManager.class); - - @Override - protected void initClientManager() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); - } - - @Override - protected TEndPoint nodeLocationToEndPoint(TConfigNodeLocation configNodeLocation) { - return configNodeLocation.getInternalEndPoint(); - } - - @Override - protected void sendAsyncRequestToNode( - AsyncRequestContext - requestContext, - int requestId, - TConfigNodeLocation targetNode, - int retryCount) { - try { - AsyncConfigNodeInternalServiceClient client; - client = clientManager.borrowClient(targetNode.getInternalEndPoint()); - Object req = requestContext.getRequest(requestId); - AsyncConfigNodeRequestRPCHandler handler = - AsyncConfigNodeRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); - AsyncConfigNodeTSStatusRPCHandler defaultHandler = - (AsyncConfigNodeTSStatusRPCHandler) handler; - - switch (requestContext.getRequestType()) { - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected ConfigNode Request Type: {} when sendAsyncRequestToConfigNode", - requestContext.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on ConfigNode {}, because {}, retrying {}...", - requestContext.getRequestType(), - targetNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } - } - - private static class ClientPoolHolder { - private static final AsyncConfigNodeInternalServiceRequestManager INSTANCE = - new AsyncConfigNodeInternalServiceRequestManager(); - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncConfigNodeInternalServiceRequestManager getInstance() { - return ClientPoolHolder.INSTANCE; - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java new file mode 100644 index 000000000000..c1c110a49871 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java @@ -0,0 +1,67 @@ +/* + * 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.db.protocol.client.cn; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.gg.ConfigNodeInternalServiceAsyncRequestManager; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ +public class DataNodeToConfigNodeInternalServiceAsyncRequestManager + extends ConfigNodeInternalServiceAsyncRequestManager { + + private static final Logger LOGGER = + LoggerFactory.getLogger(DataNodeToConfigNodeInternalServiceAsyncRequestManager.class); + + @Override + protected void initActionMapBuilder() { + actionMapBuilder.put( + DataNodeToConfigNodeRequestType.TEST_CONNECTION, + (req, client, handler) -> + client.testConnection((AsyncConfigNodeTSStatusRPCHandler) handler)); + } + + @Override + protected AsyncRequestRPCHandler + buildHandler( + AsyncRequestContext + requestContext, + int requestId, + TConfigNodeLocation targetNode) { + return AsyncConfigNodeRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); + } + + private static class ClientPoolHolder { + private static final DataNodeToConfigNodeInternalServiceAsyncRequestManager INSTANCE = + new DataNodeToConfigNodeInternalServiceAsyncRequestManager(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static DataNodeToConfigNodeInternalServiceAsyncRequestManager getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceRequestManager.java deleted file mode 100644 index 4bd325003549..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeInternalServiceRequestManager.java +++ /dev/null @@ -1,100 +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.iotdb.db.protocol.client.dn; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.commons.client.ClientPoolFactory; -import org.apache.iotdb.commons.client.IClientManager; -import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestManager; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AsyncDataNodeInternalServiceRequestManager - extends AsyncRequestManager< - DataNodeToDataNodeRequestType, TDataNodeLocation, AsyncDataNodeInternalServiceClient> { - private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeInternalServiceRequestManager.class); - - public AsyncDataNodeInternalServiceRequestManager() { - super(); - } - - @Override - protected void initClientManager() { - clientManager = - new IClientManager.Factory() - .createClientManager( - new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); - } - - @Override - protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { - return dataNodeLocation.getInternalEndPoint(); - } - - @Override - protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, - int requestId, - TDataNodeLocation targetNode, - int retryCount) { - try { - AsyncDataNodeInternalServiceClient client; - client = clientManager.borrowClient(targetNode.getInternalEndPoint()); - Object req = requestContext.getRequest(requestId); - AsyncDataNodeRPCHandler handler = - AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); - AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; - switch (requestContext.getRequestType()) { - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - throw new UnsupportedOperationException( - "unsupported request type: " + requestContext.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - requestContext.getRequestType(), - targetNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } - } - - private static class ClientPoolHolder { - - private static final AsyncDataNodeInternalServiceRequestManager INSTANCE = - new AsyncDataNodeInternalServiceRequestManager(); - - private ClientPoolHolder() { - // Empty constructor - } - } - - public static AsyncDataNodeInternalServiceRequestManager getInstance() { - return ClientPoolHolder.INSTANCE; - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java similarity index 56% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceRequestManager.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java index f1e0c2db5f24..a7c82bd237ce 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeExternalServiceRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java @@ -26,20 +26,17 @@ import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestManager; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AsyncDataNodeExternalServiceRequestManager +public class DataNodeExternalServiceAsyncRequestManager extends AsyncRequestManager< DataNodeToDataNodeRequestType, TDataNodeLocation, AsyncDataNodeExternalServiceClient> { private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeExternalServiceRequestManager.class); - - public AsyncDataNodeExternalServiceRequestManager() { - super(); - } + LoggerFactory.getLogger(DataNodeExternalServiceAsyncRequestManager.class); @Override protected void initClientManager() { @@ -49,55 +46,39 @@ protected void initClientManager() { new ClientPoolFactory.AsyncDataNodeExternalServiceClientPoolFactory()); } + @Override + protected void initActionMapBuilder() { + actionMapBuilder.put( + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (req, client, handler) -> client.testConnection((AsyncTSStatusRPCHandler) handler)); + } + @Override protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { return dataNodeLocation.getClientRpcEndPoint(); } @Override - protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, - int requestId, - TDataNodeLocation targetNode, - int retryCount) { - try { - AsyncDataNodeExternalServiceClient client = - clientManager.borrowClient(targetNode.getClientRpcEndPoint()); - Object req = requestContext.getRequest(requestId); - AsyncDataNodeRPCHandler handler = - AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); - AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; - - switch (requestContext.getRequestType()) { - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - LOGGER.error( - "Unexpected DataNode Request Type: {} when sendAsyncRequestToDataNode", - requestContext.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - requestContext.getRequestType(), - targetNode.getClientRpcEndPoint(), - e.getMessage(), - retryCount); - } + protected AsyncRequestRPCHandler + buildHandler( + AsyncRequestContext + requestContext, + int requestId, + TDataNodeLocation targetNode) { + return AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); } private static class ClientPoolHolder { - private static final AsyncDataNodeExternalServiceRequestManager INSTANCE = - new AsyncDataNodeExternalServiceRequestManager(); + private static final DataNodeExternalServiceAsyncRequestManager INSTANCE = + new DataNodeExternalServiceAsyncRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static AsyncDataNodeExternalServiceRequestManager getInstance() { - return AsyncDataNodeExternalServiceRequestManager.ClientPoolHolder.INSTANCE; + public static DataNodeExternalServiceAsyncRequestManager getInstance() { + return DataNodeExternalServiceAsyncRequestManager.ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java similarity index 56% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceRequestManager.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java index 80b76f575a00..3e1407fbc668 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeMPPServiceRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java @@ -26,21 +26,20 @@ import org.apache.iotdb.commons.client.async.AsyncDataNodeMPPDataExchangeServiceClient; import org.apache.iotdb.commons.client.gg.AsyncRequestContext; import org.apache.iotdb.commons.client.gg.AsyncRequestManager; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.apache.iotdb.db.protocol.client.dn.DataNodeToDataNodeRequestType.TEST_CONNECTION; - -public class AsyncDataNodeMPPServiceRequestManager +public class DataNodeMPPServiceAsyncRequestManager extends AsyncRequestManager< DataNodeToDataNodeRequestType, TDataNodeLocation, AsyncDataNodeMPPDataExchangeServiceClient> { private static final Logger LOGGER = - LoggerFactory.getLogger(AsyncDataNodeMPPServiceRequestManager.class); + LoggerFactory.getLogger(DataNodeMPPServiceAsyncRequestManager.class); - public AsyncDataNodeMPPServiceRequestManager() {} + public DataNodeMPPServiceAsyncRequestManager() {} @Override protected void initClientManager() { @@ -50,54 +49,39 @@ protected void initClientManager() { new ClientPoolFactory.AsyncDataNodeMPPDataExchangeServiceClientPoolFactory()); } + @Override + protected void initActionMapBuilder() { + actionMapBuilder.put( + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (req, client, handler) -> client.testConnection((AsyncTSStatusRPCHandler) handler)); + } + @Override protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { return null; } @Override - protected void sendAsyncRequestToNode( - AsyncRequestContext requestContext, - int requestId, - TDataNodeLocation targetNode, - int retryCount) { - try { - AsyncDataNodeMPPDataExchangeServiceClient client; - client = clientManager.borrowClient(targetNode.getInternalEndPoint()); - Object req = requestContext.getRequest(requestId); - AsyncDataNodeRPCHandler handler = - AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); - AsyncTSStatusRPCHandler defaultHandler = (AsyncTSStatusRPCHandler) handler; - - switch (requestContext.getRequestType()) { - case TEST_CONNECTION: - client.testConnection(defaultHandler); - break; - default: - throw new UnsupportedOperationException( - "unsupported request type: " + requestContext.getRequestType()); - } - } catch (Exception e) { - LOGGER.warn( - "{} failed on DataNode {}, because {}, retrying {}...", - requestContext.getRequestType(), - targetNode.getInternalEndPoint(), - e.getMessage(), - retryCount); - } + protected AsyncRequestRPCHandler + buildHandler( + AsyncRequestContext + requestContext, + int requestId, + TDataNodeLocation targetNode) { + return AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); } private static class ClientPoolHolder { - private static final AsyncDataNodeMPPServiceRequestManager INSTANCE = - new AsyncDataNodeMPPServiceRequestManager(); + private static final DataNodeMPPServiceAsyncRequestManager INSTANCE = + new DataNodeMPPServiceAsyncRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static AsyncDataNodeMPPServiceRequestManager getInstance() { + public static DataNodeMPPServiceAsyncRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java new file mode 100644 index 000000000000..83dc27460d80 --- /dev/null +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java @@ -0,0 +1,69 @@ +/* + * 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.db.protocol.client.dn; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.gg.DataNodeInternalServiceRequestManager; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DataNodeToDataNodeInternalServiceAsyncRequestManager + extends DataNodeInternalServiceRequestManager { + private static final Logger LOGGER = + LoggerFactory.getLogger(DataNodeToDataNodeInternalServiceAsyncRequestManager.class); + + public DataNodeToDataNodeInternalServiceAsyncRequestManager() { + super(); + } + + @Override + protected void initActionMapBuilder() { + actionMapBuilder.put( + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (req, client, handler) -> client.testConnection((AsyncTSStatusRPCHandler) handler)); + } + + @Override + protected AsyncRequestRPCHandler + buildHandler( + AsyncRequestContext + requestContext, + int requestId, + TDataNodeLocation targetNode) { + return AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); + } + + private static class ClientPoolHolder { + + private static final DataNodeToDataNodeInternalServiceAsyncRequestManager INSTANCE = + new DataNodeToDataNodeInternalServiceAsyncRequestManager(); + + private ClientPoolHolder() { + // Empty constructor + } + } + + public static DataNodeToDataNodeInternalServiceAsyncRequestManager getInstance() { + return ClientPoolHolder.INSTANCE; + } +} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 8a7b1deba7d4..07872825c0e5 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -74,13 +74,11 @@ import org.apache.iotdb.db.exception.StorageEngineException; import org.apache.iotdb.db.pipe.agent.PipeAgent; import org.apache.iotdb.db.protocol.client.ConfigNodeInfo; -import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeInternalServiceRequestManager; -import org.apache.iotdb.db.protocol.client.cn.AsyncConfigNodeRequestContext; +import org.apache.iotdb.db.protocol.client.cn.DataNodeToConfigNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.db.protocol.client.cn.DataNodeToConfigNodeRequestType; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeExternalServiceRequestManager; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeInternalServiceRequestManager; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeMPPServiceRequestManager; -import org.apache.iotdb.db.protocol.client.dn.AsyncDataNodeRequestContext; +import org.apache.iotdb.db.protocol.client.dn.DataNodeExternalServiceAsyncRequestManager; +import org.apache.iotdb.db.protocol.client.dn.DataNodeMPPServiceAsyncRequestManager; +import org.apache.iotdb.db.protocol.client.dn.DataNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.db.protocol.client.dn.DataNodeToDataNodeRequestType; import org.apache.iotdb.db.protocol.session.IClientSession; import org.apache.iotdb.db.protocol.session.InternalClientSession; @@ -1443,100 +1441,99 @@ public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations return new TTestConnectionResp(configNodeResult); } - private List testAllConnections( - List nodeLocations, - Function getId, - Function getEndPoint, - TServiceType serviceType, - RequestType requestType, - Consumer> sendRequest - ) { + private List testAllConnections( + List nodeLocations, + Function getId, + Function getEndPoint, + TServiceType serviceType, + RequestType requestType, + Consumer> sendRequest) { final TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); Map nodeLocationMap = - nodeLocations.stream() - .collect(Collectors.toMap(getId, location -> location)); - AsyncRequestContext requestContext = - new AsyncRequestContext<>( - requestType, new Object(), nodeLocationMap); + nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); + AsyncRequestContext requestContext = + new AsyncRequestContext<>(requestType, new Object(), nodeLocationMap); sendRequest.accept(requestContext); Map anotherNodeLocationMap = - nodeLocations.stream() - .collect(Collectors.toMap(getId, location -> location)); + nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); List results = new ArrayList<>(); requestContext - .getResponseMap() - .forEach( - (nodeId, status) -> { - TEndPoint endPoint = getEndPoint.apply(anotherNodeLocationMap.get(nodeId)); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, serviceType); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); + .getResponseMap() + .forEach( + (nodeId, status) -> { + TEndPoint endPoint = getEndPoint.apply(anotherNodeLocationMap.get(nodeId)); + TServiceProvider serviceProvider = new TServiceProvider(endPoint, serviceType); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); return results; } private List testAllConfigNodeConnection( - List configNodeLocations) { + List configNodeLocations) { return testAllConnections( - configNodeLocations, - TConfigNodeLocation::getConfigNodeId, - TConfigNodeLocation::getInternalEndPoint, - TServiceType.ConfigNodeInternalService, - DataNodeToConfigNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext handler) -> AsyncConfigNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(handler) - ); + configNodeLocations, + TConfigNodeLocation::getConfigNodeId, + TConfigNodeLocation::getInternalEndPoint, + TServiceType.ConfigNodeInternalService, + DataNodeToConfigNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext + handler) -> + DataNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(handler)); } private List testAllDataNodeInternalServiceConnection( - List dataNodeLocations) { + List dataNodeLocations) { return testAllConnections( - dataNodeLocations, - TDataNodeLocation::getDataNodeId, - TDataNodeLocation::getInternalEndPoint, - TServiceType.DataNodeInternalService, - DataNodeToDataNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext handler) -> AsyncDataNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(handler) - ); + dataNodeLocations, + TDataNodeLocation::getDataNodeId, + TDataNodeLocation::getInternalEndPoint, + TServiceType.DataNodeInternalService, + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext + handler) -> + DataNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(handler)); } private List testAllDataNodeMPPServiceConnection( - List dataNodeLocations) { + List dataNodeLocations) { return testAllConnections( - dataNodeLocations, - TDataNodeLocation::getDataNodeId, - TDataNodeLocation::getMPPDataExchangeEndPoint, - TServiceType.DataNodeMPPService, - DataNodeToDataNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext handler) -> AsyncDataNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(handler) - ); + dataNodeLocations, + TDataNodeLocation::getDataNodeId, + TDataNodeLocation::getMPPDataExchangeEndPoint, + TServiceType.DataNodeMPPService, + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext + handler) -> + DataNodeMPPServiceAsyncRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(handler)); } private List testAllDataNodeExternalServiceConnection( - List dataNodeLocations) { + List dataNodeLocations) { return testAllConnections( - dataNodeLocations, - TDataNodeLocation::getDataNodeId, - TDataNodeLocation::getClientRpcEndPoint, - TServiceType.DataNodeExternalService, - DataNodeToDataNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext handler) -> AsyncDataNodeInternalServiceRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(handler) - ); + dataNodeLocations, + TDataNodeLocation::getDataNodeId, + TDataNodeLocation::getClientRpcEndPoint, + TServiceType.DataNodeExternalService, + DataNodeToDataNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext + handler) -> + DataNodeExternalServiceAsyncRequestManager.getInstance() + .sendAsyncRequestToNodeWithRetry(handler)); } @Override diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java index 3ac1fa84bea1..d144ab29c158 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java @@ -22,10 +22,14 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.exception.ClientManagerException; +import org.apache.iotdb.commons.utils.function.CheckedTriConsumer; +import com.google.common.collect.ImmutableMap; +import org.apache.thrift.TException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Objects; import java.util.concurrent.TimeUnit; /** Asynchronously send RPC requests to Nodes. See queryengine.thrift for more details. */ @@ -35,14 +39,30 @@ public abstract class AsyncRequestManager { protected IClientManager clientManager; + protected ImmutableMap< + RequestType, + CheckedTriConsumer< + Object, Client, AsyncRequestRPCHandler, TException>> + actionMap; + + protected ImmutableMap.Builder< + RequestType, + CheckedTriConsumer< + Object, Client, AsyncRequestRPCHandler, TException>> + actionMapBuilder; + private static final int MAX_RETRY_NUM = 6; protected AsyncRequestManager() { initClientManager(); + initActionMapBuilder(); + this.actionMap = this.actionMapBuilder.build(); } protected abstract void initClientManager(); + protected abstract void initActionMapBuilder(); + /** * Send asynchronous requests to the specified Nodes with default retry num * @@ -123,13 +143,38 @@ private final void sendAsyncRequest( } } + protected void sendAsyncRequestToNode( + AsyncRequestContext requestContext, + int requestId, + NodeLocation targetNode, + int retryCount) { + try { + if (!actionMap.containsKey(requestContext.getRequestType())) { + throw new UnsupportedOperationException( + "unsupported request type: " + requestContext.getRequestType()); + } + Client client = clientManager.borrowClient(nodeLocationToEndPoint(targetNode)); + Object req = requestContext.getRequest(requestId); + AsyncRequestRPCHandler handler = + buildHandler(requestContext, requestId, targetNode); + Objects.requireNonNull(actionMap.get(requestContext.getRequestType())) + .accept(req, client, handler); + } catch (Exception e) { + LOGGER.warn( + "{} failed on Node {}, because {}, retrying {}...", + requestContext.getRequestType(), + nodeLocationToEndPoint(targetNode), + e.getMessage(), + retryCount); + } + } + protected abstract TEndPoint nodeLocationToEndPoint(NodeLocation location); - protected abstract void sendAsyncRequestToNode( + protected abstract AsyncRequestRPCHandler buildHandler( AsyncRequestContext requestContext, int requestId, - NodeLocation targetNode, - int retryCount); + NodeLocation targetNode); /** * Always call this interface when a Node is restarted or removed. diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/ConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/ConfigNodeInternalServiceAsyncRequestManager.java new file mode 100644 index 000000000000..659d8b7f2d0c --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/ConfigNodeInternalServiceAsyncRequestManager.java @@ -0,0 +1,43 @@ +/* + * 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.commons.client.gg; + +import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncConfigNodeInternalServiceClient; + +public abstract class ConfigNodeInternalServiceAsyncRequestManager + extends AsyncRequestManager< + RequestType, TConfigNodeLocation, AsyncConfigNodeInternalServiceClient> { + @Override + protected void initClientManager() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncConfigNodeInternalServiceClientPoolFactory()); + } + + @Override + protected TEndPoint nodeLocationToEndPoint(TConfigNodeLocation configNodeLocation) { + return configNodeLocation.getInternalEndPoint(); + } +} diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/DataNodeInternalServiceRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/DataNodeInternalServiceRequestManager.java new file mode 100644 index 000000000000..cc7bfec572b6 --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/DataNodeInternalServiceRequestManager.java @@ -0,0 +1,43 @@ +/* + * 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.commons.client.gg; + +import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.commons.client.ClientPoolFactory; +import org.apache.iotdb.commons.client.IClientManager; +import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; + +public abstract class DataNodeInternalServiceRequestManager + extends AsyncRequestManager< + RequestType, TDataNodeLocation, AsyncDataNodeInternalServiceClient> { + @Override + protected void initClientManager() { + clientManager = + new IClientManager.Factory() + .createClientManager( + new ClientPoolFactory.AsyncDataNodeInternalServiceClientPoolFactory()); + } + + @Override + protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { + return dataNodeLocation.getInternalEndPoint(); + } +} diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/function/CheckedTriConsumer.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/function/CheckedTriConsumer.java new file mode 100644 index 000000000000..bb9a5ebaaab1 --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/function/CheckedTriConsumer.java @@ -0,0 +1,25 @@ +/* + * 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.commons.utils.function; + +@FunctionalInterface +public interface CheckedTriConsumer { + void accept(INPUT1 var1, INPUT2 var2, INPUT3 var3) throws THROWABLE; +} From 8a06f109b5da563bd1b13da61ee339ecf5416dd8 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 11:12:26 +0800 Subject: [PATCH 30/52] rename gg to request --- ...ToConfigNodeInternalServiceAsyncRequestManager.java | 6 +++--- ...deToDataNodeInternalServiceAsyncRequestManager.java | 6 +++--- .../async/handlers/AsyncConfigNodeRequestContext.java | 2 +- .../async/handlers/AsyncDataNodeRequestContext.java | 2 +- .../handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java | 4 ++-- .../handlers/rpc/DataNodeAsyncRequestRPCHandler.java | 4 ++-- .../client/cn/AsyncConfigNodeRequestContext.java | 2 +- .../client/cn/AsyncConfigNodeRequestRPCHandler.java | 4 ++-- ...ToConfigNodeInternalServiceAsyncRequestManager.java | 6 +++--- .../db/protocol/client/dn/AsyncDataNodeRPCHandler.java | 4 ++-- .../client/dn/AsyncDataNodeRequestContext.java | 2 +- .../dn/DataNodeExternalServiceAsyncRequestManager.java | 6 +++--- .../dn/DataNodeMPPServiceAsyncRequestManager.java | 6 +++--- ...deToDataNodeInternalServiceAsyncRequestManager.java | 10 +++------- .../thrift/impl/DataNodeInternalRPCServiceImpl.java | 2 +- .../client/{gg => request}/AsyncRequestContext.java | 2 +- .../client/{gg => request}/AsyncRequestManager.java | 2 +- .../client/{gg => request}/AsyncRequestRPCHandler.java | 2 +- .../ConfigNodeInternalServiceAsyncRequestManager.java | 2 +- .../DataNodeInternalServiceRequestManager.java | 2 +- 20 files changed, 36 insertions(+), 40 deletions(-) rename iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/{gg => request}/AsyncRequestContext.java (98%) rename iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/{gg => request}/AsyncRequestManager.java (99%) rename iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/{gg => request}/AsyncRequestRPCHandler.java (98%) rename iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/{gg => request}/ConfigNodeInternalServiceAsyncRequestManager.java (97%) rename iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/{gg => request}/DataNodeInternalServiceRequestManager.java (97%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java index bb95ddb281aa..2881ea94aadc 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java @@ -21,9 +21,9 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TNodeLocations; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; -import org.apache.iotdb.commons.client.gg.ConfigNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.ConfigNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAsyncRequestRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeTSStatusRPCHandler; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java index 2250640086ff..32989102b58c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java @@ -26,9 +26,9 @@ import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; -import org.apache.iotdb.commons.client.gg.DataNodeInternalServiceRequestManager; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.DataNodeInternalServiceRequestManager; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java index f79e3eb9338b..7e3353768b03 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import java.util.Map; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java index 5abf76dc80f3..68ffd3723419 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import java.util.Map; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java index b9c40d217d04..e3457d2e8235 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java @@ -22,8 +22,8 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import java.util.Map; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java index 7e056ae1b8e6..c286253c9247 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java @@ -22,8 +22,8 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java index f36adf1a70ab..3eb5daabe556 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java @@ -20,7 +20,7 @@ package org.apache.iotdb.db.protocol.client.cn; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; import java.util.Map; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java index bc49a73420f6..ed6283ddcd91 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java @@ -21,8 +21,8 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; import java.util.Map; import java.util.concurrent.CountDownLatch; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java index c1c110a49871..df78328849d7 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java @@ -20,9 +20,9 @@ package org.apache.iotdb.db.protocol.client.cn; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; -import org.apache.iotdb.commons.client.gg.ConfigNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.ConfigNodeInternalServiceAsyncRequestManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java index 40a7fc26777f..7026a5df06ec 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java @@ -21,8 +21,8 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java index 4e3c75d6d7d2..982bba3c2d74 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java @@ -20,7 +20,7 @@ package org.apache.iotdb.db.protocol.client.dn; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; import java.util.Map; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java index a7c82bd237ce..a706d0e6a189 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java @@ -24,9 +24,9 @@ import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeExternalServiceClient; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestManager; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestManager; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java index 3e1407fbc668..fd8cda7b0e7a 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java @@ -24,9 +24,9 @@ import org.apache.iotdb.commons.client.ClientPoolFactory; import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.async.AsyncDataNodeMPPDataExchangeServiceClient; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestManager; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestManager; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java index 83dc27460d80..6eacce3b51d7 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java @@ -20,9 +20,9 @@ package org.apache.iotdb.db.protocol.client.dn; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; -import org.apache.iotdb.commons.client.gg.AsyncRequestRPCHandler; -import org.apache.iotdb.commons.client.gg.DataNodeInternalServiceRequestManager; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; +import org.apache.iotdb.commons.client.request.DataNodeInternalServiceRequestManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,10 +32,6 @@ public class DataNodeToDataNodeInternalServiceAsyncRequestManager private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeToDataNodeInternalServiceAsyncRequestManager.class); - public DataNodeToDataNodeInternalServiceAsyncRequestManager() { - super(); - } - @Override protected void initActionMapBuilder() { actionMapBuilder.put( diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 07872825c0e5..820dbb827daf 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -35,7 +35,7 @@ import org.apache.iotdb.common.rpc.thrift.TSettleReq; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; -import org.apache.iotdb.commons.client.gg.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.commons.conf.CommonConfig; import org.apache.iotdb.commons.conf.CommonDescriptor; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestContext.java similarity index 98% rename from iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestContext.java index 2d8fd5eeb697..8e138dd45e59 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestContext.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestContext.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.iotdb.commons.client.gg; +package org.apache.iotdb.commons.client.request; import java.util.ArrayList; import java.util.List; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java similarity index 99% rename from iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java index d144ab29c158..6ea1ae6302ce 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.iotdb.commons.client.gg; +package org.apache.iotdb.commons.client.request; import org.apache.iotdb.common.rpc.thrift.TEndPoint; import org.apache.iotdb.commons.client.IClientManager; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestRPCHandler.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestRPCHandler.java similarity index 98% rename from iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestRPCHandler.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestRPCHandler.java index f369905d8857..136f4e126f22 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/AsyncRequestRPCHandler.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestRPCHandler.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.iotdb.commons.client.gg; +package org.apache.iotdb.commons.client.request; import org.apache.thrift.async.AsyncMethodCallback; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/ConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/ConfigNodeInternalServiceAsyncRequestManager.java similarity index 97% rename from iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/ConfigNodeInternalServiceAsyncRequestManager.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/ConfigNodeInternalServiceAsyncRequestManager.java index 659d8b7f2d0c..791a1e5df0e9 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/ConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/ConfigNodeInternalServiceAsyncRequestManager.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.iotdb.commons.client.gg; +package org.apache.iotdb.commons.client.request; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/DataNodeInternalServiceRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/DataNodeInternalServiceRequestManager.java similarity index 97% rename from iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/DataNodeInternalServiceRequestManager.java rename to iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/DataNodeInternalServiceRequestManager.java index cc7bfec572b6..fcb1b01857df 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/gg/DataNodeInternalServiceRequestManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/DataNodeInternalServiceRequestManager.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.iotdb.commons.client.gg; +package org.apache.iotdb.commons.client.request; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; From 9bc5f37c17065b366a2257ae3ff5128308c31453 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 11:14:39 +0800 Subject: [PATCH 31/52] remove comments --- ...ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java | 1 - .../DataNodeToConfigNodeInternalServiceAsyncRequestManager.java | 1 - 2 files changed, 2 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java index 2881ea94aadc..5f8569e43835 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java @@ -32,7 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ public class ConfigNodeToConfigNodeInternalServiceAsyncRequestManager extends ConfigNodeInternalServiceAsyncRequestManager { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java index df78328849d7..bc859fc054cc 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java @@ -27,7 +27,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Asynchronously send RPC requests to ConfigNodes. See queryengine.thrift for more details. */ public class DataNodeToConfigNodeInternalServiceAsyncRequestManager extends ConfigNodeInternalServiceAsyncRequestManager { From c2b76e343c704584c3f9f09de9c220feb1e7457a Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 12:17:46 +0800 Subject: [PATCH 32/52] rename function --- .../confignode/manager/ClusterManager.java | 8 +++---- .../manager/ClusterQuotaManager.java | 4 ++-- .../confignode/manager/TriggerManager.java | 2 +- .../iotdb/confignode/manager/UDFManager.java | 4 ++-- .../manager/load/balancer/RouteBalancer.java | 4 ++-- .../confignode/manager/node/NodeManager.java | 18 +++++++-------- .../manager/partition/PartitionManager.java | 6 ++--- .../manager/schema/ClusterSchemaManager.java | 2 +- .../procedure/env/ConfigNodeProcedureEnv.java | 22 +++++++++---------- .../procedure/env/RegionMaintainHandler.java | 2 +- .../schema/AlterLogicalViewProcedure.java | 2 +- .../schema/DataNodeRegionTaskExecutor.java | 2 +- .../schema/DeactivateTemplateProcedure.java | 2 +- .../impl/schema/DeleteDatabaseProcedure.java | 2 +- .../schema/DeleteLogicalViewProcedure.java | 2 +- .../schema/DeleteTimeSeriesProcedure.java | 2 +- .../impl/schema/SetTTLProcedure.java | 2 +- .../impl/schema/SetTemplateProcedure.java | 6 ++--- .../impl/schema/UnsetTemplateProcedure.java | 4 ++-- .../impl/DataNodeInternalRPCServiceImpl.java | 8 +++---- .../client/request/AsyncRequestManager.java | 16 +++++++------- 21 files changed, 60 insertions(+), 60 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 31c67c568ce5..2edfa6156641 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -122,7 +122,7 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { nodeLocations, configNodeLocationMap); ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNode(configNodeClientHandler); + .sendAsyncRequest(configNodeClientHandler); Map anotherConfigNodeLocationMap = configManager.getNodeManager().getRegisteredConfigNodes().stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); @@ -149,7 +149,7 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { nodeLocations, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNode(dataNodeClientHandler); + .sendAsyncRequest(dataNodeClientHandler); Map anotherDataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodes().stream() .map(TDataNodeConfiguration::getLocation) @@ -193,7 +193,7 @@ private List testAllConfigNodeConnection( new AsyncConfigNodeRequestContext<>( ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(requestContext); + .sendAsyncRequestWithRetry(requestContext); Map anotherConfigNodeLocationMap = configNodeLocations.stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); @@ -230,7 +230,7 @@ private List testAllDataNodeConnection( new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(requestContext); + .sendAsyncRequestWithRetry(requestContext); Map anotherDataNodeLocationMap = dataNodeLocations.stream() .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java index 50a65a0e6b43..16946796a395 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java @@ -91,7 +91,7 @@ public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } return response; @@ -198,7 +198,7 @@ public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } return response; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index aa25adde4036..44734a1438a9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -252,7 +252,7 @@ public List updateTriggerLocation( new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index d2e5d9afa816..5ca5d3460466 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -131,7 +131,7 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -166,7 +166,7 @@ private List dropFunctionOnDataNodes(String functionName) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index e12722aedd16..9dcf3817aaa1 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -226,7 +226,7 @@ private void balanceRegionLeader( if (requestId.get() > 0) { // Don't retry ChangeLeader request ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNode(clientHandler); + .sendAsyncRequest(clientHandler); for (int i = 0; i < requestId.get(); i++) { if (clientHandler.getResponseMap().get(i).getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -314,7 +314,7 @@ private void broadcastLatestRegionPriorityMap() { new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); } private void recordRegionPriorityMap( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index 87c707896ddd..5103c39edbbc 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -709,7 +709,7 @@ public List merge() { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.MERGE, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -720,7 +720,7 @@ public List flush(TFlushReq req) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.FLUSH, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -731,7 +731,7 @@ public List clearCache() { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -753,7 +753,7 @@ public List setConfiguration(TSetConfigurationReq req) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.SET_CONFIGURATION, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); responseList.addAll(clientHandler.getResponseList()); } @@ -792,7 +792,7 @@ public List startRpairData() { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -803,7 +803,7 @@ public List stopRepairData() { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -814,7 +814,7 @@ public List loadConfiguration() { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -858,7 +858,7 @@ public List setSystemStatus(String status) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -893,7 +893,7 @@ private TSStatus killAllQueries() { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index a4a2da227514..1b4adb3ecf5a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -1277,7 +1277,7 @@ public void maintainRegionReplicas() { } ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(createSchemaRegionHandler); + .sendAsyncRequestWithRetry(createSchemaRegionHandler); for (Map.Entry entry : createSchemaRegionHandler.getResponseMap().entrySet()) { @@ -1313,7 +1313,7 @@ public void maintainRegionReplicas() { } ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(createDataRegionHandler); + .sendAsyncRequestWithRetry(createDataRegionHandler); for (Map.Entry entry : createDataRegionHandler.getResponseMap().entrySet()) { @@ -1350,7 +1350,7 @@ public void maintainRegionReplicas() { long startTime = System.currentTimeMillis(); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(deleteRegionHandler); + .sendAsyncRequestWithRetry(deleteRegionHandler); LOGGER.info( "Deleting regions costs {}ms", (System.currentTimeMillis() - startTime)); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index bc667bcd7f24..8d3c21c12733 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -1045,7 +1045,7 @@ public synchronized TSStatus extendSchemaTemplate( updateTemplateReq, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index 8c4dc611b8be..d9dc3dd6c737 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -446,7 +446,7 @@ public Map doRegionCreation( // Send CreateRegion requests to DataNodes ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); // Filter RegionGroups that weren't created successfully int requestId = 0; @@ -593,7 +593,7 @@ public List createTriggerOnDataNodes( new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -608,7 +608,7 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -622,7 +622,7 @@ public List activeTriggerOnDataNodes(String triggerName) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -638,7 +638,7 @@ public List inactiveTriggerOnDataNodes(String triggerName) { request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -653,7 +653,7 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -668,7 +668,7 @@ public List dropPipePluginOnDataNodes( new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -777,7 +777,7 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) .collect(Collectors.toList()); @@ -793,7 +793,7 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) .collect(Collectors.toList()); @@ -865,7 +865,7 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) .collect(Collectors.toList()); @@ -884,7 +884,7 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) .collect(Collectors.toList()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index 98ae7ac035ba..21b65d02c65d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -373,7 +373,7 @@ public Map resetPeerList( new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseMap(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index f673cc3e982e..e1edc23678ce 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -126,7 +126,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java index fe37d09ff56b..38ddb20fc1dc 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java @@ -89,7 +89,7 @@ void execute() { AsyncDataNodeRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map> currentFailedDataNodeMap = checkDataNodeExecutionResult(clientHandler.getResponseMap(), dataNodeConsensusGroupIdMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java index bf3f22056d5c..2c119914e3eb 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java @@ -204,7 +204,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { new TInvalidateMatchedSchemaCacheReq(timeSeriesPatternTreeBytes), dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schema cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java index 966d736d684e..62d8cd1f458e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java @@ -172,7 +172,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt } if (!schemaRegionDeleteTaskMap.isEmpty()) { ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(asyncClientHandler); + .sendAsyncRequestWithRetry(asyncClientHandler); for (Map.Entry entry : asyncClientHandler.getResponseMap().entrySet()) { if (entry.getValue().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index 6249efeb9258..7b7ad5e888f8 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -190,7 +190,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index 0c5998265585..5ca8a89309ae 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -196,7 +196,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaEngine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java index b321264ba8d6..5cf0e19e9e8f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java @@ -117,7 +117,7 @@ private void updateDataNodeTTL(ConfigNodeProcedureEnv env) { plan.isDataBase()), dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index df3547fd7cf1..3804c47f73da 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -214,7 +214,7 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -388,7 +388,7 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { new AsyncDataNodeRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -496,7 +496,7 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { invalidateTemplateSetInfoReq, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { // all dataNodes must clear the related template cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index c0c0df562b24..600f96ff4f83 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -161,7 +161,7 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure invalidateTemplateSetInfoReq, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related template cache @@ -259,7 +259,7 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) rollbackTemplateSetInfoReq, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(clientHandler); + .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related template cache diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index dc3957481d62..0623193ed968 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -1493,7 +1493,7 @@ private List testAllConfigNodeConnection( (AsyncRequestContext handler) -> DataNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(handler)); + .sendAsyncRequestWithRetry(handler)); } private List testAllDataNodeInternalServiceConnection( @@ -1507,7 +1507,7 @@ private List testAllDataNodeInternalServiceConnection( (AsyncRequestContext handler) -> DataNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(handler)); + .sendAsyncRequestWithRetry(handler)); } private List testAllDataNodeMPPServiceConnection( @@ -1521,7 +1521,7 @@ private List testAllDataNodeMPPServiceConnection( (AsyncRequestContext handler) -> DataNodeMPPServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(handler)); + .sendAsyncRequestWithRetry(handler)); } private List testAllDataNodeExternalServiceConnection( @@ -1535,7 +1535,7 @@ private List testAllDataNodeExternalServiceConnection( (AsyncRequestContext handler) -> DataNodeExternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestToNodeWithRetry(handler)); + .sendAsyncRequestWithRetry(handler)); } @Override diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java index 6ea1ae6302ce..96eacb9bdeb7 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java @@ -83,20 +83,20 @@ public void sendAsyncRequestToNodeWithRetryAndTimeoutInMs( * * @param requestContext which will also contain the result */ - public final void sendAsyncRequestToNodeWithRetry( + public final void sendAsyncRequestWithRetry( AsyncRequestContext requestContext) { sendAsyncRequest(requestContext, MAX_RETRY_NUM, null); } - public final void sendAsyncRequestToNode( + public final void sendAsyncRequest( AsyncRequestContext requestContext) { sendAsyncRequest(requestContext, 1, null); } - private final void sendAsyncRequest( - AsyncRequestContext requestContext, - int retryNum, - Long timeoutInMs) { + private void sendAsyncRequest( + AsyncRequestContext requestContext, + int retryNum, + Long timeoutInMs) { if (requestContext.getRequestIndices().isEmpty()) { return; } @@ -109,7 +109,7 @@ private final void sendAsyncRequest( // Send requests to all targetNodes for (int requestId : requestContext.getRequestIndices()) { NodeLocation targetNode = requestContext.getNodeLocation(requestId); - sendAsyncRequestToNode(requestContext, requestId, targetNode, retry); + sendAsyncRequest(requestContext, requestId, targetNode, retry); } // Wait for this batch of asynchronous RPC requests finish @@ -143,7 +143,7 @@ private final void sendAsyncRequest( } } - protected void sendAsyncRequestToNode( + protected void sendAsyncRequest( AsyncRequestContext requestContext, int requestId, NodeLocation targetNode, From 02ca31dc20cc4b49e066722e97256a393ef323d7 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 12:24:19 +0800 Subject: [PATCH 33/52] delete useless class --- .../cn/AsyncConfigNodeRequestContext.java | 52 ------------------- .../dn/AsyncDataNodeRequestContext.java | 52 ------------------- .../impl/DataNodeInternalRPCServiceImpl.java | 3 +- .../client/request/AsyncRequestManager.java | 6 +-- 4 files changed, 4 insertions(+), 109 deletions(-) delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java deleted file mode 100644 index 3eb5daabe556..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestContext.java +++ /dev/null @@ -1,52 +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.iotdb.db.protocol.client.cn; - -import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.commons.client.request.AsyncRequestContext; - -import java.util.Map; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public class AsyncConfigNodeRequestContext - extends AsyncRequestContext { - - public AsyncConfigNodeRequestContext(DataNodeToConfigNodeRequestType configNodeRequestType) { - super(configNodeRequestType); - } - - public AsyncConfigNodeRequestContext( - DataNodeToConfigNodeRequestType configNodeRequestType, - Map integerTConfigNodeLocationMap) { - super(configNodeRequestType, integerTConfigNodeLocationMap); - } - - public AsyncConfigNodeRequestContext( - DataNodeToConfigNodeRequestType configNodeRequestType, - Q q, - Map integerTConfigNodeLocationMap) { - super(configNodeRequestType, q, integerTConfigNodeLocationMap); - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java deleted file mode 100644 index 982bba3c2d74..000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRequestContext.java +++ /dev/null @@ -1,52 +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.iotdb.db.protocol.client.dn; - -import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.commons.client.request.AsyncRequestContext; - -import java.util.Map; - -/** - * Asynchronous Client handler. - * - * @param ClassName of RPC request - * @param ClassName of RPC response - */ -public class AsyncDataNodeRequestContext - extends AsyncRequestContext { - - public AsyncDataNodeRequestContext(DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType) { - super(dataNodeToDataNodeRequestType); - } - - public AsyncDataNodeRequestContext( - DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType, - Map dataNodeLocationMap) { - super(dataNodeToDataNodeRequestType, dataNodeLocationMap); - } - - public AsyncDataNodeRequestContext( - DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType, - Q q, - Map dataNodeLocationMap) { - super(dataNodeToDataNodeRequestType, q, dataNodeLocationMap); - } -} diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 0623193ed968..8b3a8b2196d3 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -1520,8 +1520,7 @@ private List testAllDataNodeMPPServiceConnection( DataNodeToDataNodeRequestType.TEST_CONNECTION, (AsyncRequestContext handler) -> - DataNodeMPPServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(handler)); + DataNodeMPPServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(handler)); } private List testAllDataNodeExternalServiceConnection( diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java index 96eacb9bdeb7..327f802b12e7 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java @@ -94,9 +94,9 @@ public final void sendAsyncRequest( } private void sendAsyncRequest( - AsyncRequestContext requestContext, - int retryNum, - Long timeoutInMs) { + AsyncRequestContext requestContext, + int retryNum, + Long timeoutInMs) { if (requestContext.getRequestIndices().isEmpty()) { return; } From f801c89d4c7e1e93cb617f96ab90145ba4ec12bd Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 12:36:41 +0800 Subject: [PATCH 34/52] delete something --- .../client/async/AsyncDataNodeClientPool.java | 0 .../async/handlers/AsyncConfigNodeRequestContext.java | 10 ---------- 2 files changed, 10 deletions(-) delete mode 100644 iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java index 7e3353768b03..3892b8a336d2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java @@ -34,16 +34,6 @@ public class AsyncConfigNodeRequestContext extends AsyncRequestContext { - public AsyncConfigNodeRequestContext(ConfigNodeToConfigNodeRequestType configNodeRequestType) { - super(configNodeRequestType); - } - - public AsyncConfigNodeRequestContext( - ConfigNodeToConfigNodeRequestType configNodeRequestType, - Map integerTConfigNodeLocationMap) { - super(configNodeRequestType, integerTConfigNodeLocationMap); - } - public AsyncConfigNodeRequestContext( ConfigNodeToConfigNodeRequestType configNodeRequestType, Q q, From 388e1da79ee0b403a5cb17e97959f40bdc06e849 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 14:51:01 +0800 Subject: [PATCH 35/52] fix ci --- .../apache/iotdb/commons/client/request/AsyncRequestManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java index 327f802b12e7..ed3feb6598b8 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java @@ -55,6 +55,7 @@ public abstract class AsyncRequestManager { protected AsyncRequestManager() { initClientManager(); + actionMapBuilder = ImmutableMap.builder(); initActionMapBuilder(); this.actionMap = this.actionMapBuilder.build(); } From 3972d815d9290295fa68bf53e56f84c79f327a83 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 16:30:14 +0800 Subject: [PATCH 36/52] self review --- .../SubmitTestConnectionTaskRPCHandler.java | 2 - ...tConnectionTaskToConfigNodeRPCHandler.java | 4 - .../client/sync/SyncConfigNodeClientPool.java | 4 - .../confignode/conf/ConfigNodeConfig.java | 2 +- .../confignode/manager/ClusterManager.java | 105 ++++++------------ .../iotdb/confignode/service/ConfigNode.java | 4 +- .../cn/AsyncConfigNodeRequestRPCHandler.java | 1 - .../thrift/impl/ClientRPCServiceImpl.java | 5 - .../impl/DataNodeInternalRPCServiceImpl.java | 72 ++++-------- .../iotdb/commons/client/ClientManager.java | 2 +- .../iotdb/commons/client/request/Utils.java | 76 +++++++++++++ .../src/main/thrift/client.thrift | 3 - 12 files changed, 137 insertions(+), 143 deletions(-) create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index e862e89b0b32..f866001d4fda 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -52,10 +52,8 @@ public void onComplete(TTestConnectionResp resp) { countDownLatch.countDown(); } - // TODO: 什么情况下会error? @Override public void onError(Exception e) { - LOGGER.error("gg", e); responseMap.put(requestId, new TTestConnectionResp()); nodeLocationMap.remove(requestId); countDownLatch.countDown(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index 81ea8cb1c896..e9f17b4189e9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -60,12 +60,8 @@ public void onComplete(TTestConnectionResp resp) { countDownLatch.countDown(); } - // TODO: 什么情况下会error? @Override public void onError(Exception e) { - LOGGER.error("gg", e); - TTestConnectionResp resp = new TTestConnectionResp(); - resp.setStatus(new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())); responseMap.put(requestId, new TTestConnectionResp()); nodeLocationMap.remove(requestId); countDownLatch.countDown(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java index 3be8b557dd16..130213933d8e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java @@ -92,10 +92,6 @@ public Object sendSyncRequestToConfigNodeWithRetry( return client.stopConfigNode((TConfigNodeLocation) req); case SET_CONFIGURATION: return client.setConfiguration((TSetConfigurationReq) req); - case SUBMIT_TEST_CONNECTION_TASK: - return client.submitTestConnectionTask((TNodeLocations) req); - case TEST_CONNECTION: - return client.testConnection(); default: return RpcUtils.getStatus( TSStatusCode.EXECUTE_STATEMENT_ERROR, "Unknown request type: " + requestType); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java index 226f9e5015de..603892e36811 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java @@ -1198,7 +1198,7 @@ public void setDataRegionRatisPeriodicSnapshotInterval( this.dataRegionRatisPeriodicSnapshotInterval = dataRegionRatisPeriodicSnapshotInterval; } - public TConfigNodeLocation generateLocalConfigNodeLocation(int configNodeId) { + public TConfigNodeLocation generateLocalConfigNodeLocationWithSpecifiedNodeId(int configNodeId) { return new TConfigNodeLocation( configNodeId, new TEndPoint(getInternalAddress(), getInternalPort()), diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 2edfa6156641..faea511730a6 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -30,6 +30,8 @@ import org.apache.iotdb.common.rpc.thrift.TServiceType; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; +import org.apache.iotdb.commons.client.request.AsyncRequestContext; +import org.apache.iotdb.commons.client.request.Utils; import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToConfigNodeInternalServiceAsyncRequestManager; @@ -135,7 +137,7 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { } else { resp.getResultList() .addAll( - buildAllDownConfigNodeConnectionResult( + badConfigNodeConnectionResult( anotherConfigNodeLocationMap.get(nodeId), nodeLocations)); } }); @@ -164,7 +166,7 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { } else { resp.getResultList() .addAll( - buildAllDownDataNodeConnectionResult( + badDataNodeConnectionResult( anotherDataNodeLocationMap.get(nodeId), nodeLocations)); } }); @@ -183,38 +185,26 @@ public List doConnectionTest(TNodeLocations nodeLocations private List testAllConfigNodeConnection( List configNodeLocations) { final TSender sender = - new TSender() - .setConfigNodeLocation( - ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); - Map configNodeLocationMap = - configNodeLocations.stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - AsyncConfigNodeRequestContext requestContext = - new AsyncConfigNodeRequestContext<>( - ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, new Object(), configNodeLocationMap); - ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(requestContext); - Map anotherConfigNodeLocationMap = - configNodeLocations.stream() - .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - List results = new ArrayList<>(); - requestContext - .getResponseMap() - .forEach( - (configNodeId, status) -> { - TEndPoint endPoint = - anotherConfigNodeLocationMap.get(configNodeId).getInternalEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); - collectResult(sender, results, status, serviceProvider); - }); - return results; + new TSender() + .setConfigNodeLocation( + ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); + return Utils.testConnectionsImpl( + configNodeLocations, + sender, + TConfigNodeLocation::getConfigNodeId, + TConfigNodeLocation::getInternalEndPoint, + TServiceType.ConfigNodeInternalService, + ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext + handler) -> + ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() + .sendAsyncRequestWithRetry(handler)); } - private List buildAllDownConfigNodeConnectionResult( + private List badConfigNodeConnectionResult( TConfigNodeLocation sourceConfigNode, TNodeLocations nodeLocations) { final TSender sender = new TSender().setConfigNodeLocation(sourceConfigNode); - return buildAllDownNodeConnectionResult(nodeLocations, sender); + return badNodeConnectionResult(nodeLocations, sender); } private List testAllDataNodeConnection( @@ -223,37 +213,26 @@ private List testAllDataNodeConnection( new TSender() .setConfigNodeLocation( ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); - Map dataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext requestContext = - new AsyncDataNodeRequestContext<>( - ConfigNodeToDataNodeRequestType.TEST_CONNECTION, new Object(), dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(requestContext); - Map anotherDataNodeLocationMap = - dataNodeLocations.stream() - .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - List results = new ArrayList<>(); - requestContext - .getResponseMap() - .forEach( - (dataNodeId, status) -> { - TEndPoint endPoint = anotherDataNodeLocationMap.get(dataNodeId).getInternalEndPoint(); - TServiceProvider serviceProvider = - new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); - collectResult(sender, results, status, serviceProvider); - }); - return results; + return Utils.testConnectionsImpl( + dataNodeLocations, + sender, + TDataNodeLocation::getDataNodeId, + TDataNodeLocation::getInternalEndPoint, + TServiceType.DataNodeInternalService, + ConfigNodeToDataNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext + handler) -> + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + .sendAsyncRequestWithRetry(handler)); } - private List buildAllDownDataNodeConnectionResult( + private List badDataNodeConnectionResult( TDataNodeLocation sourceDataNode, TNodeLocations nodeLocations) { final TSender sender = new TSender().setDataNodeLocation(sourceDataNode); - return buildAllDownNodeConnectionResult(nodeLocations, sender); + return badNodeConnectionResult(nodeLocations, sender); } - private List buildAllDownNodeConnectionResult( + private List badNodeConnectionResult( TNodeLocations nodeLocations, TSender sender) { List results = new ArrayList<>(); nodeLocations @@ -283,20 +262,4 @@ private List buildAllDownNodeConnectionResult( return results; } - private void collectResult( - TSender sender, - List results, - TSStatus status, - TServiceProvider serviceProvider) { - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java index 2e6b1a422f8c..0c22b5eda9fb 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java @@ -186,7 +186,7 @@ public void active() { configManager .getNodeManager() .applyConfigNode( - CONF.generateLocalConfigNodeLocation(SEED_CONFIG_NODE_ID), + CONF.generateLocalConfigNodeLocationWithSpecifiedNodeId(SEED_CONFIG_NODE_ID), new TNodeVersionInfo(IoTDBConstant.VERSION, IoTDBConstant.BUILD_INFO)); setUpMetricService(); // Notice: We always set up Seed-ConfigNode's RPC service lastly to ensure @@ -323,7 +323,7 @@ private void sendRegisterConfigNodeRequest() throws StartupException, IOExceptio TConfigNodeRegisterReq req = new TConfigNodeRegisterReq( configManager.getClusterParameters(), - CONF.generateLocalConfigNodeLocation(INIT_NON_SEED_CONFIG_NODE_ID)); + CONF.generateLocalConfigNodeLocationWithSpecifiedNodeId(INIT_NON_SEED_CONFIG_NODE_ID)); req.setVersionInfo(new TNodeVersionInfo(IoTDBConstant.VERSION, IoTDBConstant.BUILD_INFO)); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java index ed6283ddcd91..db2f37459756 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -// TODO: ConfigNodeRequestType可抽 public abstract class AsyncConfigNodeRequestRPCHandler extends AsyncRequestRPCHandler { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java index 3698734ad44f..dbaf1065b3a5 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java @@ -2675,11 +2675,6 @@ public TSStatus testConnection() throws TException { return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); } - @Override - public TSStatus SubmitTestConnectionTask() throws TException { - throw new UnsupportedOperationException(); - } - @Override public TSStatus insertStringRecord(final TSInsertStringRecordReq req) { final long t1 = System.nanoTime(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 8b3a8b2196d3..1908b93bf06e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -19,6 +19,7 @@ package org.apache.iotdb.db.protocol.thrift.impl; +import org.apache.commons.collections4.ListUtils; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; @@ -266,6 +267,7 @@ import java.time.ZoneId; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -279,7 +281,9 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; +import static org.apache.iotdb.commons.client.request.Utils.testConnectionsImpl; import static org.apache.iotdb.commons.conf.IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD; import static org.apache.iotdb.db.service.RegionMigrateService.REGION_MIGRATE_PROCESS; import static org.apache.iotdb.db.utils.ErrorHandlingUtils.onQueryException; @@ -1429,62 +1433,32 @@ public TFetchFragmentInstanceStatisticsResp fetchFragmentInstanceStatistics( @Override public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) throws TException { - List configNodeResult = - testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); - List dataNodeResult = - testAllDataNodeInternalServiceConnection(nodeLocations.getDataNodeLocations()); - List mppResult = - testAllDataNodeMPPServiceConnection(nodeLocations.getDataNodeLocations()); - List clientResult = - testAllDataNodeExternalServiceConnection(nodeLocations.getDataNodeLocations()); - configNodeResult.addAll(dataNodeResult); - configNodeResult.addAll(mppResult); - configNodeResult.addAll(clientResult); - return new TTestConnectionResp(configNodeResult); - } - - private List testAllConnections( + return new TTestConnectionResp(Stream.of( + testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()), + testAllDataNodeInternalServiceConnection(nodeLocations.getDataNodeLocations()), + testAllDataNodeMPPServiceConnection(nodeLocations.getDataNodeLocations()), + testAllDataNodeExternalServiceConnection(nodeLocations.getDataNodeLocations()) + ).flatMap(Collection::stream).collect(Collectors.toList()) + ); + } + + private static List testConnections( List nodeLocations, Function getId, Function getEndPoint, TServiceType serviceType, RequestType requestType, Consumer> sendRequest) { - final TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); - Map nodeLocationMap = - nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); - AsyncRequestContext requestContext = - new AsyncRequestContext<>(requestType, new Object(), nodeLocationMap); - sendRequest.accept(requestContext); - Map anotherNodeLocationMap = - nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); - List results = new ArrayList<>(); - requestContext - .getResponseMap() - .forEach( - (nodeId, status) -> { - TEndPoint endPoint = getEndPoint.apply(anotherNodeLocationMap.get(nodeId)); - TServiceProvider serviceProvider = new TServiceProvider(endPoint, serviceType); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); - return results; + TSender sender = + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + return testConnectionsImpl(nodeLocations, sender, getId, getEndPoint, serviceType, requestType, sendRequest); } private List testAllConfigNodeConnection( List configNodeLocations) { - return testAllConnections( + return testConnections( configNodeLocations, TConfigNodeLocation::getConfigNodeId, TConfigNodeLocation::getInternalEndPoint, @@ -1498,7 +1472,7 @@ private List testAllConfigNodeConnection( private List testAllDataNodeInternalServiceConnection( List dataNodeLocations) { - return testAllConnections( + return testConnections( dataNodeLocations, TDataNodeLocation::getDataNodeId, TDataNodeLocation::getInternalEndPoint, @@ -1512,7 +1486,7 @@ private List testAllDataNodeInternalServiceConnection( private List testAllDataNodeMPPServiceConnection( List dataNodeLocations) { - return testAllConnections( + return testConnections( dataNodeLocations, TDataNodeLocation::getDataNodeId, TDataNodeLocation::getMPPDataExchangeEndPoint, @@ -1525,7 +1499,7 @@ private List testAllDataNodeMPPServiceConnection( private List testAllDataNodeExternalServiceConnection( List dataNodeLocations) { - return testAllConnections( + return testConnections( dataNodeLocations, TDataNodeLocation::getDataNodeId, TDataNodeLocation::getClientRpcEndPoint, diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java index 212b38a49978..f04569d752ac 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/ClientManager.java @@ -35,7 +35,7 @@ public class ClientManager implements IClientManager { private final KeyedObjectPool pool; - public ClientManager(IClientPoolFactory factory) { + ClientManager(IClientPoolFactory factory) { pool = factory.createClientPool(this); } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java new file mode 100644 index 000000000000..61ee71c7b592 --- /dev/null +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java @@ -0,0 +1,76 @@ +/* + * 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.commons.client.request; + +import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TSStatus; +import org.apache.iotdb.common.rpc.thrift.TSender; +import org.apache.iotdb.common.rpc.thrift.TServiceProvider; +import org.apache.iotdb.common.rpc.thrift.TServiceType; +import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; +import org.apache.iotdb.rpc.TSStatusCode; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class Utils { + public static List testConnectionsImpl( + List nodeLocations, + TSender sender, + Function getId, + Function getEndPoint, + TServiceType serviceType, + RequestType requestType, + Consumer> sendRequest) { + // prepare request context + Map nodeLocationMap = + nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); + AsyncRequestContext requestContext = + new AsyncRequestContext<>(requestType, new Object(), nodeLocationMap); + // do the test + sendRequest.accept(requestContext); + // collect result + Map anotherNodeLocationMap = + nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); + List results = new ArrayList<>(); + requestContext + .getResponseMap() + .forEach( + (nodeId, status) -> { + TEndPoint endPoint = getEndPoint.apply(anotherNodeLocationMap.get(nodeId)); + TServiceProvider serviceProvider = new TServiceProvider(endPoint, serviceType); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); + return results; + } +} diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift index eeda9ea79451..0c0c171a340b 100644 --- a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift +++ b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift @@ -662,7 +662,4 @@ service IClientRPCService { /** For other node's call */ common.TSStatus testConnection() - - /** For user's call */ - common.TSStatus SubmitTestConnectionTask() } \ No newline at end of file From f1d65c9aad13e313fe0a43e6ffdd5e02e5b23de6 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 16:46:28 +0800 Subject: [PATCH 37/52] self review --- ...ava => ConfigNodeAsyncRequestContext.java} | 4 +- ....java => DataNodeAsyncRequestContext.java} | 8 +- .../confignode/manager/ClusterManager.java | 60 ++++++------ .../manager/ClusterQuotaManager.java | 10 +- .../confignode/manager/TriggerManager.java | 6 +- .../iotdb/confignode/manager/UDFManager.java | 10 +- .../manager/load/balancer/RouteBalancer.java | 10 +- .../confignode/manager/node/NodeManager.java | 38 ++++---- .../manager/partition/PartitionManager.java | 14 +-- .../heartbeat/PipeHeartbeatScheduler.java | 6 +- .../manager/schema/ClusterSchemaManager.java | 6 +- .../procedure/env/ConfigNodeProcedureEnv.java | 92 +++++++++---------- .../procedure/env/RegionMaintainHandler.java | 6 +- .../schema/AlterLogicalViewProcedure.java | 6 +- .../schema/DataNodeRegionTaskExecutor.java | 10 +- .../schema/DeactivateTemplateProcedure.java | 6 +- .../impl/schema/DeleteDatabaseProcedure.java | 6 +- .../schema/DeleteLogicalViewProcedure.java | 6 +- .../schema/DeleteTimeSeriesProcedure.java | 6 +- .../impl/schema/SetTTLProcedure.java | 6 +- .../impl/schema/SetTemplateProcedure.java | 14 +-- .../impl/schema/UnsetTemplateProcedure.java | 10 +- .../src/main/thrift/confignode.thrift | 2 +- .../src/main/thrift/client.thrift | 2 +- .../src/main/thrift/datanode.thrift | 4 +- 25 files changed, 174 insertions(+), 174 deletions(-) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/{AsyncConfigNodeRequestContext.java => ConfigNodeAsyncRequestContext.java} (94%) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/{AsyncDataNodeRequestContext.java => DataNodeAsyncRequestContext.java} (90%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/ConfigNodeAsyncRequestContext.java similarity index 94% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/ConfigNodeAsyncRequestContext.java index 3892b8a336d2..05b9d04e0017 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncConfigNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/ConfigNodeAsyncRequestContext.java @@ -31,10 +31,10 @@ * @param ClassName of RPC request * @param ClassName of RPC response */ -public class AsyncConfigNodeRequestContext +public class ConfigNodeAsyncRequestContext extends AsyncRequestContext { - public AsyncConfigNodeRequestContext( + public ConfigNodeAsyncRequestContext( ConfigNodeToConfigNodeRequestType configNodeRequestType, Q q, Map integerTConfigNodeLocationMap) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java similarity index 90% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java index 68ffd3723419..f885df078d38 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AsyncDataNodeRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java @@ -31,20 +31,20 @@ * @param ClassName of RPC request * @param ClassName of RPC response */ -public class AsyncDataNodeRequestContext +public class DataNodeAsyncRequestContext extends AsyncRequestContext { - public AsyncDataNodeRequestContext(ConfigNodeToDataNodeRequestType requestType) { + public DataNodeAsyncRequestContext(ConfigNodeToDataNodeRequestType requestType) { super(requestType); } - public AsyncDataNodeRequestContext( + public DataNodeAsyncRequestContext( ConfigNodeToDataNodeRequestType requestType, Map dataNodeLocationMap) { super(requestType, dataNodeLocationMap); } - public AsyncDataNodeRequestContext( + public DataNodeAsyncRequestContext( ConfigNodeToDataNodeRequestType requestType, Q q, Map dataNodeLocationMap) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index faea511730a6..1844bcea6290 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -36,8 +36,8 @@ import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToConfigNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncConfigNodeRequestContext; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.ConfigNodeAsyncRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan; import org.apache.iotdb.confignode.persistence.ClusterInfo; @@ -118,8 +118,8 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { Map configNodeLocationMap = configManager.getNodeManager().getRegisteredConfigNodes().stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - AsyncConfigNodeRequestContext configNodeClientHandler = - new AsyncConfigNodeRequestContext<>( + ConfigNodeAsyncRequestContext configNodeClientHandler = + new ConfigNodeAsyncRequestContext<>( ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); @@ -145,8 +145,8 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { configManager.getNodeManager().getRegisteredDataNodes().stream() .map(TDataNodeConfiguration::getLocation) .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - AsyncDataNodeRequestContext dataNodeClientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext dataNodeClientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); @@ -185,20 +185,21 @@ public List doConnectionTest(TNodeLocations nodeLocations private List testAllConfigNodeConnection( List configNodeLocations) { final TSender sender = - new TSender() - .setConfigNodeLocation( - ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); + new TSender() + .setConfigNodeLocation( + ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); return Utils.testConnectionsImpl( - configNodeLocations, - sender, - TConfigNodeLocation::getConfigNodeId, - TConfigNodeLocation::getInternalEndPoint, - TServiceType.ConfigNodeInternalService, - ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext - handler) -> - ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(handler)); + configNodeLocations, + sender, + TConfigNodeLocation::getConfigNodeId, + TConfigNodeLocation::getInternalEndPoint, + TServiceType.ConfigNodeInternalService, + ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext< + Object, TSStatus, ConfigNodeToConfigNodeRequestType, TConfigNodeLocation> + handler) -> + ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() + .sendAsyncRequestWithRetry(handler)); } private List badConfigNodeConnectionResult( @@ -214,16 +215,16 @@ private List testAllDataNodeConnection( .setConfigNodeLocation( ConfigNodeDescriptor.getInstance().getConf().generateLocalConfigNodeLocation()); return Utils.testConnectionsImpl( - dataNodeLocations, - sender, - TDataNodeLocation::getDataNodeId, - TDataNodeLocation::getInternalEndPoint, - TServiceType.DataNodeInternalService, - ConfigNodeToDataNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext - handler) -> - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(handler)); + dataNodeLocations, + sender, + TDataNodeLocation::getDataNodeId, + TDataNodeLocation::getInternalEndPoint, + TServiceType.DataNodeInternalService, + ConfigNodeToDataNodeRequestType.TEST_CONNECTION, + (AsyncRequestContext + handler) -> + ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + .sendAsyncRequestWithRetry(handler)); } private List badDataNodeConnectionResult( @@ -261,5 +262,4 @@ private List badNodeConnectionResult( }); return results; } - } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java index 16946796a395..89d226bbb7dd 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.quota.SetSpaceQuotaPlan; import org.apache.iotdb.confignode.consensus.request.write.quota.SetThrottleQuotaPlan; import org.apache.iotdb.confignode.manager.partition.PartitionManager; @@ -87,8 +87,8 @@ public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -194,8 +194,8 @@ public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) { if (response.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index 44734a1438a9..b609aef8adaa 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -26,7 +26,7 @@ import org.apache.iotdb.commons.trigger.TriggerInformation; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTransferringTriggersPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerJarPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerLocationPlan; @@ -248,8 +248,8 @@ public List updateTriggerLocation( final TUpdateTriggerLocationReq request = new TUpdateTriggerLocationReq(triggerName, dataNodeLocation); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index 5ca5d3460466..335a54a0ec00 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -25,7 +25,7 @@ import org.apache.iotdb.commons.udf.UDFInformation; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.function.GetFunctionTablePlan; import org.apache.iotdb.confignode.consensus.request.read.function.GetUDFJarPlan; @@ -127,8 +127,8 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, configManager.getNodeManager().getRegisteredDataNodeLocations(); final TCreateFunctionInstanceReq req = new TCreateFunctionInstanceReq(udfInformation.serialize()).setJarFile(jarFile); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -162,8 +162,8 @@ private List dropFunctionOnDataNodes(String functionName) { final TDropFunctionInstanceReq request = new TDropFunctionInstanceReq(functionName, false); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index 9dcf3817aaa1..85cf998e0307 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -27,7 +27,7 @@ import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.IManager; @@ -167,8 +167,8 @@ private void balanceRegionLeader( // Transfer leader to the optimal distribution long currentTime = System.nanoTime(); AtomicInteger requestId = new AtomicInteger(0); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.CHANGE_REGION_LEADER); + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>(ConfigNodeToDataNodeRequestType.CHANGE_REGION_LEADER); Map successTransferMap = new TreeMap<>(); optimalLeaderMap.forEach( (regionGroupId, newLeaderId) -> { @@ -308,8 +308,8 @@ private void broadcastLatestRegionPriorityMap() { long broadcastTime = System.currentTimeMillis(); Map tmpPriorityMap = getRegionPriorityMap(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_REGION_ROUTE_MAP, new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index 5103c39edbbc..2e0f14da2ba8 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -38,7 +38,7 @@ import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; @@ -705,8 +705,8 @@ private TSStatus transferLeader( public List merge() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.MERGE, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -716,8 +716,8 @@ public List merge() { public List flush(TFlushReq req) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.FLUSH, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -727,8 +727,8 @@ public List flush(TFlushReq req) { public List clearCache() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -749,8 +749,8 @@ public List setConfiguration(TSetConfigurationReq req) { targetDataNodes.putAll(dataNodeLocationMap); } if (!targetDataNodes.isEmpty()) { - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.SET_CONFIGURATION, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -788,8 +788,8 @@ public List setConfiguration(TSetConfigurationReq req) { public List startRpairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -799,8 +799,8 @@ public List startRpairData() { public List stopRepairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -810,8 +810,8 @@ public List stopRepairData() { public List loadConfiguration() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -854,8 +854,8 @@ public TShowConfigurationResp showConfiguration(int nodeId) { public List setSystemStatus(String status) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -889,8 +889,8 @@ public TSStatus killQuery(String queryId, int dataNodeId) { private TSStatus killAllQueries() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index 1b4adb3ecf5a..49be3a3a4fe1 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -36,7 +36,7 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; @@ -1255,9 +1255,9 @@ public void maintainRegionReplicas() { switch (selectedRegionMaintainTask.get(0).getRegionId().getType()) { case SchemaRegion: // create SchemaRegion - AsyncDataNodeRequestContext + DataNodeAsyncRequestContext createSchemaRegionHandler = - new AsyncDataNodeRequestContext<>( + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask schemaRegionCreateTask = @@ -1291,9 +1291,9 @@ public void maintainRegionReplicas() { break; case DataRegion: // Create DataRegion - AsyncDataNodeRequestContext + DataNodeAsyncRequestContext createDataRegionHandler = - new AsyncDataNodeRequestContext<>( + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask dataRegionCreateTask = @@ -1329,8 +1329,8 @@ public void maintainRegionReplicas() { break; case DELETE: // delete region - AsyncDataNodeRequestContext deleteRegionHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext deleteRegionHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.DELETE_REGION); Map regionIdMap = new HashMap<>(); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeatScheduler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeatScheduler.java index 62387f92a451..554d200824e0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeatScheduler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeatScheduler.java @@ -26,7 +26,7 @@ import org.apache.iotdb.commons.pipe.config.PipeConfig; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.manager.pipe.agent.PipeConfigNodeAgent; @@ -94,8 +94,8 @@ private synchronized void heartbeat() { final TPipeHeartbeatReq request = new TPipeHeartbeatReq(System.currentTimeMillis()); LOGGER.info("Collecting pipe heartbeat {} from data nodes", request.heartbeatId); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 8d3c21c12733..947226603557 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -34,7 +34,7 @@ import org.apache.iotdb.commons.utils.StatusUtils; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.database.CountDatabasePlan; @@ -1039,8 +1039,8 @@ public synchronized TSStatus extendSchemaTemplate( Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, updateTemplateReq, dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index d9dc3dd6c737..bcc41931893f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -35,7 +35,7 @@ import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.consensus.request.write.confignode.RemoveConfigNodePlan; @@ -430,7 +430,7 @@ public Map doRegionCreation( TConsensusGroupType consensusGroupType, CreateRegionGroupsPlan createRegionGroupsPlan) { // Prepare clientHandler - AsyncDataNodeRequestContext clientHandler; + DataNodeAsyncRequestContext clientHandler; switch (consensusGroupType) { case SchemaRegion: clientHandler = getCreateSchemaRegionClientHandler(createRegionGroupsPlan); @@ -470,10 +470,10 @@ public Map doRegionCreation( return failedRegions; } - private AsyncDataNodeRequestContext + private DataNodeAsyncRequestContext getCreateSchemaRegionClientHandler(CreateRegionGroupsPlan createRegionGroupsPlan) { - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION); + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>(ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -493,10 +493,10 @@ public Map doRegionCreation( return clientHandler; } - private AsyncDataNodeRequestContext + private DataNodeAsyncRequestContext getCreateDataRegionClientHandler(CreateRegionGroupsPlan createRegionGroupsPlan) { - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION); + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>(ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -589,8 +589,8 @@ public List createTriggerOnDataNodes( request.setJarFile(ByteBuffer.wrap(jarFile.getValues())); } - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -604,8 +604,8 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD final TDropTriggerInstanceReq request = new TDropTriggerInstanceReq(triggerName, needToDeleteJarFile); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -618,8 +618,8 @@ public List activeTriggerOnDataNodes(String triggerName) { nodeManager.getRegisteredDataNodeLocations(); final TActiveTriggerInstanceReq request = new TActiveTriggerInstanceReq(triggerName); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -632,8 +632,8 @@ public List inactiveTriggerOnDataNodes(String triggerName) { nodeManager.getRegisteredDataNodeLocations(); final TInactiveTriggerInstanceReq request = new TInactiveTriggerInstanceReq(triggerName); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); @@ -649,8 +649,8 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, final TCreatePipePluginInstanceReq request = new TCreatePipePluginInstanceReq(pipePluginMeta.serialize(), ByteBuffer.wrap(jarFile)); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -664,8 +664,8 @@ public List dropPipePluginOnDataNodes( final TDropPipePluginInstanceReq request = new TDropPipePluginInstanceReq(pipePluginName, needToDeleteJarFile); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -678,8 +678,8 @@ public Map pushAllPipeMetaToDataNodes( configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushPipeMetaReq request = new TPushPipeMetaReq().setPipeMetas(pipeMetaBinaryList); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( @@ -693,8 +693,8 @@ public Map pushSinglePipeMetaToDataNodes(ByteBuffer configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushSinglePipeMetaReq request = new TPushSinglePipeMetaReq().setPipeMeta(pipeMetaBinary); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( @@ -709,8 +709,8 @@ public Map dropSinglePipeOnDataNodes(String pipeName final TPushSinglePipeMetaReq request = new TPushSinglePipeMetaReq().setPipeNameToDrop(pipeNameToDrop); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( @@ -726,8 +726,8 @@ public Map pushMultiPipeMetaToDataNodes( final TPushMultiPipeMetaReq request = new TPushMultiPipeMetaReq().setPipeMetas(pipeMetaBinaryList); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( @@ -742,8 +742,8 @@ public Map dropMultiPipeOnDataNodes(List pip final TPushMultiPipeMetaReq request = new TPushMultiPipeMetaReq().setPipeNamesToDrop(pipeNamesToDrop); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( @@ -758,8 +758,8 @@ public Map pushAllTopicMetaToDataNodes( configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushTopicMetaReq request = new TPushTopicMetaReq().setTopicMetas(topicMetaBinaryList); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( @@ -773,8 +773,8 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { configManager.getNodeManager().getRegisteredDataNodeLocations(); final TPushSingleTopicMetaReq request = new TPushSingleTopicMetaReq().setTopicMeta(topicMeta); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -789,8 +789,8 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { final TPushSingleTopicMetaReq request = new TPushSingleTopicMetaReq().setTopicNameToDrop(topicNameToDrop); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -806,8 +806,8 @@ public Map pushMultiTopicMetaToDataNodes( final TPushMultiTopicMetaReq request = new TPushMultiTopicMetaReq().setTopicMetas(topicMetaBinaryList); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( @@ -822,8 +822,8 @@ public Map dropMultiTopicOnDataNodes(List t final TPushMultiTopicMetaReq request = new TPushMultiTopicMetaReq().setTopicNamesToDrop(topicNamesToDrop); - final AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + final DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( @@ -839,9 +839,9 @@ public Map pushAllConsumerGroupMetaToDataNo final TPushConsumerGroupMetaReq request = new TPushConsumerGroupMetaReq().setConsumerGroupMetas(consumerGroupMetaBinaryList); - final AsyncDataNodeRequestContext + final DataNodeAsyncRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); @@ -858,9 +858,9 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup final TPushSingleConsumerGroupMetaReq request = new TPushSingleConsumerGroupMetaReq().setConsumerGroupMeta(consumerGroupMeta); - final AsyncDataNodeRequestContext + final DataNodeAsyncRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); @@ -877,9 +877,9 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName final TPushSingleConsumerGroupMetaReq request = new TPushSingleConsumerGroupMetaReq().setConsumerGroupNameToDrop(consumerGroupNameToDrop); - final AsyncDataNodeRequestContext + final DataNodeAsyncRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index 21b65d02c65d..0fbb6928049d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -37,7 +37,7 @@ import org.apache.iotdb.commons.utils.NodeUrlUtils; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -367,8 +367,8 @@ public Map resetPeerList( TConsensusGroupId regionId, List correctDataNodeLocations, Map dataNodeLocationMap) { - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.RESET_PEER_LIST, new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index e1edc23678ce..a5d8c24afcac 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -32,7 +32,7 @@ import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; import org.apache.iotdb.confignode.procedure.exception.ProcedureSuspendedException; @@ -120,8 +120,8 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, AlterLogicalViewStat private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java index 38ddb20fc1dc..964a5e66f32a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java @@ -24,7 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -86,7 +86,7 @@ void execute() { : getLeaderDataNodeRegionGroupMap( configManager.getLoadManager().getRegionLeaderMap(), targetSchemaRegionGroup); while (!dataNodeConsensusGroupIdMap.isEmpty()) { - AsyncDataNodeRequestContext clientHandler = + DataNodeAsyncRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -114,10 +114,10 @@ void execute() { } } - private AsyncDataNodeRequestContext prepareRequestHandler( + private DataNodeAsyncRequestContext prepareRequestHandler( Map> dataNodeConsensusGroupIdMap) { - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>(dataNodeRequestType); + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>(dataNodeRequestType); for (Map.Entry> entry : dataNodeConsensusGroupIdMap.entrySet()) { clientHandler.putNodeLocation(entry.getKey().getDataNodeId(), entry.getKey()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java index 2c119914e3eb..e061155ffd3d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java @@ -30,7 +30,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeactivateTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -198,8 +198,8 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { if (!timeSeriesPatternTree.isEmpty()) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(timeSeriesPatternTreeBytes), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java index 62d8cd1f458e..fa6b481a0217 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java @@ -29,7 +29,7 @@ import org.apache.iotdb.commons.utils.ThriftConfigNodeSerDeUtils; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.database.PreDeleteDatabasePlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; import org.apache.iotdb.confignode.manager.partition.PartitionMetrics; @@ -155,8 +155,8 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt MetricService.getInstance(), deleteDatabaseSchema.getName()); // try sync delete schemaengine region - AsyncDataNodeRequestContext asyncClientHandler = - new AsyncDataNodeRequestContext<>(ConfigNodeToDataNodeRequestType.DELETE_REGION); + DataNodeAsyncRequestContext asyncClientHandler = + new DataNodeAsyncRequestContext<>(ConfigNodeToDataNodeRequestType.DELETE_REGION); Map schemaRegionDeleteTaskMap = new HashMap<>(); int requestIndex = 0; for (TRegionReplicaSet schemaRegionReplicaSet : schemaRegionReplicaSets) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index 7b7ad5e888f8..6a2bb7dd31ea 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -184,8 +184,8 @@ protected List processResponseOfOneDataNode( private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index 5ca8a89309ae..c00e75492197 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -190,8 +190,8 @@ protected List processResponseOfOneDataNode( private void invalidateCache(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java index 5cf0e19e9e8f..c87ddeecb796 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java @@ -26,7 +26,7 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; import org.apache.iotdb.confignode.consensus.request.write.database.SetTTLPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -108,8 +108,8 @@ private void setConfigNodeTTL(ConfigNodeProcedureEnv env) { private void updateDataNodeTTL(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.SET_TTL, new TSetTTLReq( Collections.singletonList(String.join(".", plan.getPathPattern())), diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index 3804c47f73da..52e574cf768b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -30,7 +30,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.read.template.CheckTemplateSettablePlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetSchemaTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -210,8 +210,8 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -384,8 +384,8 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { Map dataNodeLocationMap = env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); @@ -490,8 +490,8 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { TemplateInternalRPCUtil.generateInvalidateTemplateSetInfoBytes( template.getId(), templateSetPath)); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index 600f96ff4f83..ecaba363b997 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.handlers.AsyncDataNodeRequestContext; +import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; import org.apache.iotdb.confignode.procedure.exception.ProcedureSuspendedException; @@ -155,8 +155,8 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure invalidateTemplateSetInfoReq.setType( TemplateInternalRPCUpdateType.INVALIDATE_TEMPLATE_SET_INFO.toByte()); invalidateTemplateSetInfoReq.setTemplateInfo(getInvalidateTemplateSetInfo()); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); @@ -253,8 +253,8 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) rollbackTemplateSetInfoReq.setType( TemplateInternalRPCUpdateType.ADD_TEMPLATE_SET_INFO.toByte()); rollbackTemplateSetInfoReq.setTemplateInfo(getAddTemplateSetInfo()); - AsyncDataNodeRequestContext clientHandler = - new AsyncDataNodeRequestContext<>( + DataNodeAsyncRequestContext clientHandler = + new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, rollbackTemplateSetInfoReq, dataNodeLocationMap); diff --git a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift index ad4b140cadcd..e11cf7540fa8 100644 --- a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift +++ b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift @@ -1382,7 +1382,7 @@ service IConfigNodeRPCService { common.TTestConnectionResp submitTestConnectionTaskToLeader() /** Empty rpc, only for connection test */ - common.TSStatus testConnection() + common.TSStatus testConnectionEmptyRPC() /** * Show the matched cluster Regions' information diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift index 0c0c171a340b..917a9a579002 100644 --- a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift +++ b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift @@ -661,5 +661,5 @@ service IClientRPCService { TSConnectionInfoResp fetchAllConnectionsInfo(); /** For other node's call */ - common.TSStatus testConnection() + common.TSStatus testConnectionEmptyRPC() } \ No newline at end of file diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift b/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift index cfc5718566a9..60e605a6a34a 100644 --- a/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift +++ b/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift @@ -1003,7 +1003,7 @@ service IDataNodeRPCService { common.TTestConnectionResp submitTestConnectionTask(common.TNodeLocations nodeLocations) /** Empty rpc, only for connection test */ - common.TSStatus testConnection() + common.TSStatus testConnectionEmptyRPC() } service MPPDataExchangeService { @@ -1018,5 +1018,5 @@ service MPPDataExchangeService { void onEndOfDataBlockEvent(TEndOfDataBlockEvent e); /** Empty rpc, only for connection test */ - common.TSStatus testConnection() + common.TSStatus testConnectionEmptyRPC() } From 283f0096bef7fff5af4921612242b041df2a864a Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 16:46:35 +0800 Subject: [PATCH 38/52] self review --- ...odeInternalServiceAsyncRequestManager.java | 3 +- ...odeInternalServiceAsyncRequestManager.java | 3 +- ...tConnectionTaskToConfigNodeRPCHandler.java | 2 - .../client/sync/SyncConfigNodeClientPool.java | 1 - .../thrift/ConfigNodeRPCServiceProcessor.java | 2 +- .../db/protocol/client/ConfigNodeClient.java | 4 +- .../cn/AsyncConfigNodeTSStatusRPCHandler.java | 2 +- ... => ConfigNodeAsyncRequestRPCHandler.java} | 6 +- ...odeInternalServiceAsyncRequestManager.java | 4 +- .../client/dn/AsyncTSStatusRPCHandler.java | 2 +- ...va => DataNodeAsyncRequestRPCHandler.java} | 9 ++- ...odeExternalServiceAsyncRequestManager.java | 5 +- ...DataNodeMPPServiceAsyncRequestManager.java | 5 +- ...odeInternalServiceAsyncRequestManager.java | 5 +- .../thrift/impl/ClientRPCServiceImpl.java | 2 +- .../impl/DataNodeInternalRPCServiceImpl.java | 28 +++---- .../exchange/MPPDataExchangeManager.java | 2 +- .../iotdb/commons/client/request/Utils.java | 78 ++++++++++--------- 18 files changed, 84 insertions(+), 79 deletions(-) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/{AsyncConfigNodeRequestRPCHandler.java => ConfigNodeAsyncRequestRPCHandler.java} (94%) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/{AsyncDataNodeRPCHandler.java => DataNodeAsyncRequestRPCHandler.java} (90%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java index 5f8569e43835..1238972dc435 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java @@ -47,7 +47,8 @@ protected void initActionMapBuilder() { (TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler)); actionMapBuilder.put( ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, - (req, client, handler) -> client.testConnection((ConfigNodeTSStatusRPCHandler) handler)); + (req, client, handler) -> + client.testConnectionEmptyRPC((ConfigNodeTSStatusRPCHandler) handler)); } @Override diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java index 02d5e27a87a2..d577444932e0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java @@ -348,7 +348,8 @@ protected void initActionMapBuilder() { (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler)); actionMapBuilder.put( ConfigNodeToDataNodeRequestType.TEST_CONNECTION, - (req, client, handler) -> client.testConnection((DataNodeTSStatusRPCHandler) handler)); + (req, client, handler) -> + client.testConnectionEmptyRPC((DataNodeTSStatusRPCHandler) handler)); } @Override diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index e9f17b4189e9..0e79334b0c78 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -20,10 +20,8 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; -import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; -import org.apache.iotdb.rpc.TSStatusCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java index 130213933d8e..0790744f110c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java @@ -21,7 +21,6 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; -import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq; import org.apache.iotdb.commons.client.ClientPoolFactory; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java index 7c1ad976ff32..031130d077a2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java @@ -911,7 +911,7 @@ public TTestConnectionResp submitTestConnectionTaskToLeader() throws TException /** Call by every other nodes */ @Override - public TSStatus testConnection() throws TException { + public TSStatus testConnectionEmptyRPC() throws TException { return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java index b72585b15a71..980cb89b6e0c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java @@ -744,9 +744,9 @@ public TTestConnectionResp submitTestConnectionTaskToLeader() throws TException } @Override - public TSStatus testConnection() throws TException { + public TSStatus testConnectionEmptyRPC() throws TException { return executeRemoteCallWithRetry( - () -> client.testConnection(), resp -> !updateConfigNodeLeader(resp)); + () -> client.testConnectionEmptyRPC(), resp -> !updateConfigNodeLeader(resp)); } @Override diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java index 063b35c1c125..e845640e1250 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java @@ -31,7 +31,7 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncConfigNodeTSStatusRPCHandler extends AsyncConfigNodeRequestRPCHandler { +public class AsyncConfigNodeTSStatusRPCHandler extends ConfigNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncConfigNodeTSStatusRPCHandler.class); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java similarity index 94% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java index db2f37459756..bd38a2fbf44c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeRequestRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java @@ -27,10 +27,10 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class AsyncConfigNodeRequestRPCHandler +public abstract class ConfigNodeAsyncRequestRPCHandler extends AsyncRequestRPCHandler { - protected AsyncConfigNodeRequestRPCHandler( + protected ConfigNodeAsyncRequestRPCHandler( DataNodeToConfigNodeRequestType configNodeRequestType, int requestId, TConfigNodeLocation targetNode, @@ -55,7 +55,7 @@ protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeL + "}"; } - public static AsyncConfigNodeRequestRPCHandler buildHandler( + public static ConfigNodeAsyncRequestRPCHandler buildHandler( AsyncRequestContext context, int requestId, TConfigNodeLocation targetConfigNode) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java index bc859fc054cc..43d233a6110b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java @@ -38,7 +38,7 @@ protected void initActionMapBuilder() { actionMapBuilder.put( DataNodeToConfigNodeRequestType.TEST_CONNECTION, (req, client, handler) -> - client.testConnection((AsyncConfigNodeTSStatusRPCHandler) handler)); + client.testConnectionEmptyRPC((AsyncConfigNodeTSStatusRPCHandler) handler)); } @Override @@ -48,7 +48,7 @@ protected void initActionMapBuilder() { requestContext, int requestId, TConfigNodeLocation targetNode) { - return AsyncConfigNodeRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); + return ConfigNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); } private static class ClientPoolHolder { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java index a453df0b1724..796e202fbe43 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java @@ -31,7 +31,7 @@ import java.util.concurrent.CountDownLatch; /** General RPC handler for TSStatus response type. */ -public class AsyncTSStatusRPCHandler extends AsyncDataNodeRPCHandler { +public class AsyncTSStatusRPCHandler extends DataNodeAsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(AsyncTSStatusRPCHandler.class); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeAsyncRequestRPCHandler.java similarity index 90% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeAsyncRequestRPCHandler.java index 7026a5df06ec..7d523fe491ba 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncDataNodeRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeAsyncRequestRPCHandler.java @@ -30,11 +30,12 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -public abstract class AsyncDataNodeRPCHandler +public abstract class DataNodeAsyncRequestRPCHandler extends AsyncRequestRPCHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(AsyncDataNodeRPCHandler.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(DataNodeAsyncRequestRPCHandler.class); - protected AsyncDataNodeRPCHandler( + protected DataNodeAsyncRequestRPCHandler( DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType, int requestId, TDataNodeLocation targetNode, @@ -59,7 +60,7 @@ protected String generateFormattedTargetLocation(TDataNodeLocation dataNodeLocat + "}"; } - public static AsyncDataNodeRPCHandler createAsyncRPCHandler( + public static DataNodeAsyncRequestRPCHandler createAsyncRPCHandler( AsyncRequestContext context, int requestId, TDataNodeLocation targetDataNode) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java index a706d0e6a189..0749435c4554 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java @@ -50,7 +50,7 @@ protected void initClientManager() { protected void initActionMapBuilder() { actionMapBuilder.put( DataNodeToDataNodeRequestType.TEST_CONNECTION, - (req, client, handler) -> client.testConnection((AsyncTSStatusRPCHandler) handler)); + (req, client, handler) -> client.testConnectionEmptyRPC((AsyncTSStatusRPCHandler) handler)); } @Override @@ -65,7 +65,8 @@ protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { requestContext, int requestId, TDataNodeLocation targetNode) { - return AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); + return DataNodeAsyncRequestRPCHandler.createAsyncRPCHandler( + requestContext, requestId, targetNode); } private static class ClientPoolHolder { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java index fd8cda7b0e7a..c75ad83da81e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java @@ -53,7 +53,7 @@ protected void initClientManager() { protected void initActionMapBuilder() { actionMapBuilder.put( DataNodeToDataNodeRequestType.TEST_CONNECTION, - (req, client, handler) -> client.testConnection((AsyncTSStatusRPCHandler) handler)); + (req, client, handler) -> client.testConnectionEmptyRPC((AsyncTSStatusRPCHandler) handler)); } @Override @@ -68,7 +68,8 @@ protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { requestContext, int requestId, TDataNodeLocation targetNode) { - return AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); + return DataNodeAsyncRequestRPCHandler.createAsyncRPCHandler( + requestContext, requestId, targetNode); } private static class ClientPoolHolder { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java index 6eacce3b51d7..3bffaefd288a 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java @@ -36,7 +36,7 @@ public class DataNodeToDataNodeInternalServiceAsyncRequestManager protected void initActionMapBuilder() { actionMapBuilder.put( DataNodeToDataNodeRequestType.TEST_CONNECTION, - (req, client, handler) -> client.testConnection((AsyncTSStatusRPCHandler) handler)); + (req, client, handler) -> client.testConnectionEmptyRPC((AsyncTSStatusRPCHandler) handler)); } @Override @@ -46,7 +46,8 @@ protected void initActionMapBuilder() { requestContext, int requestId, TDataNodeLocation targetNode) { - return AsyncDataNodeRPCHandler.createAsyncRPCHandler(requestContext, requestId, targetNode); + return DataNodeAsyncRequestRPCHandler.createAsyncRPCHandler( + requestContext, requestId, targetNode); } private static class ClientPoolHolder { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java index dbaf1065b3a5..78f7d03fd2ff 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java @@ -2671,7 +2671,7 @@ public TSConnectionInfoResp fetchAllConnectionsInfo() { } @Override - public TSStatus testConnection() throws TException { + public TSStatus testConnectionEmptyRPC() throws TException { return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 1908b93bf06e..9af9bd89a186 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -19,7 +19,6 @@ package org.apache.iotdb.db.protocol.thrift.impl; -import org.apache.commons.collections4.ListUtils; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; @@ -28,7 +27,6 @@ import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TSender; -import org.apache.iotdb.common.rpc.thrift.TServiceProvider; import org.apache.iotdb.common.rpc.thrift.TServiceType; import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq; import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq; @@ -1433,13 +1431,14 @@ public TFetchFragmentInstanceStatisticsResp fetchFragmentInstanceStatistics( @Override public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) throws TException { - return new TTestConnectionResp(Stream.of( - testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()), - testAllDataNodeInternalServiceConnection(nodeLocations.getDataNodeLocations()), - testAllDataNodeMPPServiceConnection(nodeLocations.getDataNodeLocations()), - testAllDataNodeExternalServiceConnection(nodeLocations.getDataNodeLocations()) - ).flatMap(Collection::stream).collect(Collectors.toList()) - ); + return new TTestConnectionResp( + Stream.of( + testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()), + testAllDataNodeInternalServiceConnection(nodeLocations.getDataNodeLocations()), + testAllDataNodeMPPServiceConnection(nodeLocations.getDataNodeLocations()), + testAllDataNodeExternalServiceConnection(nodeLocations.getDataNodeLocations())) + .flatMap(Collection::stream) + .collect(Collectors.toList())); } private static List testConnections( @@ -1450,10 +1449,11 @@ private static List testConnectio RequestType requestType, Consumer> sendRequest) { TSender sender = - new TSender() - .setDataNodeLocation( - IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); - return testConnectionsImpl(nodeLocations, sender, getId, getEndPoint, serviceType, requestType, sendRequest); + new TSender() + .setDataNodeLocation( + IoTDBDescriptor.getInstance().getConfig().generateLocalDataNodeLocation()); + return testConnectionsImpl( + nodeLocations, sender, getId, getEndPoint, serviceType, requestType, sendRequest); } private List testAllConfigNodeConnection( @@ -1512,7 +1512,7 @@ private List testAllDataNodeExternalServiceConnection( } @Override - public TSStatus testConnection() throws TException { + public TSStatus testConnectionEmptyRPC() throws TException { return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManager.java index 2a07c497c103..a38ef923bbb3 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeManager.java @@ -287,7 +287,7 @@ public void onEndOfDataBlockEvent(TEndOfDataBlockEvent e) throws TException { } @Override - public TSStatus testConnection() throws TException { + public TSStatus testConnectionEmptyRPC() throws TException { return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()); } } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java index 61ee71c7b592..6d4704f059b8 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java @@ -35,42 +35,44 @@ import java.util.stream.Collectors; public class Utils { - public static List testConnectionsImpl( - List nodeLocations, - TSender sender, - Function getId, - Function getEndPoint, - TServiceType serviceType, - RequestType requestType, - Consumer> sendRequest) { - // prepare request context - Map nodeLocationMap = - nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); - AsyncRequestContext requestContext = - new AsyncRequestContext<>(requestType, new Object(), nodeLocationMap); - // do the test - sendRequest.accept(requestContext); - // collect result - Map anotherNodeLocationMap = - nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); - List results = new ArrayList<>(); - requestContext - .getResponseMap() - .forEach( - (nodeId, status) -> { - TEndPoint endPoint = getEndPoint.apply(anotherNodeLocationMap.get(nodeId)); - TServiceProvider serviceProvider = new TServiceProvider(endPoint, serviceType); - TTestConnectionResult result = new TTestConnectionResult(); - result.setSender(sender); - result.setServiceProvider(serviceProvider); - if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { - result.setSuccess(true); - } else { - result.setSuccess(false); - result.setReason(status.getMessage()); - } - results.add(result); - }); - return results; - } + public static + List testConnectionsImpl( + List nodeLocations, + TSender sender, + Function getId, + Function getEndPoint, + TServiceType serviceType, + RequestType requestType, + Consumer> + sendRequest) { + // prepare request context + Map nodeLocationMap = + nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); + AsyncRequestContext requestContext = + new AsyncRequestContext<>(requestType, new Object(), nodeLocationMap); + // do the test + sendRequest.accept(requestContext); + // collect result + Map anotherNodeLocationMap = + nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); + List results = new ArrayList<>(); + requestContext + .getResponseMap() + .forEach( + (nodeId, status) -> { + TEndPoint endPoint = getEndPoint.apply(anotherNodeLocationMap.get(nodeId)); + TServiceProvider serviceProvider = new TServiceProvider(endPoint, serviceType); + TTestConnectionResult result = new TTestConnectionResult(); + result.setSender(sender); + result.setServiceProvider(serviceProvider); + if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { + result.setSuccess(true); + } else { + result.setSuccess(false); + result.setReason(status.getMessage()); + } + results.add(result); + }); + return results; + } } From baf1be95ee2c929a342a81018d983c68105b5fdc Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 16:53:58 +0800 Subject: [PATCH 39/52] self review --- .../client/sync/SyncConfigNodeClientPool.java | 5 +++++ .../iotdb/confignode/manager/ClusterManager.java | 15 ++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java index 0790744f110c..afbbb8eb7ea4 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java @@ -21,6 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TNodeLocations; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq; import org.apache.iotdb.commons.client.ClientPoolFactory; @@ -91,6 +92,10 @@ public Object sendSyncRequestToConfigNodeWithRetry( return client.stopConfigNode((TConfigNodeLocation) req); case SET_CONFIGURATION: return client.setConfiguration((TSetConfigurationReq) req); + case SUBMIT_TEST_CONNECTION_TASK: + return client.submitTestConnectionTask((TNodeLocations) req); + case TEST_CONNECTION: + return client.testConnectionEmptyRPC(); default: return RpcUtils.getStatus( TSStatusCode.EXECUTE_STATEMENT_ERROR, "Unknown request type: " + requestType); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 1844bcea6290..77a879f5eb49 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -115,20 +115,21 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { configManager.getNodeManager().getRegisteredDataNodes().stream() .map(TDataNodeConfiguration::getLocation) .collect(Collectors.toList())); + // For ConfigNode Map configNodeLocationMap = configManager.getNodeManager().getRegisteredConfigNodes().stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - ConfigNodeAsyncRequestContext configNodeClientHandler = + ConfigNodeAsyncRequestContext configNodeAsyncRequestContext = new ConfigNodeAsyncRequestContext<>( ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequest(configNodeClientHandler); + .sendAsyncRequest(configNodeAsyncRequestContext); Map anotherConfigNodeLocationMap = configManager.getNodeManager().getRegisteredConfigNodes().stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - configNodeClientHandler + configNodeAsyncRequestContext .getResponseMap() .forEach( (nodeId, configNodeResp) -> { @@ -141,23 +142,23 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { anotherConfigNodeLocationMap.get(nodeId), nodeLocations)); } }); + // For DataNode Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodes().stream() .map(TDataNodeConfiguration::getLocation) .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - DataNodeAsyncRequestContext dataNodeClientHandler = + DataNodeAsyncRequestContext dataNodeAsyncRequestContext = new DataNodeAsyncRequestContext<>( ConfigNodeToDataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequest(dataNodeClientHandler); + .sendAsyncRequest(dataNodeAsyncRequestContext); Map anotherDataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodes().stream() .map(TDataNodeConfiguration::getLocation) .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); - ; - dataNodeClientHandler + dataNodeAsyncRequestContext .getResponseMap() .forEach( (nodeId, dataNodeResp) -> { From c78a149dc4a3c2fa7d529703627402f0489ac4c4 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 16:54:19 +0800 Subject: [PATCH 40/52] self review --- .../iotdb/confignode/manager/ClusterManager.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 77a879f5eb49..430a4d812469 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -119,11 +119,12 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { Map configNodeLocationMap = configManager.getNodeManager().getRegisteredConfigNodes().stream() .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, location -> location)); - ConfigNodeAsyncRequestContext configNodeAsyncRequestContext = - new ConfigNodeAsyncRequestContext<>( - ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, - nodeLocations, - configNodeLocationMap); + ConfigNodeAsyncRequestContext + configNodeAsyncRequestContext = + new ConfigNodeAsyncRequestContext<>( + ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + nodeLocations, + configNodeLocationMap); ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequest(configNodeAsyncRequestContext); Map anotherConfigNodeLocationMap = From fa57ba058644581951a9959192fd1a4ed84f936a Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 17:10:58 +0800 Subject: [PATCH 41/52] fix mpp --- .../client/dn/DataNodeMPPServiceAsyncRequestManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java index c75ad83da81e..49614d4477fb 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java @@ -58,7 +58,7 @@ protected void initActionMapBuilder() { @Override protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { - return null; + return dataNodeLocation.getMPPDataExchangeEndPoint(); } @Override From b6c76adc0327f711de19066a24a58d05b01b3bbd Mon Sep 17 00:00:00 2001 From: liyuheng Date: Wed, 12 Jun 2024 18:06:36 +0800 Subject: [PATCH 42/52] support verify connection details --- .../apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 2 +- .../execution/config/ConfigTaskVisitor.java | 2 +- .../executor/ClusterConfigTaskExecutor.java | 12 ++-- .../config/executor/IConfigTaskExecutor.java | 2 +- .../config/sys/TestConnectionTask.java | 61 ++++++++++++++++++- .../queryengine/plan/parser/ASTVisitor.java | 2 +- .../sys/TestConnectionStatement.java | 10 +++ 7 files changed, 79 insertions(+), 12 deletions(-) diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 index 6094e92c0690..191c18889fb9 100644 --- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 +++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 @@ -525,7 +525,7 @@ migrateRegion ; verifyConnection - : VERIFY CONNECTION + : VERIFY CONNECTION (DETAILS)? ; // Pipe Task ========================================================================================= diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java index f9e1253e016f..e9b36c80c914 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java @@ -245,7 +245,7 @@ public IConfigTask visitShowClusterId( @Override public IConfigTask visitTestConnection( TestConnectionStatement testConnectionStatement, MPPQueryContext context) { - return new TestConnectionTask(); + return new TestConnectionTask(testConnectionStatement.needDetails()); } @Override diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java index 169d40b950ea..538337ffa164 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java @@ -1291,15 +1291,17 @@ public SettableFuture showClusterId() { } @Override - public SettableFuture testConnection() { + public SettableFuture testConnection(boolean needDetails) { SettableFuture future = SettableFuture.create(); try (ConfigNodeClient client = CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) { - // TODO: now sync, maybe async in future TTestConnectionResp result = client.submitTestConnectionTaskToLeader(); - int configNodeNum = client.showConfigNodes().getConfigNodesInfoListSize(); - int dataNodeNum = client.showDataNodes().getDataNodesInfoListSize(); - TestConnectionTask.buildTSBlock(result, configNodeNum, dataNodeNum, future); + int configNodeNum = 0, dataNodeNum = 0; + if (!needDetails) { + configNodeNum = client.showConfigNodes().getConfigNodesInfoListSize(); + dataNodeNum = client.showDataNodes().getDataNodesInfoListSize(); + } + TestConnectionTask.buildTSBlock(result, configNodeNum, dataNodeNum, needDetails, future); } catch (Exception e) { future.setException(e); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java index 1eac0f4f94a6..05ad88bfc5e9 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java @@ -135,7 +135,7 @@ public interface IConfigTaskExecutor { SettableFuture showClusterId(); - SettableFuture testConnection(); + SettableFuture testConnection(boolean needDetails); SettableFuture showTTL(ShowTTLStatement showTTLStatement); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index 13be48cb6b1a..c208b35f9f44 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -20,7 +20,9 @@ package org.apache.iotdb.db.queryengine.plan.execution.config.sys; import org.apache.iotdb.common.rpc.thrift.TEndPoint; +import org.apache.iotdb.common.rpc.thrift.TSender; import org.apache.iotdb.common.rpc.thrift.TServiceProvider; +import org.apache.iotdb.common.rpc.thrift.TServiceType; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.db.queryengine.common.header.ColumnHeader; @@ -38,29 +40,70 @@ import org.apache.tsfile.read.common.block.TsBlockBuilder; import org.apache.tsfile.utils.Binary; +import java.util.ArrayList; import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; public class TestConnectionTask implements IConfigTask { + private final boolean needDetails; + + public TestConnectionTask(boolean needDetails) { + this.needDetails = needDetails; + } + @Override public ListenableFuture execute(IConfigTaskExecutor configTaskExecutor) throws InterruptedException { - return configTaskExecutor.testConnection(); + return configTaskExecutor.testConnection(needDetails); } public static void buildTSBlock( TTestConnectionResp resp, int configNodeNum, int dataNodeNum, + boolean needDetails, SettableFuture future) { + sortTestConnectionResp(resp); + if (!needDetails) { + Map expectedNumMap = + calculateExpectedResultNum(configNodeNum, dataNodeNum); + List newResultList = new ArrayList<>(); + for (int i = 0; i < resp.getResultListSize(); ) { + TTestConnectionResult result = resp.getResultList().get(i); + final int expectNum = expectedNumMap.get(result.getServiceProvider().getServiceType()); + final boolean allSameServiceProviderAllUp = + resp.getResultList().stream() + .skip(i) + .limit(expectNum) + .allMatch( + result1 -> + result.getServiceProvider().equals(result1.serviceProvider) + && result1.isSuccess()); + if (allSameServiceProviderAllUp) { + TTestConnectionResult allUpResult = new TTestConnectionResult(result); + allUpResult.setSender(new TSender()); + newResultList.add(allUpResult); + } else { + newResultList.addAll( + resp.getResultList().stream() + .skip(i) + .limit(expectNum) + .filter(result1 -> !result1.isSuccess()) + .collect(Collectors.toList())); + } + i += expectNum; + } + resp.setResultList(newResultList); + } List outputDataTypes = ColumnHeaderConstant.testConnectionColumnHeaders.stream() .map(ColumnHeader::getColumnType) .collect(Collectors.toList()); TsBlockBuilder builder = new TsBlockBuilder(outputDataTypes); - sortTestConnectionResp(resp); int maxLen = calculateServiceProviderMaxLen(resp); for (TTestConnectionResult result : resp.getResultList()) { // ServiceProvider column @@ -79,10 +122,12 @@ public static void buildTSBlock( senderStr = endPointToString(result.getSender().getConfigNodeLocation().getInternalEndPoint()); senderStr += " (ConfigNode)"; - } else { + } else if (result.getSender().isSetDataNodeLocation()) { senderStr = endPointToString(result.getSender().getDataNodeLocation().getInternalEndPoint()); senderStr += " (DataNode)"; + } else { + senderStr = "All"; } builder.getColumnBuilder(1).writeBinary(new Binary(senderStr, TSFileConfig.STRING_CHARSET)); // Connection column @@ -106,6 +151,16 @@ public static void buildTSBlock( DatasetHeaderFactory.getTestConnectionHeader())); } + private static Map calculateExpectedResultNum( + int configNodeNum, int dataNodeNum) { + Map result = new HashMap<>(); + result.put(TServiceType.ConfigNodeInternalService, configNodeNum + dataNodeNum); + result.put(TServiceType.DataNodeInternalService, configNodeNum + dataNodeNum); + result.put(TServiceType.DataNodeMPPService, dataNodeNum); + result.put(TServiceType.DataNodeExternalService, dataNodeNum); + return result; + } + private static String serviceProviderToString(TServiceProvider provider) { String serviceStr = endPointToString(provider.getEndPoint()); serviceStr += " (" + provider.getServiceType() + ")"; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java index 321437150db2..2df3eb2d299f 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java @@ -4016,7 +4016,7 @@ public Statement visitMigrateRegion(IoTDBSqlParser.MigrateRegionContext ctx) { @Override public Statement visitVerifyConnection(IoTDBSqlParser.VerifyConnectionContext ctx) { - return new TestConnectionStatement(); + return new TestConnectionStatement(ctx.DETAILS() != null); } // Quota diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/TestConnectionStatement.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/TestConnectionStatement.java index 280febd80545..2e01ea151dc2 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/TestConnectionStatement.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/TestConnectionStatement.java @@ -30,6 +30,16 @@ import java.util.List; public class TestConnectionStatement extends Statement implements IConfigStatement { + private boolean needDetails; + + public TestConnectionStatement(boolean needDetails) { + this.needDetails = needDetails; + } + + public boolean needDetails() { + return needDetails; + } + @Override public QueryType getQueryType() { return QueryType.READ; From 78fd70089dfe00779c70a4795ec64fedc88043ff Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 13 Jun 2024 11:01:23 +0800 Subject: [PATCH 43/52] optimize --- .../confignode/manager/ClusterManager.java | 35 +++++++++++++++- .../config/sys/TestConnectionTask.java | 42 ++++++++++++------- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 430a4d812469..dd87537e061f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -237,6 +237,7 @@ private List badDataNodeConnectionResult( private List badNodeConnectionResult( TNodeLocations nodeLocations, TSender sender) { + final String errorMessage = "ConfigNode leader cannot connect to the sender"; List results = new ArrayList<>(); nodeLocations .getConfigNodeLocations() @@ -247,7 +248,7 @@ private List badNodeConnectionResult( new TServiceProvider(endPoint, TServiceType.ConfigNodeInternalService); TTestConnectionResult result = new TTestConnectionResult().setServiceProvider(serviceProvider).setSender(sender); - result.setSuccess(false).setReason("Cannot get verification result"); + result.setSuccess(false).setReason(errorMessage); results.add(result); }); nodeLocations @@ -259,9 +260,39 @@ private List badNodeConnectionResult( new TServiceProvider(endPoint, TServiceType.DataNodeInternalService); TTestConnectionResult result = new TTestConnectionResult().setServiceProvider(serviceProvider).setSender(sender); - result.setSuccess(false).setReason("Cannot get verification result"); + result.setSuccess(false).setReason(errorMessage); results.add(result); }); + if (sender.isSetDataNodeLocation()) { + nodeLocations + .getDataNodeLocations() + .forEach( + location -> { + TEndPoint endPoint = location.getMPPDataExchangeEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeMPPService); + TTestConnectionResult result = + new TTestConnectionResult() + .setServiceProvider(serviceProvider) + .setSender(sender); + result.setSuccess(false).setReason(errorMessage); + results.add(result); + }); + nodeLocations + .getDataNodeLocations() + .forEach( + location -> { + TEndPoint endPoint = location.getClientRpcEndPoint(); + TServiceProvider serviceProvider = + new TServiceProvider(endPoint, TServiceType.DataNodeExternalService); + TTestConnectionResult result = + new TTestConnectionResult() + .setServiceProvider(serviceProvider) + .setSender(sender); + result.setSuccess(false).setReason(errorMessage); + results.add(result); + }); + } return results; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index c208b35f9f44..9d24373019f8 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -41,7 +41,6 @@ import org.apache.tsfile.utils.Binary; import java.util.ArrayList; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -104,13 +103,14 @@ public static void buildTSBlock( .map(ColumnHeader::getColumnType) .collect(Collectors.toList()); TsBlockBuilder builder = new TsBlockBuilder(outputDataTypes); - int maxLen = calculateServiceProviderMaxLen(resp); + int serviceProviderMaxLen = calculateServiceProviderMaxLen(resp); + int connectionMaxLen = calculateConnectionMaxLen(resp); for (TTestConnectionResult result : resp.getResultList()) { // ServiceProvider column builder.getTimeColumnBuilder().writeLong(0); StringBuilder serviceStr = new StringBuilder(serviceProviderToString(result.getServiceProvider())); - while (serviceStr.length() < maxLen) { + while (serviceStr.length() < serviceProviderMaxLen) { serviceStr.append(" "); } builder @@ -131,16 +131,13 @@ public static void buildTSBlock( } builder.getColumnBuilder(1).writeBinary(new Binary(senderStr, TSFileConfig.STRING_CHARSET)); // Connection column - String connectionStatus; - if (result.isSuccess()) { - connectionStatus = "up"; - } else { - // connectionStatus = addLineBreak("down" + " (" + result.getReason() + ")", 60); - connectionStatus = "down" + " (" + result.getReason() + ")"; + StringBuilder connectionStatus = new StringBuilder(connectionResultToString(result)); + while (connectionStatus.length() < connectionMaxLen) { + connectionStatus.append(" "); } builder .getColumnBuilder(2) - .writeBinary(new Binary(connectionStatus, TSFileConfig.STRING_CHARSET)); + .writeBinary(new Binary(connectionStatus.toString(), TSFileConfig.STRING_CHARSET)); builder.declarePosition(); } @@ -167,6 +164,13 @@ private static String serviceProviderToString(TServiceProvider provider) { return serviceStr; } + private static String connectionResultToString(TTestConnectionResult result) { + if (result.isSuccess()) { + return "up"; + } + return "down" + " (" + result.getReason() + ")"; + } + private static String endPointToString(TEndPoint endPoint) { return endPoint.getIp() + ":" + endPoint.getPort(); } @@ -194,13 +198,21 @@ private static void sortTestConnectionResp(TTestConnectionResp origin) { }); } - private static int calculateServiceProviderMaxLen(TTestConnectionResp origin) { - return origin.getResultList().stream() + private static int calculateServiceProviderMaxLen(TTestConnectionResp resp) { + return resp.getResultList().stream() .map(TTestConnectionResult::getServiceProvider) .map(TestConnectionTask::serviceProviderToString) - .max(Comparator.comparingInt(String::length)) - .get() - .length(); + .mapToInt(String::length) + .max() + .getAsInt(); + } + + private static int calculateConnectionMaxLen(TTestConnectionResp resp) { + return resp.getResultList().stream() + .map(TestConnectionTask::connectionResultToString) + .mapToInt(String::length) + .max() + .getAsInt(); } private static String addLineBreak(String origin, int interval) { From b11b8a3b130b985a67c97e9b136f69f5627b9527 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 13 Jun 2024 18:21:58 +0800 Subject: [PATCH 44/52] ConfigNodeToConfigNode -> CnToCn --- ...stType.java => CnToCnNodeRequestType.java} | 2 +- ...CnInternalServiceAsyncRequestManager.java} | 22 +++++++++---------- .../ConfigNodeAsyncRequestContext.java | 6 ++--- .../rpc/ConfigNodeAsyncRequestRPCHandler.java | 10 ++++----- .../rpc/ConfigNodeTSStatusRPCHandler.java | 4 ++-- ...tConnectionTaskToConfigNodeRPCHandler.java | 4 ++-- .../client/sync/SyncConfigNodeClientPool.java | 4 ++-- .../conf/ConfigNodeRemoveCheck.java | 4 ++-- .../confignode/manager/ClusterManager.java | 14 ++++++------ .../confignode/manager/node/NodeManager.java | 6 ++--- .../procedure/env/ConfigNodeProcedureEnv.java | 10 ++++----- .../iotdb/confignode/service/ConfigNode.java | 4 ++-- .../service/ConfigNodeShutdownHook.java | 4 ++-- 13 files changed, 47 insertions(+), 47 deletions(-) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/{ConfigNodeToConfigNodeRequestType.java => CnToCnNodeRequestType.java} (95%) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/{ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java => CnToCnInternalServiceAsyncRequestManager.java} (72%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToConfigNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java similarity index 95% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToConfigNodeRequestType.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java index 7ebf0756ccf1..3864f26cbc8e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToConfigNodeRequestType.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java @@ -19,7 +19,7 @@ package org.apache.iotdb.confignode.client; -public enum ConfigNodeToConfigNodeRequestType { +public enum CnToCnNodeRequestType { ADD_CONSENSUS_GROUP, NOTIFY_REGISTER_SUCCESS, REGISTER_CONFIG_NODE, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToCnInternalServiceAsyncRequestManager.java similarity index 72% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToCnInternalServiceAsyncRequestManager.java index 1238972dc435..5c7d0f0e3343 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToCnInternalServiceAsyncRequestManager.java @@ -24,7 +24,7 @@ import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; import org.apache.iotdb.commons.client.request.ConfigNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeAsyncRequestRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.ConfigNodeTSStatusRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.SubmitTestConnectionTaskToConfigNodeRPCHandler; @@ -32,29 +32,29 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ConfigNodeToConfigNodeInternalServiceAsyncRequestManager - extends ConfigNodeInternalServiceAsyncRequestManager { +public class CnToCnInternalServiceAsyncRequestManager + extends ConfigNodeInternalServiceAsyncRequestManager { private static final Logger LOGGER = - LoggerFactory.getLogger(ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.class); + LoggerFactory.getLogger(CnToCnInternalServiceAsyncRequestManager.class); @Override protected void initActionMapBuilder() { actionMapBuilder.put( - ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + CnToCnNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, (req, client, handler) -> client.submitTestConnectionTask( (TNodeLocations) req, (SubmitTestConnectionTaskToConfigNodeRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, + CnToCnNodeRequestType.TEST_CONNECTION, (req, client, handler) -> client.testConnectionEmptyRPC((ConfigNodeTSStatusRPCHandler) handler)); } @Override - protected AsyncRequestRPCHandler + protected AsyncRequestRPCHandler buildHandler( - AsyncRequestContext + AsyncRequestContext requestContext, int requestId, TConfigNodeLocation targetNode) { @@ -62,15 +62,15 @@ protected void initActionMapBuilder() { } private static class ClientPoolHolder { - private static final ConfigNodeToConfigNodeInternalServiceAsyncRequestManager INSTANCE = - new ConfigNodeToConfigNodeInternalServiceAsyncRequestManager(); + private static final CnToCnInternalServiceAsyncRequestManager INSTANCE = + new CnToCnInternalServiceAsyncRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static ConfigNodeToConfigNodeInternalServiceAsyncRequestManager getInstance() { + public static CnToCnInternalServiceAsyncRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/ConfigNodeAsyncRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/ConfigNodeAsyncRequestContext.java index 05b9d04e0017..cde2cf1c8ec2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/ConfigNodeAsyncRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/ConfigNodeAsyncRequestContext.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.commons.client.request.AsyncRequestContext; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import java.util.Map; @@ -32,10 +32,10 @@ * @param ClassName of RPC response */ public class ConfigNodeAsyncRequestContext - extends AsyncRequestContext { + extends AsyncRequestContext { public ConfigNodeAsyncRequestContext( - ConfigNodeToConfigNodeRequestType configNodeRequestType, + CnToCnNodeRequestType configNodeRequestType, Q q, Map integerTConfigNodeLocationMap) { super(configNodeRequestType, q, integerTConfigNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java index e3457d2e8235..8da7ca05b7ce 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java @@ -24,17 +24,17 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import java.util.Map; import java.util.concurrent.CountDownLatch; public abstract class ConfigNodeAsyncRequestRPCHandler extends AsyncRequestRPCHandler< - Response, ConfigNodeToConfigNodeRequestType, TConfigNodeLocation> { + Response, CnToCnNodeRequestType, TConfigNodeLocation> { protected ConfigNodeAsyncRequestRPCHandler( - ConfigNodeToConfigNodeRequestType configNodeRequestType, + CnToCnNodeRequestType configNodeRequestType, int requestId, TConfigNodeLocation targetNode, Map integerTConfigNodeLocationMap, @@ -59,10 +59,10 @@ protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeL } public static ConfigNodeAsyncRequestRPCHandler buildHandler( - AsyncRequestContext context, + AsyncRequestContext context, int requestId, TConfigNodeLocation targetConfigNode) { - ConfigNodeToConfigNodeRequestType requestType = context.getRequestType(); + CnToCnNodeRequestType requestType = context.getRequestType(); Map nodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); CountDownLatch countDownLatch = context.getCountDownLatch(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java index 4ade8a14ce1f..a28acb349626 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeTSStatusRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -37,7 +37,7 @@ public class ConfigNodeTSStatusRPCHandler extends ConfigNodeAsyncRequestRPCHandl private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNodeTSStatusRPCHandler.class); public ConfigNodeTSStatusRPCHandler( - ConfigNodeToConfigNodeRequestType requestType, + CnToCnNodeRequestType requestType, int requestId, TConfigNodeLocation targetConfigNode, Map configNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index 0e79334b0c78..34abe94f1e70 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +36,7 @@ public class SubmitTestConnectionTaskToConfigNodeRPCHandler LoggerFactory.getLogger(SubmitTestConnectionTaskToConfigNodeRPCHandler.class); public SubmitTestConnectionTaskToConfigNodeRPCHandler( - ConfigNodeToConfigNodeRequestType requestType, + CnToCnNodeRequestType requestType, int requestId, TConfigNodeLocation targetConfigNode, Map configNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java index afbbb8eb7ea4..302e587af053 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java @@ -28,7 +28,7 @@ import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.confignode.rpc.thrift.TAddConsensusGroupReq; import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeRegisterReq; import org.apache.iotdb.rpc.RpcUtils; @@ -67,7 +67,7 @@ private void updateConfigNodeLeader(TSStatus status) { } public Object sendSyncRequestToConfigNodeWithRetry( - TEndPoint endPoint, Object req, ConfigNodeToConfigNodeRequestType requestType) { + TEndPoint endPoint, Object req, CnToCnNodeRequestType requestType) { Throwable lastException = null; for (int retry = 0; retry < MAX_RETRY_NUM; retry++) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java index d2b658987fda..9c4c480b02ce 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java @@ -25,7 +25,7 @@ import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.commons.exception.BadNodeUrlException; import org.apache.iotdb.commons.utils.NodeUrlUtils; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.rpc.TSStatusCode; @@ -112,7 +112,7 @@ public void removeConfigNode(TConfigNodeLocation removedNode) .sendSyncRequestToConfigNodeWithRetry( configNodeLocation.getInternalEndPoint(), removedNode, - ConfigNodeToConfigNodeRequestType.REMOVE_CONFIG_NODE); + CnToCnNodeRequestType.REMOVE_CONFIG_NODE); if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { break; } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index dd87537e061f..0f5e2701a56b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -32,9 +32,9 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.commons.client.request.Utils; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToConfigNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.async.CnToCnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.ConfigNodeAsyncRequestContext; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; @@ -122,10 +122,10 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { ConfigNodeAsyncRequestContext configNodeAsyncRequestContext = new ConfigNodeAsyncRequestContext<>( - ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + CnToCnNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, configNodeLocationMap); - ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() + CnToCnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequest(configNodeAsyncRequestContext); Map anotherConfigNodeLocationMap = configManager.getNodeManager().getRegisteredConfigNodes().stream() @@ -196,11 +196,11 @@ private List testAllConfigNodeConnection( TConfigNodeLocation::getConfigNodeId, TConfigNodeLocation::getInternalEndPoint, TServiceType.ConfigNodeInternalService, - ConfigNodeToConfigNodeRequestType.TEST_CONNECTION, + CnToCnNodeRequestType.TEST_CONNECTION, (AsyncRequestContext< - Object, TSStatus, ConfigNodeToConfigNodeRequestType, TConfigNodeLocation> + Object, TSStatus, CnToCnNodeRequestType, TConfigNodeLocation> handler) -> - ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() + CnToCnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index 2e0f14da2ba8..66b138e2083e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -35,7 +35,7 @@ import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.consensus.ConsensusGroupId; import org.apache.iotdb.commons.service.metric.MetricService; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; @@ -774,7 +774,7 @@ public List setConfiguration(TSetConfigurationReq req) { .sendSyncRequestToConfigNodeWithRetry( configNode.getInternalEndPoint(), new TSetConfigurationReq(req.getConfigs(), configNode.getConfigNodeId()), - ConfigNodeToConfigNodeRequestType.SET_CONFIGURATION); + CnToCnNodeRequestType.SET_CONFIGURATION); } catch (Exception e) { status = RpcUtils.getStatus( @@ -845,7 +845,7 @@ public TShowConfigurationResp showConfiguration(int nodeId) { .sendSyncRequestToConfigNodeWithRetry( registeredConfigNode.getInternalEndPoint(), nodeId, - ConfigNodeToConfigNodeRequestType.SHOW_CONFIGURATION); + CnToCnNodeRequestType.SHOW_CONFIGURATION); return resp; } return resp; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index bcc41931893f..cae11705deb3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -32,7 +32,7 @@ import org.apache.iotdb.commons.pipe.config.PipeConfig; import org.apache.iotdb.commons.pipe.plugin.meta.PipePluginMeta; import org.apache.iotdb.commons.trigger.TriggerInformation; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; @@ -251,7 +251,7 @@ public void addConsensusGroup(TConfigNodeLocation tConfigNodeLocation) .sendSyncRequestToConfigNodeWithRetry( tConfigNodeLocation.getInternalEndPoint(), new TAddConsensusGroupReq(configNodeLocations), - ConfigNodeToConfigNodeRequestType.ADD_CONSENSUS_GROUP); + CnToCnNodeRequestType.ADD_CONSENSUS_GROUP); if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { throw new AddConsensusGroupException(tConfigNodeLocation); } @@ -315,7 +315,7 @@ public void deleteConfigNodePeer(TConfigNodeLocation removedConfigNode) .sendSyncRequestToConfigNodeWithRetry( removedConfigNode.getInternalEndPoint(), removedConfigNode, - ConfigNodeToConfigNodeRequestType.DELETE_CONFIG_NODE_PEER); + CnToCnNodeRequestType.DELETE_CONFIG_NODE_PEER); if (tsStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { throw new ProcedureException(tsStatus.getMessage()); } @@ -334,7 +334,7 @@ public void stopConfigNode(TConfigNodeLocation tConfigNodeLocation) throws Proce .sendSyncRequestToConfigNodeWithRetry( tConfigNodeLocation.getInternalEndPoint(), tConfigNodeLocation, - ConfigNodeToConfigNodeRequestType.STOP_CONFIG_NODE); + CnToCnNodeRequestType.STOP_CONFIG_NODE); if (tsStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { throw new ProcedureException(tsStatus.getMessage()); @@ -364,7 +364,7 @@ public void notifyRegisterSuccess(TConfigNodeLocation configNodeLocation) { .sendSyncRequestToConfigNodeWithRetry( configNodeLocation.getInternalEndPoint(), null, - ConfigNodeToConfigNodeRequestType.NOTIFY_REGISTER_SUCCESS); + CnToCnNodeRequestType.NOTIFY_REGISTER_SUCCESS); } /** diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java index 0c22b5eda9fb..3d537cdec61f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNode.java @@ -38,7 +38,7 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.service.metric.cpu.CpuUsageMetrics; import org.apache.iotdb.commons.utils.TestOnly; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeConstant; @@ -339,7 +339,7 @@ private void sendRegisterConfigNodeRequest() throws StartupException, IOExceptio Object obj = SyncConfigNodeClientPool.getInstance() .sendSyncRequestToConfigNodeWithRetry( - seedConfigNode, req, ConfigNodeToConfigNodeRequestType.REGISTER_CONFIG_NODE); + seedConfigNode, req, CnToCnNodeRequestType.REGISTER_CONFIG_NODE); if (obj instanceof TConfigNodeRegisterResp) { resp = (TConfigNodeRegisterResp) obj; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeShutdownHook.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeShutdownHook.java index 4c0cc21a905f..5c3ec5af0632 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeShutdownHook.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeShutdownHook.java @@ -24,7 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.cluster.NodeStatus; import org.apache.iotdb.commons.conf.CommonDescriptor; -import org.apache.iotdb.confignode.client.ConfigNodeToConfigNodeRequestType; +import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeConstant; @@ -71,7 +71,7 @@ public void run() { CONF.getConfigNodeId(), new TEndPoint(CONF.getInternalAddress(), CONF.getInternalPort()), new TEndPoint(CONF.getInternalAddress(), CONF.getConsensusPort())), - ConfigNodeToConfigNodeRequestType.REPORT_CONFIG_NODE_SHUTDOWN); + CnToCnNodeRequestType.REPORT_CONFIG_NODE_SHUTDOWN); if (result.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { // Report success From 5b0ed9e3ebd7d90311e09272e6855b4d89d87ab4 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 13 Jun 2024 18:22:54 +0800 Subject: [PATCH 45/52] CnToDn --- ...equestType.java => CnToDnRequestType.java} | 2 +- ...DnInternalServiceAsyncRequestManager.java} | 130 +++++++++--------- .../handlers/DataNodeAsyncRequestContext.java | 10 +- .../CheckTimeSeriesExistenceRPCHandler.java | 4 +- .../CountPathsUsingTemplateRPCHandler.java | 4 +- .../rpc/DataNodeAsyncRequestRPCHandler.java | 10 +- .../rpc/DataNodeTSStatusRPCHandler.java | 4 +- .../rpc/FetchSchemaBlackListRPCHandler.java | 4 +- .../handlers/rpc/PipeHeartbeatRPCHandler.java | 4 +- .../handlers/rpc/PipePushMetaRPCHandler.java | 4 +- .../handlers/rpc/SchemaUpdateRPCHandler.java | 4 +- .../SubmitTestConnectionTaskRPCHandler.java | 4 +- .../rpc/TransferLeaderRPCHandler.java | 4 +- ...ckSchemaRegionUsingTemplateRPCHandler.java | 4 +- .../ConsumerGroupPushMetaRPCHandler.java | 4 +- .../subscription/TopicPushMetaRPCHandler.java | 4 +- .../client/sync/SyncDataNodeClientPool.java | 8 +- .../confignode/manager/ClusterManager.java | 14 +- .../manager/ClusterQuotaManager.java | 12 +- .../confignode/manager/TriggerManager.java | 8 +- .../iotdb/confignode/manager/UDFManager.java | 12 +- .../confignode/manager/cq/CQScheduleTask.java | 4 +- .../manager/load/balancer/RouteBalancer.java | 12 +- .../confignode/manager/node/NodeManager.java | 46 +++---- .../manager/partition/PartitionManager.java | 16 +-- .../heartbeat/PipeHeartbeatScheduler.java | 8 +- .../manager/schema/ClusterSchemaManager.java | 8 +- .../procedure/env/ConfigNodeProcedureEnv.java | 94 ++++++------- .../procedure/env/RegionMaintainHandler.java | 22 +-- .../schema/AlterLogicalViewProcedure.java | 12 +- .../schema/DataNodeRegionTaskExecutor.java | 12 +- .../schema/DeactivateTemplateProcedure.java | 20 +-- .../impl/schema/DeleteDatabaseProcedure.java | 8 +- .../schema/DeleteLogicalViewProcedure.java | 16 +-- .../schema/DeleteTimeSeriesProcedure.java | 20 +-- .../procedure/impl/schema/SchemaUtils.java | 6 +- .../impl/schema/SetTTLProcedure.java | 8 +- .../impl/schema/SetTemplateProcedure.java | 18 +-- .../impl/schema/UnsetTemplateProcedure.java | 12 +- .../impl/sync/AuthOperationProcedure.java | 4 +- 40 files changed, 300 insertions(+), 300 deletions(-) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/{ConfigNodeToDataNodeRequestType.java => CnToDnRequestType.java} (98%) rename iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/{ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java => CnToDnInternalServiceAsyncRequestManager.java} (78%) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToDataNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToDnRequestType.java similarity index 98% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToDataNodeRequestType.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToDnRequestType.java index 7505248e1c8c..bc7307282573 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeToDataNodeRequestType.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToDnRequestType.java @@ -19,7 +19,7 @@ package org.apache.iotdb.confignode.client; -public enum ConfigNodeToDataNodeRequestType { +public enum CnToDnRequestType { // Node Maintenance DISABLE_DATA_NODE, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToDnInternalServiceAsyncRequestManager.java similarity index 78% rename from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java rename to iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToDnInternalServiceAsyncRequestManager.java index d577444932e0..7eaf88a07ce0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/ConfigNodeToDataNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToDnInternalServiceAsyncRequestManager.java @@ -30,7 +30,7 @@ import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; import org.apache.iotdb.commons.client.request.DataNodeInternalServiceRequestManager; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.CheckTimeSeriesExistenceRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.CountPathsUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; @@ -89,273 +89,273 @@ import org.slf4j.LoggerFactory; /** Asynchronously send RPC requests to DataNodes. See queryengine.thrift for more details. */ -public class ConfigNodeToDataNodeInternalServiceAsyncRequestManager - extends DataNodeInternalServiceRequestManager { +public class CnToDnInternalServiceAsyncRequestManager + extends DataNodeInternalServiceRequestManager { private static final Logger LOGGER = - LoggerFactory.getLogger(ConfigNodeToDataNodeInternalServiceAsyncRequestManager.class); + LoggerFactory.getLogger(CnToDnInternalServiceAsyncRequestManager.class); @Override protected void initActionMapBuilder() { actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.SET_TTL, + CnToDnRequestType.SET_TTL, (req, client, handler) -> client.setTTL((TSetTTLReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION, + CnToDnRequestType.CREATE_DATA_REGION, (req, client, handler) -> client.createDataRegion( (TCreateDataRegionReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.DELETE_REGION, + CnToDnRequestType.DELETE_REGION, (req, client, handler) -> client.deleteRegion((TConsensusGroupId) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION, + CnToDnRequestType.CREATE_SCHEMA_REGION, (req, client, handler) -> client.createSchemaRegion( (TCreateSchemaRegionReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CREATE_FUNCTION, + CnToDnRequestType.CREATE_FUNCTION, (req, client, handler) -> client.createFunction( (TCreateFunctionInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.DROP_FUNCTION, + CnToDnRequestType.DROP_FUNCTION, (req, client, handler) -> client.dropFunction( (TDropFunctionInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CREATE_TRIGGER_INSTANCE, + CnToDnRequestType.CREATE_TRIGGER_INSTANCE, (req, client, handler) -> client.createTriggerInstance( (TCreateTriggerInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.DROP_TRIGGER_INSTANCE, + CnToDnRequestType.DROP_TRIGGER_INSTANCE, (req, client, handler) -> client.dropTriggerInstance( (TDropTriggerInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, + CnToDnRequestType.ACTIVE_TRIGGER_INSTANCE, (req, client, handler) -> client.activeTriggerInstance( (TActiveTriggerInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, + CnToDnRequestType.INACTIVE_TRIGGER_INSTANCE, (req, client, handler) -> client.inactiveTriggerInstance( (TInactiveTriggerInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.UPDATE_TRIGGER_LOCATION, + CnToDnRequestType.UPDATE_TRIGGER_LOCATION, (req, client, handler) -> client.updateTriggerLocation( (TUpdateTriggerLocationReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CREATE_PIPE_PLUGIN, + CnToDnRequestType.CREATE_PIPE_PLUGIN, (req, client, handler) -> client.createPipePlugin( (TCreatePipePluginInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.DROP_PIPE_PLUGIN, + CnToDnRequestType.DROP_PIPE_PLUGIN, (req, client, handler) -> client.dropPipePlugin( (TDropPipePluginInstanceReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.PIPE_PUSH_ALL_META, + CnToDnRequestType.PIPE_PUSH_ALL_META, (req, client, handler) -> client.pushPipeMeta((TPushPipeMetaReq) req, (PipePushMetaRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.PIPE_PUSH_SINGLE_META, + CnToDnRequestType.PIPE_PUSH_SINGLE_META, (req, client, handler) -> client.pushSinglePipeMeta( (TPushSinglePipeMetaReq) req, (PipePushMetaRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.PIPE_PUSH_MULTI_META, + CnToDnRequestType.PIPE_PUSH_MULTI_META, (req, client, handler) -> client.pushMultiPipeMeta( (TPushMultiPipeMetaReq) req, (PipePushMetaRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.TOPIC_PUSH_ALL_META, + CnToDnRequestType.TOPIC_PUSH_ALL_META, (req, client, handler) -> client.pushTopicMeta((TPushTopicMetaReq) req, (TopicPushMetaRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, + CnToDnRequestType.TOPIC_PUSH_SINGLE_META, (req, client, handler) -> client.pushSingleTopicMeta( (TPushSingleTopicMetaReq) req, (TopicPushMetaRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.TOPIC_PUSH_MULTI_META, + CnToDnRequestType.TOPIC_PUSH_MULTI_META, (req, client, handler) -> client.pushMultiTopicMeta( (TPushMultiTopicMetaReq) req, (TopicPushMetaRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, + CnToDnRequestType.CONSUMER_GROUP_PUSH_ALL_META, (req, client, handler) -> client.pushConsumerGroupMeta( (TPushConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, + CnToDnRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, (req, client, handler) -> client.pushSingleConsumerGroupMeta( (TPushSingleConsumerGroupMetaReq) req, (ConsumerGroupPushMetaRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.PIPE_HEARTBEAT, + CnToDnRequestType.PIPE_HEARTBEAT, (req, client, handler) -> client.pipeHeartbeat((TPipeHeartbeatReq) req, (PipeHeartbeatRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.MERGE, + CnToDnRequestType.MERGE, (req, client, handler) -> client.merge((DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.FULL_MERGE, + CnToDnRequestType.FULL_MERGE, (req, client, handler) -> client.merge((DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.FLUSH, + CnToDnRequestType.FLUSH, (req, client, handler) -> client.flush((TFlushReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CLEAR_CACHE, + CnToDnRequestType.CLEAR_CACHE, (req, client, handler) -> client.clearCache((DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.START_REPAIR_DATA, + CnToDnRequestType.START_REPAIR_DATA, (req, client, handler) -> client.startRepairData((DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.STOP_REPAIR_DATA, + CnToDnRequestType.STOP_REPAIR_DATA, (req, client, handler) -> client.stopRepairData((DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.LOAD_CONFIGURATION, + CnToDnRequestType.LOAD_CONFIGURATION, (req, client, handler) -> client.loadConfiguration((DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS, + CnToDnRequestType.SET_SYSTEM_STATUS, (req, client, handler) -> client.setSystemStatus((String) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.SET_CONFIGURATION, + CnToDnRequestType.SET_CONFIGURATION, (req, client, handler) -> client.setConfiguration( (TSetConfigurationReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.UPDATE_REGION_ROUTE_MAP, + CnToDnRequestType.UPDATE_REGION_ROUTE_MAP, (req, client, handler) -> client.updateRegionCache((TRegionRouteReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CHANGE_REGION_LEADER, + CnToDnRequestType.CHANGE_REGION_LEADER, (req, client, handler) -> client.changeRegionLeader( (TRegionLeaderChangeReq) req, (TransferLeaderRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST, + CnToDnRequestType.CONSTRUCT_SCHEMA_BLACK_LIST, (req, client, handler) -> client.constructSchemaBlackList( (TConstructSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST, + CnToDnRequestType.ROLLBACK_SCHEMA_BLACK_LIST, (req, client, handler) -> client.rollbackSchemaBlackList( (TRollbackSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.FETCH_SCHEMA_BLACK_LIST, + CnToDnRequestType.FETCH_SCHEMA_BLACK_LIST, (req, client, handler) -> client.fetchSchemaBlackList( (TFetchSchemaBlackListReq) req, (FetchSchemaBlackListRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, (req, client, handler) -> client.invalidateMatchedSchemaCache( (TInvalidateMatchedSchemaCacheReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, + CnToDnRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, (req, client, handler) -> client.deleteDataForDeleteSchema( (TDeleteDataForDeleteSchemaReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.DELETE_TIMESERIES, + CnToDnRequestType.DELETE_TIMESERIES, (req, client, handler) -> client.deleteTimeSeries((TDeleteTimeSeriesReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + CnToDnRequestType.CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, (req, client, handler) -> client.constructSchemaBlackListWithTemplate( (TConstructSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + CnToDnRequestType.ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, (req, client, handler) -> client.rollbackSchemaBlackListWithTemplate( (TRollbackSchemaBlackListWithTemplateReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.DEACTIVATE_TEMPLATE, + CnToDnRequestType.DEACTIVATE_TEMPLATE, (req, client, handler) -> client.deactivateTemplate( (TDeactivateTemplateReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + CnToDnRequestType.UPDATE_TEMPLATE, (req, client, handler) -> client.updateTemplate((TUpdateTemplateReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.COUNT_PATHS_USING_TEMPLATE, + CnToDnRequestType.COUNT_PATHS_USING_TEMPLATE, (req, client, handler) -> client.countPathsUsingTemplate( (TCountPathsUsingTemplateReq) req, (CountPathsUsingTemplateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CHECK_SCHEMA_REGION_USING_TEMPLATE, + CnToDnRequestType.CHECK_SCHEMA_REGION_USING_TEMPLATE, (req, client, handler) -> client.checkSchemaRegionUsingTemplate( (TCheckSchemaRegionUsingTemplateReq) req, (CheckSchemaRegionUsingTemplateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CHECK_TIMESERIES_EXISTENCE, + CnToDnRequestType.CHECK_TIMESERIES_EXISTENCE, (req, client, handler) -> client.checkTimeSeriesExistence( (TCheckTimeSeriesExistenceReq) req, (CheckTimeSeriesExistenceRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, + CnToDnRequestType.CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, (req, client, handler) -> client.constructViewSchemaBlackList( (TConstructViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.ROLLBACK_VIEW_SCHEMA_BLACK_LIST, + CnToDnRequestType.ROLLBACK_VIEW_SCHEMA_BLACK_LIST, (req, client, handler) -> client.rollbackViewSchemaBlackList( (TRollbackViewSchemaBlackListReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.DELETE_VIEW, + CnToDnRequestType.DELETE_VIEW, (req, client, handler) -> client.deleteViewSchema((TDeleteViewSchemaReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.ALTER_VIEW, + CnToDnRequestType.ALTER_VIEW, (req, client, handler) -> client.alterView((TAlterViewReq) req, (SchemaUpdateRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.KILL_QUERY_INSTANCE, + CnToDnRequestType.KILL_QUERY_INSTANCE, (req, client, handler) -> client.killQueryInstance((String) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.SET_SPACE_QUOTA, + CnToDnRequestType.SET_SPACE_QUOTA, (req, client, handler) -> client.setSpaceQuota((TSetSpaceQuotaReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.SET_THROTTLE_QUOTA, + CnToDnRequestType.SET_THROTTLE_QUOTA, (req, client, handler) -> client.setThrottleQuota( (TSetThrottleQuotaReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.RESET_PEER_LIST, + CnToDnRequestType.RESET_PEER_LIST, (req, client, handler) -> client.resetPeerList((TResetPeerListReq) req, (DataNodeTSStatusRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + CnToDnRequestType.SUBMIT_TEST_CONNECTION_TASK, (req, client, handler) -> client.submitTestConnectionTask( (TNodeLocations) req, (SubmitTestConnectionTaskRPCHandler) handler)); actionMapBuilder.put( - ConfigNodeToDataNodeRequestType.TEST_CONNECTION, + CnToDnRequestType.TEST_CONNECTION, (req, client, handler) -> client.testConnectionEmptyRPC((DataNodeTSStatusRPCHandler) handler)); } @Override - protected AsyncRequestRPCHandler + protected AsyncRequestRPCHandler buildHandler( - AsyncRequestContext + AsyncRequestContext requestContext, int requestId, TDataNodeLocation targetNode) { @@ -364,15 +364,15 @@ protected void initActionMapBuilder() { private static class ClientPoolHolder { - private static final ConfigNodeToDataNodeInternalServiceAsyncRequestManager INSTANCE = - new ConfigNodeToDataNodeInternalServiceAsyncRequestManager(); + private static final CnToDnInternalServiceAsyncRequestManager INSTANCE = + new CnToDnInternalServiceAsyncRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static ConfigNodeToDataNodeInternalServiceAsyncRequestManager getInstance() { + public static CnToDnInternalServiceAsyncRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java index f885df078d38..4c5f9058661c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.commons.client.request.AsyncRequestContext; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import java.util.Map; @@ -32,20 +32,20 @@ * @param ClassName of RPC response */ public class DataNodeAsyncRequestContext - extends AsyncRequestContext { + extends AsyncRequestContext { - public DataNodeAsyncRequestContext(ConfigNodeToDataNodeRequestType requestType) { + public DataNodeAsyncRequestContext(CnToDnRequestType requestType) { super(requestType); } public DataNodeAsyncRequestContext( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, Map dataNodeLocationMap) { super(requestType, dataNodeLocationMap); } public DataNodeAsyncRequestContext( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, Q q, Map dataNodeLocationMap) { super(requestType, q, dataNodeLocationMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java index 23a71dc6f855..b12ba289f1c2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CheckTimeSeriesExistenceRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.mpp.rpc.thrift.TCheckTimeSeriesExistenceResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -39,7 +39,7 @@ public class CheckTimeSeriesExistenceRPCHandler LoggerFactory.getLogger(CheckTimeSeriesExistenceRPCHandler.class); public CheckTimeSeriesExistenceRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java index b24466d36149..f2ed0cc425c5 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/CountPathsUsingTemplateRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.mpp.rpc.thrift.TCountPathsUsingTemplateResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -39,7 +39,7 @@ public class CountPathsUsingTemplateRPCHandler LoggerFactory.getLogger(CountPathsUsingTemplateRPCHandler.class); public CountPathsUsingTemplateRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java index c286253c9247..f14a2365a9b3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeAsyncRequestRPCHandler.java @@ -24,7 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.commons.client.request.AsyncRequestRPCHandler; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.CheckSchemaRegionUsingTemplateRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.ConsumerGroupPushMetaRPCHandler; import org.apache.iotdb.confignode.client.async.handlers.rpc.subscription.TopicPushMetaRPCHandler; @@ -42,10 +42,10 @@ import java.util.concurrent.CountDownLatch; public abstract class DataNodeAsyncRequestRPCHandler - extends AsyncRequestRPCHandler { + extends AsyncRequestRPCHandler { protected DataNodeAsyncRequestRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetNode, Map dataNodeLocationMap, @@ -70,10 +70,10 @@ protected String generateFormattedTargetLocation(TDataNodeLocation dataNodeLocat } public static DataNodeAsyncRequestRPCHandler buildHandler( - AsyncRequestContext context, + AsyncRequestContext context, int requestId, TDataNodeLocation targetDataNode) { - ConfigNodeToDataNodeRequestType requestType = context.getRequestType(); + CnToDnRequestType requestType = context.getRequestType(); Map dataNodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); CountDownLatch countDownLatch = context.getCountDownLatch(); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java index 1833ff4d2df0..19d451eb671f 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -37,7 +37,7 @@ public class DataNodeTSStatusRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java index dad755f0bfe9..45c659298ca3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/FetchSchemaBlackListRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.mpp.rpc.thrift.TFetchSchemaBlackListResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -39,7 +39,7 @@ public class FetchSchemaBlackListRPCHandler LoggerFactory.getLogger(FetchSchemaBlackListRPCHandler.class); public FetchSchemaBlackListRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java index 08ab10b4b469..ec4968cfa06d 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipeHeartbeatRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.mpp.rpc.thrift.TPipeHeartbeatResp; import org.slf4j.Logger; @@ -34,7 +34,7 @@ public class PipeHeartbeatRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java index 6a9dc819bf90..3517bbeb93ea 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/PipePushMetaRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.mpp.rpc.thrift.TPushPipeMetaResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -35,7 +35,7 @@ public class PipePushMetaRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java index 5f1d7ca8ea2a..db8458a948ce 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SchemaUpdateRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -36,7 +36,7 @@ public class SchemaUpdateRPCHandler extends DataNodeTSStatusRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(SchemaUpdateRPCHandler.class); public SchemaUpdateRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index f866001d4fda..ea4e612db733 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +36,7 @@ public class SubmitTestConnectionTaskRPCHandler LoggerFactory.getLogger(SubmitTestConnectionTaskRPCHandler.class); public SubmitTestConnectionTaskRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java index 1a24808801f6..352cc0694e2b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/TransferLeaderRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.mpp.rpc.thrift.TRegionLeaderChangeResp; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.rpc.TSStatusCode; @@ -37,7 +37,7 @@ public class TransferLeaderRPCHandler private static final Logger LOGGER = LoggerFactory.getLogger(TransferLeaderRPCHandler.class); public TransferLeaderRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java index a7110692ed08..14898dcdc6c9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/CheckSchemaRegionUsingTemplateRPCHandler.java @@ -21,7 +21,7 @@ import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TSStatus; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TCheckSchemaRegionUsingTemplateResp; import org.apache.iotdb.rpc.RpcUtils; @@ -40,7 +40,7 @@ public class CheckSchemaRegionUsingTemplateRPCHandler LoggerFactory.getLogger(CheckSchemaRegionUsingTemplateRPCHandler.class); public CheckSchemaRegionUsingTemplateRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java index 2afa394ae58c..ee3c11eeb427 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/ConsumerGroupPushMetaRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc.subscription; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TPushConsumerGroupMetaResp; import org.apache.iotdb.rpc.RpcUtils; @@ -38,7 +38,7 @@ public class ConsumerGroupPushMetaRPCHandler LoggerFactory.getLogger(ConsumerGroupPushMetaRPCHandler.class); public ConsumerGroupPushMetaRPCHandler( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, int requestId, TDataNodeLocation targetDataNode, Map dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java index df0febc7abdd..cf8451feaaca 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/subscription/TopicPushMetaRPCHandler.java @@ -20,7 +20,7 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc.subscription; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeAsyncRequestRPCHandler; import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaResp; import org.apache.iotdb.rpc.RpcUtils; @@ -37,7 +37,7 @@ public class TopicPushMetaRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java index febb6d6b7129..9e980ac05997 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java @@ -27,7 +27,7 @@ import org.apache.iotdb.commons.client.IClientManager; import org.apache.iotdb.commons.client.exception.ClientManagerException; import org.apache.iotdb.commons.client.sync.SyncDataNodeInternalServiceClient; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.mpp.rpc.thrift.TCreateDataRegionReq; import org.apache.iotdb.mpp.rpc.thrift.TCreatePeerReq; import org.apache.iotdb.mpp.rpc.thrift.TCreateSchemaRegionReq; @@ -65,7 +65,7 @@ private SyncDataNodeClientPool() { } public Object sendSyncRequestToDataNodeWithRetry( - TEndPoint endPoint, Object req, ConfigNodeToDataNodeRequestType requestType) { + TEndPoint endPoint, Object req, CnToDnRequestType requestType) { Throwable lastException = new TException(); for (int retry = 0; retry < DEFAULT_RETRY_NUM; retry++) { try (SyncDataNodeInternalServiceClient client = clientManager.borrowClient(endPoint)) { @@ -84,7 +84,7 @@ public Object sendSyncRequestToDataNodeWithRetry( } public Object sendSyncRequestToDataNodeWithGivenRetry( - TEndPoint endPoint, Object req, ConfigNodeToDataNodeRequestType requestType, int retryNum) { + TEndPoint endPoint, Object req, CnToDnRequestType requestType, int retryNum) { Throwable lastException = new TException(); for (int retry = 0; retry < retryNum; retry++) { try (SyncDataNodeInternalServiceClient client = clientManager.borrowClient(endPoint)) { @@ -103,7 +103,7 @@ public Object sendSyncRequestToDataNodeWithGivenRetry( } private Object executeSyncRequest( - ConfigNodeToDataNodeRequestType requestType, + CnToDnRequestType requestType, SyncDataNodeInternalServiceClient client, Object req) throws TException { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 0f5e2701a56b..e3921270f612 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -33,9 +33,9 @@ import org.apache.iotdb.commons.client.request.AsyncRequestContext; import org.apache.iotdb.commons.client.request.Utils; import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.confignode.client.async.CnToCnInternalServiceAsyncRequestManager; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.ConfigNodeAsyncRequestContext; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -150,10 +150,10 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); DataNodeAsyncRequestContext dataNodeAsyncRequestContext = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.SUBMIT_TEST_CONNECTION_TASK, + CnToDnRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequest(dataNodeAsyncRequestContext); Map anotherDataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodes().stream() @@ -222,10 +222,10 @@ private List testAllDataNodeConnection( TDataNodeLocation::getDataNodeId, TDataNodeLocation::getInternalEndPoint, TServiceType.DataNodeInternalService, - ConfigNodeToDataNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext + CnToDnRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java index 89d226bbb7dd..b0150b349d80 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterQuotaManager.java @@ -26,8 +26,8 @@ import org.apache.iotdb.common.rpc.thrift.TSpaceQuota; import org.apache.iotdb.common.rpc.thrift.TThrottleQuota; import org.apache.iotdb.commons.conf.IoTDBConstant; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.quota.SetSpaceQuotaPlan; import org.apache.iotdb.confignode.consensus.request.write.quota.SetThrottleQuotaPlan; @@ -89,8 +89,8 @@ public TSStatus setSpaceQuota(TSetSpaceQuotaReq req) { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.SET_SPACE_QUOTA, req, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } @@ -196,8 +196,8 @@ public TSStatus setThrottleQuota(TSetThrottleQuotaReq req) { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.SET_THROTTLE_QUOTA, req, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index b609aef8adaa..453266edcbd3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -24,8 +24,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.trigger.TriggerInformation; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTransferringTriggersPlan; import org.apache.iotdb.confignode.consensus.request.read.trigger.GetTriggerJarPlan; @@ -250,8 +250,8 @@ public List updateTriggerLocation( DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index 335a54a0ec00..66817acdbab7 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -23,8 +23,8 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.conf.IoTDBConstant; import org.apache.iotdb.commons.udf.UDFInformation; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.consensus.request.read.function.GetFunctionTablePlan; @@ -129,8 +129,8 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, new TCreateFunctionInstanceReq(udfInformation.serialize()).setJarFile(jarFile); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -164,8 +164,8 @@ private List dropFunctionOnDataNodes(String functionName) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.DROP_FUNCTION, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.DROP_FUNCTION, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java index 89b33ecb4dd5..6125edc1ef7b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java @@ -24,7 +24,7 @@ import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient; import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.cq.TimeoutPolicy; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.consensus.request.write.cq.UpdateCQLastExecTimePlan; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.persistence.cq.CQInfo; @@ -188,7 +188,7 @@ public void run() { new TExecuteCQ(queryBody, startTime, endTime, everyInterval, zoneId, cqId, username); try { AsyncDataNodeInternalServiceClient client = - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .getAsyncClient(targetDataNode.get()); client.executeCQ(executeCQReq, new AsyncExecuteCQCallback(startTime, endTime)); } catch (Exception t) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index 85cf998e0307..e3a1bd028aa0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -25,8 +25,8 @@ import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.commons.cluster.NodeStatus; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -168,7 +168,7 @@ private void balanceRegionLeader( long currentTime = System.nanoTime(); AtomicInteger requestId = new AtomicInteger(0); DataNodeAsyncRequestContext clientHandler = - new DataNodeAsyncRequestContext<>(ConfigNodeToDataNodeRequestType.CHANGE_REGION_LEADER); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.CHANGE_REGION_LEADER); Map successTransferMap = new TreeMap<>(); optimalLeaderMap.forEach( (regionGroupId, newLeaderId) -> { @@ -225,7 +225,7 @@ private void balanceRegionLeader( }); if (requestId.get() > 0) { // Don't retry ChangeLeader request - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequest(clientHandler); for (int i = 0; i < requestId.get(); i++) { if (clientHandler.getResponseMap().get(i).getStatus().getCode() @@ -310,10 +310,10 @@ private void broadcastLatestRegionPriorityMap() { Map tmpPriorityMap = getRegionPriorityMap(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.UPDATE_REGION_ROUTE_MAP, + CnToDnRequestType.UPDATE_REGION_ROUTE_MAP, new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index 66b138e2083e..0076dc0818b1 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -36,8 +36,8 @@ import org.apache.iotdb.commons.consensus.ConsensusGroupId; import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; @@ -707,8 +707,8 @@ public List merge() { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.MERGE, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.MERGE, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -718,8 +718,8 @@ public List flush(TFlushReq req) { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.FLUSH, req, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.FLUSH, req, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -729,8 +729,8 @@ public List clearCache() { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CLEAR_CACHE, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.CLEAR_CACHE, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -751,8 +751,8 @@ public List setConfiguration(TSetConfigurationReq req) { if (!targetDataNodes.isEmpty()) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.SET_CONFIGURATION, req, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.SET_CONFIGURATION, req, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); responseList.addAll(clientHandler.getResponseList()); } @@ -790,8 +790,8 @@ public List startRpairData() { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.START_REPAIR_DATA, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.START_REPAIR_DATA, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -801,8 +801,8 @@ public List stopRepairData() { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -812,8 +812,8 @@ public List loadConfiguration() { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -831,7 +831,7 @@ public TShowConfigurationResp showConfiguration(int nodeId) { .sendSyncRequestToDataNodeWithRetry( dataNodeLocation.getInternalEndPoint(), null, - ConfigNodeToDataNodeRequestType.SHOW_CONFIGURATION); + CnToDnRequestType.SHOW_CONFIGURATION); } // other config node @@ -856,8 +856,8 @@ public List setSystemStatus(String status) { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -868,7 +868,7 @@ public TSStatus setDataNodeStatus(TSetDataNodeStatusReq setDataNodeStatusReq) { .sendSyncRequestToDataNodeWithRetry( setDataNodeStatusReq.getTargetDataNode().getInternalEndPoint(), setDataNodeStatusReq.getStatus(), - ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS); + CnToDnRequestType.SET_SYSTEM_STATUS); } /** @@ -891,8 +891,8 @@ private TSStatus killAllQueries() { configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } @@ -908,7 +908,7 @@ private TSStatus killSpecificQuery(String queryId, TDataNodeLocation dataNodeLoc .sendSyncRequestToDataNodeWithRetry( dataNodeLocation.getInternalEndPoint(), queryId, - ConfigNodeToDataNodeRequestType.KILL_QUERY_INSTANCE); + CnToDnRequestType.KILL_QUERY_INSTANCE); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index 49be3a3a4fe1..fe30fd8ec0c3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -34,8 +34,8 @@ import org.apache.iotdb.commons.partition.SchemaPartitionTable; import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor; import org.apache.iotdb.commons.path.PartialPath; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -1258,7 +1258,7 @@ public void maintainRegionReplicas() { DataNodeAsyncRequestContext createSchemaRegionHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION); + CnToDnRequestType.CREATE_SCHEMA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask schemaRegionCreateTask = (RegionCreateTask) regionMaintainTask; @@ -1276,7 +1276,7 @@ public void maintainRegionReplicas() { schemaRegionCreateTask.getTargetDataNode()); } - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(createSchemaRegionHandler); for (Map.Entry entry : @@ -1294,7 +1294,7 @@ public void maintainRegionReplicas() { DataNodeAsyncRequestContext createDataRegionHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION); + CnToDnRequestType.CREATE_DATA_REGION); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionCreateTask dataRegionCreateTask = (RegionCreateTask) regionMaintainTask; @@ -1312,7 +1312,7 @@ public void maintainRegionReplicas() { dataRegionCreateTask.getTargetDataNode()); } - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(createDataRegionHandler); for (Map.Entry entry : @@ -1331,7 +1331,7 @@ public void maintainRegionReplicas() { // delete region DataNodeAsyncRequestContext deleteRegionHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.DELETE_REGION); + CnToDnRequestType.DELETE_REGION); Map regionIdMap = new HashMap<>(); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionDeleteTask regionDeleteTask = (RegionDeleteTask) regionMaintainTask; @@ -1349,7 +1349,7 @@ public void maintainRegionReplicas() { } long startTime = System.currentTimeMillis(); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(deleteRegionHandler); LOGGER.info( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeatScheduler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeatScheduler.java index 554d200824e0..b21fbc815f98 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeatScheduler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeatScheduler.java @@ -24,8 +24,8 @@ import org.apache.iotdb.commons.concurrent.ThreadName; import org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil; import org.apache.iotdb.commons.pipe.config.PipeConfig; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; import org.apache.iotdb.confignode.manager.ConfigManager; @@ -96,8 +96,8 @@ private synchronized void heartbeat() { final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.PIPE_HEARTBEAT, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeHeartbeatIntervalSecondsForCollectingPipeMeta() diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 947226603557..8dcc78a027a3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -32,8 +32,8 @@ import org.apache.iotdb.commons.utils.CommonDateTimeUtils; import org.apache.iotdb.commons.utils.PathUtils; import org.apache.iotdb.commons.utils.StatusUtils; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor; @@ -1041,10 +1041,10 @@ public synchronized TSStatus extendSchemaTemplate( DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + CnToDnRequestType.UPDATE_TEMPLATE, updateTemplateReq, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index cae11705deb3..2e398677d418 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -33,8 +33,8 @@ import org.apache.iotdb.commons.pipe.plugin.meta.PipePluginMeta; import org.apache.iotdb.commons.trigger.TriggerInformation; import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; @@ -186,7 +186,7 @@ public boolean invalidateCache(String storageGroupName) throws IOException, TExc .sendSyncRequestToDataNodeWithRetry( dataNodeConfiguration.getLocation().getInternalEndPoint(), invalidateCacheReq, - ConfigNodeToDataNodeRequestType.INVALIDATE_PARTITION_CACHE); + CnToDnRequestType.INVALIDATE_PARTITION_CACHE); final TSStatus invalidateSchemaStatus = (TSStatus) @@ -194,7 +194,7 @@ public boolean invalidateCache(String storageGroupName) throws IOException, TExc .sendSyncRequestToDataNodeWithRetry( dataNodeConfiguration.getLocation().getInternalEndPoint(), invalidateCacheReq, - ConfigNodeToDataNodeRequestType.INVALIDATE_SCHEMA_CACHE); + CnToDnRequestType.INVALIDATE_SCHEMA_CACHE); if (!verifySucceed(invalidatePartitionStatus, invalidateSchemaStatus)) { LOG.error( @@ -389,14 +389,14 @@ public void markDataNodeAsRemovingAndBroadcast(TDataNodeLocation dataNodeLocatio .sendSyncRequestToDataNodeWithGivenRetry( dataNodeLocation.getInternalEndPoint(), NodeStatus.Removing.getStatus(), - ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS, + CnToDnRequestType.SET_SYSTEM_STATUS, 1); } else { SyncDataNodeClientPool.getInstance() .sendSyncRequestToDataNodeWithRetry( dataNodeLocation.getInternalEndPoint(), NodeStatus.Removing.getStatus(), - ConfigNodeToDataNodeRequestType.SET_SYSTEM_STATUS); + CnToDnRequestType.SET_SYSTEM_STATUS); } long currentTime = System.nanoTime(); @@ -445,7 +445,7 @@ public Map doRegionCreation( } // Send CreateRegion requests to DataNodes - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); // Filter RegionGroups that weren't created successfully @@ -473,7 +473,7 @@ public Map doRegionCreation( private DataNodeAsyncRequestContext getCreateSchemaRegionClientHandler(CreateRegionGroupsPlan createRegionGroupsPlan) { DataNodeAsyncRequestContext clientHandler = - new DataNodeAsyncRequestContext<>(ConfigNodeToDataNodeRequestType.CREATE_SCHEMA_REGION); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.CREATE_SCHEMA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -496,7 +496,7 @@ public Map doRegionCreation( private DataNodeAsyncRequestContext getCreateDataRegionClientHandler(CreateRegionGroupsPlan createRegionGroupsPlan) { DataNodeAsyncRequestContext clientHandler = - new DataNodeAsyncRequestContext<>(ConfigNodeToDataNodeRequestType.CREATE_DATA_REGION); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.CREATE_DATA_REGION); int requestId = 0; for (Map.Entry> sgRegionsEntry : @@ -591,8 +591,8 @@ public List createTriggerOnDataNodes( DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -606,8 +606,8 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -620,8 +620,8 @@ public List activeTriggerOnDataNodes(String triggerName) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -634,10 +634,10 @@ public List inactiveTriggerOnDataNodes(String triggerName) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.INACTIVE_TRIGGER_INSTANCE, + CnToDnRequestType.INACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -651,8 +651,8 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -666,8 +666,8 @@ public List dropPipePluginOnDataNodes( DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -680,8 +680,8 @@ public Map pushAllPipeMetaToDataNodes( final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.PIPE_PUSH_ALL_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -695,8 +695,8 @@ public Map pushSinglePipeMetaToDataNodes(ByteBuffer final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -711,8 +711,8 @@ public Map dropSinglePipeOnDataNodes(String pipeName final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.PIPE_PUSH_SINGLE_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -728,8 +728,8 @@ public Map pushMultiPipeMetaToDataNodes( final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -744,8 +744,8 @@ public Map dropMultiPipeOnDataNodes(List pip final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.PIPE_PUSH_MULTI_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -760,8 +760,8 @@ public Map pushAllTopicMetaToDataNodes( final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.TOPIC_PUSH_ALL_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -775,8 +775,8 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) @@ -791,8 +791,8 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) @@ -808,8 +808,8 @@ public Map pushMultiTopicMetaToDataNodes( final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -824,8 +824,8 @@ public Map dropMultiTopicOnDataNodes(List t final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.TOPIC_PUSH_MULTI_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -842,10 +842,10 @@ public Map pushAllConsumerGroupMetaToDataNo final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_ALL_META, + CnToDnRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, PipeConfig.getInstance().getPipeMetaSyncerSyncIntervalMinutes() * 60 * 1000 * 2 / 3); @@ -861,10 +861,10 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, + CnToDnRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) @@ -880,10 +880,10 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, + CnToDnRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index 0fbb6928049d..dab212457e27 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -35,8 +35,8 @@ import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.CommonDateTimeUtils; import org.apache.iotdb.commons.utils.NodeUrlUtils; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.conf.ConfigNodeConfig; @@ -145,7 +145,7 @@ public void broadcastDisableDataNode(TDataNodeLocation disabledDataNode) { .sendSyncRequestToDataNodeWithRetry( node.getLocation().getInternalEndPoint(), disableReq, - ConfigNodeToDataNodeRequestType.DISABLE_DATA_NODE); + CnToDnRequestType.DISABLE_DATA_NODE); if (!isSucceed(status)) { LOGGER.error( "{}, BroadcastDisableDataNode meets error, disabledDataNode: {}, error: {}", @@ -230,7 +230,7 @@ public TSStatus createNewRegionPeer(TConsensusGroupId regionId, TDataNodeLocatio .sendSyncRequestToDataNodeWithRetry( destDataNode.getInternalEndPoint(), req, - ConfigNodeToDataNodeRequestType.CREATE_NEW_REGION_PEER); + CnToDnRequestType.CREATE_NEW_REGION_PEER); if (isSucceed(status)) { LOGGER.info( @@ -276,7 +276,7 @@ public TSStatus submitAddRegionPeerTask( .sendSyncRequestToDataNodeWithRetry( coordinator.getInternalEndPoint(), maintainPeerReq, - ConfigNodeToDataNodeRequestType.ADD_REGION_PEER); + CnToDnRequestType.ADD_REGION_PEER); LOGGER.info( "{}, Send action addRegionPeer finished, regionId: {}, rpcDataNode: {}, destDataNode: {}, status: {}", REGION_MIGRATE_PROCESS, @@ -313,7 +313,7 @@ public TSStatus submitRemoveRegionPeerTask( .sendSyncRequestToDataNodeWithRetry( coordinator.getInternalEndPoint(), maintainPeerReq, - ConfigNodeToDataNodeRequestType.REMOVE_REGION_PEER); + CnToDnRequestType.REMOVE_REGION_PEER); LOGGER.info( "{}, Send action removeRegionPeer finished, regionId: {}, rpcDataNode: {}", REGION_MIGRATE_PROCESS, @@ -347,14 +347,14 @@ public TSStatus submitDeleteOldRegionPeerTask( .sendSyncRequestToDataNodeWithGivenRetry( originalDataNode.getInternalEndPoint(), maintainPeerReq, - ConfigNodeToDataNodeRequestType.DELETE_OLD_REGION_PEER, + CnToDnRequestType.DELETE_OLD_REGION_PEER, 1) : (TSStatus) SyncDataNodeClientPool.getInstance() .sendSyncRequestToDataNodeWithRetry( originalDataNode.getInternalEndPoint(), maintainPeerReq, - ConfigNodeToDataNodeRequestType.DELETE_OLD_REGION_PEER); + CnToDnRequestType.DELETE_OLD_REGION_PEER); LOGGER.info( "{}, Send action deleteOldRegionPeer finished, regionId: {}, dataNodeId: {}", REGION_MIGRATE_PROCESS, @@ -369,10 +369,10 @@ public Map resetPeerList( Map dataNodeLocationMap) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.RESET_PEER_LIST, + CnToDnRequestType.RESET_PEER_LIST, new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseMap(); } @@ -511,7 +511,7 @@ public void stopDataNode(TDataNodeLocation dataNode) { .sendSyncRequestToDataNodeWithGivenRetry( dataNode.getInternalEndPoint(), dataNode, - ConfigNodeToDataNodeRequestType.STOP_DATA_NODE, + CnToDnRequestType.STOP_DATA_NODE, 2); configManager.getLoadManager().removeNodeCache(dataNode.getDataNodeId()); LOGGER.info( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index a5d8c24afcac..70e6eebb4256 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -30,8 +30,8 @@ import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; @@ -122,10 +122,10 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -156,7 +156,7 @@ private void alterLogicalView(ConfigNodeProcedureEnv env) throws ProcedureExcept "Alter view", env, targetSchemaRegionGroup, - ConfigNodeToDataNodeRequestType.ALTER_VIEW, + CnToDnRequestType.ALTER_VIEW, (dataNodeLocation, consensusGroupIdList) -> { TAlterViewReq req = new TAlterViewReq().setIsGeneratedByPipe(isGeneratedByPipe); req.setSchemaRegionIdList(consensusGroupIdList); @@ -324,7 +324,7 @@ private class AlterLogicalViewRegionTaskExecutor String taskName, ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, - ConfigNodeToDataNodeRequestType dataNodeRequestType, + CnToDnRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super(env, targetSchemaRegionGroup, false, dataNodeRequestType, dataNodeRequestGenerator); this.taskName = taskName; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java index 964a5e66f32a..61def5836ce2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DataNodeRegionTaskExecutor.java @@ -22,8 +22,8 @@ import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; @@ -45,7 +45,7 @@ public abstract class DataNodeRegionTaskExecutor { protected final Map targetSchemaRegionGroup; protected final boolean executeOnAllReplicaset; - protected final ConfigNodeToDataNodeRequestType dataNodeRequestType; + protected final CnToDnRequestType dataNodeRequestType; protected final BiFunction, Q> dataNodeRequestGenerator; @@ -55,7 +55,7 @@ protected DataNodeRegionTaskExecutor( ConfigManager configManager, Map targetSchemaRegionGroup, boolean executeOnAllReplicaset, - ConfigNodeToDataNodeRequestType dataNodeRequestType, + CnToDnRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { this.configManager = configManager; this.targetSchemaRegionGroup = targetSchemaRegionGroup; @@ -68,7 +68,7 @@ protected DataNodeRegionTaskExecutor( ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, boolean executeOnAllReplicaset, - ConfigNodeToDataNodeRequestType dataNodeRequestType, + CnToDnRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { this.configManager = env.getConfigManager(); this.targetSchemaRegionGroup = targetSchemaRegionGroup; @@ -88,7 +88,7 @@ void execute() { while (!dataNodeConsensusGroupIdMap.isEmpty()) { DataNodeAsyncRequestContext clientHandler = prepareRequestHandler(dataNodeConsensusGroupIdMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map> currentFailedDataNodeMap = checkDataNodeExecutionResult(clientHandler.getResponseMap(), dataNodeConsensusGroupIdMap); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java index e061155ffd3d..f75814ef0f96 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeactivateTemplateProcedure.java @@ -28,8 +28,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeactivateTemplatePlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -152,7 +152,7 @@ private long constructBlackList(ConfigNodeProcedureEnv env) { "construct schema black list", env, targetSchemaRegionGroup, - ConfigNodeToDataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + CnToDnRequestType.CONSTRUCT_SCHEMA_BLACK_LIST_WITH_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TConstructSchemaBlackListWithTemplateReq( consensusGroupIdList, dataNodeRequest))) { @@ -200,10 +200,10 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(timeSeriesPatternTreeBytes), dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -233,7 +233,7 @@ private void deleteData(ConfigNodeProcedureEnv env) { env, relatedDataRegionGroup, true, - ConfigNodeToDataNodeRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, + CnToDnRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, ((dataNodeLocation, consensusGroupIdList) -> new TDeleteDataForDeleteSchemaReq( new ArrayList<>(consensusGroupIdList), timeSeriesPatternTreeBytes))); @@ -248,7 +248,7 @@ private void deactivateTemplate(ConfigNodeProcedureEnv env) { "deactivate template schema", env, env.getConfigManager().getRelatedSchemaRegionGroup(timeSeriesPatternTree), - ConfigNodeToDataNodeRequestType.DEACTIVATE_TEMPLATE, + CnToDnRequestType.DEACTIVATE_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TDeactivateTemplateReq(consensusGroupIdList, dataNodeRequest) .setIsGeneratedByPipe(isGeneratedByPipe))); @@ -286,7 +286,7 @@ protected void rollbackState( "roll back schema black list", env, env.getConfigManager().getRelatedSchemaRegionGroup(timeSeriesPatternTree), - ConfigNodeToDataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, + CnToDnRequestType.ROLLBACK_SCHEMA_BLACK_LIST_WITH_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TRollbackSchemaBlackListWithTemplateReq( consensusGroupIdList, dataNodeRequest))); @@ -439,7 +439,7 @@ private class DeactivateTemplateRegionTaskExecutor String taskName, ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, - ConfigNodeToDataNodeRequestType dataNodeRequestType, + CnToDnRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super(env, targetSchemaRegionGroup, false, dataNodeRequestType, dataNodeRequestGenerator); this.taskName = taskName; @@ -450,7 +450,7 @@ private class DeactivateTemplateRegionTaskExecutor ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, boolean executeOnAllReplicaset, - ConfigNodeToDataNodeRequestType dataNodeRequestType, + CnToDnRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super( env, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java index fa6b481a0217..d47e575a3ad6 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java @@ -27,8 +27,8 @@ import org.apache.iotdb.commons.exception.runtime.ThriftSerDeException; import org.apache.iotdb.commons.service.metric.MetricService; import org.apache.iotdb.commons.utils.ThriftConfigNodeSerDeUtils; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.database.PreDeleteDatabasePlan; import org.apache.iotdb.confignode.consensus.request.write.region.OfferRegionMaintainTasksPlan; @@ -156,7 +156,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt // try sync delete schemaengine region DataNodeAsyncRequestContext asyncClientHandler = - new DataNodeAsyncRequestContext<>(ConfigNodeToDataNodeRequestType.DELETE_REGION); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.DELETE_REGION); Map schemaRegionDeleteTaskMap = new HashMap<>(); int requestIndex = 0; for (TRegionReplicaSet schemaRegionReplicaSet : schemaRegionReplicaSets) { @@ -171,7 +171,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, DeleteStorageGroupSt } } if (!schemaRegionDeleteTaskMap.isEmpty()) { - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(asyncClientHandler); for (Map.Entry entry : asyncClientHandler.getResponseMap().entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index 6a2bb7dd31ea..2eb76ec8b579 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -26,8 +26,8 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -142,7 +142,7 @@ private long constructBlackList(ConfigNodeProcedureEnv env) { "construct view schemaengine black list", env, targetSchemaRegionGroup, - ConfigNodeToDataNodeRequestType.CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, + CnToDnRequestType.CONSTRUCT_VIEW_SCHEMA_BLACK_LIST, ((dataNodeLocation, consensusGroupIdList) -> new TConstructViewSchemaBlackListReq(consensusGroupIdList, patternTreeBytes))) { @Override @@ -186,10 +186,10 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -212,7 +212,7 @@ private void deleteViewSchema(ConfigNodeProcedureEnv env) { "delete view schemaengine", env, env.getConfigManager().getRelatedSchemaRegionGroup(patternTree), - ConfigNodeToDataNodeRequestType.DELETE_VIEW, + CnToDnRequestType.DELETE_VIEW, ((dataNodeLocation, consensusGroupIdList) -> new TDeleteViewSchemaReq(consensusGroupIdList, patternTreeBytes) .setIsGeneratedByPipe(isGeneratedByPipe))); @@ -248,7 +248,7 @@ protected void rollbackState( "roll back view schemaengine black list", env, env.getConfigManager().getRelatedSchemaRegionGroup(patternTree), - ConfigNodeToDataNodeRequestType.ROLLBACK_VIEW_SCHEMA_BLACK_LIST, + CnToDnRequestType.ROLLBACK_VIEW_SCHEMA_BLACK_LIST, (dataNodeLocation, consensusGroupIdList) -> new TRollbackViewSchemaBlackListReq(consensusGroupIdList, patternTreeBytes)); rollbackStateTask.execute(); @@ -344,7 +344,7 @@ private class DeleteLogicalViewRegionTaskExecutor String taskName, ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, - ConfigNodeToDataNodeRequestType dataNodeRequestType, + CnToDnRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super(env, targetSchemaRegionGroup, false, dataNodeRequestType, dataNodeRequestGenerator); this.taskName = taskName; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index c00e75492197..b003ae2c551b 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -26,8 +26,8 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan; import org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan; @@ -148,7 +148,7 @@ private long constructBlackList(ConfigNodeProcedureEnv env) { "construct schemaengine black list", env, targetSchemaRegionGroup, - ConfigNodeToDataNodeRequestType.CONSTRUCT_SCHEMA_BLACK_LIST, + CnToDnRequestType.CONSTRUCT_SCHEMA_BLACK_LIST, ((dataNodeLocation, consensusGroupIdList) -> new TConstructSchemaBlackListReq(consensusGroupIdList, patternTreeBytes))) { @Override @@ -192,10 +192,10 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, + CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -238,7 +238,7 @@ private void executeDeleteData(ConfigNodeProcedureEnv env, PathPatternTree patte env, relatedDataRegionGroup, true, - ConfigNodeToDataNodeRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, + CnToDnRequestType.DELETE_DATA_FOR_DELETE_SCHEMA, ((dataNodeLocation, consensusGroupIdList) -> new TDeleteDataForDeleteSchemaReq( new ArrayList<>(consensusGroupIdList), @@ -253,7 +253,7 @@ private void deleteTimeSeriesSchema(ConfigNodeProcedureEnv env) { "delete timeseries schemaengine", env, env.getConfigManager().getRelatedSchemaRegionGroup(patternTree), - ConfigNodeToDataNodeRequestType.DELETE_TIMESERIES, + CnToDnRequestType.DELETE_TIMESERIES, ((dataNodeLocation, consensusGroupIdList) -> new TDeleteTimeSeriesReq(consensusGroupIdList, patternTreeBytes) .setIsGeneratedByPipe(isGeneratedByPipe))); @@ -290,7 +290,7 @@ protected void rollbackState( "roll back schemaengine black list", env, env.getConfigManager().getRelatedSchemaRegionGroup(patternTree), - ConfigNodeToDataNodeRequestType.ROLLBACK_SCHEMA_BLACK_LIST, + CnToDnRequestType.ROLLBACK_SCHEMA_BLACK_LIST, (dataNodeLocation, consensusGroupIdList) -> new TRollbackSchemaBlackListReq(consensusGroupIdList, patternTreeBytes)); rollbackStateTask.execute(); @@ -387,7 +387,7 @@ private class DeleteTimeSeriesRegionTaskExecutor String taskName, ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, - ConfigNodeToDataNodeRequestType dataNodeRequestType, + CnToDnRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super(env, targetSchemaRegionGroup, false, dataNodeRequestType, dataNodeRequestGenerator); this.taskName = taskName; @@ -398,7 +398,7 @@ private class DeleteTimeSeriesRegionTaskExecutor ConfigNodeProcedureEnv env, Map targetSchemaRegionGroup, boolean executeOnAllReplicaset, - ConfigNodeToDataNodeRequestType dataNodeRequestType, + CnToDnRequestType dataNodeRequestType, BiFunction, Q> dataNodeRequestGenerator) { super( env, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SchemaUtils.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SchemaUtils.java index b5e3417c18c0..86215919aa19 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SchemaUtils.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SchemaUtils.java @@ -26,7 +26,7 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.confignode.manager.ConfigManager; import org.apache.iotdb.db.exception.metadata.PathNotExistException; import org.apache.iotdb.db.schemaengine.template.Template; @@ -76,7 +76,7 @@ public static boolean checkDataNodeTemplateActivation( configManager, relatedSchemaRegionGroup, false, - ConfigNodeToDataNodeRequestType.COUNT_PATHS_USING_TEMPLATE, + CnToDnRequestType.COUNT_PATHS_USING_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TCountPathsUsingTemplateReq( template.getId(), patternTreeBytes, consensusGroupIdList))) { @@ -155,7 +155,7 @@ public static void checkSchemaRegionUsingTemplate( configManager, relatedSchemaRegionGroup, false, - ConfigNodeToDataNodeRequestType.CHECK_SCHEMA_REGION_USING_TEMPLATE, + CnToDnRequestType.CHECK_SCHEMA_REGION_USING_TEMPLATE, ((dataNodeLocation, consensusGroupIdList) -> new TCheckSchemaRegionUsingTemplateReq(consensusGroupIdList))) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java index c87ddeecb796..70b4892a4f5a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java @@ -24,8 +24,8 @@ import org.apache.iotdb.common.rpc.thrift.TSetTTLReq; import org.apache.iotdb.commons.exception.IoTDBException; import org.apache.iotdb.commons.exception.MetadataException; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; import org.apache.iotdb.confignode.consensus.request.write.database.SetTTLPlan; @@ -110,13 +110,13 @@ private void updateDataNodeTTL(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.SET_TTL, + CnToDnRequestType.SET_TTL, new TSetTTLReq( Collections.singletonList(String.join(".", plan.getPathPattern())), plan.getTTL(), plan.isDataBase()), dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index 52e574cf768b..5087e1f0f475 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -28,8 +28,8 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.consensus.request.read.template.CheckTemplateSettablePlan; import org.apache.iotdb.confignode.consensus.request.read.template.GetSchemaTemplatePlan; @@ -212,8 +212,8 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { @@ -283,7 +283,7 @@ private void validateTimeSeriesExistence(ConfigNodeProcedureEnv env) { env, relatedSchemaRegionGroup, false, - ConfigNodeToDataNodeRequestType.CHECK_TIMESERIES_EXISTENCE, + CnToDnRequestType.CHECK_TIMESERIES_EXISTENCE, ((dataNodeLocation, consensusGroupIdList) -> new TCheckTimeSeriesExistenceReq(patternTreeBytes, consensusGroupIdList))) { @@ -386,8 +386,8 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { env.getConfigManager().getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { @@ -492,10 +492,10 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + CnToDnRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index ecaba363b997..2810914a3edb 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -26,8 +26,8 @@ import org.apache.iotdb.commons.path.PartialPath; import org.apache.iotdb.commons.path.PathDeserializeUtil; import org.apache.iotdb.commons.path.PathPatternTree; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; -import org.apache.iotdb.confignode.client.async.ConfigNodeToDataNodeInternalServiceAsyncRequestManager; +import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.confignode.client.async.CnToDnInternalServiceAsyncRequestManager; import org.apache.iotdb.confignode.client.async.handlers.DataNodeAsyncRequestContext; import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv; import org.apache.iotdb.confignode.procedure.exception.ProcedureException; @@ -157,10 +157,10 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure invalidateTemplateSetInfoReq.setTemplateInfo(getInvalidateTemplateSetInfo()); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + CnToDnRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { @@ -255,10 +255,10 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) rollbackTemplateSetInfoReq.setTemplateInfo(getAddTemplateSetInfo()); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - ConfigNodeToDataNodeRequestType.UPDATE_TEMPLATE, + CnToDnRequestType.UPDATE_TEMPLATE, rollbackTemplateSetInfoReq, dataNodeLocationMap); - ConfigNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java index f8937c253c22..d8e999cd1878 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/sync/AuthOperationProcedure.java @@ -25,7 +25,7 @@ import org.apache.iotdb.commons.conf.CommonDescriptor; import org.apache.iotdb.commons.exception.IoTDBException; import org.apache.iotdb.commons.utils.ThriftCommonsSerDeUtils; -import org.apache.iotdb.confignode.client.ConfigNodeToDataNodeRequestType; +import org.apache.iotdb.confignode.client.CnToDnRequestType; import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool; import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan; import org.apache.iotdb.confignode.consensus.request.auth.AuthorPlan; @@ -112,7 +112,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, AuthOperationProcedu .sendSyncRequestToDataNodeWithRetry( pair.getLeft().getLocation().getInternalEndPoint(), req, - ConfigNodeToDataNodeRequestType.INVALIDATE_PERMISSION_CACHE); + CnToDnRequestType.INVALIDATE_PERMISSION_CACHE); if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { it.remove(); } From 3eab19a52303620af2c27d99ddf2ca2f6ef99e8f Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 13 Jun 2024 18:23:39 +0800 Subject: [PATCH 46/52] DnToDn --- .../client/dn/AsyncTSStatusRPCHandler.java | 2 +- .../dn/DataNodeAsyncRequestRPCHandler.java | 8 ++++---- ...NodeExternalServiceAsyncRequestManager.java | 8 ++++---- .../DataNodeMPPServiceAsyncRequestManager.java | 8 ++++---- ...oDnInternalServiceAsyncRequestManager.java} | 18 +++++++++--------- ...RequestType.java => DnToDnRequestType.java} | 2 +- .../impl/DataNodeInternalRPCServiceImpl.java | 18 +++++++++--------- 7 files changed, 32 insertions(+), 32 deletions(-) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/{DataNodeToDataNodeInternalServiceAsyncRequestManager.java => DnToDnInternalServiceAsyncRequestManager.java} (72%) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/{DataNodeToDataNodeRequestType.java => DnToDnRequestType.java} (95%) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java index 796e202fbe43..9672d431c384 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java @@ -36,7 +36,7 @@ public class AsyncTSStatusRPCHandler extends DataNodeAsyncRequestRPCHandler dataNodeLocationMap, diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeAsyncRequestRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeAsyncRequestRPCHandler.java index 7d523fe491ba..76be9ac9d715 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeAsyncRequestRPCHandler.java @@ -31,12 +31,12 @@ import java.util.concurrent.CountDownLatch; public abstract class DataNodeAsyncRequestRPCHandler - extends AsyncRequestRPCHandler { + extends AsyncRequestRPCHandler { private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeAsyncRequestRPCHandler.class); protected DataNodeAsyncRequestRPCHandler( - DataNodeToDataNodeRequestType dataNodeToDataNodeRequestType, + DnToDnRequestType dataNodeToDataNodeRequestType, int requestId, TDataNodeLocation targetNode, Map dataNodeLocationMap, @@ -61,10 +61,10 @@ protected String generateFormattedTargetLocation(TDataNodeLocation dataNodeLocat } public static DataNodeAsyncRequestRPCHandler createAsyncRPCHandler( - AsyncRequestContext context, + AsyncRequestContext context, int requestId, TDataNodeLocation targetDataNode) { - DataNodeToDataNodeRequestType requestType = context.getRequestType(); + DnToDnRequestType requestType = context.getRequestType(); Map nodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); CountDownLatch countDownLatch = context.getCountDownLatch(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java index 0749435c4554..6f51fa2968be 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java @@ -33,7 +33,7 @@ public class DataNodeExternalServiceAsyncRequestManager extends AsyncRequestManager< - DataNodeToDataNodeRequestType, TDataNodeLocation, AsyncDataNodeExternalServiceClient> { + DnToDnRequestType, TDataNodeLocation, AsyncDataNodeExternalServiceClient> { private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeExternalServiceAsyncRequestManager.class); @@ -49,7 +49,7 @@ protected void initClientManager() { @Override protected void initActionMapBuilder() { actionMapBuilder.put( - DataNodeToDataNodeRequestType.TEST_CONNECTION, + DnToDnRequestType.TEST_CONNECTION, (req, client, handler) -> client.testConnectionEmptyRPC((AsyncTSStatusRPCHandler) handler)); } @@ -59,9 +59,9 @@ protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { } @Override - protected AsyncRequestRPCHandler + protected AsyncRequestRPCHandler buildHandler( - AsyncRequestContext + AsyncRequestContext requestContext, int requestId, TDataNodeLocation targetNode) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java index 49614d4477fb..25ed8c54a10c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java @@ -33,7 +33,7 @@ public class DataNodeMPPServiceAsyncRequestManager extends AsyncRequestManager< - DataNodeToDataNodeRequestType, + DnToDnRequestType, TDataNodeLocation, AsyncDataNodeMPPDataExchangeServiceClient> { private static final Logger LOGGER = @@ -52,7 +52,7 @@ protected void initClientManager() { @Override protected void initActionMapBuilder() { actionMapBuilder.put( - DataNodeToDataNodeRequestType.TEST_CONNECTION, + DnToDnRequestType.TEST_CONNECTION, (req, client, handler) -> client.testConnectionEmptyRPC((AsyncTSStatusRPCHandler) handler)); } @@ -62,9 +62,9 @@ protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { } @Override - protected AsyncRequestRPCHandler + protected AsyncRequestRPCHandler buildHandler( - AsyncRequestContext + AsyncRequestContext requestContext, int requestId, TDataNodeLocation targetNode) { diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnInternalServiceAsyncRequestManager.java similarity index 72% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnInternalServiceAsyncRequestManager.java index 3bffaefd288a..33338f3512e9 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnInternalServiceAsyncRequestManager.java @@ -27,22 +27,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DataNodeToDataNodeInternalServiceAsyncRequestManager - extends DataNodeInternalServiceRequestManager { +public class DnToDnInternalServiceAsyncRequestManager + extends DataNodeInternalServiceRequestManager { private static final Logger LOGGER = - LoggerFactory.getLogger(DataNodeToDataNodeInternalServiceAsyncRequestManager.class); + LoggerFactory.getLogger(DnToDnInternalServiceAsyncRequestManager.class); @Override protected void initActionMapBuilder() { actionMapBuilder.put( - DataNodeToDataNodeRequestType.TEST_CONNECTION, + DnToDnRequestType.TEST_CONNECTION, (req, client, handler) -> client.testConnectionEmptyRPC((AsyncTSStatusRPCHandler) handler)); } @Override - protected AsyncRequestRPCHandler + protected AsyncRequestRPCHandler buildHandler( - AsyncRequestContext + AsyncRequestContext requestContext, int requestId, TDataNodeLocation targetNode) { @@ -52,15 +52,15 @@ protected void initActionMapBuilder() { private static class ClientPoolHolder { - private static final DataNodeToDataNodeInternalServiceAsyncRequestManager INSTANCE = - new DataNodeToDataNodeInternalServiceAsyncRequestManager(); + private static final DnToDnInternalServiceAsyncRequestManager INSTANCE = + new DnToDnInternalServiceAsyncRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static DataNodeToDataNodeInternalServiceAsyncRequestManager getInstance() { + public static DnToDnInternalServiceAsyncRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnRequestType.java similarity index 95% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeRequestType.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnRequestType.java index 20b023062c29..a46d93a72956 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeToDataNodeRequestType.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnRequestType.java @@ -19,6 +19,6 @@ package org.apache.iotdb.db.protocol.client.dn; -public enum DataNodeToDataNodeRequestType { +public enum DnToDnRequestType { TEST_CONNECTION, } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 9af9bd89a186..c20858dc67cf 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -80,8 +80,8 @@ import org.apache.iotdb.db.protocol.client.cn.DataNodeToConfigNodeRequestType; import org.apache.iotdb.db.protocol.client.dn.DataNodeExternalServiceAsyncRequestManager; import org.apache.iotdb.db.protocol.client.dn.DataNodeMPPServiceAsyncRequestManager; -import org.apache.iotdb.db.protocol.client.dn.DataNodeToDataNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.db.protocol.client.dn.DataNodeToDataNodeRequestType; +import org.apache.iotdb.db.protocol.client.dn.DnToDnInternalServiceAsyncRequestManager; +import org.apache.iotdb.db.protocol.client.dn.DnToDnRequestType; import org.apache.iotdb.db.protocol.session.IClientSession; import org.apache.iotdb.db.protocol.session.InternalClientSession; import org.apache.iotdb.db.protocol.session.SessionManager; @@ -1477,10 +1477,10 @@ private List testAllDataNodeInternalServiceConnection( TDataNodeLocation::getDataNodeId, TDataNodeLocation::getInternalEndPoint, TServiceType.DataNodeInternalService, - DataNodeToDataNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext + DnToDnRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> - DataNodeToDataNodeInternalServiceAsyncRequestManager.getInstance() + DnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); } @@ -1491,8 +1491,8 @@ private List testAllDataNodeMPPServiceConnection( TDataNodeLocation::getDataNodeId, TDataNodeLocation::getMPPDataExchangeEndPoint, TServiceType.DataNodeMPPService, - DataNodeToDataNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext + DnToDnRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> DataNodeMPPServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(handler)); } @@ -1504,8 +1504,8 @@ private List testAllDataNodeExternalServiceConnection( TDataNodeLocation::getDataNodeId, TDataNodeLocation::getClientRpcEndPoint, TServiceType.DataNodeExternalService, - DataNodeToDataNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext + DnToDnRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> DataNodeExternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); From 179de7231612ddb7dde4019ed9b89a354f769ea1 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 13 Jun 2024 18:24:22 +0800 Subject: [PATCH 47/52] DnToCn --- .../cn/AsyncConfigNodeTSStatusRPCHandler.java | 2 +- .../cn/ConfigNodeAsyncRequestRPCHandler.java | 8 ++++---- ...oCnInternalServiceAsyncRequestManager.java} | 18 +++++++++--------- ...RequestType.java => DnToCnRequestType.java} | 2 +- .../impl/DataNodeInternalRPCServiceImpl.java | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/{DataNodeToConfigNodeInternalServiceAsyncRequestManager.java => DnToCnInternalServiceAsyncRequestManager.java} (71%) rename iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/{DataNodeToConfigNodeRequestType.java => DnToCnRequestType.java} (95%) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java index e845640e1250..fd1cbd539fbf 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/AsyncConfigNodeTSStatusRPCHandler.java @@ -37,7 +37,7 @@ public class AsyncConfigNodeTSStatusRPCHandler extends ConfigNodeAsyncRequestRPC LoggerFactory.getLogger(AsyncConfigNodeTSStatusRPCHandler.class); public AsyncConfigNodeTSStatusRPCHandler( - DataNodeToConfigNodeRequestType requestType, + DnToCnRequestType requestType, int requestId, TConfigNodeLocation targetConfigNode, Map configNodeLocationMap, diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java index bd38a2fbf44c..ece9a2fa5f0e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/ConfigNodeAsyncRequestRPCHandler.java @@ -28,10 +28,10 @@ import java.util.concurrent.CountDownLatch; public abstract class ConfigNodeAsyncRequestRPCHandler - extends AsyncRequestRPCHandler { + extends AsyncRequestRPCHandler { protected ConfigNodeAsyncRequestRPCHandler( - DataNodeToConfigNodeRequestType configNodeRequestType, + DnToCnRequestType configNodeRequestType, int requestId, TConfigNodeLocation targetNode, Map integerTConfigNodeLocationMap, @@ -56,10 +56,10 @@ protected String generateFormattedTargetLocation(TConfigNodeLocation configNodeL } public static ConfigNodeAsyncRequestRPCHandler buildHandler( - AsyncRequestContext context, + AsyncRequestContext context, int requestId, TConfigNodeLocation targetConfigNode) { - DataNodeToConfigNodeRequestType requestType = context.getRequestType(); + DnToCnRequestType requestType = context.getRequestType(); Map nodeLocationMap = context.getNodeLocationMap(); Map responseMap = context.getResponseMap(); CountDownLatch countDownLatch = context.getCountDownLatch(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnInternalServiceAsyncRequestManager.java similarity index 71% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnInternalServiceAsyncRequestManager.java index 43d233a6110b..b9f3753e1b26 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnInternalServiceAsyncRequestManager.java @@ -27,24 +27,24 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DataNodeToConfigNodeInternalServiceAsyncRequestManager - extends ConfigNodeInternalServiceAsyncRequestManager { +public class DnToCnInternalServiceAsyncRequestManager + extends ConfigNodeInternalServiceAsyncRequestManager { private static final Logger LOGGER = - LoggerFactory.getLogger(DataNodeToConfigNodeInternalServiceAsyncRequestManager.class); + LoggerFactory.getLogger(DnToCnInternalServiceAsyncRequestManager.class); @Override protected void initActionMapBuilder() { actionMapBuilder.put( - DataNodeToConfigNodeRequestType.TEST_CONNECTION, + DnToCnRequestType.TEST_CONNECTION, (req, client, handler) -> client.testConnectionEmptyRPC((AsyncConfigNodeTSStatusRPCHandler) handler)); } @Override - protected AsyncRequestRPCHandler + protected AsyncRequestRPCHandler buildHandler( - AsyncRequestContext + AsyncRequestContext requestContext, int requestId, TConfigNodeLocation targetNode) { @@ -52,15 +52,15 @@ protected void initActionMapBuilder() { } private static class ClientPoolHolder { - private static final DataNodeToConfigNodeInternalServiceAsyncRequestManager INSTANCE = - new DataNodeToConfigNodeInternalServiceAsyncRequestManager(); + private static final DnToCnInternalServiceAsyncRequestManager INSTANCE = + new DnToCnInternalServiceAsyncRequestManager(); private ClientPoolHolder() { // Empty constructor } } - public static DataNodeToConfigNodeInternalServiceAsyncRequestManager getInstance() { + public static DnToCnInternalServiceAsyncRequestManager getInstance() { return ClientPoolHolder.INSTANCE; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnRequestType.java similarity index 95% rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeRequestType.java rename to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnRequestType.java index 5adf0406ca35..3c6e364273d3 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DataNodeToConfigNodeRequestType.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnRequestType.java @@ -19,7 +19,7 @@ package org.apache.iotdb.db.protocol.client.cn; -public enum DataNodeToConfigNodeRequestType { +public enum DnToCnRequestType { SUBMIT_TEST_CONNECTION_TASK, TEST_CONNECTION, } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index c20858dc67cf..76545cab0d18 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -76,8 +76,8 @@ import org.apache.iotdb.db.exception.StorageEngineException; import org.apache.iotdb.db.pipe.agent.PipeAgent; import org.apache.iotdb.db.protocol.client.ConfigNodeInfo; -import org.apache.iotdb.db.protocol.client.cn.DataNodeToConfigNodeInternalServiceAsyncRequestManager; -import org.apache.iotdb.db.protocol.client.cn.DataNodeToConfigNodeRequestType; +import org.apache.iotdb.db.protocol.client.cn.DnToCnInternalServiceAsyncRequestManager; +import org.apache.iotdb.db.protocol.client.cn.DnToCnRequestType; import org.apache.iotdb.db.protocol.client.dn.DataNodeExternalServiceAsyncRequestManager; import org.apache.iotdb.db.protocol.client.dn.DataNodeMPPServiceAsyncRequestManager; import org.apache.iotdb.db.protocol.client.dn.DnToDnInternalServiceAsyncRequestManager; @@ -1463,10 +1463,10 @@ private List testAllConfigNodeConnection( TConfigNodeLocation::getConfigNodeId, TConfigNodeLocation::getInternalEndPoint, TServiceType.ConfigNodeInternalService, - DataNodeToConfigNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext + DnToCnRequestType.TEST_CONNECTION, + (AsyncRequestContext handler) -> - DataNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance() + DnToCnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); } From 2f5e1597c4775d9e373b0dfb4bb6f0bff101e8e2 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 13 Jun 2024 18:35:29 +0800 Subject: [PATCH 48/52] rename --- .../iotdb/commons/client/request/AsyncRequestContext.java | 1 - .../java/org/apache/iotdb/commons/client/request/Utils.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestContext.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestContext.java index 8e138dd45e59..8b54072a4c40 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestContext.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestContext.java @@ -85,7 +85,6 @@ public void putNodeLocation(int requestId, NodeLocation nodeLocation) { public AsyncRequestContext(RequestType requestType, Map nodeLocationMap) { this.requestType = requestType; this.nodeLocationMap = nodeLocationMap; - this.requestMap = new ConcurrentHashMap<>(); this.responseMap = new ConcurrentHashMap<>(); } diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java index 6d4704f059b8..31a4b7221ef4 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java @@ -49,7 +49,7 @@ List testConnectionsImpl( Map nodeLocationMap = nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); AsyncRequestContext requestContext = - new AsyncRequestContext<>(requestType, new Object(), nodeLocationMap); + new AsyncRequestContext<>(requestType, null, nodeLocationMap); // do the test sendRequest.accept(requestContext); // collect result From a8f4e8f1fb9ae89d870ca172fdc2880ab2699aab Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 13 Jun 2024 18:38:19 +0800 Subject: [PATCH 49/52] spotless --- ...oCnInternalServiceAsyncRequestManager.java | 10 ++-- ...oDnInternalServiceAsyncRequestManager.java | 10 ++-- .../handlers/DataNodeAsyncRequestContext.java | 7 +-- .../rpc/ConfigNodeAsyncRequestRPCHandler.java | 3 +- .../client/sync/SyncDataNodeClientPool.java | 6 +-- .../confignode/manager/ClusterManager.java | 10 ++-- .../confignode/manager/TriggerManager.java | 3 +- .../iotdb/confignode/manager/UDFManager.java | 6 +-- .../manager/load/balancer/RouteBalancer.java | 6 +-- .../confignode/manager/node/NodeManager.java | 39 +++++---------- .../manager/partition/PartitionManager.java | 3 +- .../manager/schema/ClusterSchemaManager.java | 7 +-- .../procedure/env/ConfigNodeProcedureEnv.java | 49 ++++++------------- .../procedure/env/RegionMaintainHandler.java | 8 +-- .../schema/AlterLogicalViewProcedure.java | 3 +- .../schema/DeleteLogicalViewProcedure.java | 3 +- .../schema/DeleteTimeSeriesProcedure.java | 3 +- .../impl/schema/SetTTLProcedure.java | 3 +- .../impl/schema/SetTemplateProcedure.java | 13 ++--- .../impl/schema/UnsetTemplateProcedure.java | 14 ++---- ...oCnInternalServiceAsyncRequestManager.java | 10 ++-- ...odeExternalServiceAsyncRequestManager.java | 10 ++-- ...DataNodeMPPServiceAsyncRequestManager.java | 14 ++---- ...oDnInternalServiceAsyncRequestManager.java | 10 ++-- .../impl/DataNodeInternalRPCServiceImpl.java | 12 ++--- 25 files changed, 87 insertions(+), 175 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToCnInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToCnInternalServiceAsyncRequestManager.java index 5c7d0f0e3343..bd5ee3fe4995 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToCnInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToCnInternalServiceAsyncRequestManager.java @@ -52,12 +52,10 @@ protected void initActionMapBuilder() { } @Override - protected AsyncRequestRPCHandler - buildHandler( - AsyncRequestContext - requestContext, - int requestId, - TConfigNodeLocation targetNode) { + protected AsyncRequestRPCHandler buildHandler( + AsyncRequestContext requestContext, + int requestId, + TConfigNodeLocation targetNode) { return ConfigNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToDnInternalServiceAsyncRequestManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToDnInternalServiceAsyncRequestManager.java index 7eaf88a07ce0..8f3e7c720fc6 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToDnInternalServiceAsyncRequestManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToDnInternalServiceAsyncRequestManager.java @@ -353,12 +353,10 @@ protected void initActionMapBuilder() { } @Override - protected AsyncRequestRPCHandler - buildHandler( - AsyncRequestContext - requestContext, - int requestId, - TDataNodeLocation targetNode) { + protected AsyncRequestRPCHandler buildHandler( + AsyncRequestContext requestContext, + int requestId, + TDataNodeLocation targetNode) { return DataNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java index 4c5f9058661c..2b813c081d7e 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/DataNodeAsyncRequestContext.java @@ -39,15 +39,12 @@ public DataNodeAsyncRequestContext(CnToDnRequestType requestType) { } public DataNodeAsyncRequestContext( - CnToDnRequestType requestType, - Map dataNodeLocationMap) { + CnToDnRequestType requestType, Map dataNodeLocationMap) { super(requestType, dataNodeLocationMap); } public DataNodeAsyncRequestContext( - CnToDnRequestType requestType, - Q q, - Map dataNodeLocationMap) { + CnToDnRequestType requestType, Q q, Map dataNodeLocationMap) { super(requestType, q, dataNodeLocationMap); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java index 8da7ca05b7ce..4825629ee559 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/ConfigNodeAsyncRequestRPCHandler.java @@ -30,8 +30,7 @@ import java.util.concurrent.CountDownLatch; public abstract class ConfigNodeAsyncRequestRPCHandler - extends AsyncRequestRPCHandler< - Response, CnToCnNodeRequestType, TConfigNodeLocation> { + extends AsyncRequestRPCHandler { protected ConfigNodeAsyncRequestRPCHandler( CnToCnNodeRequestType configNodeRequestType, diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java index 9e980ac05997..84e609ffb38c 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java @@ -84,7 +84,7 @@ public Object sendSyncRequestToDataNodeWithRetry( } public Object sendSyncRequestToDataNodeWithGivenRetry( - TEndPoint endPoint, Object req, CnToDnRequestType requestType, int retryNum) { + TEndPoint endPoint, Object req, CnToDnRequestType requestType, int retryNum) { Throwable lastException = new TException(); for (int retry = 0; retry < retryNum; retry++) { try (SyncDataNodeInternalServiceClient client = clientManager.borrowClient(endPoint)) { @@ -103,9 +103,7 @@ public Object sendSyncRequestToDataNodeWithGivenRetry( } private Object executeSyncRequest( - CnToDnRequestType requestType, - SyncDataNodeInternalServiceClient client, - Object req) + CnToDnRequestType requestType, SyncDataNodeInternalServiceClient client, Object req) throws TException { switch (requestType) { case INVALIDATE_PARTITION_CACHE: diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index e3921270f612..76c56afb84fe 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -150,9 +150,7 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, location -> location)); DataNodeAsyncRequestContext dataNodeAsyncRequestContext = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.SUBMIT_TEST_CONNECTION_TASK, - nodeLocations, - dataNodeLocationMap); + CnToDnRequestType.SUBMIT_TEST_CONNECTION_TASK, nodeLocations, dataNodeLocationMap); CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequest(dataNodeAsyncRequestContext); Map anotherDataNodeLocationMap = @@ -197,8 +195,7 @@ private List testAllConfigNodeConnection( TConfigNodeLocation::getInternalEndPoint, TServiceType.ConfigNodeInternalService, CnToCnNodeRequestType.TEST_CONNECTION, - (AsyncRequestContext< - Object, TSStatus, CnToCnNodeRequestType, TConfigNodeLocation> + (AsyncRequestContext handler) -> CnToCnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); @@ -223,8 +220,7 @@ private List testAllDataNodeConnection( TDataNodeLocation::getInternalEndPoint, TServiceType.DataNodeInternalService, CnToDnRequestType.TEST_CONNECTION, - (AsyncRequestContext - handler) -> + (AsyncRequestContext handler) -> CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java index 453266edcbd3..b1a96d029af2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/TriggerManager.java @@ -251,8 +251,7 @@ public List updateTriggerLocation( DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.UPDATE_TRIGGER_LOCATION, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java index 66817acdbab7..ad86879d8280 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java @@ -130,8 +130,7 @@ private List createFunctionOnDataNodes(UDFInformation udfInformation, DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.CREATE_FUNCTION, req, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -165,8 +164,7 @@ private List dropFunctionOnDataNodes(String functionName) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.DROP_FUNCTION, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java index e3a1bd028aa0..dd362d18c5b3 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java @@ -225,8 +225,7 @@ private void balanceRegionLeader( }); if (requestId.get() > 0) { // Don't retry ChangeLeader request - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequest(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequest(clientHandler); for (int i = 0; i < requestId.get(); i++) { if (clientHandler.getResponseMap().get(i).getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -313,8 +312,7 @@ private void broadcastLatestRegionPriorityMap() { CnToDnRequestType.UPDATE_REGION_ROUTE_MAP, new TRegionRouteReq(broadcastTime, tmpPriorityMap), dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); } private void recordRegionPriorityMap( diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java index 0076dc0818b1..0877acd336c2 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java @@ -706,10 +706,8 @@ public List merge() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = - new DataNodeAsyncRequestContext<>( - CnToDnRequestType.MERGE, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.MERGE, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -717,10 +715,8 @@ public List flush(TFlushReq req) { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = - new DataNodeAsyncRequestContext<>( - CnToDnRequestType.FLUSH, req, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.FLUSH, req, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -728,10 +724,8 @@ public List clearCache() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = - new DataNodeAsyncRequestContext<>( - CnToDnRequestType.CLEAR_CACHE, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.CLEAR_CACHE, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -789,10 +783,8 @@ public List startRpairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = - new DataNodeAsyncRequestContext<>( - CnToDnRequestType.START_REPAIR_DATA, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.START_REPAIR_DATA, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -800,10 +792,8 @@ public List stopRepairData() { Map dataNodeLocationMap = configManager.getNodeManager().getRegisteredDataNodeLocations(); DataNodeAsyncRequestContext clientHandler = - new DataNodeAsyncRequestContext<>( - CnToDnRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.STOP_REPAIR_DATA, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -813,8 +803,7 @@ public List loadConfiguration() { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.LOAD_CONFIGURATION, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -857,8 +846,7 @@ public List setSystemStatus(String status) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.SET_SYSTEM_STATUS, status, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -892,8 +880,7 @@ private TSStatus killAllQueries() { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.KILL_QUERY_INSTANCE, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return RpcUtils.squashResponseStatusList(clientHandler.getResponseList()); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java index fe30fd8ec0c3..c7b0c4bc19b9 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java @@ -1330,8 +1330,7 @@ public void maintainRegionReplicas() { case DELETE: // delete region DataNodeAsyncRequestContext deleteRegionHandler = - new DataNodeAsyncRequestContext<>( - CnToDnRequestType.DELETE_REGION); + new DataNodeAsyncRequestContext<>(CnToDnRequestType.DELETE_REGION); Map regionIdMap = new HashMap<>(); for (RegionMaintainTask regionMaintainTask : selectedRegionMaintainTask) { RegionDeleteTask regionDeleteTask = (RegionDeleteTask) regionMaintainTask; diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java index 8dcc78a027a3..fd978ceb8335 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java @@ -1041,11 +1041,8 @@ public synchronized TSStatus extendSchemaTemplate( DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.UPDATE_TEMPLATE, - updateTemplateReq, - dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnRequestType.UPDATE_TEMPLATE, updateTemplateReq, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java index 2e398677d418..c2040a05328a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java @@ -445,8 +445,7 @@ public Map doRegionCreation( } // Send CreateRegion requests to DataNodes - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); // Filter RegionGroups that weren't created successfully int requestId = 0; @@ -592,8 +591,7 @@ public List createTriggerOnDataNodes( DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.CREATE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -607,8 +605,7 @@ public List dropTriggerOnDataNodes(String triggerName, boolean needToD DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.DROP_TRIGGER_INSTANCE, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -621,8 +618,7 @@ public List activeTriggerOnDataNodes(String triggerName) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.ACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -634,11 +630,8 @@ public List inactiveTriggerOnDataNodes(String triggerName) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.INACTIVE_TRIGGER_INSTANCE, - request, - dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnRequestType.INACTIVE_TRIGGER_INSTANCE, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -652,8 +645,7 @@ public List createPipePluginOnDataNodes(PipePluginMeta pipePluginMeta, final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.CREATE_PIPE_PLUGIN, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -667,8 +659,7 @@ public List dropPipePluginOnDataNodes( DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.DROP_PIPE_PLUGIN, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList(); } @@ -776,8 +767,7 @@ public List pushSingleTopicOnDataNode(ByteBuffer topicMeta) { final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) .collect(Collectors.toList()); @@ -792,8 +782,7 @@ public List dropSingleTopicOnDataNode(String topicNameToDrop) { final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.TOPIC_PUSH_SINGLE_META, request, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushTopicMetaResp::getStatus) .collect(Collectors.toList()); @@ -842,9 +831,7 @@ public Map pushAllConsumerGroupMetaToDataNo final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.CONSUMER_GROUP_PUSH_ALL_META, - request, - dataNodeLocationMap); + CnToDnRequestType.CONSUMER_GROUP_PUSH_ALL_META, request, dataNodeLocationMap); CnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestToNodeWithRetryAndTimeoutInMs( clientHandler, @@ -861,11 +848,8 @@ public List pushSingleConsumerGroupOnDataNode(ByteBuffer consumerGroup final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, - request, - dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) .collect(Collectors.toList()); @@ -880,11 +864,8 @@ public List dropSingleConsumerGroupOnDataNode(String consumerGroupName final DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, - request, - dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnRequestType.CONSUMER_GROUP_PUSH_SINGLE_META, request, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseList().stream() .map(TPushConsumerGroupMetaResp::getStatus) .collect(Collectors.toList()); diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java index dab212457e27..9bb5b860eb9a 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java @@ -372,8 +372,7 @@ public Map resetPeerList( CnToDnRequestType.RESET_PEER_LIST, new TResetPeerListReq(regionId, correctDataNodeLocations), dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); return clientHandler.getResponseMap(); } @@ -509,10 +508,7 @@ public void stopDataNode(TDataNodeLocation dataNode) { (TSStatus) SyncDataNodeClientPool.getInstance() .sendSyncRequestToDataNodeWithGivenRetry( - dataNode.getInternalEndPoint(), - dataNode, - CnToDnRequestType.STOP_DATA_NODE, - 2); + dataNode.getInternalEndPoint(), dataNode, CnToDnRequestType.STOP_DATA_NODE, 2); configManager.getLoadManager().removeNodeCache(dataNode.getDataNodeId()); LOGGER.info( "{}, Stop Data Node result: {}, stoppedDataNode: {}", diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java index 70e6eebb4256..8c6eed065534 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterLogicalViewProcedure.java @@ -125,8 +125,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java index 2eb76ec8b579..97583dfc03b0 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteLogicalViewProcedure.java @@ -189,8 +189,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java index b003ae2c551b..40b8c55d2374 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java @@ -195,8 +195,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) { CnToDnRequestType.INVALIDATE_MATCHED_SCHEMA_CACHE, new TInvalidateMatchedSchemaCacheReq(patternTreeBytes), dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaEngine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java index 70b4892a4f5a..ec9b003d7eee 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTTLProcedure.java @@ -116,8 +116,7 @@ private void updateDataNodeTTL(ConfigNodeProcedureEnv env) { plan.getTTL(), plan.isDataBase()), dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related schemaengine cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java index 5087e1f0f475..902221285e26 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/SetTemplateProcedure.java @@ -213,8 +213,7 @@ private void preReleaseTemplate(ConfigNodeProcedureEnv env) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -387,8 +386,7 @@ private void commitReleaseTemplate(ConfigNodeProcedureEnv env) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( CnToDnRequestType.UPDATE_TEMPLATE, req, dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { if (entry.getValue().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) { @@ -492,11 +490,8 @@ private void rollbackPreRelease(ConfigNodeProcedureEnv env) { DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.UPDATE_TEMPLATE, - invalidateTemplateSetInfoReq, - dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (Map.Entry entry : statusMap.entrySet()) { // all dataNodes must clear the related template cache diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java index 2810914a3edb..ee70f3c7a7d1 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/UnsetTemplateProcedure.java @@ -157,11 +157,8 @@ private void executeInvalidateCache(ConfigNodeProcedureEnv env) throws Procedure invalidateTemplateSetInfoReq.setTemplateInfo(getInvalidateTemplateSetInfo()); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.UPDATE_TEMPLATE, - invalidateTemplateSetInfoReq, - dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnRequestType.UPDATE_TEMPLATE, invalidateTemplateSetInfoReq, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related template cache @@ -255,11 +252,8 @@ private void executeRollbackInvalidateCache(ConfigNodeProcedureEnv env) rollbackTemplateSetInfoReq.setTemplateInfo(getAddTemplateSetInfo()); DataNodeAsyncRequestContext clientHandler = new DataNodeAsyncRequestContext<>( - CnToDnRequestType.UPDATE_TEMPLATE, - rollbackTemplateSetInfoReq, - dataNodeLocationMap); - CnToDnInternalServiceAsyncRequestManager.getInstance() - .sendAsyncRequestWithRetry(clientHandler); + CnToDnRequestType.UPDATE_TEMPLATE, rollbackTemplateSetInfoReq, dataNodeLocationMap); + CnToDnInternalServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(clientHandler); Map statusMap = clientHandler.getResponseMap(); for (TSStatus status : statusMap.values()) { // all dataNodes must clear the related template cache diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnInternalServiceAsyncRequestManager.java index b9f3753e1b26..3f6763672409 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnInternalServiceAsyncRequestManager.java @@ -42,12 +42,10 @@ protected void initActionMapBuilder() { } @Override - protected AsyncRequestRPCHandler - buildHandler( - AsyncRequestContext - requestContext, - int requestId, - TConfigNodeLocation targetNode) { + protected AsyncRequestRPCHandler buildHandler( + AsyncRequestContext requestContext, + int requestId, + TConfigNodeLocation targetNode) { return ConfigNodeAsyncRequestRPCHandler.buildHandler(requestContext, requestId, targetNode); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java index 6f51fa2968be..dd56e1366c03 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeExternalServiceAsyncRequestManager.java @@ -59,12 +59,10 @@ protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { } @Override - protected AsyncRequestRPCHandler - buildHandler( - AsyncRequestContext - requestContext, - int requestId, - TDataNodeLocation targetNode) { + protected AsyncRequestRPCHandler buildHandler( + AsyncRequestContext requestContext, + int requestId, + TDataNodeLocation targetNode) { return DataNodeAsyncRequestRPCHandler.createAsyncRPCHandler( requestContext, requestId, targetNode); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java index 25ed8c54a10c..ab08d83f2645 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DataNodeMPPServiceAsyncRequestManager.java @@ -33,9 +33,7 @@ public class DataNodeMPPServiceAsyncRequestManager extends AsyncRequestManager< - DnToDnRequestType, - TDataNodeLocation, - AsyncDataNodeMPPDataExchangeServiceClient> { + DnToDnRequestType, TDataNodeLocation, AsyncDataNodeMPPDataExchangeServiceClient> { private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeMPPServiceAsyncRequestManager.class); @@ -62,12 +60,10 @@ protected TEndPoint nodeLocationToEndPoint(TDataNodeLocation dataNodeLocation) { } @Override - protected AsyncRequestRPCHandler - buildHandler( - AsyncRequestContext - requestContext, - int requestId, - TDataNodeLocation targetNode) { + protected AsyncRequestRPCHandler buildHandler( + AsyncRequestContext requestContext, + int requestId, + TDataNodeLocation targetNode) { return DataNodeAsyncRequestRPCHandler.createAsyncRPCHandler( requestContext, requestId, targetNode); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnInternalServiceAsyncRequestManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnInternalServiceAsyncRequestManager.java index 33338f3512e9..88766458b649 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnInternalServiceAsyncRequestManager.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnInternalServiceAsyncRequestManager.java @@ -40,12 +40,10 @@ protected void initActionMapBuilder() { } @Override - protected AsyncRequestRPCHandler - buildHandler( - AsyncRequestContext - requestContext, - int requestId, - TDataNodeLocation targetNode) { + protected AsyncRequestRPCHandler buildHandler( + AsyncRequestContext requestContext, + int requestId, + TDataNodeLocation targetNode) { return DataNodeAsyncRequestRPCHandler.createAsyncRPCHandler( requestContext, requestId, targetNode); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index 76545cab0d18..dab19dee50c2 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -1464,8 +1464,7 @@ private List testAllConfigNodeConnection( TConfigNodeLocation::getInternalEndPoint, TServiceType.ConfigNodeInternalService, DnToCnRequestType.TEST_CONNECTION, - (AsyncRequestContext - handler) -> + (AsyncRequestContext handler) -> DnToCnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); } @@ -1478,8 +1477,7 @@ private List testAllDataNodeInternalServiceConnection( TDataNodeLocation::getInternalEndPoint, TServiceType.DataNodeInternalService, DnToDnRequestType.TEST_CONNECTION, - (AsyncRequestContext - handler) -> + (AsyncRequestContext handler) -> DnToDnInternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); } @@ -1492,8 +1490,7 @@ private List testAllDataNodeMPPServiceConnection( TDataNodeLocation::getMPPDataExchangeEndPoint, TServiceType.DataNodeMPPService, DnToDnRequestType.TEST_CONNECTION, - (AsyncRequestContext - handler) -> + (AsyncRequestContext handler) -> DataNodeMPPServiceAsyncRequestManager.getInstance().sendAsyncRequestWithRetry(handler)); } @@ -1505,8 +1502,7 @@ private List testAllDataNodeExternalServiceConnection( TDataNodeLocation::getClientRpcEndPoint, TServiceType.DataNodeExternalService, DnToDnRequestType.TEST_CONNECTION, - (AsyncRequestContext - handler) -> + (AsyncRequestContext handler) -> DataNodeExternalServiceAsyncRequestManager.getInstance() .sendAsyncRequestWithRetry(handler)); } From 83747df723a4ddf9fcefc36a91b1de32db9ee344 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Thu, 13 Jun 2024 19:23:50 +0800 Subject: [PATCH 50/52] tan review --- .../service/thrift/ConfigNodeRPCServiceProcessor.java | 1 + .../db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java | 1 + .../java/org/apache/iotdb/commons/client/request/Utils.java | 2 +- iotdb-protocol/thrift-commons/src/main/thrift/common.thrift | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java index 031130d077a2..019d88bd7cf5 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java @@ -900,6 +900,7 @@ public TShowDatabaseResp showDatabase(TGetDatabaseReq req) { public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) throws TException { return new TTestConnectionResp( + new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()), configManager.getClusterManager().doConnectionTest(nodeLocations)); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java index dab19dee50c2..0db6eff2e712 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java @@ -1432,6 +1432,7 @@ public TFetchFragmentInstanceStatisticsResp fetchFragmentInstanceStatistics( public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) throws TException { return new TTestConnectionResp( + new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()), Stream.of( testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()), testAllDataNodeInternalServiceConnection(nodeLocations.getDataNodeLocations()), diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java index 31a4b7221ef4..6d4704f059b8 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/Utils.java @@ -49,7 +49,7 @@ List testConnectionsImpl( Map nodeLocationMap = nodeLocations.stream().collect(Collectors.toMap(getId, location -> location)); AsyncRequestContext requestContext = - new AsyncRequestContext<>(requestType, null, nodeLocationMap); + new AsyncRequestContext<>(requestType, new Object(), nodeLocationMap); // do the test sendRequest.accept(requestContext); // collect result diff --git a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift index dc5c9d0603d3..495a7fc6a67b 100644 --- a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift +++ b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift @@ -216,7 +216,7 @@ struct TTestConnectionResult { } struct TTestConnectionResp { - 1: optional TSStatus status + 1: required TSStatus status 2: required list resultList } From 1ed92922f367a4eef78491d688da8d1c781694fa Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 14 Jun 2024 10:24:07 +0800 Subject: [PATCH 51/52] add Exception --- .../org/apache/iotdb/rpc/TSStatusCode.java | 1 + .../SubmitTestConnectionTaskRPCHandler.java | 9 ++++- ...tConnectionTaskToConfigNodeRPCHandler.java | 9 ++++- .../confignode/manager/ClusterManager.java | 39 ++++++++++++------- .../thrift/ConfigNodeRPCServiceProcessor.java | 4 +- .../protocol/client/cn/DnToCnRequestType.java | 1 + .../protocol/client/dn/DnToDnRequestType.java | 1 + .../config/sys/TestConnectionTask.java | 17 ++------ 8 files changed, 47 insertions(+), 34 deletions(-) diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java index 41ac7bf47f8f..0d281a0bf3a1 100644 --- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java +++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java @@ -158,6 +158,7 @@ public enum TSStatusCode { CAN_NOT_CONNECT_DATANODE(1007), TRANSFER_LEADER_ERROR(1008), GET_CLUSTER_ID_ERROR(1009), + CAN_NOT_CONNECT_CONFIGNODE(1010), // Sync, Load TsFile LOAD_FILE_ERROR(1100), diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java index ea4e612db733..4abf0a0eca11 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskRPCHandler.java @@ -20,8 +20,10 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.CnToDnRequestType; +import org.apache.iotdb.rpc.TSStatusCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +56,12 @@ public void onComplete(TTestConnectionResp resp) { @Override public void onError(Exception e) { - responseMap.put(requestId, new TTestConnectionResp()); + responseMap.put( + requestId, + new TTestConnectionResp() + .setStatus( + new TSStatus(TSStatusCode.CAN_NOT_CONNECT_DATANODE.getStatusCode()) + .setMessage(e.getMessage()))); nodeLocationMap.remove(requestId); countDownLatch.countDown(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java index 34abe94f1e70..d26984fd0a70 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/SubmitTestConnectionTaskToConfigNodeRPCHandler.java @@ -20,8 +20,10 @@ package org.apache.iotdb.confignode.client.async.handlers.rpc; import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation; +import org.apache.iotdb.common.rpc.thrift.TSStatus; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.confignode.client.CnToCnNodeRequestType; +import org.apache.iotdb.rpc.TSStatusCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,7 +62,12 @@ public void onComplete(TTestConnectionResp resp) { @Override public void onError(Exception e) { - responseMap.put(requestId, new TTestConnectionResp()); + responseMap.put( + requestId, + new TTestConnectionResp() + .setStatus( + new TSStatus(TSStatusCode.CAN_NOT_CONNECT_CONFIGNODE.getStatusCode()) + .setMessage(e.getMessage()))); nodeLocationMap.remove(requestId); countDownLatch.countDown(); } diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java index 76c56afb84fe..808112cff4cd 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java @@ -48,10 +48,12 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; +import java.util.stream.Stream; public class ClusterManager { @@ -105,6 +107,7 @@ private void generateClusterId() { } } + // TODO: Parallel test ConfigNode and DataNode public TTestConnectionResp submitTestConnectionTaskToEveryNode() { TTestConnectionResp resp = new TTestConnectionResp(); resp.resultList = new ArrayList<>(); @@ -140,7 +143,9 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { resp.getResultList() .addAll( badConfigNodeConnectionResult( - anotherConfigNodeLocationMap.get(nodeId), nodeLocations)); + configNodeResp.getStatus(), + anotherConfigNodeLocationMap.get(nodeId), + nodeLocations)); } }); // For DataNode @@ -167,19 +172,22 @@ public TTestConnectionResp submitTestConnectionTaskToEveryNode() { resp.getResultList() .addAll( badDataNodeConnectionResult( - anotherDataNodeLocationMap.get(nodeId), nodeLocations)); + dataNodeResp.getStatus(), + anotherDataNodeLocationMap.get(nodeId), + nodeLocations)); } }); return resp; } - public List doConnectionTest(TNodeLocations nodeLocations) { - List configNodeResult = - testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()); - List dataNodeResult = - testAllDataNodeConnection(nodeLocations.getDataNodeLocations()); - configNodeResult.addAll(dataNodeResult); - return configNodeResult; + public TTestConnectionResp doConnectionTest(TNodeLocations nodeLocations) { + return new TTestConnectionResp( + new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()), + Stream.of( + testAllConfigNodeConnection(nodeLocations.getConfigNodeLocations()), + testAllDataNodeConnection(nodeLocations.getDataNodeLocations())) + .flatMap(Collection::stream) + .collect(Collectors.toList())); } private List testAllConfigNodeConnection( @@ -202,9 +210,9 @@ private List testAllConfigNodeConnection( } private List badConfigNodeConnectionResult( - TConfigNodeLocation sourceConfigNode, TNodeLocations nodeLocations) { + TSStatus badStatus, TConfigNodeLocation sourceConfigNode, TNodeLocations nodeLocations) { final TSender sender = new TSender().setConfigNodeLocation(sourceConfigNode); - return badNodeConnectionResult(nodeLocations, sender); + return badNodeConnectionResult(badStatus, nodeLocations, sender); } private List testAllDataNodeConnection( @@ -226,14 +234,15 @@ private List testAllDataNodeConnection( } private List badDataNodeConnectionResult( - TDataNodeLocation sourceDataNode, TNodeLocations nodeLocations) { + TSStatus badStatus, TDataNodeLocation sourceDataNode, TNodeLocations nodeLocations) { final TSender sender = new TSender().setDataNodeLocation(sourceDataNode); - return badNodeConnectionResult(nodeLocations, sender); + return badNodeConnectionResult(badStatus, nodeLocations, sender); } private List badNodeConnectionResult( - TNodeLocations nodeLocations, TSender sender) { - final String errorMessage = "ConfigNode leader cannot connect to the sender"; + TSStatus badStatus, TNodeLocations nodeLocations, TSender sender) { + final String errorMessage = + "ConfigNode leader cannot connect to the sender: " + badStatus.getMessage(); List results = new ArrayList<>(); nodeLocations .getConfigNodeLocations() diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java index 019d88bd7cf5..0eeb3e9b8913 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java @@ -899,9 +899,7 @@ public TShowDatabaseResp showDatabase(TGetDatabaseReq req) { @Override public TTestConnectionResp submitTestConnectionTask(TNodeLocations nodeLocations) throws TException { - return new TTestConnectionResp( - new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()), - configManager.getClusterManager().doConnectionTest(nodeLocations)); + return configManager.getClusterManager().doConnectionTest(nodeLocations); } /** Call by client connected DataNode */ diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnRequestType.java index 3c6e364273d3..5708fec5bed2 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnRequestType.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/cn/DnToCnRequestType.java @@ -19,6 +19,7 @@ package org.apache.iotdb.db.protocol.client.cn; +/** For DataNode async call ConfigNode */ public enum DnToCnRequestType { SUBMIT_TEST_CONNECTION_TASK, TEST_CONNECTION, diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnRequestType.java index a46d93a72956..35f5b8d93a9b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnRequestType.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/DnToDnRequestType.java @@ -19,6 +19,7 @@ package org.apache.iotdb.db.protocol.client.dn; +/** For DataNode async call DataNode */ public enum DnToDnRequestType { TEST_CONNECTION, } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java index 9d24373019f8..ce37a7ad44c9 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/TestConnectionTask.java @@ -25,6 +25,7 @@ import org.apache.iotdb.common.rpc.thrift.TServiceType; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp; import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult; +import org.apache.iotdb.commons.service.ThriftService; import org.apache.iotdb.db.queryengine.common.header.ColumnHeader; import org.apache.iotdb.db.queryengine.common.header.ColumnHeaderConstant; import org.apache.iotdb.db.queryengine.common.header.DatasetHeaderFactory; @@ -166,9 +167,9 @@ private static String serviceProviderToString(TServiceProvider provider) { private static String connectionResultToString(TTestConnectionResult result) { if (result.isSuccess()) { - return "up"; + return ThriftService.STATUS_UP; } - return "down" + " (" + result.getReason() + ")"; + return ThriftService.STATUS_DOWN + " (" + result.getReason() + ")"; } private static String endPointToString(TEndPoint endPoint) { @@ -214,16 +215,4 @@ private static int calculateConnectionMaxLen(TTestConnectionResp resp) { .max() .getAsInt(); } - - private static String addLineBreak(String origin, int interval) { - if (origin.length() < interval) { - return origin; - } - StringBuilder builder = new StringBuilder(origin.substring(0, interval)); - for (int i = interval; i < origin.length(); i += interval) { - builder.append("\n"); - builder.append(origin, i, Math.min(origin.length(), i + interval)); - } - return builder.toString(); - } } From 3ffac24a87648d5ad4bdcffe1b1ab90356281ed8 Mon Sep 17 00:00:00 2001 From: liyuheng Date: Fri, 14 Jun 2024 11:44:23 +0800 Subject: [PATCH 52/52] add IT --- .../iotdb/itbase/runtime/RequestDelegate.java | 10 +- .../iotdb/db/it/IoTDBVerifyConnectionIT.java | 123 ++++++++++++++++++ 2 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBVerifyConnectionIT.java diff --git a/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/RequestDelegate.java b/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/RequestDelegate.java index bc32c31e7932..47f31004e6f2 100644 --- a/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/RequestDelegate.java +++ b/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/RequestDelegate.java @@ -76,14 +76,10 @@ public final void addRequest(Callable request) { */ public final T requestAllAndCompare() throws SQLException { List results = requestAll(); - T data = results.get(0); - for (int i = 1; i < results.size(); i++) { - T anotherData = results.get(i); - if (!compare(data, anotherData)) { - throw new InconsistentDataException(results, endpoints); - } + if (!results.stream().allMatch(result -> compare(results.get(0), result))) { + throw new InconsistentDataException(results, endpoints); } - return data; + return results.get(0); } private boolean compare(T data, T anotherData) { diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBVerifyConnectionIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBVerifyConnectionIT.java new file mode 100644 index 000000000000..e442264eb7bf --- /dev/null +++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBVerifyConnectionIT.java @@ -0,0 +1,123 @@ +/* + * 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.db.it; + +import org.apache.iotdb.commons.service.ThriftService; +import org.apache.iotdb.consensus.ConsensusFactory; +import org.apache.iotdb.it.env.EnvFactory; +import org.apache.iotdb.it.framework.IoTDBTestRunner; +import org.apache.iotdb.itbase.category.ClusterIT; + +import com.google.common.collect.ImmutableMap; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; + +@RunWith(IoTDBTestRunner.class) +@Category({ClusterIT.class}) +public class IoTDBVerifyConnectionIT { + private static final String testConsensusProtocolClass = ConsensusFactory.RATIS_CONSENSUS; + + @Before + public void setUp() throws Exception { + EnvFactory.getEnv() + .getConfig() + .getCommonConfig() + .setConfigNodeConsensusProtocolClass(testConsensusProtocolClass) + .setSchemaRegionConsensusProtocolClass(testConsensusProtocolClass) + .setDataRegionConsensusProtocolClass(testConsensusProtocolClass); + } + + @After + public void tearDown() throws Exception { + EnvFactory.getEnv().cleanClusterEnvironment(); + } + + @Test + public void verifyConnectionAllUpTest() throws Exception { + EnvFactory.getEnv().initClusterEnvironment(3, 3); + try (Connection connection = EnvFactory.getEnv().getConnection(); + Statement statement = connection.createStatement()) { + ResultSet resultSet = statement.executeQuery("verify connection"); + Assert.assertEquals( + ImmutableMap.of(ThriftService.STATUS_UP, 12), collectConnectionResult(resultSet)); + resultSet = statement.executeQuery("verify connection details"); + Assert.assertEquals( + ImmutableMap.of(ThriftService.STATUS_UP, 54), collectConnectionResult(resultSet)); + } + } + + @Test + public void verifyConnectionWithNodeCorruptTest() throws Exception { + EnvFactory.getEnv().initClusterEnvironment(5, 1); + try (Connection connection = EnvFactory.getEnv().getConnection(); + Statement statement = connection.createStatement()) { + ResultSet resultSet = statement.executeQuery("verify connection details"); + Assert.assertEquals( + ImmutableMap.of(ThriftService.STATUS_UP, 38), collectConnectionResult(resultSet)); + EnvFactory.getEnv().getConfigNodeWrapperList().get(0).stopForcibly(); + resultSet = statement.executeQuery("verify connection"); + Assert.assertEquals( + ImmutableMap.of(ThriftService.STATUS_UP, 2, ThriftService.STATUS_DOWN, 11), + collectConnectionResult(resultSet)); + resultSet = statement.executeQuery("verify connection details"); + Assert.assertEquals( + ImmutableMap.of(ThriftService.STATUS_UP, 27, ThriftService.STATUS_DOWN, 11), + collectConnectionResult(resultSet)); + EnvFactory.getEnv().getConfigNodeWrapperList().get(1).stopForcibly(); + Thread.sleep(10000); + resultSet = statement.executeQuery("verify connection"); + Assert.assertEquals( + ImmutableMap.of(ThriftService.STATUS_UP, 2, ThriftService.STATUS_DOWN, 20), + collectConnectionResult(resultSet)); + resultSet = statement.executeQuery("verify connection details"); + Assert.assertEquals( + ImmutableMap.of(ThriftService.STATUS_UP, 18, ThriftService.STATUS_DOWN, 20), + collectConnectionResult(resultSet)); + } + } + + private static Map collectConnectionResult(ResultSet resultSet) + throws Exception { + Map map = new HashMap<>(); + while (resultSet.next()) { + String result = resultSet.getString(3).split(" ")[0]; + map.computeIfPresent(result, (key, value) -> value + 1); + map.putIfAbsent(result, 1); + } + return map; + } + + private static void showResult(ResultSet resultSet) throws Exception { + while (resultSet.next()) { + System.out.printf( + "%s %s %s\n", resultSet.getString(1), resultSet.getString(2), resultSet.getString(3)); + } + } +}