Skip to content

Commit 316c777

Browse files
authored
Merge branch 'apache:research/traft' into research/traft
2 parents e9ac801 + 9acf1e9 commit 316c777

57 files changed

Lines changed: 772 additions & 1032 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.

dependencies.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,9 @@
3333
"com.nimbusds:nimbus-jose-jwt",
3434
"com.nimbusds:oauth2-oidc-sdk",
3535
"com.sun.istack:istack-commons-runtime",
36-
"org.apache.ratis:ratis-client",
37-
"org.apache.ratis:ratis-common",
38-
"org.apache.ratis:ratis-grpc",
39-
"org.apache.ratis:ratis-metrics-api",
40-
"org.apache.ratis:ratis-proto",
41-
"org.apache.ratis:ratis-server",
42-
"org.apache.ratis:ratis-server-api",
4336
"com.zaxxer:HikariCP",
4437
"commons-cli:commons-cli",
4538
"commons-codec:commons-codec",
46-
"commons-codec:commons-codec",
4739
"commons-logging:commons-logging",
4840
"io.airlift:airline",
4941
"io.airlift:units",
@@ -93,18 +85,25 @@
9385
"jakarta.validation:jakarta.validation-api",
9486
"jakarta.ws.rs:jakarta.ws.rs-api",
9587
"jakarta.xml.bind:jakarta.xml.bind-api",
88+
"javax.xml.bind:jaxb-api",
9689
"net.java.dev.jna:jna",
9790
"net.java.dev.jna:jna-platform",
9891
"net.minidev:accessors-smart",
9992
"net.minidev:json-smart",
10093
"org.antlr:antlr4-runtime",
10194
"org.apache.commons:commons-csv",
10295
"org.apache.commons:commons-lang3",
103-
"org.apache.commons:commons-lang3",
10496
"org.apache.commons:commons-math3",
10597
"org.apache.commons:commons-pool2",
10698
"org.apache.httpcomponents:httpclient",
10799
"org.apache.httpcomponents:httpcore",
100+
"org.apache.ratis:ratis-client",
101+
"org.apache.ratis:ratis-common",
102+
"org.apache.ratis:ratis-grpc",
103+
"org.apache.ratis:ratis-metrics-api",
104+
"org.apache.ratis:ratis-proto",
105+
"org.apache.ratis:ratis-server",
106+
"org.apache.ratis:ratis-server-api",
108107
"org.apache.ratis:ratis-thirdparty-misc",
109108
"org.apache.thrift:libthrift",
110109
"org.apache.tsfile:common",
@@ -113,7 +112,6 @@
113112
"org.bouncycastle:bcprov-jdk18on",
114113
"org.bouncycastle:bcutil-jdk18on",
115114
"org.checkerframework:checker-qual",
116-
"org.checkerframework:checker-qual",
117115
"org.eclipse.collections:eclipse-collections",
118116
"org.eclipse.collections:eclipse-collections-api",
119117
"org.eclipse.jetty:jetty-http",

example/session/src/main/java/org/apache/iotdb/SessionPoolExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static void queryByIterator() {
115115
while (dataIterator.next()) {
116116
StringBuilder builder = new StringBuilder();
117117
for (String columnName : wrapper.getColumnNames()) {
118-
builder.append(dataIterator.getString(columnName) + " ");
118+
builder.append(dataIterator.getString(columnName)).append(" ");
119119
}
120120
System.out.println(builder);
121121
}

integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBComplexQueryTableViewIT.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public class IoTDBComplexQueryTableViewIT {
4848
"create aligned timeseries root.test.employees.D002(name TEXT,Gender TEXT,Status BOOLEAN,employee_id INT32,salary DOUBLE,date_of_birth DATE,Contac_info string)",
4949
"create aligned timeseries root.test.employees.D002(name TEXT,Gender TEXT,Status BOOLEAN,employee_id INT32,salary DOUBLE,date_of_birth DATE,Contac_info string)",
5050
"create aligned timeseries root.test.employees.D003(name TEXT,Gender TEXT,Status BOOLEAN,employee_id INT32,salary DOUBLE,date_of_birth DATE,Contac_info string)",
51-
"create aligned timeseries root.test.departments.D001(department_id STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
52-
"create aligned timeseries root.test.departments.D002(department_id STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
53-
"create aligned timeseries root.test.departments.D003(department_id STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
54-
"create aligned timeseries root.test.departments.D004(department_id STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
51+
"create aligned timeseries root.test.departments.D001(`1department_id` STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
52+
"create aligned timeseries root.test.departments.D002(`1department_id` STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
53+
"create aligned timeseries root.test.departments.D003(`1department_id` STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
54+
"create aligned timeseries root.test.departments.D004(`1department_id` STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
5555
"insert into root.test.employees.D001(time, name, gender, status, employee_id, salary, date_of_birth, contac_info) aligned values(1, 'Mary','Female', false, 1223, 5500.22, '1988-10-12', '133-1212-1234')",
5656
"insert into root.test.employees.D001(time, name, gender, status, employee_id, salary, date_of_birth, contac_info) aligned values(2, 'John', 'Male', true, 40012, 8822, '1985-06-15', '130-1002-1334')",
5757
"insert into root.test.employees.D002(time, name, gender, status, employee_id, salary, date_of_birth, contac_info) aligned values(3, 'Nancy', 'Female', true, 30112, 10002, '1983-08-15', '135-1302-1354')",
@@ -69,8 +69,8 @@ public class IoTDBComplexQueryTableViewIT {
6969
new String[] {
7070
"CREATE DATABASE " + DATABASE_NAME,
7171
"USE " + DATABASE_NAME,
72-
"create view employees(department_id STRING TAG,name TEXT FIELD,Gender TEXT FIELD,Status BOOLEAN FIELD,employee_id INT32 FIELD,salary DOUBLE FIELD,date_of_birth DATE FIELD,Contac_info string FIELD) as root.test.employees.**",
73-
"create view departments(department_id STRING TAG,dep_name TEXT FIELD,dep_phone TEXT FIELD,dep_status BOOLEAN FIELD,dep_member INT32 FIELD,employee_id INT32 FIELD) as root.test.departments.**",
72+
"create view employees(\"`1department_id`\" STRING TAG,name TEXT FIELD,Gender TEXT FIELD,Status BOOLEAN FIELD,employee_id INT32 FIELD,salary DOUBLE FIELD,date_of_birth DATE FIELD,Contac_info string FIELD) as root.test.employees.**",
73+
"create view departments(\"`1department_id`\" STRING TAG,dep_name TEXT FIELD,dep_phone TEXT FIELD,dep_status BOOLEAN FIELD,dep_member INT32 FIELD,employee_id INT32 FIELD) as root.test.departments.**",
7474
};
7575

7676
@BeforeClass
@@ -88,11 +88,11 @@ public static void tearDown() throws Exception {
8888
@Test
8989
public void queryTest1() {
9090
// Look for the non-intersecting departments in the two tables
91-
String[] expectedHeader = new String[] {"department_id", "dep_name"};
91+
String[] expectedHeader = new String[] {"`1department_id`", "dep_name"};
9292
String[] retArray = new String[] {"D004,人事部,"};
9393
tableResultSetEqualTest(
94-
"select department_id, dep_name from departments where not exists("
95-
+ "select 1 from employees where employees.department_id = departments.department_id)",
94+
"select \"`1department_id`\", dep_name from departments where not exists("
95+
+ "select 1 from employees where employees.\"`1department_id`\" = departments.\"`1department_id`\")",
9696
expectedHeader,
9797
retArray,
9898
DATABASE_NAME);

integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -761,10 +761,10 @@ public void testTreeViewTable() throws Exception {
761761
try (final Connection connection = EnvFactory.getEnv().getConnection();
762762
final Statement statement = connection.createStatement()) {
763763
statement.execute("create database root.another");
764-
statement.execute("create database root.`重庆`.b");
765-
statement.execute("create timeSeries root.`重庆`.b.c.S1 int32");
766-
statement.execute("create timeSeries root.`重庆`.b.c.s2 string");
767-
statement.execute("create timeSeries root.`重庆`.b.S1 int32");
764+
statement.execute("create database root.`重庆`.`1`.b");
765+
statement.execute("create timeSeries root.`重庆`.`1`.b.`2`.S1 int32");
766+
statement.execute("create timeSeries root.`重庆`.`1`.b.`2`.s2 string");
767+
statement.execute("create timeSeries root.`重庆`.`1`.b.S1 int32");
768768
} catch (SQLException e) {
769769
fail(e.getMessage());
770770
}
@@ -783,13 +783,13 @@ public void testTreeViewTable() throws Exception {
783783
"701: Cannot specify view pattern to match more than one tree database.",
784784
e.getMessage());
785785
}
786-
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".**");
786+
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".\"1\".**");
787787
statement.execute("drop view tree_table");
788788
}
789789

790790
try (final Connection connection = EnvFactory.getEnv().getConnection();
791791
final Statement statement = connection.createStatement()) {
792-
statement.execute("create timeSeries root.`重庆`.b.d.s1 int32");
792+
statement.execute("create timeSeries root.`重庆`.`1`.b.`1`.s1 int32");
793793
} catch (SQLException e) {
794794
fail(e.getMessage());
795795
}
@@ -800,7 +800,7 @@ public void testTreeViewTable() throws Exception {
800800
statement.execute("use tree_view_db");
801801

802802
try {
803-
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".**");
803+
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".\"1\".**");
804804
fail();
805805
} catch (final SQLException e) {
806806
final Set<String> result =
@@ -814,13 +814,13 @@ public void testTreeViewTable() throws Exception {
814814

815815
try (final Connection connection = EnvFactory.getEnv().getConnection();
816816
final Statement statement = connection.createStatement()) {
817-
statement.execute("drop timeSeries root.`重庆`.b.d.s1");
817+
statement.execute("drop timeSeries root.`重庆`.`1`.b.`1`.s1");
818818
statement.execute("create device template t1 (S1 boolean, s9 int32)");
819-
statement.execute("set schema template t1 to root.`重庆`.b.d");
820-
statement.execute("create timeSeries root.`重庆`.b.c.f.g.h.S1 int32");
819+
statement.execute("set schema template t1 to root.`重庆`.`1`.b.`1`");
820+
statement.execute("create timeSeries root.`重庆`.`1`.b.`2`.f.g.h.S1 int32");
821821

822822
// Put schema cache
823-
statement.execute("select S1, s2 from root.`重庆`.b.c");
823+
statement.execute("select S1, s2 from root.`重庆`.`1`.b.`2`");
824824
} catch (SQLException e) {
825825
fail(e.getMessage());
826826
}
@@ -831,7 +831,7 @@ public void testTreeViewTable() throws Exception {
831831
statement.execute("use tree_view_db");
832832

833833
try {
834-
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".**");
834+
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".\"1\".**");
835835
fail();
836836
} catch (final SQLException e) {
837837
assertEquals(
@@ -841,7 +841,7 @@ public void testTreeViewTable() throws Exception {
841841

842842
try {
843843
statement.execute(
844-
"create view tree_table (tag1 tag, tag2 tag, S1 field) as root.\"重庆\".**");
844+
"create view tree_table (tag1 tag, tag2 tag, S1 field) as root.\"重庆\".\"1\".**");
845845
fail();
846846
} catch (final SQLException e) {
847847
assertEquals(
@@ -852,7 +852,7 @@ public void testTreeViewTable() throws Exception {
852852

853853
try (final Connection connection = EnvFactory.getEnv().getConnection();
854854
final Statement statement = connection.createStatement()) {
855-
statement.execute("create timeSeries root.`重庆`.b.e.s1 int32");
855+
statement.execute("create timeSeries root.`重庆`.`1`.b.e.s1 int32");
856856
} catch (SQLException e) {
857857
fail(e.getMessage());
858858
}
@@ -873,7 +873,7 @@ public void testTreeViewTable() throws Exception {
873873
// Temporary
874874
try {
875875
statement.execute(
876-
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 boolean from S1) as root.\"重庆\".**");
876+
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 boolean from S1) as root.\"重庆\".\"1\".**");
877877
fail();
878878
} catch (final SQLException e) {
879879
assertEquals(
@@ -882,14 +882,14 @@ public void testTreeViewTable() throws Exception {
882882

883883
try {
884884
statement.execute(
885-
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 from s2, s8 field) as root.\"重庆\".**");
885+
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 from s2, s8 field) as root.\"重庆\".\"1\".**");
886886
fail();
887887
} catch (final SQLException e) {
888888
assertEquals("528: Measurements not found for s8, cannot auto detect", e.getMessage());
889889
}
890890

891891
statement.execute(
892-
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 from s2) as root.\"重庆\".**");
892+
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 from s2) as root.\"重庆\".\"1\".**");
893893

894894
// Cannot be written
895895
try {
@@ -937,11 +937,15 @@ public void testTreeViewTable() throws Exception {
937937
TestUtils.assertResultSetEqual(
938938
statement.executeQuery("show devices from view_table where tag1 = 'b'"),
939939
"tag1,tag2,",
940-
new HashSet<>(Arrays.asList("b,c,", "b,null,", "b,e,")));
940+
new HashSet<>(Arrays.asList("b,`2`,", "b,null,", "b,e,")));
941941
TestUtils.assertResultSetEqual(
942942
statement.executeQuery("show devices from view_table where tag1 = 'b' and tag2 is null"),
943943
"tag1,tag2,",
944944
Collections.singleton("b,null,"));
945+
TestUtils.assertResultSetEqual(
946+
statement.executeQuery("show devices from view_table where tag1 = 'b' and tag2 = '`2`'"),
947+
"tag1,tag2,",
948+
Collections.singleton("b,`2`,"));
945949
TestUtils.assertResultSetEqual(
946950
statement.executeQuery("count devices from view_table"),
947951
"count(devices),",
@@ -953,7 +957,7 @@ public void testTreeViewTable() throws Exception {
953957
final Statement statement = connection.createStatement()) {
954958
// Test create & replace + restrict
955959
statement.execute(
956-
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.`重庆`.**");
960+
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.`重庆`.`1`.**");
957961
fail();
958962
} catch (final SQLException e) {
959963
assertTrue(
@@ -974,7 +978,7 @@ public void testTreeViewTable() throws Exception {
974978
.getConnection("testUser", "testUser123456", BaseEnv.TABLE_SQL_DIALECT);
975979
final Statement statement = connection.createStatement()) {
976980
statement.execute(
977-
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".**");
981+
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".\"1\".**");
978982
fail();
979983
} catch (final SQLException e) {
980984
assertEquals(
@@ -995,7 +999,7 @@ public void testTreeViewTable() throws Exception {
995999
.getConnection("testUser", "testUser123456", BaseEnv.TABLE_SQL_DIALECT);
9961000
final Statement statement = connection.createStatement()) {
9971001
statement.execute(
998-
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".**");
1002+
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".\"1\".**");
9991003
fail();
10001004
} catch (final SQLException e) {
10011005
assertEquals(
@@ -1015,7 +1019,7 @@ public void testTreeViewTable() throws Exception {
10151019
.getConnection("testUser", "testUser123456", BaseEnv.TABLE_SQL_DIALECT);
10161020
final Statement statement = connection.createStatement()) {
10171021
statement.execute(
1018-
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".**");
1022+
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".\"1\".**");
10191023
fail();
10201024
} catch (final SQLException e) {
10211025
assertEquals(
@@ -1035,7 +1039,7 @@ public void testTreeViewTable() throws Exception {
10351039
.getConnection("testUser", "testUser123456", BaseEnv.TABLE_SQL_DIALECT);
10361040
final Statement statement = connection.createStatement()) {
10371041
statement.execute(
1038-
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".**");
1042+
"create or replace view tree_view_db.view_table (tag1 tag, tag2 tag, s11 int32 field, s3 from s2) restrict with (ttl=100) as root.\"重庆\".\"1\".**");
10391043
} catch (final SQLException e) {
10401044
fail();
10411045
}
@@ -1054,14 +1058,14 @@ public void testTreeViewTable() throws Exception {
10541058
statement.executeQuery("show create view view_table"),
10551059
"View,Create View,",
10561060
Collections.singleton(
1057-
"view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") RESTRICT WITH (ttl=100) AS root.\"重庆\".**,"));
1061+
"view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") RESTRICT WITH (ttl=100) AS root.\"重庆\".\"1\".**,"));
10581062

10591063
// Can also use "show create table"
10601064
TestUtils.assertResultSetEqual(
10611065
statement.executeQuery("show create table view_table"),
10621066
"View,Create View,",
10631067
Collections.singleton(
1064-
"view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") RESTRICT WITH (ttl=100) AS root.\"重庆\".**,"));
1068+
"view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") RESTRICT WITH (ttl=100) AS root.\"重庆\".\"1\".**,"));
10651069

10661070
statement.execute("create table a ()");
10671071
try {

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public class ConfigNodeConfig {
7777
/** Data region consensus protocol. */
7878
private String dataRegionConsensusProtocolClass = ConsensusFactory.IOT_CONSENSUS;
7979

80+
/** IoTConsensusV2 replicate mode: "batch" or "stream". */
81+
private String iotConsensusV2Mode = "batch";
82+
8083
/** Default number of DataRegion replicas. */
8184
private int dataReplicationFactor = 1;
8285

@@ -530,6 +533,14 @@ public void setDataRegionConsensusProtocolClass(String dataRegionConsensusProtoc
530533
this.dataRegionConsensusProtocolClass = dataRegionConsensusProtocolClass;
531534
}
532535

536+
public String getIotConsensusV2Mode() {
537+
return iotConsensusV2Mode;
538+
}
539+
540+
public void setIotConsensusV2Mode(String iotConsensusV2Mode) {
541+
this.iotConsensusV2Mode = iotConsensusV2Mode;
542+
}
543+
533544
public int getDataRegionPerDataNode() {
534545
return dataRegionPerDataNode;
535546
}

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ private void loadProperties(TrimProperties properties) throws BadNodeUrlExceptio
205205
properties.getProperty(
206206
"data_region_consensus_protocol_class", conf.getDataRegionConsensusProtocolClass()));
207207

208+
conf.setIotConsensusV2Mode(
209+
properties.getProperty("iot_consensus_v2_mode", conf.getIotConsensusV2Mode()));
210+
208211
conf.setDataReplicationFactor(
209212
Integer.parseInt(
210213
properties.getProperty(

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ public enum ConfigPhysicalPlanType {
135135
CreateUserWithRawPassword((short) 638),
136136
UpdateUserMaxSession((short) 639),
137137
UpdateUserMinSession((short) 640),
138-
AccountUnlock((short) 641),
139138

140139
/** Table Author */
141140
RCreateUser((short) 641),

0 commit comments

Comments
 (0)