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

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 699998f  [IOTDB-872] Use system timezone in CLI (Session) (#1846)
699998f is described below

commit 699998f8d16ee638f0154e8693e54fd6aef5ddde
Author: Xiangwei Wei <[email protected]>
AuthorDate: Thu Oct 29 11:29:33 2020 +0800

    [IOTDB-872] Use system timezone in CLI (Session) (#1846)
    
    Co-authored-by: Jialin Qiao <[email protected]>
    Co-authored-by: Alima777 <[email protected]>
---
 .../java/org/apache/iotdb/cli/AbstractCli.java     |   2 -
 .../org/apache/iotdb/jdbc/IoTDBConnection.java     |   9 +-
 .../resources/conf/iotdb-engine.properties         |   5 -
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java |  10 -
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  |   7 -
 .../main/java/org/apache/iotdb/db/qp/Planner.java  |   2 +-
 .../apache/iotdb/db/qp/constant/DatetimeUtils.java |   3 +-
 .../org/apache/iotdb/db/service/TSServiceImpl.java |   2 +-
 .../iotdb/db/qp/plan/LogicalPlanSmallTest.java     |  65 ++---
 .../java/org/apache/iotdb/session/Session.java     |  70 +++---
 .../org/apache/iotdb/session/pool/SessionPool.java |  28 ++-
 .../java/org/apache/iotdb/session/SessionUT.java   | 266 +++++++++++----------
 .../apache/iotdb/session/pool/SessionPoolTest.java |   6 +-
 thrift/rpc-changelist.md                           |   4 +-
 thrift/src/main/thrift/rpc.thrift                  |   7 +-
 15 files changed, 239 insertions(+), 247 deletions(-)

diff --git a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java 
b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
index 2da461b..4f967ec 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
@@ -548,8 +548,6 @@ public abstract class AbstractCli {
     } catch (SQLException e) {
       println(String.format("Failed to import from %s because %s",
           cmd.split(" ")[1], e.getMessage()));
-    } catch (TException e) {
-      println("Cannot connect to server");
     }
   }
 
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java 
b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
index b217bb9..1924cfc 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
@@ -419,6 +419,7 @@ public class IoTDBConnection implements Connection {
 
     openReq.setUsername(params.getUsername());
     openReq.setPassword(params.getPassword());
+    openReq.setZoneId(getTimeZone());
 
     TSOpenSessionResp openResp = null;
     try {
@@ -437,12 +438,6 @@ public class IoTDBConnection implements Connection {
         }
       }
 
-      if (zoneId != null) {
-        setTimeZone(zoneId.toString());
-      } else {
-        zoneId = ZoneId.of(getTimeZone());
-      }
-
     } catch (TException e) {
       transport.close();
       if (e.getMessage().contains("Required field 'client_protocol' was not 
present!")) {
@@ -491,7 +486,7 @@ public class IoTDBConnection implements Connection {
     return flag;
   }
 
-  public String getTimeZone() throws TException, IoTDBSQLException {
+  public String getTimeZone() {
     if (zoneId != null) {
       return zoneId.toString();
     }
diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties 
b/server/src/assembly/resources/conf/iotdb-engine.properties
index 82d83f0..db1e03b 100644
--- a/server/src/assembly/resources/conf/iotdb-engine.properties
+++ b/server/src/assembly/resources/conf/iotdb-engine.properties
@@ -173,11 +173,6 @@ timestamp_precision=ms
 # If it sets a value smaller than 0, use the default value 16777216
 wal_buffer_size=16777216
 
-# time zone of server side
-# default value is +08:00
-# eg. +08:00, -01:00
-time_zone=+08:00
-
 # When a TsFile's file size (in byte) exceeds this, the TsFile is forced 
closed. The default threshold is 512 MB.
 tsfile_size_threshold=536870912
 
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 7dddbce..261a927 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -241,8 +241,6 @@ public class IoTDBConfig {
    */
   private int concurrentQueryThread = 
Runtime.getRuntime().availableProcessors();
 
-  private ZoneId zoneID = ZoneId.systemDefault();
-
   /**
    * When a TsFile's file size (in byte) exceed this, the TsFile is forced 
closed.
    */
@@ -773,14 +771,6 @@ public class IoTDBConfig {
     this.partitionInterval = partitionInterval;
   }
 
-  public ZoneId getZoneID() {
-    return zoneID;
-  }
-
-  void setZoneID(ZoneId zoneID) {
-    this.zoneID = zoneID;
-  }
-
   void updatePath() {
     formulateFolders();
     confirmMultiDirStrategy();
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index f45359b..0463828 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -338,9 +338,6 @@ public class IoTDBDescriptor {
         conf.setChunkBufferPoolEnable(Boolean
             .parseBoolean(properties.getProperty("chunk_buffer_pool_enable")));
       }
-      conf.setZoneID(
-          ZoneId.of(properties.getProperty("time_zone", 
conf.getZoneID().toString().trim())));
-      logger.info("Time zone has been set to {}", conf.getZoneID());
 
       conf.setEnableExternalSort(Boolean.parseBoolean(properties
           .getProperty("enable_external_sort", 
Boolean.toString(conf.isEnableExternalSort()))));
@@ -681,10 +678,6 @@ public class IoTDBDescriptor {
       // update WAL conf
       loadWALProps(properties);
 
-      // time zone
-      conf.setZoneID(
-          ZoneId.of(properties.getProperty("time_zone", 
conf.getZoneID().toString().trim())));
-
       // dynamic parameters
       long tsfileSizeThreshold = Long.parseLong(properties
           .getProperty("tsfile_size_threshold",
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/Planner.java 
b/server/src/main/java/org/apache/iotdb/db/qp/Planner.java
index b8632d2..3f4f84b 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/Planner.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/Planner.java
@@ -66,7 +66,7 @@ public class Planner {
   public PhysicalPlan parseSQLToPhysicalPlan(String sqlStr)
       throws QueryProcessException {
     IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-    return parseSQLToPhysicalPlan(sqlStr, config.getZoneID(), 1024);
+    return parseSQLToPhysicalPlan(sqlStr, ZoneId.systemDefault(), 1024);
   }
 
   /**
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/constant/DatetimeUtils.java 
b/server/src/main/java/org/apache/iotdb/db/qp/constant/DatetimeUtils.java
index 1702449..2e3dc65 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/constant/DatetimeUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/constant/DatetimeUtils.java
@@ -542,8 +542,7 @@ public class DatetimeUtils {
   }
 
   public static ZonedDateTime convertMillsecondToZonedDateTime(long 
millisecond) {
-    return ZonedDateTime.ofInstant(Instant.ofEpochMilli(millisecond),
-        IoTDBDescriptor.getInstance().getConfig().getZoneID());
+    return ZonedDateTime.ofInstant(Instant.ofEpochMilli(millisecond), 
ZoneId.systemDefault());
   }
 
   public enum DurationUnit {
diff --git 
a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java 
b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 7295755..dd78b8d 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -224,7 +224,7 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
       tsStatus = RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS, "Login 
successfully");
       sessionId = sessionIdGenerator.incrementAndGet();
       sessionIdUsernameMap.put(sessionId, req.getUsername());
-      sessionIdZoneIdMap.put(sessionId, config.getZoneID());
+      sessionIdZoneIdMap.put(sessionId, ZoneId.of(req.getZoneId()));
       currSessionId.set(sessionId);
     } else {
       tsStatus = RpcUtils.getStatus(TSStatusCode.WRONG_LOGIN_PASSWORD_ERROR);
diff --git 
a/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java 
b/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
index c68eea7..0e17394 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iotdb.db.qp.plan;
 
+import java.time.ZoneId;
 import java.util.ArrayList;
 import org.antlr.v4.runtime.misc.ParseCancellationException;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -52,7 +53,7 @@ public class LogicalPlanSmallTest {
   public void testLimit() {
     String sqlStr = "select * from root.vehicle.d1 limit 10";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(QueryOperator.class, operator.getClass());
     Assert.assertEquals(10, ((QueryOperator) operator).getRowLimit());
     Assert.assertEquals(0, ((QueryOperator) operator).getRowOffset());
@@ -64,7 +65,7 @@ public class LogicalPlanSmallTest {
   public void testOffset() {
     String sqlStr = "select * from root.vehicle.d1 limit 10 offset 20";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(QueryOperator.class, operator.getClass());
     Assert.assertEquals(10, ((QueryOperator) operator).getRowLimit());
     Assert.assertEquals(20, ((QueryOperator) operator).getRowOffset());
@@ -76,7 +77,7 @@ public class LogicalPlanSmallTest {
   public void testSlimit() {
     String sqlStr = "select * from root.vehicle.d1 limit 10 slimit 1";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(QueryOperator.class, operator.getClass());
     Assert.assertEquals(10, ((QueryOperator) operator).getRowLimit());
     Assert.assertEquals(0, ((QueryOperator) operator).getRowOffset());
@@ -88,7 +89,7 @@ public class LogicalPlanSmallTest {
   public void testSOffset() {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() limit 50 slimit 10 soffset 100";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(QueryOperator.class, operator.getClass());
     Assert.assertEquals(50, ((QueryOperator) operator).getRowLimit());
     Assert.assertEquals(0, ((QueryOperator) operator).getRowOffset());
@@ -100,7 +101,7 @@ public class LogicalPlanSmallTest {
   public void testSOffsetTimestamp() {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and timestamp 
<= now() limit 50 slimit 10 soffset 100";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(QueryOperator.class, operator.getClass());
     Assert.assertEquals(50, ((QueryOperator) operator).getRowLimit());
     Assert.assertEquals(0, ((QueryOperator) operator).getRowOffset());
@@ -112,7 +113,7 @@ public class LogicalPlanSmallTest {
   public void testLimitOutOfRange() {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() limit 1111111111111111111111";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     // expected to throw SQLParserException: Out of range. LIMIT <N>: N should 
be Int32.
   }
 
@@ -120,7 +121,7 @@ public class LogicalPlanSmallTest {
   public void testLimitNotPositive() {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() limit 0";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     // expected to throw SQLParserException: LIMIT <N>: N should be greater 
than 0.
   }
 
@@ -129,7 +130,7 @@ public class LogicalPlanSmallTest {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() "
         + "limit 1 offset 1111111111111111111111";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     // expected to throw SQLParserException: Out of range. OFFSET 
<OFFSETValue>: OFFSETValue should be Int32.
   }
 
@@ -137,7 +138,7 @@ public class LogicalPlanSmallTest {
   public void testOffsetNotPositive() {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() limit 1 offset -1";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     // expected to throw SQLParserException: OFFSET <OFFSETValue>: OFFSETValue 
should >= 0.
   }
 
@@ -145,7 +146,7 @@ public class LogicalPlanSmallTest {
   public void testSlimitOutOfRange() {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() slimit 1111111111111111111111";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     // expected to throw SQLParserException: Out of range. SLIMIT <SN>: SN 
should be Int32.
   }
 
@@ -153,7 +154,7 @@ public class LogicalPlanSmallTest {
   public void testSlimitNotPositive() {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() slimit 0";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     // expected to throw SQLParserException: SLIMIT <SN>: SN should be greater 
than 0.
   }
 
@@ -162,7 +163,7 @@ public class LogicalPlanSmallTest {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() "
         + "slimit 1 soffset 1111111111111111111111";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     // expected to throw SQLParserException: Out of range. SOFFSET 
<SOFFSETValue>: SOFFSETValue should be Int32.
   }
 
@@ -170,7 +171,7 @@ public class LogicalPlanSmallTest {
   public void testSoffsetNotPositive() {
     String sqlStr = "select * from root.vehicle.d1 where s1 < 20 and time <= 
now() slimit 1 soffset 1";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(1, ((QueryOperator) operator).getSeriesOffset());
     Assert.assertEquals(1, ((QueryOperator) operator).getSeriesLimit());
   }
@@ -179,7 +180,7 @@ public class LogicalPlanSmallTest {
   public void testSoffsetExceedColumnNum() throws QueryProcessException {
     String sqlStr = "select s1 from root.vehicle.d1 where s1 < 20 and time <= 
now() slimit 2 soffset 1";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     IoTDB.metaManager.init();
     ConcatPathOptimizer concatPathOptimizer = new ConcatPathOptimizer();
     concatPathOptimizer.transform(operator, 1000);
@@ -191,7 +192,7 @@ public class LogicalPlanSmallTest {
   public void testDeleteStorageGroup() throws IllegalPathException {
     String sqlStr = "delete storage group root.vehicle.d1";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(DeleteStorageGroupOperator.class, operator.getClass());
     PartialPath path = new PartialPath("root.vehicle.d1");
     Assert.assertEquals(path, ((DeleteStorageGroupOperator) 
operator).getDeletePathList().get(0));
@@ -201,7 +202,7 @@ public class LogicalPlanSmallTest {
   public void testDisableAlign() {
     String sqlStr = "select * from root.vehicle disable align";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(QueryOperator.class, operator.getClass());
     Assert.assertFalse(((QueryOperator) operator).isAlignByTime());
   }
@@ -210,7 +211,7 @@ public class LogicalPlanSmallTest {
   public void testNotDisableAlign() {
     String sqlStr = "select * from root.vehicle";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
     Assert.assertEquals(QueryOperator.class, operator.getClass());
     Assert.assertTrue(((QueryOperator) operator).isAlignByTime());
   }
@@ -219,20 +220,20 @@ public class LogicalPlanSmallTest {
   public void testDisableAlignConflictAlignByDevice() {
     String sqlStr = "select * from root.vehicle disable align align by device";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr, ZoneId.systemDefault());
   }
 
   @Test
   public void testChineseCharacter() throws IllegalPathException {
     String sqlStr1 = "set storage group to root.一级";
     RootOperator operator = (RootOperator) parseDriver
-        .parse(sqlStr1, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr1, ZoneId.systemDefault());
     Assert.assertEquals(SetStorageGroupOperator.class, operator.getClass());
     Assert.assertEquals(new PartialPath("root.一级"), ((SetStorageGroupOperator) 
operator).getPath());
 
     String sqlStr2 = "select * from root.一级.设备1 limit 10 offset 20";
     operator = (RootOperator) parseDriver
-        .parse(sqlStr2, IoTDBDescriptor.getInstance().getConfig().getZoneID());
+        .parse(sqlStr2, ZoneId.systemDefault());
     Assert.assertEquals(QueryOperator.class, operator.getClass());
     ArrayList<PartialPath> paths = new ArrayList<>();
     paths.add(new PartialPath("*"));
@@ -252,7 +253,7 @@ public class LogicalPlanSmallTest {
               + 
"FIRST_VALUE.SUM.LAST_VALUE.LAST.DISABLE.ALIGN.COMPRESSION.TIME.ATTRIBUTES.TAGS.RENAME.FULL.CLEAR.CACHE."
               + "SNAPSHOT.FOR.SCHEMA.TRACING.OFF where time>=1 and time < 3";
 
-      Operator op = parseDriver.parse(sql, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+      Operator op = parseDriver.parse(sql, ZoneId.systemDefault());
       Assert.assertEquals(DeleteDataOperator.class, op.getClass());
     } catch (ParseCancellationException ignored) {
 
@@ -262,7 +263,7 @@ public class LogicalPlanSmallTest {
   @Test
   public void testRangeDelete() throws IllegalPathException {
     String sql1 = "delete from root.d1.s1 where time>=1 and time < 3";
-    Operator op = parseDriver.parse(sql1, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+    Operator op = parseDriver.parse(sql1, ZoneId.systemDefault());
     Assert.assertEquals(DeleteDataOperator.class, op.getClass());
     ArrayList<PartialPath> paths = new ArrayList<>();
     paths.add(new PartialPath("root.d1.s1"));
@@ -271,37 +272,37 @@ public class LogicalPlanSmallTest {
     Assert.assertEquals(2, ((DeleteDataOperator) op).getEndTime());
 
     String sql2 = "delete from root.d1.s1 where time>=1";
-    op = parseDriver.parse(sql2, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+    op = parseDriver.parse(sql2, ZoneId.systemDefault());
     Assert.assertEquals(paths, ((DeleteDataOperator) op).getSelectedPaths());
     Assert.assertEquals(1, ((DeleteDataOperator) op).getStartTime());
     Assert.assertEquals(Long.MAX_VALUE, ((DeleteDataOperator) 
op).getEndTime());
 
     String sql3 = "delete from root.d1.s1 where time>1";
-    op = parseDriver.parse(sql3, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+    op = parseDriver.parse(sql3, ZoneId.systemDefault());
     Assert.assertEquals(paths, ((DeleteDataOperator) op).getSelectedPaths());
     Assert.assertEquals(2, ((DeleteDataOperator) op).getStartTime());
     Assert.assertEquals(Long.MAX_VALUE, ((DeleteDataOperator) 
op).getEndTime());
 
     String sql4 = "delete from root.d1.s1 where time <= 1";
-    op = parseDriver.parse(sql4, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+    op = parseDriver.parse(sql4, ZoneId.systemDefault());
     Assert.assertEquals(paths, ((DeleteDataOperator) op).getSelectedPaths());
     Assert.assertEquals(Long.MIN_VALUE, ((DeleteDataOperator) 
op).getStartTime());
     Assert.assertEquals(1, ((DeleteDataOperator) op).getEndTime());
 
     String sql5 = "delete from root.d1.s1 where time<1";
-    op = parseDriver.parse(sql5, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+    op = parseDriver.parse(sql5, ZoneId.systemDefault());
     Assert.assertEquals(paths, ((DeleteDataOperator) op).getSelectedPaths());
     Assert.assertEquals(Long.MIN_VALUE, ((DeleteDataOperator) 
op).getStartTime());
     Assert.assertEquals(0, ((DeleteDataOperator) op).getEndTime());
 
     String sql6 = "delete from root.d1.s1 where time = 3";
-    op = parseDriver.parse(sql6, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+    op = parseDriver.parse(sql6, ZoneId.systemDefault());
     Assert.assertEquals(paths, ((DeleteDataOperator) op).getSelectedPaths());
     Assert.assertEquals(3, ((DeleteDataOperator) op).getStartTime());
     Assert.assertEquals(3, ((DeleteDataOperator) op).getEndTime());
 
     String sql7 = "delete from root.d1.s1 where time > 5 and time >= 2";
-    op = parseDriver.parse(sql7, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+    op = parseDriver.parse(sql7, ZoneId.systemDefault());
     Assert.assertEquals(paths, ((DeleteDataOperator) op).getSelectedPaths());
     Assert.assertEquals(6, ((DeleteDataOperator) op).getStartTime());
     Assert.assertEquals(Long.MAX_VALUE, ((DeleteDataOperator) 
op).getEndTime());
@@ -312,7 +313,7 @@ public class LogicalPlanSmallTest {
     String sql = "delete from root.d1.s1 where time>=1 and time < 3 or time 
>1";
     String errorMsg = null;
     try {
-      parseDriver.parse(sql, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+      parseDriver.parse(sql, ZoneId.systemDefault());
     } catch (SQLParserException e) {
       errorMsg = e.getMessage();
     }
@@ -324,7 +325,7 @@ public class LogicalPlanSmallTest {
     sql = "delete from root.d1.s1 where time>=1 or time < 3";
     errorMsg = null;
     try {
-      parseDriver.parse(sql, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+      parseDriver.parse(sql, ZoneId.systemDefault());
     } catch (SQLParserException e) {
       errorMsg = e.getMessage();
     }
@@ -336,7 +337,7 @@ public class LogicalPlanSmallTest {
     String sql7 = "delete from root.d1.s1 where time = 1 and time < -1";
     errorMsg = null;
     try {
-      parseDriver.parse(sql7, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+      parseDriver.parse(sql7, ZoneId.systemDefault());
     } catch (RuntimeException e) {
       errorMsg = e.getMessage();
     }
@@ -345,7 +346,7 @@ public class LogicalPlanSmallTest {
     sql = "delete from root.d1.s1 where time > 5 and time <= 0";
     errorMsg = null;
     try {
-      parseDriver.parse(sql, 
IoTDBDescriptor.getInstance().getConfig().getZoneID());
+      parseDriver.parse(sql, ZoneId.systemDefault());
     } catch (SQLParserException e) {
       errorMsg = e.getMessage();
     }
diff --git a/session/src/main/java/org/apache/iotdb/session/Session.java 
b/session/src/main/java/org/apache/iotdb/session/Session.java
index 036caa0..2f587e9 100644
--- a/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -35,7 +35,6 @@ import 
org.apache.iotdb.service.rpc.thrift.TSCreateTimeseriesReq;
 import org.apache.iotdb.service.rpc.thrift.TSDeleteDataReq;
 import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq;
 import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
-import org.apache.iotdb.service.rpc.thrift.TSGetTimeZoneResp;
 import org.apache.iotdb.service.rpc.thrift.TSIService;
 import org.apache.iotdb.service.rpc.thrift.TSInsertRecordReq;
 import org.apache.iotdb.service.rpc.thrift.TSInsertRecordsReq;
@@ -87,27 +86,28 @@ public class Session {
   private int connectionTimeoutInMs;
 
   public Session(String host, int rpcPort) {
-    this(host, rpcPort, Config.DEFAULT_USER, Config.DEFAULT_PASSWORD);
+    this(host, rpcPort, Config.DEFAULT_USER, Config.DEFAULT_PASSWORD, 
Config.DEFAULT_FETCH_SIZE, null);
   }
 
   public Session(String host, String rpcPort, String username, String 
password) {
-    this(host, Integer.parseInt(rpcPort), username, password);
+    this(host, Integer.parseInt(rpcPort), username, password, 
Config.DEFAULT_FETCH_SIZE, null);
   }
 
   public Session(String host, int rpcPort, String username, String password) {
-    this.host = host;
-    this.rpcPort = rpcPort;
-    this.username = username;
-    this.password = password;
-    this.fetchSize = Config.DEFAULT_FETCH_SIZE;
+    this(host, rpcPort, username, password, Config.DEFAULT_FETCH_SIZE, null);
   }
 
-  public Session(String host, int rpcPort, String username, String password, 
int fetchSize) {
+  public Session(String host, int rpcPort, String username, String password, 
ZoneId zoneId) {
+    this(host, rpcPort, username, password, Config.DEFAULT_FETCH_SIZE, zoneId);
+  }
+
+  public Session(String host, int rpcPort, String username, String password, 
int fetchSize, ZoneId zoneId) {
     this.host = host;
     this.rpcPort = rpcPort;
     this.username = username;
     this.password = password;
     this.fetchSize = fetchSize;
+    this.zoneId = zoneId;
   }
 
   public synchronized void open() throws IoTDBConnectionException {
@@ -146,6 +146,7 @@ public class Session {
     TSOpenSessionReq openReq = new TSOpenSessionReq();
     openReq.setUsername(username);
     openReq.setPassword(password);
+    openReq.setZoneId(getTimeZone());
 
     try {
       TSOpenSessionResp openResp = client.openSession(openReq);
@@ -166,12 +167,6 @@ public class Session {
 
       statementId = client.requestStatementId(sessionId);
 
-      if (zoneId != null) {
-        setTimeZone(zoneId.toString());
-      } else {
-        zoneId = ZoneId.of(getTimeZone());
-      }
-
     } catch (Exception e) {
       transport.close();
       throw new IoTDBConnectionException(e);
@@ -179,7 +174,6 @@ public class Session {
     isClosed = false;
 
     client = RpcUtils.newSynchronizedClient(client);
-
   }
 
   public synchronized void close() throws IoTDBConnectionException {
@@ -251,7 +245,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
   }
@@ -313,7 +308,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
   }
@@ -373,7 +369,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
   }
@@ -429,7 +426,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
   }
@@ -474,7 +472,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
   }
@@ -517,7 +516,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
   }
@@ -916,23 +916,14 @@ public class Session {
     return result;
   }
 
-  private synchronized String getTimeZone()
-      throws StatementExecutionException, IoTDBConnectionException {
+  public String getTimeZone() {
     if (zoneId != null) {
       return zoneId.toString();
     }
-
-    TSGetTimeZoneResp resp;
-    try {
-      resp = client.getTimeZone(sessionId);
-    } catch (TException e) {
-      throw new IoTDBConnectionException(e);
-    }
-    RpcUtils.verifySuccess(resp.getStatus());
-    return resp.getTimeZone();
+    return ZoneId.systemDefault().getId();
   }
 
-  private synchronized void setTimeZone(String zoneId)
+  public synchronized void setTimeZone(String zoneId)
       throws StatementExecutionException, IoTDBConnectionException {
     TSSetTimeZoneReq req = new TSSetTimeZoneReq(sessionId, zoneId);
     TSStatus resp;
@@ -969,7 +960,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
 
@@ -999,7 +991,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
     RpcUtils.verifySuccess(execResp.getStatus());
@@ -1034,7 +1027,8 @@ public class Session {
           throw new IoTDBConnectionException(tException);
         }
       } else {
-        throw new IoTDBConnectionException("Fail to reconnect to server. 
Please check server status");
+        throw new IoTDBConnectionException(
+            "Fail to reconnect to server. Please check server status");
       }
     }
 
@@ -1156,4 +1150,4 @@ public class Session {
     return flag;
   }
 
-}
+}
\ No newline at end of file
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 8925e67..a80ec41 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
@@ -18,6 +18,7 @@
  */
 package org.apache.iotdb.session.pool;
 
+import java.time.ZoneId;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -73,19 +74,26 @@ public class SessionPool {
   private long timeout; //ms
   private static int FINAL_RETRY = RETRY - 1;
   private boolean enableCompression = false;
+  private ZoneId zoneId;
 
   public SessionPool(String ip, int port, String user, String password, int 
maxSize) {
-    this(ip, port, user, password, maxSize, Config.DEFAULT_FETCH_SIZE, 60_000, 
false);
+    this(ip, port, user, password, maxSize, Config.DEFAULT_FETCH_SIZE, 60_000, 
false, null);
   }
 
   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);
+    this(ip, port, user, password, maxSize, Config.DEFAULT_FETCH_SIZE, 60_000, 
enableCompression,
+        null);
+  }
+
+  public SessionPool(String ip, int port, String user, String password, int 
maxSize,
+      ZoneId zoneId) {
+    this(ip, port, user, password, maxSize, Config.DEFAULT_FETCH_SIZE, 60_000, 
false, zoneId);
   }
 
   @SuppressWarnings("squid:S107")
   public SessionPool(String ip, int port, String user, String password, int 
maxSize, int fetchSize,
-      long timeout, boolean enableCompression) {
+      long timeout, boolean enableCompression, ZoneId zoneId) {
     this.maxSize = maxSize;
     this.ip = ip;
     this.port = port;
@@ -94,6 +102,7 @@ public class SessionPool {
     this.fetchSize = fetchSize;
     this.timeout = timeout;
     this.enableCompression = enableCompression;
+    this.zoneId = zoneId;
   }
 
   //if this method throws an exception, either the server is broken, or the 
ip/port/user/password is incorrect.
@@ -121,7 +130,8 @@ public class SessionPool {
                 logger.warn(
                     "the SessionPool has wait for {} seconds to get a new 
connection: {}:{} with {}, {}",
                     (System.currentTimeMillis() - start) / 1000, ip, port, 
user, password);
-                logger.warn("current occupied size {}, queue size {}, 
considered size {} ",occupied.size(), queue.size(), size);
+                logger.warn("current occupied size {}, queue size {}, 
considered size {} ",
+                    occupied.size(), queue.size(), size);
                 if (System.currentTimeMillis() - start > timeout) {
                   throw new IoTDBConnectionException(
                       String.format("timeout to get a connection from %s:%s", 
ip, port));
@@ -141,14 +151,14 @@ public class SessionPool {
       if (logger.isDebugEnabled()) {
         logger.debug("Create a new Session {}, {}, {}, {}", ip, port, user, 
password);
       }
-      session = new Session(ip, port, user, password, fetchSize);
+      session = new Session(ip, port, user, password, fetchSize, zoneId);
       try {
         session.open(enableCompression);
       } catch (IoTDBConnectionException e) {
         //if exception, we will throw the exception.
         //Meanwhile, we have to set size--
         synchronized (this) {
-          size --;
+          size--;
         }
         throw e;
       }
@@ -229,7 +239,8 @@ public class SessionPool {
     }
   }
 
-  private void cleanSessionAndMayThrowConnectionException(Session session, int 
times, IoTDBConnectionException e) throws IoTDBConnectionException {
+  private void cleanSessionAndMayThrowConnectionException(Session session, int 
times,
+      IoTDBConnectionException e) throws IoTDBConnectionException {
     closeSession(session);
     removeSession();
     if (times == FINAL_RETRY) {
@@ -550,7 +561,8 @@ public class SessionPool {
    * this method should be used to test other time cost in client
    */
   public void testInsertRecord(String deviceId, long time, List<String> 
measurements,
-      List<TSDataType> types, List<Object> values) throws 
IoTDBConnectionException, StatementExecutionException {
+      List<TSDataType> types, List<Object> values)
+      throws IoTDBConnectionException, StatementExecutionException {
     for (int i = 0; i < RETRY; i++) {
       Session session = getSession();
       try {
diff --git a/session/src/test/java/org/apache/iotdb/session/SessionUT.java 
b/session/src/test/java/org/apache/iotdb/session/SessionUT.java
index 2ac21a0..39842ed 100644
--- a/session/src/test/java/org/apache/iotdb/session/SessionUT.java
+++ b/session/src/test/java/org/apache/iotdb/session/SessionUT.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
+import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.iotdb.db.conf.IoTDBConstant;
@@ -41,137 +42,150 @@ import org.junit.Test;
 
 public class SessionUT {
 
-    private Session session;
-
-    @Before
-    public void setUp() {
-        System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
-        EnvironmentUtils.closeStatMonitor();
-        EnvironmentUtils.envSetUp();
+  private Session session;
+
+  @Before
+  public void setUp() {
+    System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
+    EnvironmentUtils.closeStatMonitor();
+    EnvironmentUtils.envSetUp();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    session.close();
+    EnvironmentUtils.cleanEnv();
+  }
+
+  @Test
+  public void testSortTablet() {
+    /*
+    To test sortTablet in Class Session
+    !!!
+    Before testing, change the sortTablet from private method to public method
+    !!!
+     */
+    session = new Session("127.0.0.1", 6667, "root", "root");
+    List<MeasurementSchema> schemaList = new ArrayList<>();
+    schemaList.add(new MeasurementSchema("s1", TSDataType.INT64, 
TSEncoding.RLE));
+    // insert three rows data
+    Tablet tablet = new Tablet("root.sg1.d1", schemaList, 3);
+    long[] timestamps = tablet.timestamps;
+    Object[] values = tablet.values;
+
+      /*
+      inorder data before inserting
+      timestamp   s1
+      2           0
+      0           1
+      1           2
+       */
+    // inorder timestamps
+    timestamps[0] = 2;
+    timestamps[1] = 0;
+    timestamps[2] = 1;
+    // just one column INT64 data
+    long[] sensor = (long[]) values[0];
+    sensor[0] = 0;
+    sensor[1] = 1;
+    sensor[2] = 2;
+    tablet.rowSize = 3;
+
+    session.sortTablet(tablet);
+        
+    /*
+    After sorting, if the tablet data is sorted according to the timestamps,
+    data in tablet will be
+    timestamp   s1
+    0           1
+    1           2
+    2           0
+
+    If the data equal to above tablet, test pass, otherwise test fialed
+     */
+    long[] resTimestamps = tablet.timestamps;
+    long[] resValues = (long[]) tablet.values[0];
+    long[] expectedTimestamps = new long[]{0, 1, 2};
+    long[] expectedValues = new long[]{1, 2, 0};
+    try {
+      assertArrayEquals(expectedTimestamps, resTimestamps);
+      assertArrayEquals(expectedValues, resValues);
+    } catch (Exception e) {
+      fail();
     }
-
-    @After
-    public void tearDown() throws Exception {
-        session.close();
-        EnvironmentUtils.cleanEnv();
+  }
+
+  @Test
+  public void testInsertByStrAndSelectFailedData()
+      throws IoTDBConnectionException, StatementExecutionException {
+    session = new Session("127.0.0.1", 6667, "root", "root");
+    session.open();
+
+    String deviceId = "root.sg1.d1";
+
+    session.createTimeseries(deviceId + ".s1", TSDataType.INT64, 
TSEncoding.RLE,
+        CompressionType.UNCOMPRESSED);
+    session.createTimeseries(deviceId + ".s2", TSDataType.INT64, 
TSEncoding.RLE,
+        CompressionType.UNCOMPRESSED);
+    session.createTimeseries(deviceId + ".s3", TSDataType.INT64, 
TSEncoding.RLE,
+        CompressionType.UNCOMPRESSED);
+    session.createTimeseries(deviceId + ".s4", TSDataType.DOUBLE, 
TSEncoding.RLE,
+        CompressionType.UNCOMPRESSED);
+
+    List<MeasurementSchema> schemaList = new ArrayList<>();
+    schemaList.add(new MeasurementSchema("s1", TSDataType.INT64, 
TSEncoding.RLE));
+    schemaList.add(new MeasurementSchema("s2", TSDataType.DOUBLE, 
TSEncoding.RLE));
+    schemaList.add(new MeasurementSchema("s3", TSDataType.TEXT, 
TSEncoding.PLAIN));
+    schemaList.add(new MeasurementSchema("s4", TSDataType.INT64, 
TSEncoding.PLAIN));
+
+    Tablet tablet = new Tablet("root.sg1.d1", schemaList, 10);
+
+    long[] timestamps = tablet.timestamps;
+    Object[] values = tablet.values;
+
+    for (long time = 0; time < 10; time++) {
+      int row = tablet.rowSize++;
+      timestamps[row] = time;
+      long[] sensor = (long[]) values[0];
+      sensor[row] = time;
+      double[] sensor2 = (double[]) values[1];
+      sensor2[row] = 0.1 + time;
+      Binary[] sensor3 = (Binary[]) values[2];
+      sensor3[row] = Binary.valueOf("ha" + time);
+      long[] sensor4 = (long[]) values[3];
+      sensor4[row] = time;
     }
 
-    @Test
-    public void testSortTablet() {
-        /*
-        To test sortTablet in Class Session
-        !!!
-        Before testing, change the sortTablet from private method to public 
method
-        !!!
-         */
-        session = new Session("127.0.0.1", 6667, "root", "root");
-        List<MeasurementSchema> schemaList = new ArrayList<>();
-        schemaList.add(new MeasurementSchema("s1",TSDataType.INT64, 
TSEncoding.RLE));
-        // insert three rows data
-        Tablet tablet = new Tablet("root.sg1.d1", schemaList, 3);
-        long[] timestamps = tablet.timestamps;
-        Object[] values = tablet.values;
-
-        /*
-        inorder data before inserting
-        timestamp   s1
-        2           0
-        0           1
-        1           2
-         */
-        // inorder timestamps
-        timestamps[0] = 2;
-        timestamps[1] = 0;
-        timestamps[2] = 1;
-        // just one column INT64 data
-        long[] sensor = (long[]) values[0];
-        sensor[0] = 0;
-        sensor[1] = 1;
-        sensor[2] = 2;
-        tablet.rowSize = 3;
-
-        session.sortTablet(tablet);
-        
-        /*
-        After sorting, if the tablet data is sorted according to the 
timestamps,
-        data in tablet will be
-        timestamp   s1
-        0           1
-        1           2
-        2           0
-
-        If the data equal to above tablet, test pass, otherwise test fialed
-         */
-        long[] resTimestamps = tablet.timestamps;
-        long[] resValues = (long[])tablet.values[0];
-        long[] expectedTimestamps = new long[]{0, 1, 2};
-        long[] expectedValues = new long[]{1,2,0};
-        try {
-            assertArrayEquals(expectedTimestamps, resTimestamps);
-            assertArrayEquals(expectedValues, resValues);
-        }
-        catch (Exception e) {
-            fail();
-        }
+    try {
+      session.insertTablet(tablet);
+      fail();
+    } catch (StatementExecutionException e) {
+      // ignore
     }
 
-    @Test
-    public void testInsertByStrAndSelectFailedData() throws 
IoTDBConnectionException, StatementExecutionException {
-        session = new Session("127.0.0.1", 6667, "root", "root");
-        session.open();
-
-        String deviceId = "root.sg1.d1";
-
-        session.createTimeseries(deviceId + ".s1", TSDataType.INT64, 
TSEncoding.RLE, CompressionType.UNCOMPRESSED);
-        session.createTimeseries(deviceId + ".s2", TSDataType.INT64, 
TSEncoding.RLE, CompressionType.UNCOMPRESSED);
-        session.createTimeseries(deviceId + ".s3", TSDataType.INT64, 
TSEncoding.RLE, CompressionType.UNCOMPRESSED);
-        session.createTimeseries(deviceId + ".s4", TSDataType.DOUBLE, 
TSEncoding.RLE, CompressionType.UNCOMPRESSED);
-
-        List<MeasurementSchema> schemaList = new ArrayList<>();
-        schemaList.add(new MeasurementSchema("s1", TSDataType.INT64, 
TSEncoding.RLE));
-        schemaList.add(new MeasurementSchema("s2", TSDataType.DOUBLE, 
TSEncoding.RLE));
-        schemaList.add(new MeasurementSchema("s3", TSDataType.TEXT, 
TSEncoding.PLAIN));
-        schemaList.add(new MeasurementSchema("s4", TSDataType.INT64, 
TSEncoding.PLAIN));
-
-        Tablet tablet = new Tablet("root.sg1.d1", schemaList, 10);
-
-        long[] timestamps = tablet.timestamps;
-        Object[] values = tablet.values;
-
-        for (long time = 0; time < 10; time++) {
-            int row = tablet.rowSize++;
-            timestamps[row] = time;
-            long[] sensor = (long[]) values[0];
-            sensor[row] = time;
-            double[] sensor2 = (double[]) values[1];
-            sensor2[row] = 0.1 + time;
-            Binary[] sensor3 = (Binary[]) values[2];
-            sensor3[row] = Binary.valueOf("ha" + time);
-            long[] sensor4 = (long[]) values[3];
-            sensor4[row] = time;
-        }
-
-        try {
-            session.insertTablet(tablet);
-            fail();
-        } catch (StatementExecutionException e) {
-            // ignore
-        }
-
-        SessionDataSet dataSet = session.executeQueryStatement("select * from 
root.sg1.d1");
-        int i = 0;
-        while (dataSet.hasNext()) {
-            RowRecord record = dataSet.next();
-            int nullCount = 0;
-            for (int j = 0; j < 4; ++j) {
-                if (record.getFields().get(j).isNull()) {
-                    ++nullCount;
-                } else {
-                    assertEquals(i, record.getFields().get(j).getLongV());
-                }
-            }
-            assertEquals(3, nullCount);
-            i++;
+    SessionDataSet dataSet = session.executeQueryStatement("select * from 
root.sg1.d1");
+    int i = 0;
+    while (dataSet.hasNext()) {
+      RowRecord record = dataSet.next();
+      int nullCount = 0;
+      for (int j = 0; j < 4; ++j) {
+        if (record.getFields().get(j).isNull()) {
+          ++nullCount;
+        } else {
+          assertEquals(i, record.getFields().get(j).getLongV());
         }
+      }
+      assertEquals(3, nullCount);
+      i++;
     }
+  }
+
+  @Test
+  public void testSetTimeZone() throws StatementExecutionException, 
IoTDBConnectionException {
+    session = new Session("127.0.0.1", 6667, "root", "root", 
ZoneId.of("+05:00"));
+    session.open();
+    assertEquals("+05:00", session.getTimeZone());
+    session.setTimeZone("+09:00");
+    assertEquals("+09:00", session.getTimeZone());
+  }
 }
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 af9bf2a..9076d19 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
@@ -163,7 +163,7 @@ public class SessionPoolTest {
 
   @Test
   public void tryIfTheServerIsRestart() {
-    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3, 
1, 6000, false);
+    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3, 
1, 6000, false, null);
     write10Data(pool, true);
     SessionDataSetWrapper wrapper = null;
     try {
@@ -187,7 +187,7 @@ public class SessionPoolTest {
 
   @Test
   public void tryIfTheServerIsRestartButDataIsGotten() {
-    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3, 
1, 60000, false);
+    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 3, 
1, 60000, false, null);
     write10Data(pool, true);
     assertEquals(1, pool.currentAvailableSize());
     SessionDataSetWrapper wrapper = null;
@@ -210,7 +210,7 @@ public class SessionPoolTest {
 
   @Test
   public void restart() throws Exception {
-    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 1, 
1, 1000, false);
+    SessionPool pool = new SessionPool("127.0.0.1", 6667, "root", "root", 1, 
1, 1000, false, null);
     write10Data(pool, true);
     //stop the server.
     EnvironmentUtils.stopDaemon();
diff --git a/thrift/rpc-changelist.md b/thrift/rpc-changelist.md
index d8986b7..424d39a 100644
--- a/thrift/rpc-changelist.md
+++ b/thrift/rpc-changelist.md
@@ -21,7 +21,7 @@
 
 # 0.10.x (version-2) -> 0.11.x (version-3)
 
-Last Updated on 2020-07-08 by Wei Shao.
+Last Updated on 2020-10-27 by Xiangwei Wei.
 
 
 ## 1. Delete Old
@@ -45,7 +45,7 @@ Last Updated on 2020-07-08 by Wei Shao.
 | Add sub-status in TSStatus  | Tian Jiang  |
 | Change the result of executeBatchStatement  as   TSStatus    | Tian Jiang  |
 | Change TSDeleteDataReq, delete timestamp and add startTime and endTime   | 
Wei Shao   |
-
+| Add zoneId in TSOpenSessionReq | Xiangwei Wei |
 
 
 # 0.9.x (version-1) -> 0.10.x (version-2)
diff --git a/thrift/src/main/thrift/rpc.thrift 
b/thrift/src/main/thrift/rpc.thrift
index 7cd8349..7b83144 100644
--- a/thrift/src/main/thrift/rpc.thrift
+++ b/thrift/src/main/thrift/rpc.thrift
@@ -79,9 +79,10 @@ struct TSOpenSessionResp {
 // Open a session (connection) on the server against which operations may be 
executed.
 struct TSOpenSessionReq {
   1: required TSProtocolVersion client_protocol = 
TSProtocolVersion.IOTDB_SERVICE_PROTOCOL_V3
-  2: optional string username
-  3: optional string password
-  4: optional map<string, string> configuration
+  2: required string zoneId
+  3: optional string username
+  4: optional string password
+  5: optional map<string, string> configuration
 }
 
 // CloseSession()

Reply via email to