Skip to content

Commit efbd551

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

File tree

53 files changed

+470
-149
lines changed

Some content is hidden

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

53 files changed

+470
-149
lines changed

confignode/src/main/java/org/apache/iotdb/confignode/consensus/statemachine/PartitionRegionStateMachine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
2222
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2323
import org.apache.iotdb.commons.auth.AuthException;
24+
import org.apache.iotdb.commons.conf.CommonDescriptor;
2425
import org.apache.iotdb.commons.consensus.ConsensusGroupId;
2526
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
2627
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
@@ -31,7 +32,6 @@
3132
import org.apache.iotdb.consensus.common.DataSet;
3233
import org.apache.iotdb.consensus.common.request.ByteBufferConsensusRequest;
3334
import org.apache.iotdb.consensus.common.request.IConsensusRequest;
34-
import org.apache.iotdb.db.conf.IoTDBDescriptor;
3535
import org.apache.iotdb.rpc.TSStatusCode;
3636

3737
import org.slf4j.Logger;
@@ -167,6 +167,6 @@ public void stop() {
167167

168168
@Override
169169
public boolean isReadOnly() {
170-
return IoTDBDescriptor.getInstance().getConfig().isReadOnly();
170+
return CommonDescriptor.getInstance().getConfig().isReadOnly();
171171
}
172172
}

influxdb-protocol/src/main/java/org/apache/iotdb/influxdb/session/InfluxDBSession.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ public void init() throws IoTDBConnectionException {
128128
RpcTransportFactory.INSTANCE.getTransport(
129129
// as there is a try-catch already, we do not need to use TSocket.wrap
130130
defaultEndPoint.getIp(), defaultEndPoint.getPort(), connectionTimeoutInMs);
131-
transport.open();
131+
if (!transport.isOpen()) {
132+
transport.open();
133+
}
132134
} catch (TTransportException e) {
133135
throw new IoTDBConnectionException(e);
134136
}

integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ public void testShowPathsSetOrUsingSchemaTemplate() throws SQLException {
271271
statement.execute("SET SCHEMA TEMPLATE t1 TO root.sg2.d2");
272272
statement.execute("SET SCHEMA TEMPLATE t2 TO root.sg3.d1");
273273
statement.execute("SET SCHEMA TEMPLATE t2 TO root.sg3.d2");
274+
statement.execute("INSERT INTO root.sg3.d2.verify(time, show) VALUES (1, 1)");
275+
276+
try (ResultSet resultSet = statement.executeQuery("SHOW PATHS USING SCHEMA TEMPLATE t1")) {
277+
String resultRecord;
278+
while (resultSet.next()) {
279+
resultRecord = resultSet.getString(1);
280+
Assert.assertEquals("", resultRecord);
281+
}
282+
}
274283

275284
// activate schema template
276285
statement.execute("CREATE TIMESERIES OF SCHEMA TEMPLATE ON root.sg1.d2");

node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818
*/
1919
package org.apache.iotdb.commons.conf;
2020

21+
import org.apache.iotdb.commons.cluster.NodeStatus;
22+
import org.apache.iotdb.commons.enums.HandleSystemErrorStrategy;
2123
import org.apache.iotdb.tsfile.fileSystem.FSType;
2224

25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2328
import java.io.File;
2429
import java.util.concurrent.TimeUnit;
2530

2631
public class CommonConfig {
32+
private static final Logger logger = LoggerFactory.getLogger(CommonConfig.class);
2733

2834
// Open ID Secret
2935
private String openIdProviderUrl = "";
@@ -94,6 +100,13 @@ public class CommonConfig {
94100
/** whether to use thrift compression. */
95101
private boolean isRpcThriftCompressionEnabled = false;
96102

103+
/** What will the system do when unrecoverable error occurs. */
104+
private HandleSystemErrorStrategy handleSystemErrorStrategy =
105+
HandleSystemErrorStrategy.CHANGE_TO_READ_ONLY;
106+
107+
/** Status of current system. */
108+
private volatile NodeStatus status = NodeStatus.Running;
109+
97110
CommonConfig() {}
98111

99112
public void updatePath(String homeDir) {
@@ -233,4 +246,35 @@ public boolean isRpcThriftCompressionEnabled() {
233246
public void setRpcThriftCompressionEnabled(boolean rpcThriftCompressionEnabled) {
234247
isRpcThriftCompressionEnabled = rpcThriftCompressionEnabled;
235248
}
249+
250+
HandleSystemErrorStrategy getHandleSystemErrorStrategy() {
251+
return handleSystemErrorStrategy;
252+
}
253+
254+
void setHandleSystemErrorStrategy(HandleSystemErrorStrategy handleSystemErrorStrategy) {
255+
this.handleSystemErrorStrategy = handleSystemErrorStrategy;
256+
}
257+
258+
public boolean isReadOnly() {
259+
return status == NodeStatus.ReadOnly
260+
|| (status == NodeStatus.Error
261+
&& handleSystemErrorStrategy == HandleSystemErrorStrategy.CHANGE_TO_READ_ONLY);
262+
}
263+
264+
public NodeStatus getNodeStatus() {
265+
return status;
266+
}
267+
268+
public void setNodeStatus(NodeStatus newStatus) {
269+
if (newStatus == NodeStatus.ReadOnly) {
270+
logger.error(
271+
"Change system status to read-only! Only query statements are permitted!",
272+
new RuntimeException("System mode is set to READ_ONLY"));
273+
} else if (newStatus == NodeStatus.Error) {
274+
newStatus = handleSystemErrorStrategy.handle();
275+
} else {
276+
logger.info("Set system mode from {} to {}.", status, newStatus);
277+
}
278+
this.status = newStatus;
279+
}
236280
}

node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.apache.iotdb.commons.conf;
2121

22+
import org.apache.iotdb.commons.enums.HandleSystemErrorStrategy;
23+
2224
import org.slf4j.Logger;
2325
import org.slf4j.LoggerFactory;
2426

@@ -95,5 +97,10 @@ public void loadCommonProps(Properties properties) {
9597
properties.getProperty(
9698
"selector_thread_nums_of_client_manager",
9799
String.valueOf(config.getSelectorNumOfClientManager()))));
100+
101+
config.setHandleSystemErrorStrategy(
102+
HandleSystemErrorStrategy.valueOf(
103+
properties.getProperty(
104+
"handle_system_error", String.valueOf(config.getHandleSystemErrorStrategy()))));
98105
}
99106
}

server/src/main/java/org/apache/iotdb/db/utils/HandleSystemErrorStrategy.java renamed to node-commons/src/main/java/org/apache/iotdb/commons/enums/HandleSystemErrorStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.iotdb.db.utils;
19+
package org.apache.iotdb.commons.enums;
2020

2121
import org.apache.iotdb.commons.cluster.NodeStatus;
2222

server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ public void connect(TEndPoint endpoint) throws TException {
160160
RpcTransportFactory.INSTANCE.getTransport(
161161
// as there is a try-catch already, we do not need to use TSocket.wrap
162162
endpoint.getIp(), endpoint.getPort(), (int) connectionTimeout);
163-
transport.open();
163+
if (!transport.isOpen()) {
164+
transport.open();
165+
}
164166
configNode = endpoint;
165167
} catch (TTransportException e) {
166168
throw new TException(e);

server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.iotdb.db.conf;
2020

2121
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
22-
import org.apache.iotdb.commons.cluster.NodeStatus;
2322
import org.apache.iotdb.commons.conf.IoTDBConstant;
2423
import org.apache.iotdb.consensus.ConsensusFactory;
2524
import org.apache.iotdb.db.conf.directories.DirectoryManager;
@@ -35,7 +34,6 @@
3534
import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
3635
import org.apache.iotdb.db.service.thrift.impl.InfluxDBServiceImpl;
3736
import org.apache.iotdb.db.service.thrift.impl.TSServiceImpl;
38-
import org.apache.iotdb.db.utils.HandleSystemErrorStrategy;
3937
import org.apache.iotdb.db.wal.utils.WALMode;
4038
import org.apache.iotdb.rpc.RpcTransportFactory;
4139
import org.apache.iotdb.rpc.RpcUtils;
@@ -85,13 +83,6 @@ public class IoTDBConfig {
8583

8684
public static final Pattern NODE_PATTERN = Pattern.compile(NODE_MATCHER);
8785

88-
/** What will the system do when unrecoverable error occurs. */
89-
private HandleSystemErrorStrategy handleSystemErrorStrategy =
90-
HandleSystemErrorStrategy.CHANGE_TO_READ_ONLY;
91-
92-
/** Status of current system. */
93-
private volatile NodeStatus status = NodeStatus.Running;
94-
9586
/** whether to enable the mqtt service. */
9687
private boolean enableMQTTService = false;
9788

@@ -1557,37 +1548,6 @@ public void setSessionTimeoutThreshold(int sessionTimeoutThreshold) {
15571548
this.sessionTimeoutThreshold = sessionTimeoutThreshold;
15581549
}
15591550

1560-
public HandleSystemErrorStrategy getHandleSystemErrorStrategy() {
1561-
return handleSystemErrorStrategy;
1562-
}
1563-
1564-
public void setHandleSystemErrorStrategy(HandleSystemErrorStrategy handleSystemErrorStrategy) {
1565-
this.handleSystemErrorStrategy = handleSystemErrorStrategy;
1566-
}
1567-
1568-
public boolean isReadOnly() {
1569-
return status == NodeStatus.ReadOnly
1570-
|| (status == NodeStatus.Error
1571-
&& handleSystemErrorStrategy == HandleSystemErrorStrategy.CHANGE_TO_READ_ONLY);
1572-
}
1573-
1574-
public NodeStatus getNodeStatus() {
1575-
return status;
1576-
}
1577-
1578-
public void setNodeStatus(NodeStatus newStatus) {
1579-
if (newStatus == NodeStatus.ReadOnly) {
1580-
logger.error(
1581-
"Change system status to read-only! Only query statements are permitted!",
1582-
new RuntimeException("System mode is set to READ_ONLY"));
1583-
} else if (newStatus == NodeStatus.Error) {
1584-
newStatus = handleSystemErrorStrategy.handle();
1585-
} else {
1586-
logger.info("Set system mode from {} to {}.", status, newStatus);
1587-
}
1588-
this.status = newStatus;
1589-
}
1590-
15911551
public String getRpcImplClassName() {
15921552
return rpcImplClassName;
15931553
}

server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.apache.iotdb.db.exception.query.QueryProcessException;
3838
import org.apache.iotdb.db.qp.utils.DatetimeUtils;
3939
import org.apache.iotdb.db.service.metrics.MetricService;
40-
import org.apache.iotdb.db.utils.HandleSystemErrorStrategy;
4140
import org.apache.iotdb.db.wal.WALManager;
4241
import org.apache.iotdb.db.wal.utils.WALMode;
4342
import org.apache.iotdb.metrics.config.MetricConfigDescriptor;
@@ -717,11 +716,6 @@ public void loadProperties(Properties properties) {
717716
conf.setKerberosPrincipal(
718717
properties.getProperty("kerberos_principal", conf.getKerberosPrincipal()));
719718

720-
conf.setHandleSystemErrorStrategy(
721-
HandleSystemErrorStrategy.valueOf(
722-
properties.getProperty(
723-
"handle_system_error", String.valueOf(conf.getHandleSystemErrorStrategy()))));
724-
725719
// the num of memtables in each storage group
726720
conf.setConcurrentWritingTimePartition(
727721
Integer.parseInt(

server/src/main/java/org/apache/iotdb/db/conf/directories/DirectoryManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.iotdb.db.conf.directories;
2020

2121
import org.apache.iotdb.commons.cluster.NodeStatus;
22+
import org.apache.iotdb.commons.conf.CommonDescriptor;
2223
import org.apache.iotdb.commons.conf.IoTDBConstant;
2324
import org.apache.iotdb.commons.utils.TestOnly;
2425
import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -147,7 +148,7 @@ public String getNextFolderForSequenceFile() throws DiskSpaceInsufficientExcepti
147148
return sequenceFileFolders.get(sequenceStrategy.nextFolderIndex());
148149
} catch (DiskSpaceInsufficientException e) {
149150
logger.error("All disks of wal folders are full, change system mode to read-only.", e);
150-
IoTDBDescriptor.getInstance().getConfig().setNodeStatus(NodeStatus.ReadOnly);
151+
CommonDescriptor.getInstance().getConfig().setNodeStatus(NodeStatus.ReadOnly);
151152
throw e;
152153
}
153154
}
@@ -161,7 +162,7 @@ public String getNextFolderForUnSequenceFile() throws DiskSpaceInsufficientExcep
161162
return unsequenceFileFolders.get(unsequenceStrategy.nextFolderIndex());
162163
} catch (DiskSpaceInsufficientException e) {
163164
logger.error("All disks of wal folders are full, change system mode to read-only.", e);
164-
IoTDBDescriptor.getInstance().getConfig().setNodeStatus(NodeStatus.ReadOnly);
165+
CommonDescriptor.getInstance().getConfig().setNodeStatus(NodeStatus.ReadOnly);
165166
throw e;
166167
}
167168
}

0 commit comments

Comments
 (0)