This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch rel/1.2
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/1.2 by this push:
     new 4e0a44e1739 [To rel/1.2][IOTDB-6156] Fixed TConfiguration invalidly in 
Thrift AsyncServer For IoTConsensus
4e0a44e1739 is described below

commit 4e0a44e173942186efeea4fa9a79c6ef2c988d22
Author: Potato <tanxi...@apache.org>
AuthorDate: Fri Sep 15 21:05:21 2023 +0800

    [To rel/1.2][IOTDB-6156] Fixed TConfiguration invalidly in Thrift 
AsyncServer For IoTConsensus
---
 .../org/apache/iotdb/rpc/RpcTransportFactory.java  | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git 
a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/RpcTransportFactory.java
 
b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/RpcTransportFactory.java
index d6d8ef2cb69..c7aeef8ec36 100644
--- 
a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/RpcTransportFactory.java
+++ 
b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/RpcTransportFactory.java
@@ -19,6 +19,7 @@
 
 package org.apache.iotdb.rpc;
 
+import org.apache.thrift.transport.TMemoryInputTransport;
 import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
@@ -46,9 +47,33 @@ public class RpcTransportFactory extends TTransportFactory {
 
   @Override
   public TTransport getTransport(TTransport trans) throws TTransportException {
+    updateConfigurationForAsyncServerIfNecessary(trans);
     return inner.getTransport(trans);
   }
 
+  /**
+   * The Thrift AsyncServer uses TMemoryInputTransport (<a
+   * 
href="https://github.com/apache/thrift/blob/master/lib/java/src/main/java/org/apache/thrift/server/AbstractNonblockingServer.java#L291";>...</a>),
+   * which employs the default configuration and performs size checks during 
the read and write
+   * processes. This behavior is not in line with our expectations of manually 
adjusting certain
+   * parameters. Therefore, special handling is required for it in this 
function.
+   *
+   * @param trans TTransport
+   */
+  private void updateConfigurationForAsyncServerIfNecessary(TTransport trans) {
+    if (trans instanceof TMemoryInputTransport) {
+      trans
+          .getConfiguration()
+          
.setRecursionLimit(TConfigurationConst.defaultTConfiguration.getRecursionLimit());
+      trans
+          .getConfiguration()
+          
.setMaxMessageSize(TConfigurationConst.defaultTConfiguration.getMaxMessageSize());
+      trans
+          .getConfiguration()
+          
.setMaxFrameSize(TConfigurationConst.defaultTConfiguration.getMaxFrameSize());
+    }
+  }
+
   public TTransport getTransportWithNoTimeout(String ip, int port) throws 
TTransportException {
     return inner.getTransport(new 
TSocket(TConfigurationConst.defaultTConfiguration, ip, port));
   }

Reply via email to