You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by do...@apache.org on 2019/04/08 14:15:44 UTC
[incubator-iotdb] branch cluster updated: add show timeseries in
json query case
This is an automated email from the ASF dual-hosted git repository.
dope pushed a commit to branch cluster
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/cluster by this push:
new f07dc37 add show timeseries in json query case
f07dc37 is described below
commit f07dc374f54a4e65b1f0195be61c1403e420f81b
Author: xuyi556677@163.com <xu...@163.com>
AuthorDate: Mon Apr 8 22:15:33 2019 +0800
add show timeseries in json query case
---
.../apache/iotdb/cluster/qp/ClusterQPExecutor.java | 4 -
.../org/apache/iotdb/cluster/utils/RaftUtils.java | 5 -
.../cluster/integration/IoTDBMetadataFetchIT.java | 124 +++++++++++++++------
3 files changed, 93 insertions(+), 40 deletions(-)
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/qp/ClusterQPExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/qp/ClusterQPExecutor.java
index 90438a4..87de676 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/qp/ClusterQPExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/qp/ClusterQPExecutor.java
@@ -31,16 +31,12 @@ 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.entity.raft.DataPartitionRaftHolder;
import org.apache.iotdb.cluster.entity.raft.MetadataRaftHolder;
-import org.apache.iotdb.cluster.entity.raft.RaftService;
import org.apache.iotdb.cluster.exception.ConsistencyLevelException;
import org.apache.iotdb.cluster.exception.RaftConnectionException;
import org.apache.iotdb.cluster.rpc.NodeAsClient;
import org.apache.iotdb.cluster.rpc.impl.RaftNodeAsClientManager;
import org.apache.iotdb.cluster.rpc.response.BasicResponse;
-import org.apache.iotdb.cluster.rpc.response.DataGroupNonQueryResponse;
-import org.apache.iotdb.cluster.rpc.response.MetaGroupNonQueryResponse;
import org.apache.iotdb.cluster.utils.RaftUtils;
import org.apache.iotdb.cluster.utils.hash.PhysicalNode;
import org.apache.iotdb.cluster.utils.hash.Router;
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/utils/RaftUtils.java b/cluster/src/main/java/org/apache/iotdb/cluster/utils/RaftUtils.java
index 000da40..50d19ee 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/utils/RaftUtils.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/utils/RaftUtils.java
@@ -21,24 +21,19 @@ package org.apache.iotdb.cluster.utils;
import com.alipay.remoting.AsyncContext;
import com.alipay.remoting.exception.CodecException;
import com.alipay.remoting.serialization.SerializerManager;
-import com.alipay.sofa.jraft.RouteTable;
-import com.alipay.sofa.jraft.conf.Configuration;
import com.alipay.sofa.jraft.entity.PeerId;
import com.alipay.sofa.jraft.entity.Task;
-import com.alipay.sofa.jraft.rpc.impl.cli.BoltCliClientService;
import com.alipay.sofa.jraft.util.Bits;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.TimeoutException;
import org.apache.iotdb.cluster.callback.QPTask;
import org.apache.iotdb.cluster.config.ClusterConfig;
import org.apache.iotdb.cluster.entity.Server;
import org.apache.iotdb.cluster.entity.raft.DataPartitionRaftHolder;
import org.apache.iotdb.cluster.entity.raft.MetadataRaftHolder;
import org.apache.iotdb.cluster.entity.raft.RaftService;
-import org.apache.iotdb.cluster.exception.RaftConnectionException;
import org.apache.iotdb.cluster.rpc.closure.ResponseClosure;
import org.apache.iotdb.cluster.rpc.request.BasicRequest;
import org.apache.iotdb.cluster.rpc.response.BasicResponse;
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchIT.java b/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchIT.java
index f1b3704..19db49c 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchIT.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchIT.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.cluster.integration;
import static org.junit.Assert.fail;
import java.sql.Connection;
+import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
@@ -60,30 +61,32 @@ public class IoTDBMetadataFetchIT {
}
@Test
- public void showTimeseriesTest() throws SQLException {
+ public void test() throws SQLException {
Connection connection = null;
try {
connection = DriverManager.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
insertSQL(connection, false);
- testShowTimeseries(connection);
- testShowTimeseriesPath(connection);
+// testShowStorageGroup(connection);
+ testDatabaseMetadata(connection);
+// testShowTimeseries(connection);
+// testShowTimeseriesPath(connection);
} finally {
connection.close();
}
}
//Test
- public void showTimeseriesTestBatch() throws SQLException {
- Connection connection = null;
- try {
- connection = DriverManager.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- insertSQL(connection, true);
- testShowTimeseries(connection);
- testShowTimeseriesPath(connection);
- } finally {
- connection.close();
- }
- }
+// public void testBatch() throws SQLException {
+// Connection connection = null;
+// try {
+// connection = DriverManager.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+// insertSQL(connection, true);
+// testShowTimeseries(connection);
+// testShowTimeseriesPath(connection);
+// } finally {
+// connection.close();
+// }
+// }
private void insertSQL(Connection connection, boolean isBatch) throws SQLException {
Statement statement = connection.createStatement();
@@ -124,16 +127,33 @@ public class IoTDBMetadataFetchIT {
private void testShowStorageGroup(Connection connection) throws SQLException {
Statement statement = connection.createStatement();
+ String[] sqls = new String[]{
+ "show storage group",
+// "show storage group root.ln",
+ };
+ String[] standards = new String[]{
+ "root.ln.wf04,\n"
+ + "root.ln.wf03,\n"
+ + "root.ln.wf02,\n"
+ + "root.ln.wf01,\n"
+ + "root.ln.wf05,\n",
+// "root.ln.wf04,\n"
+// + "root.ln.wf03,\n"
+// + "root.ln.wf02,\n"
+// + "root.ln.wf01,\n"
+// + "root.ln.wf05,\n"
+ };
+ checkCorrectness(sqls, standards, statement);
}
private void testShowTimeseriesPath(Connection connection) throws SQLException{
Statement statement = connection.createStatement();
String[] sqls = new String[]{
-// "show timeseries root.ln.wf01.wt01.status", // full seriesPath
+ "show timeseries root.ln.wf01.wt01.status", // full seriesPath
// "show timeseries root.ln", // prefix seriesPath
// "show timeseries root.ln.wf01.wt01", // prefix seriesPath
- "show timeseries root.ln.*.wt01.status", // seriesPath with stars
+// "show timeseries root.ln.*.wt01.status", // seriesPath with stars
// "show timeseries root.ln.*.wt01.*", // seriesPath with stars
// "show timeseries root.a.b", // nonexistent timeseries, thus returning ""
// "show timeseries root.ln,root.ln",
@@ -141,7 +161,7 @@ public class IoTDBMetadataFetchIT {
// returning ""
};
String[] standards = new String[]{
-// "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n",
+ "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n",
// "root.ln.wf04.wt04.status,root.ln.wf04,TEXT,PLAIN,\n"
// +"root.ln.wf04.wt05.temperature,root.ln.wf04,FLOAT,GORILLA,\n"
// +"root.ln.wf03.wt02.status,root.ln.wf03,INT64,PLAIN,\n"
@@ -154,14 +174,37 @@ public class IoTDBMetadataFetchIT {
// +"root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
// "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
// +"root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n",
- "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
- + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
+// "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
+// + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
// "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
// + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,PLAIN,\n"
// + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
// "",
// ""
};
+ checkCorrectness(sqls, standards, statement);
+ }
+
+ private void testShowTimeseries(Connection connection) throws SQLException {
+ Statement statement = connection.createStatement();
+ try {
+ statement.execute("show timeseries");
+ } catch (SQLException e){
+ return;
+ } catch (Exception e){
+ fail(e.getMessage());
+ } finally {
+ statement.close();
+ }
+ }
+
+ private void testDatabaseMetadata(Connection connection) throws SQLException{
+ DatabaseMetaData databaseMetaData = connection.getMetaData();
+
+ showTimeseriesInJson(databaseMetaData);
+ }
+
+ private void checkCorrectness(String[] sqls, String[] standards, Statement statement) throws SQLException{
for (int i = 0; i < sqls.length; i++) {
String sql = sqls[i];
String standard = standards[i];
@@ -188,17 +231,36 @@ public class IoTDBMetadataFetchIT {
}
}
- private void testShowTimeseries(Connection connection) throws SQLException {
- Statement statement = connection.createStatement();
- try {
- statement.execute("show timeseries");
- } catch (SQLException e){
- return;
- } catch (Exception e){
- fail(e.getMessage());
- } finally {
- statement.close();
- }
- }
+ private void showTimeseriesInJson(DatabaseMetaData databaseMetaData) {
+ String metadataInJson = databaseMetaData.toString();
+ String standard =
+ "=== Timeseries Tree ===\n"
+ + "\n"
+ + "{\n"
+ + "\t\"root\":{\n"
+ + "\t\t\"ln\":{\n"
+ + "\t\t\t\"wf01\":{\n"
+ + "\t\t\t\t\"wt01\":{\n"
+ + "\t\t\t\t\t\"temperature\":{\n"
+ + "\t\t\t\t\t\t\"args\":\"{max_point_number=3}\",\n"
+ + "\t\t\t\t\t\t\"StorageGroup\":\"root.ln.wf01.wt01\",\n"
+ + "\t\t\t\t\t\t\"DataType\":\"FLOAT\",\n"
+ + "\t\t\t\t\t\t\"Compressor\":\"SNAPPY\",\n"
+ + "\t\t\t\t\t\t\"Encoding\":\"RLE\"\n"
+ + "\t\t\t\t\t},\n"
+ + "\t\t\t\t\t\"status\":{\n"
+ + "\t\t\t\t\t\t\"args\":\"{}\",\n"
+ + "\t\t\t\t\t\t\"StorageGroup\":\"root.ln.wf01.wt01\",\n"
+ + "\t\t\t\t\t\t\"DataType\":\"BOOLEAN\",\n"
+ + "\t\t\t\t\t\t\"Compressor\":\"UNCOMPRESSED\",\n"
+ + "\t\t\t\t\t\t\"Encoding\":\"PLAIN\"\n"
+ + "\t\t\t\t\t}\n"
+ + "\t\t\t\t}\n"
+ + "\t\t\t}\n"
+ + "\t\t}\n"
+ + "\t}\n"
+ + "}";
+ Assert.assertEquals(standard, metadataInJson);
+ }
}