You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by lt...@apache.org on 2019/06/04 02:39:54 UTC

[incubator-iotdb] branch cluster updated (fb6847a -> 27252b1)

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

lta pushed a change to branch cluster
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


    from fb6847a  update StorageGroup to query all storage groups
     add 5cc46a9  [IOTDB-96]Refactor author query (#179)
     add 343c7bd  [IOTDB-108]Fix mistakes in doc (#187)
     add 39e82b2  organize properties
     add 1108632  organize properties
     add 87ad8ab  add init method
     new 57e6b58  merge master
     new ca9e9e0  modify set read consistency level
     new 27252b1  Merge branch 'cluster' of github.com:apache/incubator-iotdb into cluster

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../ClusterConsistencyLevel.java}                  |  33 +-
 .../iotdb/cluster/config/ClusterConstant.java      |   6 +-
 .../cluster/qp/executor/AbstractQPExecutor.java    |  17 +-
 .../qp/executor/ClusterQueryProcessExecutor.java   |   3 +-
 .../cluster/qp/executor/QueryMetadataExecutor.java |   3 +-
 .../querydata/InitSeriesReaderSyncProcessor.java   |   3 +-
 .../querymetadata/QueryMetadataAsyncProcessor.java |   3 +-
 .../QueryMetadataInStringAsyncProcessor.java       |   3 +-
 .../querymetadata/QueryPathsAsyncProcessor.java    |   3 +-
 .../QuerySeriesTypeAsyncProcessor.java             |   3 +-
 .../QueryTimeSeriesAsyncProcessor.java             |   3 +-
 .../cluster/service/TSServiceClusterImpl.java      |  17 +-
 .../iotdb/cluster/qp/AbstractQPExecutorTest.java   |  91 ++++-
 .../UserGuideV0.7.0/5-SQL Documentation.md         |  13 +-
 .../apache/iotdb/cli/client/AbstractClient.java    |   4 +
 iotdb/iotdb/conf/iotdb-engine.properties           |  46 ++-
 iotdb/iotdb/conf/iotdb-sync-client.properties      |   4 +-
 .../apache/iotdb/db/auth/entity/PathPrivilege.java |   1 -
 .../org/apache/iotdb/db/conf/IoTDBConstant.java    |   4 +
 .../db/qp/executor/IQueryProcessExecutor.java      |   3 +-
 .../iotdb/db/qp/executor/OverflowQPExecutor.java   | 263 ++++++++-----
 .../iotdb/db/qp/executor/QueryProcessExecutor.java |  18 +-
 .../apache/iotdb/db/qp/physical/PhysicalPlan.java  |   4 +
 .../iotdb/db/qp/physical/sys/AuthorPlan.java       |   6 +
 .../apache/iotdb/db/query/dataset/AuthDataSet.java |  34 +-
 .../org/apache/iotdb/db/service/TSServiceImpl.java | 195 ++++++----
 .../org/apache/iotdb/db/sync/conf/Constans.java    |  10 +
 .../iotdb/db/sync/conf/SyncSenderConfig.java       |  24 +-
 .../iotdb/db/sync/conf/SyncSenderDescriptor.java   |   7 +-
 .../apache/iotdb/db/sync/sender/SyncSender.java    |  10 +
 .../iotdb/db/sync/sender/SyncSenderImpl.java       | 106 +++---
 .../iotdb/db/integration/IoTDBAuthorizationIT.java | 416 +++++++++++----------
 .../apache/iotdb/db/qp/utils/MemIntQpExecutor.java |   6 +
 .../org/apache/iotdb/jdbc/IoTDBQueryResultSet.java |   9 +
 .../java/org/apache/iotdb/jdbc/IoTDBStatement.java |   9 +-
 service-rpc/src/main/thrift/rpc.thrift             |   1 +
 36 files changed, 838 insertions(+), 543 deletions(-)
 copy cluster/src/main/java/org/apache/iotdb/cluster/{concurrent/ThreadName.java => config/ClusterConsistencyLevel.java} (59%)
 copy cluster/src/main/java/org/apache/iotdb/cluster/query/timegenerator/ClusterLeafNode.java => iotdb/src/main/java/org/apache/iotdb/db/query/dataset/AuthDataSet.java (56%)


[incubator-iotdb] 02/03: modify set read consistency level

Posted by lt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ca9e9e016c27bcc0c28eca5d008d09f38b087d2c
Author: lta <li...@163.com>
AuthorDate: Tue Jun 4 10:39:16 2019 +0800

    modify set read consistency level
---
 .../cluster/config/ClusterConsistencyLevel.java    | 48 ++++++++++++
 .../iotdb/cluster/config/ClusterConstant.java      |  6 +-
 .../cluster/qp/executor/AbstractQPExecutor.java    | 17 +---
 .../qp/executor/ClusterQueryProcessExecutor.java   |  3 +-
 .../cluster/qp/executor/QueryMetadataExecutor.java |  3 +-
 .../querydata/InitSeriesReaderSyncProcessor.java   |  3 +-
 .../querymetadata/QueryMetadataAsyncProcessor.java |  3 +-
 .../QueryMetadataInStringAsyncProcessor.java       |  3 +-
 .../querymetadata/QueryPathsAsyncProcessor.java    |  3 +-
 .../QuerySeriesTypeAsyncProcessor.java             |  3 +-
 .../QueryTimeSeriesAsyncProcessor.java             |  3 +-
 .../cluster/service/TSServiceClusterImpl.java      | 17 +++-
 .../iotdb/cluster/qp/AbstractQPExecutorTest.java   | 91 +++++++++++++++++-----
 .../iotdb/db/qp/executor/QueryProcessExecutor.java |  1 +
 14 files changed, 155 insertions(+), 49 deletions(-)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConsistencyLevel.java b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConsistencyLevel.java
new file mode 100644
index 0000000..80f0c4a
--- /dev/null
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConsistencyLevel.java
@@ -0,0 +1,48 @@
+/**
+ * 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.cluster.config;
+
+public enum ClusterConsistencyLevel {
+  /**
+   * Strong consistency level
+   */
+  STRONG("strong"),
+
+  /**
+   * Weak consistency level
+   */
+  WEAK("weak");
+
+  private String levelName;
+
+  public static final int UNSUPPORT_LEVEL = -1;
+
+  ClusterConsistencyLevel(String levelName) {
+    this.levelName = levelName;
+  }
+
+  public static int getLevel(String levelName) {
+    for(ClusterConsistencyLevel consistencyLevel: values()){
+      if(consistencyLevel.levelName.equals(levelName)){
+        return consistencyLevel.ordinal();
+      }
+    }
+    return UNSUPPORT_LEVEL;
+  }
+}
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConstant.java b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConstant.java
index 77e2476..fba692f 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConstant.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConstant.java
@@ -26,10 +26,8 @@ public class ClusterConstant {
   /**
    * Set read metadata consistency level pattern
    */
-  public static final String SET_READ_METADATA_CONSISTENCY_LEVEL_PATTERN = "set\\s+read\\s+metadata\\s+level\\s+to\\s+\\d+";
-  public static final String SET_READ_DATA_CONSISTENCY_LEVEL_PATTERN = "set\\s+read\\s+data\\s+level\\s+to\\s+\\d+";
-  public static final int MAX_CONSISTENCY_LEVEL = 2;
-  public static final int STRONG_CONSISTENCY_LEVEL = 1;
+  public static final String SET_READ_METADATA_CONSISTENCY_LEVEL_PATTERN = "(set\\s+)(read\\s+metadata\\s+level\\s+)(to\\s+.*)";
+  public static final String SET_READ_DATA_CONSISTENCY_LEVEL_PATTERN = "(set\\s+)(read\\s+data\\s+level\\s+)(to\\s+.*)";
   public static final int WEAK_CONSISTENCY_LEVEL = 2;
 
   /**
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/AbstractQPExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/AbstractQPExecutor.java
index 21c7786..44049cf 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/AbstractQPExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/AbstractQPExecutor.java
@@ -22,7 +22,6 @@ import com.alipay.sofa.jraft.entity.PeerId;
 import java.util.HashSet;
 import java.util.Set;
 import org.apache.iotdb.cluster.config.ClusterConfig;
-import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.config.ClusterDescriptor;
 import org.apache.iotdb.cluster.entity.Server;
 import org.apache.iotdb.cluster.exception.ConsistencyLevelException;
@@ -198,20 +197,12 @@ public abstract class AbstractQPExecutor {
     }
   }
 
-  public void setReadMetadataConsistencyLevel(int level) throws ConsistencyLevelException {
-    if (level <= ClusterConstant.MAX_CONSISTENCY_LEVEL) {
-      readMetadataConsistencyLevel.set(level);
-    } else {
-      throw new ConsistencyLevelException(String.format("Consistency level %d not support", level));
-    }
+  public void setReadMetadataConsistencyLevel(int level) {
+    readMetadataConsistencyLevel.set(level);
   }
 
-  public void setReadDataConsistencyLevel(int level) throws ConsistencyLevelException {
-    if (level <= ClusterConstant.MAX_CONSISTENCY_LEVEL) {
-      readDataConsistencyLevel.set(level);
-    } else {
-      throw new ConsistencyLevelException(String.format("Consistency level %d not support", level));
-    }
+  public void setReadDataConsistencyLevel(int level) {
+    readDataConsistencyLevel.set(level);
   }
 
   public int getReadMetadataConsistencyLevel() {
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/ClusterQueryProcessExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/ClusterQueryProcessExecutor.java
index 30659e5..e8e0aec 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/ClusterQueryProcessExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/ClusterQueryProcessExecutor.java
@@ -58,10 +58,11 @@ public class ClusterQueryProcessExecutor extends AbstractQPExecutor implements I
   }
 
   @Override
-  public QueryDataSet processQuery(QueryPlan queryPlan, QueryContext context)
+  public QueryDataSet processQuery(PhysicalPlan plan, QueryContext context)
       throws IOException, FileNodeManagerException, PathErrorException,
       QueryFilterOptimizationException, ProcessorException {
 
+    QueryPlan queryPlan = (QueryPlan) plan;
     QueryExpression queryExpression = QueryExpression.create().setSelectSeries(queryPlan.getPaths())
         .setExpression(queryPlan.getExpression());
     clusterQueryRouter.setReadDataConsistencyLevel(getReadDataConsistencyLevel());
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/QueryMetadataExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/QueryMetadataExecutor.java
index a2528c6..92f4c97 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/QueryMetadataExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/QueryMetadataExecutor.java
@@ -28,6 +28,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import org.apache.iotdb.cluster.config.ClusterConfig;
+import org.apache.iotdb.cluster.config.ClusterConsistencyLevel;
 import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.entity.raft.MetadataRaftHolder;
 import org.apache.iotdb.cluster.entity.raft.RaftService;
@@ -398,7 +399,7 @@ public class QueryMetadataExecutor extends AbstractQPExecutor {
         ClusterConfig.METADATA_GROUP_ID, getReadMetadataConsistencyLevel());
     SingleQPTask task = new SingleQPTask(false, request);
     MetadataRaftHolder metadataHolder = (MetadataRaftHolder) server.getMetadataHolder();
-    if (getReadMetadataConsistencyLevel() == ClusterConstant.WEAK_CONSISTENCY_LEVEL) {
+    if (getReadMetadataConsistencyLevel() == ClusterConsistencyLevel.WEAK.ordinal()) {
       QueryStorageGroupResponse response;
       response = QueryStorageGroupResponse
           .createSuccessResponse(metadataHolder.getFsm().getAllStorageGroups());
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querydata/InitSeriesReaderSyncProcessor.java b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querydata/InitSeriesReaderSyncProcessor.java
index a64d909..8a388d3 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querydata/InitSeriesReaderSyncProcessor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querydata/InitSeriesReaderSyncProcessor.java
@@ -20,6 +20,7 @@ package org.apache.iotdb.cluster.rpc.raft.processor.querydata;
 
 import com.alipay.remoting.BizContext;
 import com.alipay.sofa.jraft.Status;
+import org.apache.iotdb.cluster.config.ClusterConsistencyLevel;
 import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.query.manager.querynode.ClusterLocalQueryManager;
 import org.apache.iotdb.cluster.rpc.raft.processor.BasicSyncUserProcessor;
@@ -51,7 +52,7 @@ public class InitSeriesReaderSyncProcessor extends BasicSyncUserProcessor<InitSe
    */
   private void handleNullRead(int readConsistencyLevel, String groupId) throws ProcessorException {
     LOGGER.debug("Read data level is {}", readConsistencyLevel);
-    if (readConsistencyLevel == ClusterConstant.STRONG_CONSISTENCY_LEVEL && !QPExecutorUtils
+    if (readConsistencyLevel == ClusterConsistencyLevel.STRONG.ordinal() && !QPExecutorUtils
         .checkDataGroupLeader(groupId)) {
       Status nullReadTaskStatus = Status.OK();
       RaftUtils.handleNullReadToDataGroup(nullReadTaskStatus, groupId);
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryMetadataAsyncProcessor.java b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryMetadataAsyncProcessor.java
index 3073df9..446fe88 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryMetadataAsyncProcessor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryMetadataAsyncProcessor.java
@@ -22,6 +22,7 @@ import com.alipay.remoting.AsyncContext;
 import com.alipay.remoting.BizContext;
 import com.alipay.sofa.jraft.Status;
 import com.alipay.sofa.jraft.closure.ReadIndexClosure;
+import org.apache.iotdb.cluster.config.ClusterConsistencyLevel;
 import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.entity.raft.DataPartitionRaftHolder;
 import org.apache.iotdb.cluster.entity.raft.RaftService;
@@ -42,7 +43,7 @@ public class QueryMetadataAsyncProcessor extends
       QueryMetadataRequest request) {
     String groupId = request.getGroupID();
 
-    if (request.getReadConsistencyLevel() == ClusterConstant.WEAK_CONSISTENCY_LEVEL) {
+    if (request.getReadConsistencyLevel() == ClusterConsistencyLevel.WEAK.ordinal()) {
       QueryMetadataResponse response;
       try {
         response = QueryMetadataResponse
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryMetadataInStringAsyncProcessor.java b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryMetadataInStringAsyncProcessor.java
index 8771eea..857f360 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryMetadataInStringAsyncProcessor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryMetadataInStringAsyncProcessor.java
@@ -22,6 +22,7 @@ import com.alipay.remoting.AsyncContext;
 import com.alipay.remoting.BizContext;
 import com.alipay.sofa.jraft.Status;
 import com.alipay.sofa.jraft.closure.ReadIndexClosure;
+import org.apache.iotdb.cluster.config.ClusterConsistencyLevel;
 import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.entity.raft.DataPartitionRaftHolder;
 import org.apache.iotdb.cluster.entity.raft.RaftService;
@@ -41,7 +42,7 @@ public class QueryMetadataInStringAsyncProcessor extends
       QueryMetadataInStringRequest request) {
     String groupId = request.getGroupID();
 
-    if (request.getReadConsistencyLevel() == ClusterConstant.WEAK_CONSISTENCY_LEVEL) {
+    if (request.getReadConsistencyLevel() == ClusterConsistencyLevel.WEAK.ordinal()) {
       QueryMetadataInStringResponse response = QueryMetadataInStringResponse
           .createSuccessResponse(groupId, mManager.getMetadataInString());
       response.addResult(true);
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryPathsAsyncProcessor.java b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryPathsAsyncProcessor.java
index 8e1e47b..9f65929 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryPathsAsyncProcessor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryPathsAsyncProcessor.java
@@ -22,6 +22,7 @@ import com.alipay.remoting.AsyncContext;
 import com.alipay.remoting.BizContext;
 import com.alipay.sofa.jraft.Status;
 import com.alipay.sofa.jraft.closure.ReadIndexClosure;
+import org.apache.iotdb.cluster.config.ClusterConsistencyLevel;
 import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.entity.raft.DataPartitionRaftHolder;
 import org.apache.iotdb.cluster.entity.raft.RaftService;
@@ -41,7 +42,7 @@ public class QueryPathsAsyncProcessor extends BasicAsyncUserProcessor<QueryPaths
       QueryPathsRequest request) {
     String groupId = request.getGroupID();
 
-    if (request.getReadConsistencyLevel() == ClusterConstant.WEAK_CONSISTENCY_LEVEL) {
+    if (request.getReadConsistencyLevel() == ClusterConsistencyLevel.WEAK.ordinal()) {
       QueryPathsResponse response = QueryPathsResponse
           .createEmptyResponse(groupId);
       try {
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QuerySeriesTypeAsyncProcessor.java b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QuerySeriesTypeAsyncProcessor.java
index 9e4b1c7..dcb774f 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QuerySeriesTypeAsyncProcessor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QuerySeriesTypeAsyncProcessor.java
@@ -22,6 +22,7 @@ import com.alipay.remoting.AsyncContext;
 import com.alipay.remoting.BizContext;
 import com.alipay.sofa.jraft.Status;
 import com.alipay.sofa.jraft.closure.ReadIndexClosure;
+import org.apache.iotdb.cluster.config.ClusterConsistencyLevel;
 import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.entity.raft.DataPartitionRaftHolder;
 import org.apache.iotdb.cluster.entity.raft.RaftService;
@@ -41,7 +42,7 @@ public class QuerySeriesTypeAsyncProcessor extends BasicAsyncUserProcessor<Query
       QuerySeriesTypeRequest request) {
     String groupId = request.getGroupID();
 
-    if (request.getReadConsistencyLevel() == ClusterConstant.WEAK_CONSISTENCY_LEVEL) {
+    if (request.getReadConsistencyLevel() == ClusterConsistencyLevel.WEAK.ordinal()) {
       QuerySeriesTypeResponse response;
       try {
         response = QuerySeriesTypeResponse.createSuccessResponse(groupId, mManager.getSeriesType(request.getPath()));
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryTimeSeriesAsyncProcessor.java b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryTimeSeriesAsyncProcessor.java
index 593f99d..c36120f 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryTimeSeriesAsyncProcessor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querymetadata/QueryTimeSeriesAsyncProcessor.java
@@ -22,6 +22,7 @@ import com.alipay.remoting.AsyncContext;
 import com.alipay.remoting.BizContext;
 import com.alipay.sofa.jraft.Status;
 import com.alipay.sofa.jraft.closure.ReadIndexClosure;
+import org.apache.iotdb.cluster.config.ClusterConsistencyLevel;
 import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.entity.raft.DataPartitionRaftHolder;
 import org.apache.iotdb.cluster.entity.raft.RaftService;
@@ -42,7 +43,7 @@ public class QueryTimeSeriesAsyncProcessor extends BasicAsyncUserProcessor<Query
       QueryTimeSeriesRequest request) {
     String groupId = request.getGroupID();
 
-    if (request.getReadConsistencyLevel() == ClusterConstant.WEAK_CONSISTENCY_LEVEL) {
+    if (request.getReadConsistencyLevel() == ClusterConsistencyLevel.WEAK.ordinal()) {
       QueryTimeSeriesResponse response = QueryTimeSeriesResponse
           .createEmptyResponse(groupId);
       try {
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/service/TSServiceClusterImpl.java b/cluster/src/main/java/org/apache/iotdb/cluster/service/TSServiceClusterImpl.java
index 7ae40c2..b2b4fab 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/service/TSServiceClusterImpl.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/service/TSServiceClusterImpl.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+import org.apache.iotdb.cluster.config.ClusterConsistencyLevel;
 import org.apache.iotdb.cluster.config.ClusterConstant;
 import org.apache.iotdb.cluster.exception.ConsistencyLevelException;
 import org.apache.iotdb.cluster.qp.executor.ClusterQueryProcessExecutor;
@@ -251,14 +252,12 @@ public class TSServiceClusterImpl extends TSServiceImpl {
     statement = statement.toLowerCase().trim();
     try {
       if (Pattern.matches(ClusterConstant.SET_READ_METADATA_CONSISTENCY_LEVEL_PATTERN, statement)) {
-        String[] splits = statement.split("\\s+");
-        int level = Integer.parseInt(splits[splits.length - 1]);
+        int level = parseConsistencyLevel(statement);
         queryMetadataExecutor.setReadMetadataConsistencyLevel(level);
         return true;
       } else if (Pattern
           .matches(ClusterConstant.SET_READ_DATA_CONSISTENCY_LEVEL_PATTERN, statement)) {
-        String[] splits = statement.split("\\s+");
-        int level = Integer.parseInt(splits[splits.length - 1]);
+        int level = parseConsistencyLevel(statement);
         queryDataExecutor.setReadDataConsistencyLevel(level);
         return true;
       } else {
@@ -269,6 +268,16 @@ public class TSServiceClusterImpl extends TSServiceImpl {
     }
   }
 
+  private int parseConsistencyLevel(String statement) throws ConsistencyLevelException {
+    String[] splits = statement.split("\\s+");
+    String levelName = splits[splits.length - 1].toLowerCase();
+    int level = ClusterConsistencyLevel.getLevel(levelName);
+    if (level == ClusterConsistencyLevel.UNSUPPORT_LEVEL) {
+      throw new ConsistencyLevelException(String.format("Consistency level %s not support", levelName));
+    }
+    return level;
+  }
+
   @Override
   protected boolean executeNonQuery(PhysicalPlan plan) throws ProcessorException {
     return nonQueryExecutor.processNonQuery(plan);
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/qp/AbstractQPExecutorTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/qp/AbstractQPExecutorTest.java
index 02b0311..8f35029 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/qp/AbstractQPExecutorTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/qp/AbstractQPExecutorTest.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.cluster.qp;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.apache.iotdb.cluster.config.ClusterConfig;
 import org.apache.iotdb.cluster.config.ClusterDescriptor;
@@ -61,28 +62,49 @@ public class AbstractQPExecutorTest {
     assertEquals(CLUSTER_CONFIG.getReadMetadataConsistencyLevel(),
         queryMetadataExecutor.getReadMetadataConsistencyLevel());
     boolean exec;
-    exec= impl.execSetConsistencyLevel("set read metadata level to 1");
+    exec = impl.execSetConsistencyLevel("set read metadata level to strong");
     assertTrue(exec);
-    assertEquals(1, queryMetadataExecutor.getReadMetadataConsistencyLevel());
+    assertEquals(0, queryMetadataExecutor.getReadMetadataConsistencyLevel());
 
-    exec= impl.execSetConsistencyLevel("show timeseries");
-    assertEquals(1, queryMetadataExecutor.getReadMetadataConsistencyLevel());
+    exec = impl.execSetConsistencyLevel("show timeseries");
+    assertEquals(0, queryMetadataExecutor.getReadMetadataConsistencyLevel());
     assertFalse(exec);
 
-    exec= impl.execSetConsistencyLevel("set read metadata level to 2");
+    exec = impl.execSetConsistencyLevel("set read metadata level to weak");
+    assertTrue(exec);
+    assertEquals(1, queryMetadataExecutor.getReadMetadataConsistencyLevel());
+
+    exec = impl.execSetConsistencyLevel("set READ    metadata level  to STRONG");
     assertTrue(exec);
-    assertEquals(2, queryMetadataExecutor.getReadMetadataConsistencyLevel());
+    assertEquals(0, queryMetadataExecutor.getReadMetadataConsistencyLevel());
 
-    exec = impl.execSetConsistencyLevel("set read metadata level to -2");
-    assertEquals(2, queryMetadataExecutor.getReadMetadataConsistencyLevel());
-    assertFalse(exec);
+    exec = impl.execSetConsistencyLevel("  SET read    metadata level  to WEAK");
+    assertTrue(exec);
+    assertEquals(1, queryMetadataExecutor.getReadMetadataConsistencyLevel());
+
+    try {
+      impl.execSetConsistencyLevel("set read metadata level to -2");
+      fail();
+    } catch (Exception e) {
+      assertEquals("Consistency level -2 not support", e.getMessage());
+    }
+    assertEquals(1, queryMetadataExecutor.getReadMetadataConsistencyLevel());
+
+    try {
+      impl.execSetConsistencyLevel("set read metadata level  to final_consistency");
+      fail();
+    } catch (Exception e) {
+      assertEquals("Consistency level final_consistency not support", e.getMessage());
+    }
+    assertEquals(1, queryMetadataExecutor.getReadMetadataConsistencyLevel());
 
     try {
       impl.execSetConsistencyLevel("set read metadata level to 90");
+      fail();
     } catch (Exception e) {
       assertEquals("Consistency level 90 not support", e.getMessage());
     }
-    assertEquals(2, queryMetadataExecutor.getReadMetadataConsistencyLevel());
+    assertEquals(1, queryMetadataExecutor.getReadMetadataConsistencyLevel());
   }
 
   @Test
@@ -90,27 +112,56 @@ public class AbstractQPExecutorTest {
     assertEquals(CLUSTER_CONFIG.getReadDataConsistencyLevel(),
         queryMetadataExecutor.getReadDataConsistencyLevel());
     boolean exec;
-    exec= impl.execSetConsistencyLevel("set read data level to 1");
+    exec = impl.execSetConsistencyLevel(" set read data level to strong");
     assertTrue(exec);
-    assertEquals(1, queryExecutor.getReadDataConsistencyLevel());
+    assertEquals(0, queryExecutor.getReadDataConsistencyLevel());
 
-    exec= impl.execSetConsistencyLevel("show timeseries");
-    assertEquals(1, queryExecutor.getReadDataConsistencyLevel());
+    exec = impl.execSetConsistencyLevel("show timeseries");
+    assertEquals(0, queryExecutor.getReadDataConsistencyLevel());
     assertFalse(exec);
 
-    exec= impl.execSetConsistencyLevel("set read data level  to 2");
+    exec = impl.execSetConsistencyLevel("set read data level  to weak");
     assertTrue(exec);
-    assertEquals(2, queryExecutor.getReadDataConsistencyLevel());
+    assertEquals(1, queryExecutor.getReadDataConsistencyLevel());
 
-    exec = impl.execSetConsistencyLevel("set read data level  to -2");
-    assertEquals(2, queryExecutor.getReadDataConsistencyLevel());
-    assertFalse(exec);
+    exec = impl.execSetConsistencyLevel("set READ    data level  to STRONG");
+    assertTrue(exec);
+    assertEquals(0, queryExecutor.getReadDataConsistencyLevel());
+
+    exec = impl.execSetConsistencyLevel("  SET read    data level  to WEAK");
+    assertTrue(exec);
+    assertEquals(1, queryExecutor.getReadDataConsistencyLevel());
+
+    try {
+      impl.execSetConsistencyLevel("set read data level  to -2");
+      fail();
+    } catch (Exception e) {
+      assertEquals("Consistency level -2 not support", e.getMessage());
+    }
+    assertEquals(1, queryExecutor.getReadDataConsistencyLevel());
+
+    try {
+      impl.execSetConsistencyLevel("set read data level  to 1");
+      fail();
+    } catch (Exception e) {
+      assertEquals("Consistency level 1 not support", e.getMessage());
+    }
+    assertEquals(1, queryExecutor.getReadDataConsistencyLevel());
+
+    try {
+      impl.execSetConsistencyLevel("set read data level  to final_consistency");
+      fail();
+    } catch (Exception e) {
+      assertEquals("Consistency level final_consistency not support", e.getMessage());
+    }
+    assertEquals(1, queryExecutor.getReadDataConsistencyLevel());
 
     try {
       impl.execSetConsistencyLevel("set read data level  to 90");
+      fail();
     } catch (Exception e) {
       assertEquals("Consistency level 90 not support", e.getMessage());
     }
-    assertEquals(2, queryExecutor.getReadDataConsistencyLevel());
+    assertEquals(1, queryExecutor.getReadDataConsistencyLevel());
   }
 }
\ No newline at end of file
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
index 0a88640..6bdfb79 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
@@ -27,6 +27,7 @@ import org.apache.iotdb.db.exception.FileNodeManagerException;
 import org.apache.iotdb.db.exception.PathErrorException;
 import org.apache.iotdb.db.exception.ProcessorException;
 import org.apache.iotdb.db.metadata.MManager;
+import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.db.qp.physical.crud.AggregationPlan;
 import org.apache.iotdb.db.qp.physical.crud.FillQueryPlan;
 import org.apache.iotdb.db.qp.physical.crud.GroupByPlan;


[incubator-iotdb] 01/03: merge master

Posted by lt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 57e6b5897bcd32fcfbde4967b529e696a17a5a59
Merge: ffc9d89 87ad8ab
Author: lta <li...@163.com>
AuthorDate: Tue Jun 4 09:21:58 2019 +0800

    merge master

 .../UserGuideV0.7.0/5-SQL Documentation.md         |  13 +-
 .../apache/iotdb/cli/client/AbstractClient.java    |   4 +
 iotdb/iotdb/conf/iotdb-engine.properties           |  46 ++-
 iotdb/iotdb/conf/iotdb-sync-client.properties      |   4 +-
 .../apache/iotdb/db/auth/entity/PathPrivilege.java |   1 -
 .../org/apache/iotdb/db/conf/IoTDBConstant.java    |   4 +
 .../db/qp/executor/IQueryProcessExecutor.java      |   3 +-
 .../iotdb/db/qp/executor/OverflowQPExecutor.java   | 263 ++++++++-----
 .../iotdb/db/qp/executor/QueryProcessExecutor.java |  17 +-
 .../apache/iotdb/db/qp/physical/PhysicalPlan.java  |   4 +
 .../iotdb/db/qp/physical/sys/AuthorPlan.java       |   6 +
 .../apache/iotdb/db/query/dataset/AuthDataSet.java |  53 +++
 .../org/apache/iotdb/db/service/TSServiceImpl.java | 195 ++++++----
 .../org/apache/iotdb/db/sync/conf/Constans.java    |  10 +
 .../iotdb/db/sync/conf/SyncSenderConfig.java       |  24 +-
 .../iotdb/db/sync/conf/SyncSenderDescriptor.java   |   7 +-
 .../apache/iotdb/db/sync/sender/SyncSender.java    |  10 +
 .../iotdb/db/sync/sender/SyncSenderImpl.java       | 106 +++---
 .../iotdb/db/integration/IoTDBAuthorizationIT.java | 416 +++++++++++----------
 .../apache/iotdb/db/qp/utils/MemIntQpExecutor.java |   6 +
 .../org/apache/iotdb/jdbc/IoTDBQueryResultSet.java |   9 +
 .../java/org/apache/iotdb/jdbc/IoTDBStatement.java |   9 +-
 service-rpc/src/main/thrift/rpc.thrift             |   1 +
 23 files changed, 748 insertions(+), 463 deletions(-)

diff --cc iotdb/iotdb/conf/iotdb-engine.properties
index 7015e60,c52f5ea..7351604
--- a/iotdb/iotdb/conf/iotdb-engine.properties
+++ b/iotdb/iotdb/conf/iotdb-engine.properties
@@@ -38,18 -45,21 +45,21 @@@ flush_wal_period_in_ms=1
  # Set this parameter to 0 may slow down the ingestion on slow disk.
  force_wal_period_in_ms=10
  
- # database features configuration
+ ####################
+ ### Directory Configuration
+ ####################
+ 
  # data dir
 -# If this property is unset, system will save the data in the default relative path directory under the IoTDB folder(i.e., %IOTDB_HOME%/data/data).
 +# If this property is unset, system will save the data in the default relative metric directory under the IoTDB folder(i.e., %IOTDB_HOME%/data/data).
  # If it is absolute, system will save the data in exact location it points to.
 -# If it is relative, system will save the data in the relative path directory it indicates under the IoTDB folder.
 -# Note: If data_dir is assigned an empty string(i.e.,zero-length), it will be handled as a relative path.
 +# If it is relative, system will save the data in the relative metric directory it indicates under the IoTDB folder.
 +# Note: If data_dir is assigned an empty string(i.e.,zero-length), it will be handled as a relative metric.
  # For windows platform
 -# If its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\", then the path is absolute. Otherwise, it is relative.
 +# If its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\", then the metric is absolute. Otherwise, it is relative.
  # data_dir=D:\\iotdb\\data\\data
  # For Linux platform
 -# If its prefix is "/", then the path is absolute. Otherwise, it is relative.
 -# data_dir=/path/iotdb/data/data
 +# If its prefix is "/", then the metric is absolute. Otherwise, it is relative.
 +# data_dir=/metric/iotdb/data/data
  
  # tsfile dir
  # For this property, multiple directories should be set, and all directories should be separated by ",". All TsFiles will be allocated separately in all these directories. Moreover, setting absolute directories is suggested.
@@@ -77,29 -87,33 +87,33 @@@
  # mult_dir_strategy=MaxDiskUsableSpaceFirstStrategy
  
  # system dir
 -# If this property is unset, system will save the data in the default relative path directory under the IoTDB folder(i.e., %IOTDB_HOME%/data/system).
 +# If this property is unset, system will save the data in the default relative metric directory under the IoTDB folder(i.e., %IOTDB_HOME%/data/system).
  # If it is absolute, system will save the data in exact location it points to.
 -# If it is relative, system will save the data in the relative path directory it indicates under the IoTDB folder.
 -# Note: If sys_dir is assigned an empty string(i.e.,zero-length), it will be handled as a relative path.
 +# If it is relative, system will save the data in the relative metric directory it indicates under the IoTDB folder.
 +# Note: If sys_dir is assigned an empty string(i.e.,zero-length), it will be handled as a relative metric.
  # For windows platform
 -# If its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\", then the path is absolute. Otherwise, it is relative.
 +# If its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\", then the metric is absolute. Otherwise, it is relative.
  # sys_dir=D:\\iotdb\\data\\system
  # For Linux platform
 -# If its prefix is "/", then the path is absolute. Otherwise, it is relative.
 -# sys_dir=/path/iotdb/data/system
 +# If its prefix is "/", then the metric is absolute. Otherwise, it is relative.
 +# sys_dir=/metric/iotdb/data/system
  
  # wal dir
 -# If this property is unset, system will save the data in the default relative path directory under the IoTDB folder(i.e., %IOTDB_HOME%/data).
 +# If this property is unset, system will save the data in the default relative metric directory under the IoTDB folder(i.e., %IOTDB_HOME%/data).
  # If it is absolute, system will save the data in the exact location it points to.
 -# If it is relative, system will save the data in the relative path directory it indicates under the IoTDB folder.
 -# Note: If wal_dir is assigned an empty string(i.e.,zero-length), it will be handled as a relative path.
 +# If it is relative, system will save the data in the relative metric directory it indicates under the IoTDB folder.
 +# Note: If wal_dir is assigned an empty string(i.e.,zero-length), it will be handled as a relative metric.
  # For windows platform
 -# If its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\", then the path is absolute. Otherwise, it is relative.
 +# If its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\", then the metric is absolute. Otherwise, it is relative.
  # wal_dir=D:\\iotdb\\data
  # For Linux platform
 -# If its prefix is "/", then the path is absolute. Otherwise, it is relative.
 -# wal_dir=/path/iotdb/data
 +# If its prefix is "/", then the metric is absolute. Otherwise, it is relative.
 +# wal_dir=/metric/iotdb/data
  
+ ####################
+ ### Memory Control Configuration
+ ####################
+ 
  # The maximum concurrent thread number for merging overflow
  # Increase this value, it will increase IO and CPU consumption
  # Decrease this value, when there is much overflow data, it will increase disk usage, which will reduce read speed
diff --cc iotdb/iotdb/conf/iotdb-sync-client.properties
index cb67443,72e31c5..3cff138
--- a/iotdb/iotdb/conf/iotdb-sync-client.properties
+++ b/iotdb/iotdb/conf/iotdb-sync-client.properties
@@@ -23,10 -23,10 +23,10 @@@ server_ip=127.0.0.
  # Sync client port
  server_port=5555
  
- # The cycle time of post data back to receiver, the unit of time is second
- upload_cycle_in_seconds=600
+ # The period time of sync process, the unit of time is second
+ sync_period_in_seconds=600
  
 -# Set bufferWrite data absolute path of IoTDB
 +# Set bufferWrite data absolute metric of IoTDB
  # It needs to be set with iotdb_schema_directory, they have to belong to the same IoTDB
  # iotdb_bufferWrite_directory = D:\\iotdb\\data\\data\\settled
  
diff --cc iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
index d430bf6,94939e9..0a88640
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
@@@ -31,9 -32,10 +31,10 @@@ import org.apache.iotdb.db.qp.physical.
  import org.apache.iotdb.db.qp.physical.crud.FillQueryPlan;
  import org.apache.iotdb.db.qp.physical.crud.GroupByPlan;
  import org.apache.iotdb.db.qp.physical.crud.QueryPlan;
+ import org.apache.iotdb.db.qp.physical.sys.AuthorPlan;
  import org.apache.iotdb.db.query.context.QueryContext;
 +import org.apache.iotdb.db.query.executor.AbstractQueryRouter;
  import org.apache.iotdb.db.query.executor.EngineQueryRouter;
 -import org.apache.iotdb.db.query.executor.IEngineQueryRouter;
  import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
  import org.apache.iotdb.tsfile.read.common.Path;
  import org.apache.iotdb.tsfile.read.expression.QueryExpression;
@@@ -42,10 -44,10 +43,10 @@@ import org.apache.iotdb.tsfile.read.que
  public abstract class QueryProcessExecutor implements IQueryProcessExecutor {
  
    protected ThreadLocal<Integer> fetchSize = new ThreadLocal<>();
 -  protected IEngineQueryRouter queryRouter = new EngineQueryRouter();
 +  protected AbstractQueryRouter queryRouter = new EngineQueryRouter();
  
    @Override
-   public QueryDataSet processQuery(QueryPlan queryPlan, QueryContext context)
+   public QueryDataSet processQuery(PhysicalPlan queryPlan, QueryContext context)
        throws IOException, FileNodeManagerException, PathErrorException,
        QueryFilterOptimizationException, ProcessorException {
  


[incubator-iotdb] 03/03: Merge branch 'cluster' of github.com:apache/incubator-iotdb into cluster

Posted by lt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 27252b160cee094d764d4a85a0a9c32b65cc28ba
Merge: ca9e9e0 fb6847a
Author: lta <li...@163.com>
AuthorDate: Tue Jun 4 10:39:30 2019 +0800

    Merge branch 'cluster' of github.com:apache/incubator-iotdb into cluster

 .../iotdb/cluster/service/ClusterMonitor.java      |  6 +++++
 .../iotdb/cluster/service/ClusterMonitorMBean.java |  8 ++++++
 .../iotdb/cluster/service/nodetool/Ring.java       |  1 +
 .../cluster/service/nodetool/StorageGroup.java     | 20 +++++++++++++--
 .../org/apache/iotdb/cluster/utils/RaftUtils.java  |  5 ++++
 .../UserGuideV0.7.0/7-Tools-NodeTool.md            | 30 +++++++++++++++++++---
 6 files changed, 64 insertions(+), 6 deletions(-)