You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/04/08 08:40:05 UTC

[incubator-iotdb] 01/01: enable compression in session pool

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

qiaojialin pushed a commit to branch enable_compression_in_session_pool
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 9c845391d420df093d8c34674ac680a6fa181c09
Author: qiaojialin <64...@qq.com>
AuthorDate: Wed Apr 8 16:39:55 2020 +0800

    enable compression in session pool
---
 .../java/org/apache/iotdb/session/pool/SessionPool.java     | 13 ++++++++++---
 .../java/org/apache/iotdb/session/pool/SessionPoolTest.java |  4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java b/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
index 1f7b579..8c103ca 100644
--- a/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
+++ b/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
@@ -76,13 +76,19 @@ public class SessionPool {
 
   private long timeout; //ms
   private static int RETRY = 3;
+  private boolean enableCompression = false;
 
   public SessionPool(String ip, int port, String user, String password, int maxSize) {
-    this(ip, port, user, password, maxSize, Config.DEFAULT_FETCH_SIZE, 60_000);
+    this(ip, port, user, password, maxSize, Config.DEFAULT_FETCH_SIZE, 60_000, false);
+  }
+
+  public SessionPool(String ip, int port, String user, String password, int maxSize,
+      boolean enableCompression) {
+    this(ip, port, user, password, maxSize, Config.DEFAULT_FETCH_SIZE, 60_000, enableCompression);
   }
 
   public SessionPool(String ip, int port, String user, String password, int maxSize, int fetchSize,
-      long timeout) {
+      long timeout, boolean enableCompression) {
     this.maxSize = maxSize;
     this.ip = ip;
     this.port = port;
@@ -90,6 +96,7 @@ public class SessionPool {
     this.password = password;
     this.fetchSize = fetchSize;
     this.timeout = timeout;
+    this.enableCompression = enableCompression;
   }
 
   //if this method throws an exception, either the server is broken, or the ip/port/user/password is incorrect.
@@ -135,7 +142,7 @@ public class SessionPool {
         logger.error("Create a new Session {}, {}, {}, {}", ip, port, user, password);
       }
       session = new Session(ip, port, user, password, fetchSize);
-      session.open();
+      session.open(enableCompression);
       return session;
     }
   }
diff --git a/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java b/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
index 59dda6b..9b649aa 100644
--- a/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
+++ b/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
@@ -171,7 +171,7 @@ public class SessionPoolTest {
 
   @Test
   public void tryIfTheServerIsRestart() {
-    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3, 1,6000);
+    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3, 1, 6000, false);
     for (int i = 0; i < 10; i++) {
       try {
         pool.insert("root.sg1.d1", i, Collections.singletonList("s" + i), Collections.singletonList("" + i));
@@ -206,7 +206,7 @@ public class SessionPoolTest {
 
   @Test
   public void tryIfTheServerIsRestartButDataIsGotten() {
-    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3, 1,60000);
+    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3, 1, 60000, false);
     for (int i = 0; i < 10; i++) {
       try {
         pool.insert("root.sg1.d1", i, Collections.singletonList("s" + i), Collections.singletonList("" + i));