You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/24 09:17:56 UTC

[GitHub] [iotdb] wangchao316 commented on a diff in pull request #5994: [IOTDB-2919] Refactor delete storage group

wangchao316 commented on code in PR #5994:
URL: https://github.com/apache/iotdb/pull/5994#discussion_r879402592


##########
confignode/src/main/java/org/apache/iotdb/confignode/client/SyncDataNodeClientPool.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.confignode.client;
+
+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.TRegionReplicaSet;
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.client.sync.SyncDataNodeInternalServiceClient;
+import org.apache.iotdb.mpp.rpc.thrift.TInvalidateCacheReq;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/** Asynchronously send RPC requests to DataNodes. See mpp.thrift for more details. */
+public class SyncDataNodeClientPool {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(SyncDataNodeClientPool.class);
+
+  private final IClientManager<TEndPoint, SyncDataNodeInternalServiceClient> clientManager;
+
+  private SyncDataNodeClientPool() {
+    clientManager =
+        new IClientManager.Factory<TEndPoint, SyncDataNodeInternalServiceClient>()
+            .createClientManager(
+                new ConfigNodeClientPoolFactory.SyncDataNodeInternalServiceClientPoolFactory());
+  }
+
+  public TSStatus invalidatePartitionCache(
+      TEndPoint endPoint, TInvalidateCacheReq invalidateCacheReq) {
+    SyncDataNodeInternalServiceClient client;
+    TSStatus status;
+    try {
+      client = clientManager.borrowClient(endPoint);
+      status = client.invalidatePartitionCache(invalidateCacheReq);
+      LOGGER.info("Invalid Schema Cache {} successfully", invalidateCacheReq);
+    } catch (IOException e) {
+      LOGGER.error("Can't connect to DataNode {}", endPoint, e);
+      status = new TSStatus(TSStatusCode.TIME_OUT.getStatusCode());
+    } catch (TException e) {
+      LOGGER.error("Invalid Schema Cache on DataNode {} failed", endPoint, e);
+      status = new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode());
+    }
+    return status;
+  }
+
+  public TSStatus invalidateSchemaCache(
+      TEndPoint endPoint, TInvalidateCacheReq invalidateCacheReq) {
+    SyncDataNodeInternalServiceClient client;
+    TSStatus status;
+    try {
+      client = clientManager.borrowClient(endPoint);
+      status = client.invalidateSchemaCache(invalidateCacheReq);

Review Comment:
   need close client.  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org