You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ge...@apache.org on 2020/12/28 10:10:29 UTC

[iotdb] 01/03: add show configuration add client

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

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

commit a86668ad00ab3d01c008db12fdc5c670f9576643
Author: Boris <96...@qq.com>
AuthorDate: Mon Dec 28 18:07:02 2020 +0800

    add show configuration add client
---
 .../antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4   |   8 +
 .../java/org/apache/iotdb/tool/MonitorTool.java    | 162 +++++++++++++++++++++
 .../iotdb/cluster/query/ClusterPlanExecutor.java   |   3 +-
 .../org/apache/iotdb/db/conf/IoTDBConstant.java    |   1 +
 .../apache/iotdb/db/qp/constant/SQLConstant.java   |   2 +
 .../apache/iotdb/db/qp/executor/IPlanExecutor.java |   4 +-
 .../apache/iotdb/db/qp/executor/PlanExecutor.java  |  56 ++++++-
 .../db/qp/logical/sys/ShowConfigOperator.java      |  28 ++++
 .../iotdb/db/qp/physical/sys/ShowConfigPlan.java   |  27 ++++
 .../apache/iotdb/db/qp/physical/sys/ShowPlan.java  |   2 +-
 .../apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java    |  13 ++
 .../iotdb/db/qp/strategy/PhysicalGenerator.java    |   5 +
 .../org/apache/iotdb/db/service/TSServiceImpl.java |  10 +-
 .../iotdb/db/engine/storagegroup/TTLTest.java      |   3 +-
 .../iotdb/db/query/dataset/ListDataSetTest.java    |   8 +-
 .../iotdb/db/query/dataset/SingleDataSetTest.java  |  10 +-
 16 files changed, 326 insertions(+), 16 deletions(-)

diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
index 1f86f1e..50052fd 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
@@ -79,12 +79,14 @@ statement
     | SHOW CHILD PATHS prefixPath? #showChildPaths
     | SHOW DEVICES prefixPath? #showDevices
     | SHOW MERGE #showMergeStatus
+    | SHOW CONFIGURATION #showConf
     | TRACING ON #tracingOn
     | TRACING OFF #tracingOff
     | COUNT TIMESERIES prefixPath? (GROUP BY LEVEL OPERATOR_EQ INT)? #countTimeseries
     | COUNT DEVICES prefixPath? #countDevices
     | COUNT STORAGE GROUP prefixPath? #countStorageGroup
     | COUNT NODES prefixPath LEVEL OPERATOR_EQ INT #countNodes
+    | COUNT CLIENTS #countClients
     | LOAD CONFIGURATION (MINUS GLOBAL)? #loadConfigurationStatement
     | LOAD stringLiteral autoCreateSchema?#loadFiles
     | REMOVE stringLiteral #removeFile
@@ -507,6 +509,7 @@ nodeName
     | PARTITION
     | DESC
     | ASC
+    | CLIENTS
     ;
 
 nodeNameWithoutStar
@@ -619,6 +622,7 @@ nodeNameWithoutStar
     | PARTITION
     | DESC
     | ASC
+    | CLIENTS
     ;
 
 dataType
@@ -1197,6 +1201,10 @@ LIKE
 TOLERANCE
     : T O L E R A N C E
     ;
+
+CLIENTS
+    : C L I E N T S
+    ;
 //============================
 // End of the keywords list
 //============================
diff --git a/cli/src/main/java/org/apache/iotdb/tool/MonitorTool.java b/cli/src/main/java/org/apache/iotdb/tool/MonitorTool.java
new file mode 100644
index 0000000..71fd8ed
--- /dev/null
+++ b/cli/src/main/java/org/apache/iotdb/tool/MonitorTool.java
@@ -0,0 +1,162 @@
+package org.apache.iotdb.tool;
+
+import com.sun.management.OperatingSystemMXBean;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.NetworkInterface;
+import java.nio.file.FileStore;
+import java.nio.file.FileSystems;
+import java.util.Enumeration;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.SessionDataSet;
+import org.apache.iotdb.tsfile.read.common.RowRecord;
+
+public class MonitorTool {
+
+  private static String url;
+
+  public static void main(String[] args) throws ParseException, IoTDBConnectionException {
+    int port = 6667;
+    String password = "root";
+    Options options = new Options();
+    Option opt_help = new Option("help", "help", false, "print help message");
+    opt_help.setRequired(false);
+    options.addOption(opt_help);
+
+    Option opt_port = new Option("p", "port", true, "port");
+    opt_port.setRequired(false);
+    options.addOption(opt_port);
+
+    Option opt_password = new Option("pw", "password", true, "password");
+    opt_password.setRequired(false);
+    options.addOption(opt_password);
+
+    HelpFormatter hf=new HelpFormatter();
+    hf.setWidth(110);
+
+    CommandLine commandLine;
+    CommandLineParser parser=new DefaultParser();
+
+    commandLine = parser.parse(options,args);
+
+    if(commandLine.hasOption("help")){
+      hf.printHelp("correctionTest",options,true);
+    } else {
+      if(commandLine.hasOption("p")) {
+        port = Integer.parseInt(commandLine.getOptionValue("p"));
+      }
+      if(commandLine.hasOption("pw")) {
+        password = commandLine.getOptionValue("pw");
+      }
+      Session session = new Session("127.0.0.1", port, "root", password);
+      session.open();
+
+      url = System.getProperty("IOTDB_HOME", null);
+
+      if(url == null) {
+        url = MonitorTool.class.getResource("/").toString();
+      }
+    }
+
+  }
+
+  public static void generateOsFile() throws IOException {
+
+    BufferedWriter writer = new BufferedWriter(new FileWriter(new File(url + "/os.txt")));
+    //operate system name
+    String osName = System.getProperty("os.name");
+    writer.write("operate system: " + osName + "\n");
+
+    //jvm memory size in mb
+    long freeMemory = Runtime.getRuntime().freeMemory() / (1024 * 1024);
+    long maxMemory = Runtime.getRuntime().maxMemory() / (1024 * 1024);
+    long totalMemory = Runtime.getRuntime().totalMemory() / (1024 * 1024);
+    long usedMemory = totalMemory - freeMemory;
+    writer.write("jvm max memory: " + maxMemory + "mb"+ "\n");
+    writer.write("jvm total memory: " + totalMemory + "mb" + "\n");
+    writer.write("jvm used memory: " + usedMemory + "mb" + "\n");
+    writer.write("jvm free memory: " + freeMemory + "mb" + "\n");
+
+    // underlying file stores size in mb
+    for (FileStore store : FileSystems.getDefault().getFileStores()) {
+      writer.write("file store name: " + store.name());
+      long total = store.getTotalSpace() / (1024 * 1024);
+      long used = (store.getTotalSpace() - store.getUnallocatedSpace()) / (1024 * 1024);
+      long avail = store.getUsableSpace() / (1024 * 1024);
+      writer.write("---- " + store.name() + "'s total space: " + total + "mb" + "\n");
+      writer.write("---- " + store.name() + "'s used space: " + used + "mb" + "\n");
+      writer.write("---- " + store.name() + "'s avail space: " + avail + "mb" + "\n");
+    }
+
+    //network interface name
+    Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
+
+    writer.write("network interface name: " + "\n");
+    while (interfaces.hasMoreElements())
+    {
+      NetworkInterface networkInterface = interfaces.nextElement();
+      String interfacesName = networkInterface.getDisplayName();
+      writer.write("---- " + interfacesName + "\n");
+    }
+
+    //jdk version
+    String jdk = System.getProperty("java.version");
+    writer.write("jdk version: " + jdk + "\n");
+
+    //operate system memory size in mb
+    OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(
+        OperatingSystemMXBean.class);
+
+    long freeSystemMemory = osBean.getFreePhysicalMemorySize() / (1024 * 1024);
+    long totalSystemMemory = osBean.getTotalPhysicalMemorySize() / (1024 * 1024);
+    long usedSystemMemory = totalSystemMemory - freeSystemMemory / (1024 * 1024);
+
+    writer.write("free system memory: " + freeSystemMemory);
+    writer.write("total system memory: " + totalSystemMemory);
+    writer.write("used system memory: " + usedSystemMemory);
+
+    writer.write("Thread info: ");
+    for(Thread thread : Thread.getAllStackTraces().keySet()) {
+      writer.write("---- " + thread.getName());
+    }
+
+    writer.close();
+  }
+
+  public static void generateIoTDBRuntimeFile(int port, String password)
+      throws IoTDBConnectionException, StatementExecutionException, IOException {
+    BufferedWriter writer = new BufferedWriter(new FileWriter(new File(url + "/iotdb.txt")));
+    Session session = new Session("127.0.0.1", port, "root", password);
+    session.open();
+    SessionDataSet dataSet = session.executeQueryStatement("count timeseries root");
+    RowRecord record = dataSet.next();
+    writer.write("number of sensors: " + record.getFields().get(0).getLongV() + "\n");
+    dataSet = session.executeQueryStatement("count devices root");
+    record = dataSet.next();
+    writer.write("number of devices: " + record.getFields().get(0).getLongV() + "\n");
+    dataSet = session.executeQueryStatement("count storage group root");
+    record = dataSet.next();
+    writer.write("number of storage group: " + record.getFields().get(0).getLongV() + "\n");
+    dataSet = session.executeQueryStatement("count clients");
+    record = dataSet.next();
+    writer.write("number of clients: " + record.getFields().get(0).getLongV() + "\n");
+    dataSet = session.executeQueryStatement("show configuration");
+    while(dataSet.hasNext()) {
+      record = dataSet.next();
+      writer.write(record.getFields().get(0).getBinaryV().toString() + ": ");
+      writer.write(record.getFields().get(1).getBinaryV().toString());
+    }
+  }
+}
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPlanExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPlanExecutor.java
index 8b7116b..d6885e3 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPlanExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPlanExecutor.java
@@ -20,6 +20,7 @@
 package org.apache.iotdb.cluster.query;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -93,7 +94,7 @@ public class ClusterPlanExecutor extends PlanExecutor {
   @Override
   public QueryDataSet processQuery(PhysicalPlan queryPlan, QueryContext context)
       throws IOException, StorageEngineException, QueryFilterOptimizationException, QueryProcessException,
-      MetadataException {
+      MetadataException, InvocationTargetException, IllegalAccessException {
     if (queryPlan instanceof QueryPlan) {
       logger.debug("Executing a query: {}", queryPlan);
       return processDataQuery((QueryPlan) queryPlan, context);
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
index e176dcf..9172a47 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
@@ -72,6 +72,7 @@ public class IoTDBConstant {
   public static final String COLUMN_COUNT = "count";
   public static final String COLUMN_TAGS = "tags";
   public static final String COLUMN_ATTRIBUTES = "attributes";
+  public static final String COLUMN_KEY = "key";
 
   public static final String COLUMN_ROLE = "role";
   public static final String COLUMN_USER = "user";
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/constant/SQLConstant.java b/server/src/main/java/org/apache/iotdb/db/qp/constant/SQLConstant.java
index f1003b8..9f3c2c8 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/constant/SQLConstant.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/constant/SQLConstant.java
@@ -157,6 +157,8 @@ public class SQLConstant {
 
   public static final int TOK_COUNT_DEVICES = 92;
   public static final int TOK_COUNT_STORAGE_GROUP = 93;
+  public static final int TOK_COUNT_CLIENT = 94;
+  public static final int TOK_CONFIG = 95;
 
   public static final Map<Integer, String> tokenSymbol = new HashMap<>();
   public static final Map<Integer, String> tokenNames = new HashMap<>();
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/IPlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/IPlanExecutor.java
index 5febac6..85d9420 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/IPlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/IPlanExecutor.java
@@ -18,7 +18,9 @@
  */
 package org.apache.iotdb.db.qp.executor;
 
+import java.beans.IntrospectionException;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import org.apache.iotdb.db.exception.BatchProcessException;
 import org.apache.iotdb.db.exception.StorageEngineException;
@@ -45,7 +47,7 @@ public interface IPlanExecutor {
    */
   QueryDataSet processQuery(PhysicalPlan queryPlan, QueryContext context)
       throws IOException, StorageEngineException,
-      QueryFilterOptimizationException, QueryProcessException, MetadataException, SQLException, TException, InterruptedException;
+      QueryFilterOptimizationException, QueryProcessException, MetadataException, SQLException, TException, InterruptedException, IllegalAccessException, IntrospectionException, InvocationTargetException;
 
   /**
    * Process Non-Query Physical plan, including insert/update/delete operation of
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index 68497de..9995b96 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -26,6 +26,7 @@ import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CREATED_TIME;
 import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DEVICES;
 import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DONE;
 import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ITEM;
+import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_KEY;
 import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PRIVILEGE;
 import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PROGRESS;
 import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ROLE;
@@ -38,6 +39,8 @@ import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFF
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -56,6 +59,7 @@ import org.apache.iotdb.db.auth.authorizer.IAuthorizer;
 import org.apache.iotdb.db.auth.entity.PathPrivilege;
 import org.apache.iotdb.db.auth.entity.Role;
 import org.apache.iotdb.db.auth.entity.User;
+import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBConstant;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.engine.StorageEngine;
@@ -128,6 +132,7 @@ import org.apache.iotdb.db.query.dataset.SingleDataSet;
 import org.apache.iotdb.db.query.executor.IQueryRouter;
 import org.apache.iotdb.db.query.executor.QueryRouter;
 import org.apache.iotdb.db.service.IoTDB;
+import org.apache.iotdb.db.service.TSServiceImpl;
 import org.apache.iotdb.db.utils.AuthUtils;
 import org.apache.iotdb.db.utils.FileLoaderUtils;
 import org.apache.iotdb.db.utils.UpgradeUtils;
@@ -156,7 +161,7 @@ public class PlanExecutor implements IPlanExecutor {
   // for data query
   protected IQueryRouter queryRouter;
   // for administration
-  private IAuthorizer authorizer;
+  private final IAuthorizer authorizer;
 
   private static final String INSERT_MEASUREMENTS_FAILED_MESSAGE = "failed to insert measurements ";
 
@@ -172,7 +177,7 @@ public class PlanExecutor implements IPlanExecutor {
   @Override
   public QueryDataSet processQuery(PhysicalPlan queryPlan, QueryContext context)
       throws IOException, StorageEngineException, QueryFilterOptimizationException,
-      QueryProcessException, MetadataException {
+      QueryProcessException, MetadataException, IllegalAccessException, InvocationTargetException {
     if (queryPlan instanceof QueryPlan) {
       return processDataQuery((QueryPlan) queryPlan, context);
     } else if (queryPlan instanceof AuthorPlan) {
@@ -394,7 +399,7 @@ public class PlanExecutor implements IPlanExecutor {
   }
 
   protected QueryDataSet processShowQuery(ShowPlan showPlan, QueryContext context)
-      throws QueryProcessException, MetadataException {
+      throws QueryProcessException, MetadataException, InvocationTargetException, IllegalAccessException {
     switch (showPlan.getShowContentType()) {
       case TTL:
         return processShowTTLQuery((ShowTTLPlan) showPlan);
@@ -408,6 +413,8 @@ public class PlanExecutor implements IPlanExecutor {
         return processShowStorageGroup((ShowStorageGroupPlan) showPlan);
       case DEVICES:
         return processShowDevices((ShowDevicesPlan) showPlan);
+      case CONFIG:
+        return processShowConfig();
       case CHILD_PATH:
         return processShowChildPaths((ShowChildPathsPlan) showPlan);
       case COUNT_TIMESERIES:
@@ -422,11 +429,54 @@ public class PlanExecutor implements IPlanExecutor {
         return processCountNodes((CountPlan) showPlan);
       case MERGE_STATUS:
         return processShowMergeStatus();
+      case COUNT_CLIENT:
+        return processCountClients();
       default:
         throw new QueryProcessException(String.format("Unrecognized show plan %s", showPlan));
     }
   }
 
+  private QueryDataSet processCountClients() {
+    return createSingleDataSet(COLUMN_COUNT, TSDataType.INT64,
+        TSServiceImpl.getSessionIdGenerator());
+  }
+
+  private QueryDataSet processShowConfig()
+      throws InvocationTargetException, IllegalAccessException {
+    ListDataSet listDataSet = new ListDataSet(
+        Arrays.asList(new PartialPath(COLUMN_KEY, false), new PartialPath(COLUMN_VALUE, false)),
+        Arrays.asList(TSDataType.TEXT, TSDataType.TEXT));
+    IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+    Method[] methods = IoTDBConfig.class.getMethods();
+    for (Method method : methods) {
+      boolean needInvoke = false;
+      String methodName = method.getName();
+      if (methodName.startsWith("is")) {
+        methodName = methodName.replace("is", "").toLowerCase();
+        needInvoke = true;
+      } else if (methodName.startsWith("get")) {
+        methodName = methodName.replace("get", "").toLowerCase();
+        needInvoke = true;
+      }
+      if (needInvoke) {
+        RowRecord record = new RowRecord(0);
+        Field field = new Field(TSDataType.TEXT);
+        field.setBinaryV(new Binary(methodName));
+        record.addField(field);
+        Object value = method.invoke(config);
+        field = new Field(TSDataType.TEXT);
+        if(value != null) {
+          field.setBinaryV(new Binary(value.toString()));
+        } else {
+          field.setBinaryV(new Binary("null"));
+        }
+        record.addField(field);
+        listDataSet.putRecord(record);
+      }
+    }
+    return listDataSet;
+  }
+
   private QueryDataSet processCountNodes(CountPlan countPlan) throws MetadataException {
     int num = getNodesNumInGivenLevel(countPlan.getPath(), countPlan.getLevel());
     return createSingleDataSet(COLUMN_COUNT, TSDataType.INT32, num);
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/ShowConfigOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/ShowConfigOperator.java
new file mode 100644
index 0000000..fa600ca
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/ShowConfigOperator.java
@@ -0,0 +1,28 @@
+/*
+ * 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.db.qp.logical.sys;
+
+public class ShowConfigOperator extends ShowOperator{
+
+  public ShowConfigOperator(int tokenIntType) {
+    super(tokenIntType);
+  }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowConfigPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowConfigPlan.java
new file mode 100644
index 0000000..8947114
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowConfigPlan.java
@@ -0,0 +1,27 @@
+/*
+ * 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.db.qp.physical.sys;
+
+public class ShowConfigPlan extends ShowPlan{
+
+  public ShowConfigPlan(ShowContentType showContentType) {
+    super(showContentType);
+  }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowPlan.java
index dabb949..d1198ea 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowPlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/ShowPlan.java
@@ -51,7 +51,7 @@ public class ShowPlan extends PhysicalPlan {
 
   public enum ShowContentType {
     FLUSH_TASK_INFO, TTL, VERSION, TIMESERIES, STORAGE_GROUP, CHILD_PATH, DEVICES,
-    COUNT_TIMESERIES, COUNT_NODE_TIMESERIES, COUNT_NODES, MERGE_STATUS, COUNT_DEVICES, COUNT_STORAGE_GROUP
+    COUNT_TIMESERIES, COUNT_NODE_TIMESERIES, COUNT_NODES, MERGE_STATUS, COUNT_DEVICES, COUNT_STORAGE_GROUP, CONFIG, COUNT_CLIENT
   }
 
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
index 980fa64..9730c61 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
@@ -78,6 +78,7 @@ import org.apache.iotdb.db.qp.logical.sys.RemoveFileOperator;
 import org.apache.iotdb.db.qp.logical.sys.SetStorageGroupOperator;
 import org.apache.iotdb.db.qp.logical.sys.SetTTLOperator;
 import org.apache.iotdb.db.qp.logical.sys.ShowChildPathsOperator;
+import org.apache.iotdb.db.qp.logical.sys.ShowConfigOperator;
 import org.apache.iotdb.db.qp.logical.sys.ShowDevicesOperator;
 import org.apache.iotdb.db.qp.logical.sys.ShowMergeStatusOperator;
 import org.apache.iotdb.db.qp.logical.sys.ShowOperator;
@@ -98,6 +99,7 @@ import org.apache.iotdb.db.qp.sql.SqlBaseParser.AttributeClauseContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.AttributeClausesContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.ClearcacheContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.ConstantContext;
+import org.apache.iotdb.db.qp.sql.SqlBaseParser.CountClientsContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.CountDevicesContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.CountNodesContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.CountStorageGroupContext;
@@ -183,6 +185,7 @@ import org.apache.iotdb.db.qp.sql.SqlBaseParser.SetStorageGroupContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.SetTTLStatementContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowAllTTLStatementContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowChildPathsContext;
+import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowConfContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowDevicesContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowFlushTaskInfoContext;
 import org.apache.iotdb.db.qp.sql.SqlBaseParser.ShowMergeStatusContext;
@@ -697,6 +700,16 @@ public class IoTDBSqlVisitor extends SqlBaseBaseVisitor<Operator> {
   }
 
   @Override
+  public Operator visitShowConf(ShowConfContext ctx) {
+    return new ShowConfigOperator(SQLConstant.TOK_CONFIG);
+  }
+
+  @Override
+  public Operator visitCountClients(CountClientsContext ctx) {
+    return new CountOperator(SQLConstant.TOK_COUNT_CLIENT, null);
+  }
+
+  @Override
   public Operator visitShowTimeseries(ShowTimeseriesContext ctx) {
     boolean orderByHeat = ctx.LATEST() != null;
     ShowTimeSeriesOperator showTimeSeriesOperator;
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java b/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
index 5e71f72..31db477 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
@@ -101,6 +101,7 @@ import org.apache.iotdb.db.qp.physical.sys.OperateFilePlan;
 import org.apache.iotdb.db.qp.physical.sys.SetStorageGroupPlan;
 import org.apache.iotdb.db.qp.physical.sys.SetTTLPlan;
 import org.apache.iotdb.db.qp.physical.sys.ShowChildPathsPlan;
+import org.apache.iotdb.db.qp.physical.sys.ShowConfigPlan;
 import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan;
 import org.apache.iotdb.db.qp.physical.sys.ShowMergeStatusPlan;
 import org.apache.iotdb.db.qp.physical.sys.ShowPlan;
@@ -269,6 +270,10 @@ public class PhysicalGenerator {
           case SQLConstant.TOK_CHILD_PATHS:
             return new ShowChildPathsPlan(
                 ShowContentType.CHILD_PATH, ((ShowChildPathsOperator) operator).getPath());
+          case SQLConstant.TOK_COUNT_CLIENT:
+            return new CountPlan(ShowContentType.COUNT_CLIENT, null);
+          case SQLConstant.TOK_CONFIG:
+            return new ShowConfigPlan(ShowContentType.CONFIG);
           default:
             throw new LogicalOperatorException(
                 String.format(
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 6e75bfb..abcad63 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
@@ -18,7 +18,9 @@
  */
 package org.apache.iotdb.db.service;
 
+import java.beans.IntrospectionException;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.nio.ByteBuffer;
 import java.sql.SQLException;
 import java.time.ZoneId;
@@ -171,7 +173,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
   private Map<Long, ZoneId> sessionIdZoneIdMap = new ConcurrentHashMap<>();
 
   // The sessionId is unique in one IoTDB instance.
-  private AtomicLong sessionIdGenerator = new AtomicLong();
+  private final static AtomicLong sessionIdGenerator = new AtomicLong();
   // The statementId is unique in one IoTDB instance.
   private AtomicLong statementIdGenerator = new AtomicLong();
 
@@ -1087,7 +1089,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
    */
   private QueryDataSet createQueryDataSet(long queryId, PhysicalPlan physicalPlan)
       throws QueryProcessException, QueryFilterOptimizationException, StorageEngineException,
-      IOException, MetadataException, SQLException, TException, InterruptedException {
+      IOException, MetadataException, SQLException, TException, InterruptedException, IllegalAccessException, IntrospectionException, InvocationTargetException {
 
     QueryContext context = genQueryContext(queryId);
     QueryDataSet queryDataSet = executor.processQuery(physicalPlan, context);
@@ -1829,4 +1831,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
   public static int getDefaultFetchSize() {
     return DEFAULT_FETCH_SIZE;
   }
+
+  public static long getSessionIdGenerator() {
+    return sessionIdGenerator.get();
+  }
 }
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java
index 45e6619..e751b10 100644
--- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -355,7 +356,7 @@ public class TTLTest {
   @Test
   public void testShowTTL()
       throws IOException, QueryProcessException, QueryFilterOptimizationException,
-      StorageEngineException, MetadataException {
+      StorageEngineException, MetadataException, InvocationTargetException, IllegalAccessException {
     IoTDB.metaManager.setTTL(new PartialPath(sg1), ttl);
 
     ShowTTLPlan plan = new ShowTTLPlan(Collections.emptyList());
diff --git a/server/src/test/java/org/apache/iotdb/db/query/dataset/ListDataSetTest.java b/server/src/test/java/org/apache/iotdb/db/query/dataset/ListDataSetTest.java
index f03209b..ffb2b5c 100644
--- a/server/src/test/java/org/apache/iotdb/db/query/dataset/ListDataSetTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/query/dataset/ListDataSetTest.java
@@ -18,7 +18,9 @@
  */
 package org.apache.iotdb.db.query.dataset;
 
+import java.beans.IntrospectionException;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import org.apache.iotdb.db.exception.StorageEngineException;
 import org.apache.iotdb.db.exception.metadata.MetadataException;
@@ -69,7 +71,7 @@ public class ListDataSetTest {
 
   @Test
   public void showStorageGroups()
-      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException {
+      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException, IllegalAccessException, IntrospectionException, InvocationTargetException {
     String[] results = new String [] {"0\troot.test", "0\troot.vehicle"};
     PhysicalPlan plan = processor
         .parseSQLToPhysicalPlan(
@@ -88,7 +90,7 @@ public class ListDataSetTest {
 
   @Test
   public void showChildPaths()
-      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException {
+      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException, IllegalAccessException, IntrospectionException, InvocationTargetException {
     String[] results = new String [] {"0\troot.test.d0", "0\troot.test.d1"};
     PhysicalPlan plan = processor
         .parseSQLToPhysicalPlan(
@@ -107,7 +109,7 @@ public class ListDataSetTest {
 
   @Test
   public void showDevices()
-      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException {
+      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException, IllegalAccessException, IntrospectionException, InvocationTargetException {
     String[] results = new String [] {"0\troot.test.d0", "0\troot.test.d1", "0\troot.vehicle.d0"};
     PhysicalPlan plan = processor
         .parseSQLToPhysicalPlan(
diff --git a/server/src/test/java/org/apache/iotdb/db/query/dataset/SingleDataSetTest.java b/server/src/test/java/org/apache/iotdb/db/query/dataset/SingleDataSetTest.java
index f2cc8c8..b217a02 100644
--- a/server/src/test/java/org/apache/iotdb/db/query/dataset/SingleDataSetTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/query/dataset/SingleDataSetTest.java
@@ -18,7 +18,9 @@
  */
 package org.apache.iotdb.db.query.dataset;
 
+import java.beans.IntrospectionException;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import org.apache.iotdb.db.exception.StorageEngineException;
 import org.apache.iotdb.db.exception.metadata.MetadataException;
@@ -68,7 +70,7 @@ public class SingleDataSetTest {
 
   @Test
   public void countDevice()
-      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException {
+      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException, IllegalAccessException, IntrospectionException, InvocationTargetException {
     PhysicalPlan plan = processor
         .parseSQLToPhysicalPlan(
             "count devices");
@@ -84,7 +86,7 @@ public class SingleDataSetTest {
 
   @Test
   public void countTimeSeries()
-      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException {
+      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException, IllegalAccessException, IntrospectionException, InvocationTargetException {
     PhysicalPlan plan = processor
         .parseSQLToPhysicalPlan(
             "count TimeSeries");
@@ -100,7 +102,7 @@ public class SingleDataSetTest {
 
   @Test
   public void countStorageGroup()
-      throws TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException, QueryProcessException {
+      throws TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException, QueryProcessException, IllegalAccessException, IntrospectionException, InvocationTargetException {
     PhysicalPlan plan = processor
         .parseSQLToPhysicalPlan(
             "count storage group");
@@ -116,7 +118,7 @@ public class SingleDataSetTest {
 
   @Test
   public void countNodes()
-      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException {
+      throws QueryProcessException, TException, StorageEngineException, QueryFilterOptimizationException, MetadataException, IOException, InterruptedException, SQLException, IllegalAccessException, IntrospectionException, InvocationTargetException {
     PhysicalPlan plan = processor
         .parseSQLToPhysicalPlan(
             "count nodes root.test level=2");