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 2021/06/08 02:59:48 UTC

[GitHub] [iotdb] neuyilan commented on a change in pull request #3364: Remove the broken cached leader connection & optimize the insertRecords method in session

neuyilan commented on a change in pull request #3364:
URL: https://github.com/apache/iotdb/pull/3364#discussion_r647074582



##########
File path: session/src/main/java/org/apache/iotdb/session/Session.java
##########
@@ -685,6 +685,27 @@ private SessionConnection getSessionConnection(String deviceId) {
     }
   }
 
+  // TODO https://issues.apache.org/jira/browse/IOTDB-1399
+  private void removeBrokenSessionConnection(SessionConnection sessionConnection) {
+    // remove the cached broken leader session
+    if (enableCacheLeader) {
+      EndPoint endPoint = null;
+      for (Map.Entry<EndPoint, SessionConnection> entry : endPointToSessionConnection.entrySet()) {
+        if (entry.getValue().equals(sessionConnection)) {
+          endPoint = entry.getKey();
+          endPointToSessionConnection.remove(endPoint);
+          break;
+        }
+      }
+
+      for (Map.Entry<String, EndPoint> entry : deviceIdToEndpoint.entrySet()) {
+        if (entry.getValue().equals(endPoint)) {
+          deviceIdToEndpoint.remove(entry.getKey());

Review comment:
       Thanks, done

##########
File path: service-rpc/src/main/java/org/apache/iotdb/rpc/RpcUtils.java
##########
@@ -95,6 +95,22 @@ public static void verifySuccessWithRedirection(TSStatus status)
     }
   }
 
+  public static void verifySuccessWithRedirectionForMultiDevices(
+      TSStatus status, List<String> devices) throws StatementExecutionException, RedirectException {
+    verifySuccess(status);
+    if (status.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
+      Map<String, EndPoint> deviceEndPointMap = new HashMap<>();
+      List<TSStatus> statusSubStatus = status.getSubStatus();
+      for (int i = 0; i < statusSubStatus.size(); i++) {
+        TSStatus subStatus = statusSubStatus.get(i);
+        if (subStatus.isSetRedirectNode()) {
+          deviceEndPointMap.put(devices.get(i), subStatus.getRedirectNode());
+        }
+      }
+      throw new RedirectException(deviceEndPointMap);
+    }
+  }
+
   public static void verifySuccessWithRedirectionForInsertTablets(

Review comment:
       sure




-- 
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.

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