Skip to content

Commit 8bc4967

Browse files
committed
Merge branch 'master' of https://github.com/apache/iotdb into session-last-bug
2 parents 5b65f8d + 1768bd9 commit 8bc4967

142 files changed

Lines changed: 3418 additions & 550 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

example/mqtt/src/main/java/org/apache/iotdb/mqtt/MQTTClient.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
public class MQTTClient {
2828

2929
private static final String DATABASE = "myMqttTest";
30+
private static final String MY_TOPIC = "/myTopic";
3031

3132
public static void main(String[] args) throws Exception {
3233
MQTT mqtt = new MQTT();
@@ -74,39 +75,39 @@ private static void jsonPayloadFormatter(BlockingConnection connection) throws E
7475
private static void linePayloadFormatter(BlockingConnection connection) throws Exception {
7576
// myTable,tag1=t1,tag2=t2 fieldKey1="1,2,3" 1740109006001
7677
String payload = "myTable,tag1=t1,tag2=t2 fieldKey1=\"1,2,3\" 1740109006001";
77-
connection.publish(DATABASE + "/myTopic", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
78+
connection.publish(DATABASE + MY_TOPIC, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
7879
Thread.sleep(10);
7980

8081
payload = "myTable,tag1=t1,tag2=t2 fieldKey1=\"1,2,3\" 1740109006002";
81-
connection.publish(DATABASE + "/myTopic", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
82+
connection.publish(DATABASE + MY_TOPIC, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
8283
Thread.sleep(10);
8384

8485
payload = "myTable,tag1=t1,tag2=t2 fieldKey1=\"1,2,3\" 1740109006003";
85-
connection.publish(DATABASE + "/myTopic", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
86+
connection.publish(DATABASE + MY_TOPIC, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
8687
Thread.sleep(10);
8788
payload =
8889
"test1,tag1=t1,tag2=t2 attr3=a5,attr4=a4 field1=\"fieldValue1\",field2=1i,field3=1u 1";
89-
connection.publish(DATABASE + "/myTopic", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
90+
connection.publish(DATABASE + MY_TOPIC, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
9091
Thread.sleep(10);
9192

9293
payload = "test1,tag1=t1,tag2=t2 field4=2,field5=2i32,field6=2f 2";
93-
connection.publish(DATABASE, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
94+
connection.publish(DATABASE + MY_TOPIC, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
9495
Thread.sleep(10);
9596

9697
payload =
9798
"test1,tag1=t1,tag2=t2 field7=t,field8=T,field9=true 3 \n "
9899
+ "test1,tag1=t1,tag2=t2 field7=f,field8=F,field9=FALSE 4";
99-
connection.publish(DATABASE + "/myTopic", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
100+
connection.publish(DATABASE + MY_TOPIC, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
100101
Thread.sleep(10);
101102

102103
payload =
103104
"test1,tag1=t1,tag2=t2 attr1=a1,attr2=a2 field1=\"fieldValue1\",field2=1i,field3=1u 4 \n "
104105
+ "test1,tag1=t1,tag2=t2 field4=2,field5=2i32,field6=2f 5";
105-
connection.publish(DATABASE + "/myTopic", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
106+
connection.publish(DATABASE + MY_TOPIC, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
106107
Thread.sleep(10);
107108

108109
payload = "# It's a remark\n " + "test1,tag1=t1,tag2=t2 field4=2,field5=2i32,field6=2f 6";
109-
connection.publish(DATABASE + "/myTopic", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
110+
connection.publish(DATABASE + MY_TOPIC, payload.getBytes(), QoS.AT_LEAST_ONCE, false);
110111
Thread.sleep(10);
111112
}
112113
}

integration-test/src/main/java/org/apache/iotdb/it/env/cluster/node/DataNodeWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public DataNodeWrapper(
103103
this.schemaRegionConsensusPort = portList[4];
104104
this.mqttPort = portList[5];
105105
this.pipeAirGapReceiverPort = portList[6];
106-
this.restServicePort = portList[10] + 6000;
106+
this.restServicePort = portList[7];
107107
this.defaultNodePropertiesFile =
108108
EnvUtils.getFilePathFromSysVar(DEFAULT_DATA_NODE_PROPERTIES, clusterIndex);
109109
this.defaultCommonPropertiesFile =

integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBSystemPermissionIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ public void maintainOperationsTest() {
213213
grantUserSystemPrivileges("test6", PrivilegeType.SYSTEM);
214214
executeNonQuery("flush", "test6", "test123123456");
215215
executeNonQuery("clear cache", "test6", "test123123456");
216+
executeNonQuery("clear auth cache", "test6", "test123123456");
216217
executeNonQuery("set system to readonly", "test6", "test123123456");
217218
executeNonQuery("set system to running", "test6", "test123123456");
218219
executeNonQuery(
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.db.it.schema;
21+
22+
import org.apache.iotdb.isession.ISession;
23+
import org.apache.iotdb.it.env.EnvFactory;
24+
import org.apache.iotdb.itbase.category.ClusterIT;
25+
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
26+
import org.apache.iotdb.util.AbstractSchemaIT;
27+
28+
import org.apache.tsfile.enums.TSDataType;
29+
import org.apache.tsfile.file.metadata.enums.CompressionType;
30+
import org.apache.tsfile.file.metadata.enums.TSEncoding;
31+
import org.apache.tsfile.write.record.Tablet;
32+
import org.junit.After;
33+
import org.junit.Assert;
34+
import org.junit.Test;
35+
import org.junit.experimental.categories.Category;
36+
import org.junit.runners.Parameterized;
37+
38+
import java.io.File;
39+
import java.nio.file.Files;
40+
import java.nio.file.Paths;
41+
import java.sql.Connection;
42+
import java.sql.Statement;
43+
import java.util.ArrayList;
44+
import java.util.Arrays;
45+
import java.util.Collections;
46+
import java.util.List;
47+
48+
@Category({LocalStandaloneIT.class, ClusterIT.class})
49+
public class IoTDBSchemaSyntaxIT extends AbstractSchemaIT {
50+
public IoTDBSchemaSyntaxIT(SchemaTestMode schemaTestMode) {
51+
super(schemaTestMode);
52+
}
53+
54+
@Parameterized.BeforeParam
55+
public static void before() throws Exception {
56+
setUpEnvironment();
57+
EnvFactory.getEnv().initClusterEnvironment();
58+
}
59+
60+
@Parameterized.AfterParam
61+
public static void after() throws Exception {
62+
EnvFactory.getEnv().cleanClusterEnvironment();
63+
tearDownEnvironment();
64+
}
65+
66+
@After
67+
public void tearDown() throws Exception {
68+
clearSchema();
69+
}
70+
71+
@Test
72+
public void testInvalidCreation() throws Exception {
73+
final List<String> invalidSQLs =
74+
Arrays.asList(
75+
"CREATE TIMESERIES root.sg1.d1.s1 OBJECT",
76+
"CREATE ALIGNED TIMESERIES root.sg1.d1.vector1(s1 OBJECT encoding=PLAIN compressor=UNCOMPRESSED,s2 INT64 encoding=RLE)",
77+
"create schema template t1 (s2 OBJECT encoding=RLE, s3 INT64 encoding=RLE compression=SNAPPY)");
78+
79+
try (final Connection connection = EnvFactory.getEnv().getConnection();
80+
final Statement statement = connection.createStatement()) {
81+
for (final String invalidSQL : invalidSQLs) {
82+
try {
83+
statement.execute(invalidSQL);
84+
Assert.fail();
85+
} catch (final Exception ignore) {
86+
// Expected
87+
}
88+
}
89+
}
90+
91+
final String testObject =
92+
System.getProperty("user.dir")
93+
+ File.separator
94+
+ "target"
95+
+ File.separator
96+
+ "test-classes"
97+
+ File.separator
98+
+ "object-example.pt";
99+
final byte[] objectBytes = Files.readAllBytes(Paths.get(testObject));
100+
final List<byte[]> objectSegments = new ArrayList<>();
101+
for (int i = 0; i < objectBytes.length; i += 512) {
102+
objectSegments.add(Arrays.copyOfRange(objectBytes, i, Math.min(i + 512, objectBytes.length)));
103+
}
104+
try (final ISession session = EnvFactory.getEnv().getSessionConnection()) {
105+
// insert table data by tablet
106+
final List<String> columnNameList =
107+
Arrays.asList("region_id", "plant_id", "device_id", "temperature", "file");
108+
final List<TSDataType> dataTypeList =
109+
Arrays.asList(
110+
TSDataType.STRING,
111+
TSDataType.STRING,
112+
TSDataType.STRING,
113+
TSDataType.FLOAT,
114+
TSDataType.OBJECT);
115+
final Tablet tablet = new Tablet(columnNameList, dataTypeList);
116+
tablet.setDeviceId("root.test.objectDevice");
117+
for (int i = 0; i < columnNameList.size() - 1; i++) {
118+
int rowIndex = tablet.getRowSize();
119+
tablet.addTimestamp(rowIndex, 1);
120+
tablet.addValue(rowIndex, 0, "1");
121+
tablet.addValue(rowIndex, 1, "5");
122+
tablet.addValue(rowIndex, 2, "3");
123+
tablet.addValue(rowIndex, 3, 37.6F);
124+
tablet.addValue(rowIndex, 4, false, i * 512L, objectSegments.get(i));
125+
}
126+
try {
127+
session.insertTablet(tablet);
128+
Assert.fail();
129+
} catch (final Exception ignore) {
130+
// Expected
131+
}
132+
try {
133+
session.insertAlignedTablet(tablet);
134+
Assert.fail();
135+
} catch (final Exception ignore) {
136+
// Expected
137+
}
138+
try {
139+
session.createMultiTimeseries(
140+
Collections.singletonList("root.sg1.d1.s1"),
141+
Collections.singletonList(TSDataType.OBJECT),
142+
Collections.singletonList(TSEncoding.PLAIN),
143+
Collections.singletonList(CompressionType.LZ4),
144+
null,
145+
null,
146+
null,
147+
null);
148+
} catch (final Exception ignore) {
149+
// Expected
150+
}
151+
tablet.reset();
152+
}
153+
}
154+
}

0 commit comments

Comments
 (0)