Skip to content

Commit 4ef8fde

Browse files
committed
Merge branch 'master' of https://github.com/apache/iotdb into rel/0.14.0-preview2
2 parents efbd551 + ecaa0f2 commit 4ef8fde

File tree

139 files changed

+3658
-888
lines changed

Some content is hidden

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

139 files changed

+3658
-888
lines changed

RELEASE_NOTES.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ The 0.14.0-preview2 version only contains the new cluster version.
2929
* Support Between expression
3030
* Support order by timeseries in last query
3131
* Support hot configuration of data_dirs
32-
* Support set system mode to readonly, running and error
3332
* Support schema template
3433
* Support executeBatchStatement in JDBC
35-
* Support clear cache
3634
* Support new UDF 'change_points'
3735

3836
## Improvements

antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ keyWords
7575
| EVERY
7676
| EXPLAIN
7777
| FILL
78+
| FILE
7879
| FLUSH
7980
| FOR
8081
| FROM
@@ -169,6 +170,7 @@ keyWords
169170
| UNSET
170171
| UPDATE
171172
| UPSERT
173+
| URI
172174
| USER
173175
| USING
174176
| VALUES

antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ uri
126126

127127
// Create Trigger
128128
createTrigger
129-
: CREATE triggerType? TRIGGER triggerName=identifier triggerEventClause ON prefixPath AS className=STRING_LITERAL triggerAttributeClause?
129+
: CREATE triggerType? TRIGGER triggerName=identifier triggerEventClause ON prefixPath AS className=STRING_LITERAL jarLocation? triggerAttributeClause?
130130
;
131131

132132
triggerType
@@ -137,6 +137,10 @@ triggerEventClause
137137
: (BEFORE | AFTER) (INSERT | DELETE)
138138
;
139139

140+
jarLocation
141+
: USING ((FILE fileName=STRING_LITERAL) | URI uri)
142+
;
143+
140144
triggerAttributeClause
141145
: WITH LR_BRACKET triggerAttribute (COMMA triggerAttribute)* RR_BRACKET
142146
;

antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ FILL
215215
: F I L L
216216
;
217217

218+
FILE
219+
: F I L E
220+
;
221+
218222
FLUSH
219223
: F L U S H
220224
;
@@ -603,6 +607,10 @@ UPSERT
603607
: U P S E R T
604608
;
605609

610+
URI
611+
: U R I
612+
;
613+
606614
USER
607615
: U S E R
608616
;

confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/CreateRegionGroupsPlan.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ public void addRegionGroup(String storageGroup, TRegionReplicaSet regionReplicaS
6060
.add(regionReplicaSet);
6161
}
6262

63+
public void serializeForProcedure(DataOutputStream stream) throws IOException {
64+
this.serializeImpl(stream);
65+
}
66+
67+
public void deserializeForProcedure(ByteBuffer buffer) throws IOException {
68+
// to remove the ordinal of ConfigPhysicalPlanType
69+
buffer.getInt();
70+
this.deserializeImpl(buffer);
71+
}
72+
6373
@Override
6474
protected void serializeImpl(DataOutputStream stream) throws IOException {
6575
stream.writeInt(ConfigPhysicalPlanType.CreateRegionGroups.ordinal());

confignode/src/main/java/org/apache/iotdb/confignode/persistence/UDFInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
package org.apache.iotdb.confignode.persistence;
2121

2222
import org.apache.iotdb.common.rpc.thrift.TSStatus;
23+
import org.apache.iotdb.commons.executable.ExecutableResource;
2324
import org.apache.iotdb.commons.snapshot.SnapshotProcessor;
2425
import org.apache.iotdb.commons.udf.service.UDFClassLoader;
2526
import org.apache.iotdb.commons.udf.service.UDFExecutableManager;
26-
import org.apache.iotdb.commons.udf.service.UDFExecutableResource;
2727
import org.apache.iotdb.commons.udf.service.UDFRegistrationService;
2828
import org.apache.iotdb.confignode.conf.ConfigNodeConfig;
2929
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
@@ -78,7 +78,7 @@ private void fetchExecutablesAndCheckInstantiation(String className) throws Exce
7878

7979
private void fetchExecutablesAndCheckInstantiation(String className, List<String> uris)
8080
throws Exception {
81-
final UDFExecutableResource resource = udfExecutableManager.request(uris);
81+
final ExecutableResource resource = udfExecutableManager.request(uris);
8282
try (UDFClassLoader temporaryUdfClassLoader = new UDFClassLoader(resource.getResourceDir())) {
8383
Class.forName(className, true, temporaryUdfClassLoader)
8484
.getDeclaredConstructor()

confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/CreateRegionGroupsProcedure.java

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,50 @@
2020

2121
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
2222
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
23+
import org.apache.iotdb.commons.utils.ThriftCommonsSerDeUtils;
2324
import org.apache.iotdb.confignode.consensus.request.write.CreateRegionGroupsPlan;
2425
import org.apache.iotdb.confignode.consensus.request.write.DeleteRegionGroupsPlan;
2526
import org.apache.iotdb.confignode.procedure.StateMachineProcedure;
2627
import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv;
2728
import org.apache.iotdb.confignode.procedure.exception.ProcedureException;
2829
import org.apache.iotdb.confignode.procedure.state.CreateRegionGroupsState;
30+
import org.apache.iotdb.confignode.procedure.store.ProcedureFactory;
2931

32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
34+
35+
import java.io.DataOutputStream;
36+
import java.io.IOException;
37+
import java.nio.ByteBuffer;
38+
import java.util.HashMap;
3039
import java.util.Map;
40+
import java.util.Objects;
3141

3242
public class CreateRegionGroupsProcedure
3343
extends StateMachineProcedure<ConfigNodeProcedureEnv, CreateRegionGroupsState> {
3444

35-
private final CreateRegionGroupsPlan createRegionGroupsPlan;
36-
// Map<TConsensusGroupId, Failed RegionReplicas>
37-
private Map<TConsensusGroupId, TRegionReplicaSet> failedRegions;
45+
private static final Logger LOGGER = LoggerFactory.getLogger(CreateRegionGroupsProcedure.class);
46+
47+
private CreateRegionGroupsPlan createRegionGroupsPlan = new CreateRegionGroupsPlan();
48+
49+
/** key: TConsensusGroupId value: Failed RegionReplicas */
50+
private Map<TConsensusGroupId, TRegionReplicaSet> failedRegions = new HashMap<>();
51+
52+
public CreateRegionGroupsProcedure() {
53+
super();
54+
}
3855

3956
public CreateRegionGroupsProcedure(CreateRegionGroupsPlan createRegionGroupsPlan) {
4057
this.createRegionGroupsPlan = createRegionGroupsPlan;
4158
}
4259

60+
public CreateRegionGroupsProcedure(
61+
CreateRegionGroupsPlan createRegionGroupsPlan,
62+
Map<TConsensusGroupId, TRegionReplicaSet> failedRegions) {
63+
this.createRegionGroupsPlan = createRegionGroupsPlan;
64+
this.failedRegions = failedRegions;
65+
}
66+
4367
@Override
4468
protected Flow executeFromState(ConfigNodeProcedureEnv env, CreateRegionGroupsState state) {
4569
switch (state) {
@@ -130,6 +154,59 @@ protected int getStateId(CreateRegionGroupsState createRegionGroupsState) {
130154

131155
@Override
132156
protected CreateRegionGroupsState getInitialState() {
133-
return CreateRegionGroupsState.CREATE_REGION_GROUPS;
157+
return CreateRegionGroupsState.CREATE_REGION_GROUPS_PREPARE;
158+
}
159+
160+
@Override
161+
public void serialize(DataOutputStream stream) throws IOException {
162+
// must serialize CREATE_REGION_GROUPS.ordinal() firstly
163+
stream.writeInt(ProcedureFactory.ProcedureType.CREATE_REGION_GROUPS.ordinal());
164+
super.serialize(stream);
165+
createRegionGroupsPlan.serializeForProcedure(stream);
166+
stream.writeInt(failedRegions.size());
167+
failedRegions.forEach(
168+
(groupId, replica) -> {
169+
ThriftCommonsSerDeUtils.serializeTConsensusGroupId(groupId, stream);
170+
ThriftCommonsSerDeUtils.serializeTRegionReplicaSet(replica, stream);
171+
});
172+
}
173+
174+
@Override
175+
public void deserialize(ByteBuffer byteBuffer) {
176+
super.deserialize(byteBuffer);
177+
try {
178+
createRegionGroupsPlan.deserializeForProcedure(byteBuffer);
179+
failedRegions.clear();
180+
int failedRegionsSize = byteBuffer.getInt();
181+
while (failedRegionsSize-- > 0) {
182+
TConsensusGroupId groupId =
183+
ThriftCommonsSerDeUtils.deserializeTConsensusGroupId(byteBuffer);
184+
TRegionReplicaSet replica =
185+
ThriftCommonsSerDeUtils.deserializeTRegionReplicaSet(byteBuffer);
186+
failedRegions.put(groupId, replica);
187+
}
188+
} catch (Exception e) {
189+
LOGGER.error("Deserialize meets error in CreateRegionGroupsProcedure", e);
190+
throw new RuntimeException(e);
191+
}
192+
}
193+
194+
@Override
195+
public boolean equals(Object that) {
196+
if (that instanceof CreateRegionGroupsProcedure) {
197+
CreateRegionGroupsProcedure thatProc = (CreateRegionGroupsProcedure) that;
198+
return thatProc.getProcId() == this.getProcId()
199+
&& thatProc.getState() == this.getState()
200+
&& thatProc.createRegionGroupsPlan.equals(this.createRegionGroupsPlan)
201+
&& thatProc.failedRegions.equals(this.failedRegions);
202+
}
203+
return false;
204+
}
205+
206+
@Override
207+
public int hashCode() {
208+
int result = createRegionGroupsPlan.hashCode();
209+
result = 31 * result + Objects.hash(failedRegions);
210+
return result;
134211
}
135212
}

confignode/src/main/java/org/apache/iotdb/confignode/procedure/state/RemoveConfigNodeState.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
package org.apache.iotdb.confignode.procedure.state;
2121

2222
public enum RemoveConfigNodeState {
23-
REMOVE_CONSENSUS_GROUP,
2423
REMOVE_PEER,
25-
24+
REMOVE_CONSENSUS_GROUP,
2625
STOP_CONFIG_NODE
2726
}

confignode/src/main/java/org/apache/iotdb/confignode/procedure/store/ProcedureFactory.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,21 @@
2727
import org.apache.iotdb.confignode.procedure.impl.RemoveConfigNodeProcedure;
2828
import org.apache.iotdb.confignode.procedure.impl.RemoveDataNodeProcedure;
2929

30+
import org.slf4j.Logger;
31+
import org.slf4j.LoggerFactory;
32+
3033
import java.io.IOException;
3134
import java.nio.ByteBuffer;
3235

3336
public class ProcedureFactory implements IProcedureFactory {
3437

38+
private static final Logger LOGGER = LoggerFactory.getLogger(ProcedureFactory.class);
39+
3540
@Override
3641
public Procedure create(ByteBuffer buffer) throws IOException {
3742
int typeNum = buffer.getInt();
3843
if (typeNum >= ProcedureType.values().length) {
44+
LOGGER.error("unrecognized log type " + typeNum);
3945
throw new IOException("unrecognized log type " + typeNum);
4046
}
4147
ProcedureType type = ProcedureType.values()[typeNum];
@@ -56,7 +62,11 @@ public Procedure create(ByteBuffer buffer) throws IOException {
5662
case REGION_MIGRATE_PROCEDURE:
5763
procedure = new RegionMigrateProcedure();
5864
break;
65+
case CREATE_REGION_GROUPS:
66+
procedure = new CreateRegionGroupsProcedure();
67+
break;
5968
default:
69+
LOGGER.error("unknown Procedure type: " + typeNum);
6070
throw new IOException("unknown Procedure type: " + typeNum);
6171
}
6272
procedure.deserialize(buffer);

confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void initThriftServiceThread() throws IllegalAccessException {
7272
new ThriftServiceThread(
7373
processor,
7474
getID().getName(),
75-
ThreadName.CONFIG_NODE_RPC_CLIENT.getName(),
75+
ThreadName.CONFIGNODE_RPC_PROCESSOR.getName(),
7676
getBindIP(),
7777
getBindPort(),
7878
configConf.getRpcMaxConcurrentClientNum(),
@@ -82,15 +82,15 @@ public void initThriftServiceThread() throws IllegalAccessException {
8282
} catch (RPCServiceException e) {
8383
throw new IllegalAccessException(e.getMessage());
8484
}
85-
thriftServiceThread.setName(ThreadName.CONFIG_NODE_RPC_SERVER.getName());
85+
thriftServiceThread.setName(ThreadName.CONFIGNODE_RPC_SERVICE.getName());
8686
MetricService.getInstance()
8787
.getOrCreateAutoGauge(
8888
Metric.THRIFT_ACTIVE_THREADS.toString(),
8989
MetricLevel.CORE,
9090
thriftServiceThread,
9191
AbstractThriftServiceThread::getActiveThreadCount,
9292
Tag.NAME.toString(),
93-
ThreadName.CONFIG_NODE_RPC_SERVER.getName());
93+
ThreadName.CONFIGNODE_RPC_SERVICE.getName());
9494
}
9595

9696
@Override

0 commit comments

Comments
 (0)