You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/11/20 07:00:11 UTC
[iotdb] branch master updated: Remove trigger of old standalone version
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 748b8835f1 Remove trigger of old standalone version
748b8835f1 is described below
commit 748b8835f1e8361e944beffbadb9e701ab640bcd
Author: Liao Lanyu <14...@qq.com>
AuthorDate: Sun Nov 20 15:00:05 2022 +0800
Remove trigger of old standalone version
---
integration-test/import-control.xml | 2 -
.../iotdb/session/it/IoTDBSessionComplexIT.java | 57 --
.../db/integration/IoTDBTriggerExecutionIT.java | 678 ---------------------
.../db/integration/IoTDBTriggerForwardIT.java | 305 ---------
.../db/integration/IoTDBTriggerManagementIT.java | 539 ----------------
.../schemaregion/rocksdb/mnode/RMNode.java | 20 -
.../rocksdb/mnode/RMeasurementMNode.java | 11 -
.../statemachine/visitor/DataExecutionVisitor.java | 7 +-
.../iotdb/db/engine/storagegroup/DataRegion.java | 12 +-
.../db/engine/trigger/builtin/ForwardTrigger.java | 2 +-
.../db/engine/trigger/executor/TriggerEngine.java | 64 --
.../db/engine/trigger/executor/TriggerEvent.java | 53 --
.../engine/trigger/executor/TriggerExecutor.java | 250 --------
.../trigger/service/TriggerClassLoaderManager.java | 95 ---
.../engine/trigger/service/TriggerLogReader.java | 48 --
.../engine/trigger/service/TriggerLogWriter.java | 68 ---
.../service/TriggerRegistrationInformation.java | 82 ---
.../service/TriggerRegistrationService.java | 505 ---------------
.../db/exception/TriggerExecutionException.java | 32 -
.../db/exception/TriggerManagementException.java | 32 -
.../idtable/entry/InsertMeasurementMNode.java | 37 --
.../org/apache/iotdb/db/metadata/mnode/IMNode.java | 8 -
.../iotdb/db/metadata/mnode/IMeasurementMNode.java | 5 -
.../org/apache/iotdb/db/metadata/mnode/MNode.java | 29 -
.../iotdb/db/metadata/mnode/MeasurementMNode.java | 11 -
.../schemaregion/SchemaRegionMemoryImpl.java | 6 -
.../schemaregion/SchemaRegionSchemaFileImpl.java | 6 -
.../apache/iotdb/db/qp/executor/PlanExecutor.java | 7 -
.../db/qp/logical/sys/CreateTriggerOperator.java | 92 ---
.../db/qp/logical/sys/DropTriggerOperator.java | 50 --
.../db/qp/logical/sys/StartTriggerOperator.java | 50 --
.../db/qp/logical/sys/StopTriggerOperator.java | 50 --
.../apache/iotdb/db/qp/physical/PhysicalPlan.java | 16 -
.../db/qp/physical/sys/CreateTriggerPlan.java | 166 -----
.../iotdb/db/qp/physical/sys/DropTriggerPlan.java | 102 ----
.../iotdb/db/qp/physical/sys/StartTriggerPlan.java | 102 ----
.../iotdb/db/qp/physical/sys/StopTriggerPlan.java | 102 ----
.../apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java | 60 --
.../java/org/apache/iotdb/db/service/DataNode.java | 2 -
.../java/org/apache/iotdb/db/service/IoTDB.java | 2 -
.../java/org/apache/iotdb/db/service/NewIoTDB.java | 2 -
.../db/engine/storagegroup/DataRegionTest.java | 49 +-
.../iotdb/db/engine/storagegroup/TTLTest.java | 10 +-
.../apache/iotdb/db/utils/EnvironmentUtils.java | 7 +-
44 files changed, 31 insertions(+), 3802 deletions(-)
diff --git a/integration-test/import-control.xml b/integration-test/import-control.xml
index 97cc327898..9e7bee380d 100644
--- a/integration-test/import-control.xml
+++ b/integration-test/import-control.xml
@@ -85,8 +85,6 @@
<allow class="org.apache.iotdb.commons.conf.IoTDBConstant" />
<allow class="org.apache.iotdb.db.conf.IoTDBDescriptor" />
<allow class="org.apache.iotdb.db.conf.OperationType" />
- <allow class="org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService" />
- <allow class="org.apache.iotdb.db.exception.TriggerManagementException" />
<allow class="org.apache.iotdb.db.utils.EnvironmentUtils" />
<allow class="org.apache.iotdb.tsfile.common.constant.TsFileConstant" />
<allow class="org.apache.iotdb.service.rpc.thrift.TSConnectionInfoResp" />
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionComplexIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionComplexIT.java
index 0fb1a8e2d2..38e8b97dad 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionComplexIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionComplexIT.java
@@ -20,9 +20,6 @@ package org.apache.iotdb.session.it;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.metadata.idtable.trigger_example.Counter;
import org.apache.iotdb.it.env.DataNodeWrapper;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
@@ -41,7 +38,6 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
@@ -440,59 +436,6 @@ public class IoTDBSessionComplexIT {
}
}
- @Ignore
- @Test
- public void insertTabletWithTriggersTest() {
- try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
- session.setStorageGroup("root.sg1");
- createTimeseries(session);
-
- session.executeNonQueryStatement(
- "create trigger d1s1 after insert on root.sg1.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- session.executeNonQueryStatement(
- "create trigger d1s2 before insert on root.sg1.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- assertEquals(
- Counter.BASE,
- ((Counter) TriggerRegistrationService.getInstance().getTriggerInstance("d1s1"))
- .getCounter());
- assertEquals(
- Counter.BASE,
- ((Counter) TriggerRegistrationService.getInstance().getTriggerInstance("d1s2"))
- .getCounter());
- try {
- int counter =
- ((Counter) TriggerRegistrationService.getInstance().getTriggerInstance("d1s3"))
- .getCounter();
- fail(String.valueOf(counter - Counter.BASE));
- } catch (TriggerManagementException e) {
- assertEquals("Trigger d1s3 does not exist.", e.getMessage());
- }
-
- insertTablet(session, "root.sg1.d1");
-
- assertEquals(
- Counter.BASE + 200,
- ((Counter) TriggerRegistrationService.getInstance().getTriggerInstance("d1s1"))
- .getCounter());
- assertEquals(
- Counter.BASE + 200,
- ((Counter) TriggerRegistrationService.getInstance().getTriggerInstance("d1s2"))
- .getCounter());
- try {
- int counter =
- ((Counter) TriggerRegistrationService.getInstance().getTriggerInstance("d1s3"))
- .getCounter();
- fail(String.valueOf(counter - Counter.BASE));
- } catch (TriggerManagementException e) {
- assertEquals("Trigger d1s3 does not exist.", e.getMessage());
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
@Test
@Category({ClusterIT.class})
public void sessionClusterTest() {
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
deleted file mode 100644
index 9016dbcde6..0000000000
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
+++ /dev/null
@@ -1,678 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.integration;
-
-import org.apache.iotdb.commons.exception.MetadataException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.example.Counter;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Arrays;
-import java.util.Collections;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-@SuppressWarnings("squid:S2925") // enable to use Thread.sleep(long) without warnings
-@Category({LocalStandaloneTest.class})
-public class IoTDBTriggerExecutionIT {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBTriggerExecutionIT.class);
-
- private volatile long count = 0;
- private volatile Exception exception = null;
-
- private final Thread dataGenerator =
- new Thread() {
-
- @Override
- public void run() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- do {
- ++count;
- statement.execute(
- String.format(
- "insert into root.vehicle.a.b.c.d1(timestamp,s1,s2,s3,s4,s5,s6) values(%d,%d,%d,%d,%d,%s,'%d')",
- count, count, count, count, count, count % 2 == 0 ? "true" : "false", count));
- } while (!isInterrupted());
- } catch (Exception e) {
- exception = e;
- }
- }
- };
-
- private void startDataGenerator() {
- dataGenerator.start();
- }
-
- private void stopDataGenerator() throws InterruptedException {
- if (!dataGenerator.isInterrupted()) {
- dataGenerator.interrupt();
- }
- dataGenerator.join();
- }
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- createTimeseries();
- Class.forName(Config.JDBC_DRIVER_NAME);
- }
-
- private void createTimeseries() throws MetadataException {
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s1"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s2"),
- TSDataType.INT64,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s3"),
- TSDataType.FLOAT,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s4"),
- TSDataType.DOUBLE,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s5"),
- TSDataType.BOOLEAN,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s6"),
- TSDataType.TEXT,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- }
-
- private void waitCountIncreaseBy(final long increment) throws InterruptedException {
- final long previous = count;
- while (count - previous < increment) {
- Thread.sleep(100);
- }
- }
-
- @Test
- public void checkFireTimes() throws InterruptedException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_4 after insert on root.vehicle.a.b.c.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_5 before insert on root.vehicle.a.b.c.d1.s5 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_6 after insert on root.vehicle.a.b.c.d1.s6 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- int[] counters1 = getCounters(6);
- LOGGER.info(Arrays.toString(counters1));
- for (int i = 1; i < 6; ++i) {
- assertEquals(Counter.BASE, counters1[i]);
- }
-
- startDataGenerator();
- waitCountIncreaseBy(500);
- stopDataGenerator();
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- int[] counters2 = getCounters(6);
- LOGGER.info(Arrays.toString(counters2));
- int expectedTimes = counters2[0] - counters1[0];
- for (int i = 1; i < 6; ++i) {
- assertEquals(expectedTimes, counters2[i] - counters1[i]);
- }
- } catch (SQLException | TriggerManagementException | InterruptedException e) {
- fail(e.getMessage());
- } finally {
- stopDataGenerator();
- }
- }
-
- @Test
- public void testCreateTriggersMultipleTimesWhileInserting() throws InterruptedException {
- startDataGenerator();
-
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- waitCountIncreaseBy(500);
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- waitCountIncreaseBy(500);
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- int[] counters1 = getCounters(3);
- for (int i = 0; i < 3; ++i) {
- assertTrue(Counter.BASE < counters1[i]);
- }
-
- waitCountIncreaseBy(500);
-
- statement.execute(
- "create trigger trigger_4 after insert on root.vehicle.a.b.c.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_5 before insert on root.vehicle.a.b.c.d1.s5 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_6 after insert on root.vehicle.a.b.c.d1.s6 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- int[] counters2 = getCounters(3);
- LOGGER.info(Arrays.toString(counters2));
- for (int i = 0; i < 3; ++i) {
- assertTrue(counters1[i] < counters2[i]);
- }
- } catch (SQLException | TriggerManagementException e) {
- fail(e.getMessage());
- } finally {
- stopDataGenerator();
- }
- }
-
- @Test
- public void testCreateAndDropTriggersMultipleTimesWhileInserting() throws InterruptedException {
- startDataGenerator();
-
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- waitCountIncreaseBy(500);
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- waitCountIncreaseBy(500);
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- int[] counters1 = getCounters(3);
- LOGGER.info(Arrays.toString(counters1));
- for (int i = 0; i < 3; ++i) {
- assertTrue(Counter.BASE < counters1[i]);
- }
-
- waitCountIncreaseBy(100);
- statement.execute("drop trigger trigger_1");
- statement.execute("drop trigger trigger_2");
- statement.execute("drop trigger trigger_3");
- waitCountIncreaseBy(100);
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- waitCountIncreaseBy(100);
- statement.execute("drop trigger trigger_1");
- statement.execute("drop trigger trigger_2");
- statement.execute("drop trigger trigger_3");
- waitCountIncreaseBy(100);
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- waitCountIncreaseBy(500);
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- int[] counters2 = getCounters(3);
- LOGGER.info(Arrays.toString(counters2));
- for (int i = 0; i < 3; ++i) {
- assertTrue(Counter.BASE < counters1[i]);
- }
- } catch (SQLException | TriggerManagementException e) {
- fail(e.getMessage());
- } finally {
- stopDataGenerator();
- }
- }
-
- @Test
- public void testStopAndStartTriggersWhileInserting() throws InterruptedException {
- startDataGenerator();
-
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- waitCountIncreaseBy(500);
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_4 after insert on root.vehicle.a.b.c.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_5 before insert on root.vehicle.a.b.c.d1.s5 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_6 after insert on root.vehicle.a.b.c.d1.s6 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- waitCountIncreaseBy(500);
-
- statement.execute("stop trigger trigger_1");
- statement.execute("stop trigger trigger_2");
- statement.execute("stop trigger trigger_3");
-
- int[] counters1 = getCounters(6);
- LOGGER.info(Arrays.toString(counters1));
-
- waitCountIncreaseBy(500);
-
- statement.execute("stop trigger trigger_4");
- statement.execute("stop trigger trigger_5");
- statement.execute("stop trigger trigger_6");
-
- int[] counters2 = getCounters(6);
- LOGGER.info(Arrays.toString(counters2));
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- for (int i = 0; i < 3; ++i) {
- assertEquals(counters1[i], counters2[i]);
- }
- for (int i = 3; i < 6; ++i) {
- assertTrue(counters1[i] < counters2[i]);
- }
-
- statement.execute("start trigger trigger_1");
- statement.execute("start trigger trigger_2");
- statement.execute("start trigger trigger_3");
-
- waitCountIncreaseBy(500);
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- int[] counters3 = getCounters(6);
- LOGGER.info(Arrays.toString(counters3));
- for (int i = 0; i < 3; ++i) {
- assertTrue(counters2[i] < counters3[i]);
- }
- for (int i = 3; i < 6; ++i) {
- assertEquals(counters2[i], counters3[i]);
- }
-
- statement.execute("start trigger trigger_4");
- statement.execute("start trigger trigger_5");
- statement.execute("start trigger trigger_6");
-
- waitCountIncreaseBy(500);
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- int[] counters4 = getCounters(6);
- LOGGER.info(Arrays.toString(counters4));
- for (int i = 0; i < 6; ++i) {
- assertTrue(counters3[i] < counters4[i]);
- }
-
- statement.execute("stop trigger trigger_1");
- statement.execute("stop trigger trigger_2");
- statement.execute("stop trigger trigger_3");
- statement.execute("stop trigger trigger_4");
- statement.execute("stop trigger trigger_5");
- statement.execute("stop trigger trigger_6");
-
- waitCountIncreaseBy(500);
- int[] counters5 = getCounters(6);
- waitCountIncreaseBy(500);
- int[] counters6 = getCounters(6);
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- assertEquals(Arrays.toString(counters5), Arrays.toString(counters6));
- } catch (SQLException | TriggerManagementException e) {
- fail(e.getMessage());
- } finally {
- stopDataGenerator();
- }
- }
-
- private static int[] getCounters(int limit) throws TriggerManagementException {
- int[] counters = new int[limit];
- for (int i = 1; i <= limit; ++i) {
- counters[i - 1] =
- ((Counter) TriggerRegistrationService.getInstance().getTriggerInstance("trigger_" + i))
- .getCounter();
- }
- return counters;
- }
-
- @Test
- public void testInsertAndRemoveTimeseriesWithTriggers() throws InterruptedException {
- startDataGenerator();
-
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- waitCountIncreaseBy(500);
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_4 after insert on root.vehicle.a.b.c.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_5 before insert on root.vehicle.a.b.c.d1.s5 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_6 after insert on root.vehicle.a.b.c.d1.s6 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- waitCountIncreaseBy(500);
-
- // IOTDB-1825: if the background data generator's connection is closed, the following checks
- // will be meaningless, in which case we ignore the checks
- if (exception != null) {
- return;
- }
- int[] counters1 = getCounters(6);
- LOGGER.info(Arrays.toString(counters1));
- for (int i = 0; i < 6; ++i) {
- assertTrue(Counter.BASE < counters1[i]);
- }
-
- stopDataGenerator();
-
- IoTDB.schemaProcessor.deleteTimeseries(new PartialPath("root.vehicle.a.b.c.d1.s1"));
- IoTDB.schemaProcessor.deleteTimeseries(new PartialPath("root.vehicle.a.b.c.d1.s2"));
- IoTDB.schemaProcessor.deleteTimeseries(new PartialPath("root.vehicle.a.b.c.d1.s3"));
- IoTDB.schemaProcessor.deleteTimeseries(new PartialPath("root.vehicle.a.b.c.d1.s4"));
- IoTDB.schemaProcessor.deleteTimeseries(new PartialPath("root.vehicle.a.b.c.d1.s5"));
- IoTDB.schemaProcessor.deleteTimeseries(new PartialPath("root.vehicle.a.b.c.d1.s6"));
-
- for (int i = 0; i < 6; ++i) {
- try {
- TriggerRegistrationService.getInstance().getTriggerInstance("trigger_" + i);
- fail();
- } catch (TriggerManagementException e) {
- assertTrue(e.getMessage().contains("does not exist"));
- }
- }
-
- createTimeseries();
-
- for (int i = 0; i < 6; ++i) {
- try {
- TriggerRegistrationService.getInstance().getTriggerInstance("trigger_" + i);
- fail();
- } catch (TriggerManagementException e) {
- assertTrue(e.getMessage().contains("does not exist"));
- }
- }
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_4 after insert on root.vehicle.a.b.c.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_5 before insert on root.vehicle.a.b.c.d1.s5 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_6 after insert on root.vehicle.a.b.c.d1.s6 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- Thread.sleep(500);
-
- int[] counters2 = getCounters(6);
- LOGGER.info(Arrays.toString(counters2));
- for (int i = 0; i < 6; ++i) {
- assertEquals(Counter.BASE, counters2[2]);
- }
- } catch (SQLException | TriggerManagementException | MetadataException e) {
- fail(e.getMessage());
- } finally {
- stopDataGenerator();
- }
- }
-
- @Test
- public void testInsertAndRemoveStorageGroupWithTriggers() throws InterruptedException {
- startDataGenerator();
-
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_4 after insert on root.vehicle.a.b.c.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_5 before insert on root.vehicle.a.b.c.d1.s5 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_6 after insert on root.vehicle.a.b.c.d1.s6 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- waitCountIncreaseBy(500);
-
- stopDataGenerator();
-
- IoTDB.schemaProcessor.deleteStorageGroups(
- Collections.singletonList(new PartialPath("root.vehicle")));
-
- for (int i = 0; i < 6; ++i) {
- try {
- TriggerRegistrationService.getInstance().getTriggerInstance("trigger_" + i);
- fail();
- } catch (TriggerManagementException e) {
- assertTrue(e.getMessage().contains("does not exist"));
- }
- }
-
- createTimeseries();
-
- for (int i = 0; i < 6; ++i) {
- try {
- TriggerRegistrationService.getInstance().getTriggerInstance("trigger_" + i);
- fail();
- } catch (TriggerManagementException e) {
- assertTrue(e.getMessage().contains("does not exist"));
- }
- }
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_4 after insert on root.vehicle.a.b.c.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_5 before insert on root.vehicle.a.b.c.d1.s5 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_6 after insert on root.vehicle.a.b.c.d1.s6 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- Thread.sleep(500);
-
- int[] counters1 = getCounters(6);
- LOGGER.info(Arrays.toString(counters1));
- for (int i = 0; i < 6; ++i) {
- assertEquals(Counter.BASE, counters1[2]);
- }
- } catch (SQLException | TriggerManagementException | MetadataException e) {
- fail(e.getMessage());
- } finally {
- stopDataGenerator();
- }
- }
-
- @Test
- public void testCreateMultipleLevelTriggersMultipleTimesWhileInserting()
- throws InterruptedException {
-
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.a.b.c.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 before insert on root.vehicle.a.b.c.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.a.b.c.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_4 before insert on root.vehicle.a.b.c.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_5 before insert on root.vehicle.a.b.c.d1.s5 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_6 before insert on root.vehicle.a.b.c.d1.s6 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- statement.execute(
- "create trigger trigger_7 before insert on root.vehicle.a.b.c.d1 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_8 before insert on root.vehicle.a.b.c as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_9 after insert on root.vehicle.a.b as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_10 before insert on root.vehicle.a as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_11 after insert on root.vehicle as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- startDataGenerator();
- waitCountIncreaseBy(500);
- stopDataGenerator();
- int[] counters = getCounters(11);
- assertEquals(counters[0], counters[1]);
- assertEquals(counters[3], counters[4]);
- int sumCount =
- counters[0]
- + counters[1]
- + counters[2]
- + counters[3]
- + counters[4]
- + counters[5]
- - 6 * Counter.BASE;
- assertEquals(sumCount, (counters[6] - Counter.BASE));
- assertEquals(sumCount, (counters[7] - Counter.BASE));
- assertEquals(sumCount, (counters[8] - Counter.BASE));
- assertEquals(sumCount, (counters[9] - Counter.BASE));
- assertEquals(sumCount, (counters[10] - Counter.BASE));
- LOGGER.info(Arrays.toString(counters));
-
- } catch (SQLException | TriggerManagementException e) {
- fail(e.getMessage());
- } finally {
- stopDataGenerator();
- }
- }
-}
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerForwardIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerForwardIT.java
deleted file mode 100644
index 3473752a66..0000000000
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerForwardIT.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.integration;
-
-import org.apache.iotdb.commons.exception.MetadataException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.sink.forward.ForwardEvent;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import com.google.common.collect.Lists;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.sun.net.httpserver.HttpServer;
-import io.moquette.BrokerConstants;
-import io.moquette.broker.Server;
-import io.moquette.broker.config.IConfig;
-import io.moquette.broker.config.MemoryConfig;
-import io.moquette.interception.AbstractInterceptHandler;
-import io.moquette.interception.InterceptHandler;
-import io.moquette.interception.messages.InterceptPublishMessage;
-import org.apache.http.HttpStatus;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetSocketAddress;
-import java.nio.charset.StandardCharsets;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.fail;
-
-public class IoTDBTriggerForwardIT {
- private volatile long count = 0;
- private volatile Exception exception = null;
-
- private HttpServer httpServer;
- private Server mqttServer;
-
- private final Gson gson = new Gson();
- private final AtomicLong resultCount = new AtomicLong(0);
-
- private final Thread dataGenerator =
- new Thread() {
- @Override
- public void run() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- do {
- ++count;
- statement.execute(
- String.format(
- "insert into root.vehicle.a.b.c.d1(timestamp,s1,s2,s3,s4,s5,s6) values(%d,%d,%d,%d,%d,%s,'%d')",
- count, count, count, count, count, count % 2 == 0 ? "true" : "false", count));
- } while (!isInterrupted());
- } catch (Exception e) {
- exception = e;
- }
- }
- };
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- createTimeseries();
- Class.forName(Config.JDBC_DRIVER_NAME);
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void testForwardHTTPTrigger() throws InterruptedException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- startHTTPService();
- statement.execute(
- "create trigger trigger_forward_http_before before insert on root.vehicle.a.b.c.d1.s1 "
- + "as 'org.apache.iotdb.db.engine.trigger.builtin.ForwardTrigger' "
- + "with ('protocol' = 'http', 'endpoint' = 'http://127.0.0.1:8080/')");
- statement.execute(
- "create trigger trigger_forward_http_after after insert on root.vehicle.a.b.c.d1.s2 "
- + "as 'org.apache.iotdb.db.engine.trigger.builtin.ForwardTrigger' "
- + "with ('protocol' = 'http', 'endpoint' = 'http://127.0.0.1:8080/')");
- startDataGenerator();
- waitCountIncreaseBy(500);
- stopDataGenerator();
- // ensure no exception occurs when inserting data
- if (exception != null) {
- fail(exception.getMessage());
- }
-
- await().atMost(1, TimeUnit.MINUTES).until(() -> 2 * count == resultCount.get());
- if (exception != null) {
- fail(exception.getMessage());
- }
- } catch (Exception e) {
- fail(e.getMessage());
- } finally {
- if (httpServer != null) {
- httpServer.stop(0);
- }
- stopDataGenerator();
- }
- }
-
- @Test
- public void testForwardMQTTTrigger() throws InterruptedException {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- startMQTTService();
- statement.execute(
- "create trigger trigger_forward_mqtt_before before insert on root.vehicle.a.b.c.d1.s3 "
- + "as 'org.apache.iotdb.db.engine.trigger.builtin.ForwardTrigger' "
- + "with ('protocol' = 'mqtt', 'host' = '127.0.0.1', 'port' = '1884',"
- + " 'username' = 'root', 'password' = 'root', 'topic' = 'mqtt-test')");
- statement.execute(
- "create trigger trigger_forward_mqtt_after after insert on root.vehicle.a.b.c.d1.s4 "
- + "as 'org.apache.iotdb.db.engine.trigger.builtin.ForwardTrigger' "
- + "with ('protocol' = 'mqtt', 'host' = '127.0.0.1', 'port' = '1884',"
- + " 'username' = 'root', 'password' = 'root', 'topic' = 'mqtt-test')");
- startDataGenerator();
- waitCountIncreaseBy(500);
- stopDataGenerator();
- // ensure no exception occurs when inserting data
- if (exception != null) {
- fail(exception.getMessage());
- }
-
- await().atMost(1, TimeUnit.MINUTES).until(() -> 2 * count == resultCount.get());
- if (exception != null) {
- fail(exception.getMessage());
- }
- } catch (SQLException | InterruptedException | IOException e) {
- fail(e.getMessage());
- } finally {
- stopDataGenerator();
- if (mqttServer != null) {
- mqttServer.stopServer();
- }
- }
- }
-
- private void createTimeseries() throws MetadataException {
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s1"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s2"),
- TSDataType.INT64,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s3"),
- TSDataType.FLOAT,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s4"),
- TSDataType.DOUBLE,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s5"),
- TSDataType.BOOLEAN,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.a.b.c.d1.s6"),
- TSDataType.TEXT,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- }
-
- private void startDataGenerator() {
- dataGenerator.start();
- }
-
- private void stopDataGenerator() throws InterruptedException {
- if (!dataGenerator.isInterrupted()) {
- dataGenerator.interrupt();
- }
- dataGenerator.join();
- }
-
- private void waitCountIncreaseBy(final long increment) throws InterruptedException {
- final long previous = count;
- while (count - previous < increment) {
- Thread.sleep(100);
- }
- }
-
- private void startHTTPService() throws IOException {
- httpServer = HttpServer.create(new InetSocketAddress(8080), 0);
- httpServer.createContext(
- "/",
- exchange -> {
- String entity = "";
- try {
- InputStream in = exchange.getRequestBody();
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] b = new byte[1024 * 8];
- int len;
- while ((len = in.read(b)) != -1) {
- out.write(b, 0, len);
- }
- entity = out.toString();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- if (!checkPayload(entity)) {
- exception = new IOException("HTTP forward payload error");
- }
- JsonArray receiveData = gson.fromJson(entity, JsonArray.class);
- resultCount.addAndGet(receiveData.size());
-
- exchange.sendResponseHeaders(HttpStatus.SC_OK, -1);
- });
- httpServer.start();
- }
-
- private void startMQTTService() throws IOException {
- Properties properties = new Properties();
- properties.setProperty(BrokerConstants.HOST_PROPERTY_NAME, "0.0.0.0");
- properties.setProperty(BrokerConstants.PORT_PROPERTY_NAME, "1884");
- properties.setProperty(BrokerConstants.BROKER_INTERCEPTOR_THREAD_POOL_SIZE, "1");
- IConfig config = new MemoryConfig(properties);
-
- List<InterceptHandler> handlers = Lists.newArrayList(new ForwardTestHandler());
-
- mqttServer = new Server();
- mqttServer.startServer(config, handlers);
- }
-
- private class ForwardTestHandler extends AbstractInterceptHandler {
- @Override
- public String getID() {
- return "forward-test-handler";
- }
-
- @Override
- public void onPublish(InterceptPublishMessage msg) {
- String payload = msg.getPayload().toString(StandardCharsets.UTF_8);
- if (!checkPayload(payload)) {
- exception = new IOException("MQTT forward payload error");
- }
- JsonArray receiveData = gson.fromJson(payload, JsonArray.class);
- resultCount.addAndGet(receiveData.size());
- }
- }
-
- private boolean checkPayload(String payload) {
- return payload.matches(ForwardEvent.PAYLOADS_FORMATTER_REGEX);
- }
-}
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerManagementIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerManagementIT.java
deleted file mode 100644
index 4723972a85..0000000000
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerManagementIT.java
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.integration;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.example.Accumulator;
-import org.apache.iotdb.db.engine.trigger.example.Counter;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerEvent;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationInformation;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-@Category({LocalStandaloneTest.class})
-public class IoTDBTriggerManagementIT {
-
- @Before
- public void setUp() throws Exception {
- EnvironmentUtils.envSetUp();
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.d1.s1"),
- TSDataType.FLOAT,
- TSEncoding.PLAIN,
- CompressionType.UNCOMPRESSED,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.d1.s2"),
- TSDataType.DOUBLE,
- TSEncoding.GORILLA,
- CompressionType.LZ4,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.d1.s3"),
- TSDataType.INT32,
- TSEncoding.RLE,
- CompressionType.LZ4,
- null);
- IoTDB.schemaProcessor.createTimeseries(
- new PartialPath("root.vehicle.d1.s4"),
- TSDataType.INT64,
- TSEncoding.RLE,
- CompressionType.LZ4,
- null);
- Class.forName(Config.JDBC_DRIVER_NAME);
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void testManageTriggersNormally() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- // show
- ResultSet resultSet = statement.executeQuery("show triggers");
- assertFalse(resultSet.next());
-
- // create trigger
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- assertFalse(
- ((Accumulator) TriggerRegistrationService.getInstance().getTriggerInstance("trigger_1"))
- .isStopped());
- assertFalse(
- ((Counter) TriggerRegistrationService.getInstance().getTriggerInstance("trigger_2"))
- .isStopped());
-
- // show
- resultSet = statement.executeQuery("show triggers");
- assertTrue(resultSet.next());
- assertTrue(resultSet.next());
- assertFalse(resultSet.next());
-
- // stop trigger
- statement.execute("stop trigger trigger_1");
- assertTrue(
- ((Accumulator) TriggerRegistrationService.getInstance().getTriggerInstance("trigger_1"))
- .isStopped());
-
- // show
- resultSet = statement.executeQuery("show triggers");
- assertTrue(resultSet.next());
- assertTrue(resultSet.next());
- assertFalse(resultSet.next());
-
- // start trigger
- statement.execute("start trigger trigger_1");
- assertFalse(
- ((Accumulator) TriggerRegistrationService.getInstance().getTriggerInstance("trigger_1"))
- .isStopped());
-
- // drop trigger
- statement.execute("drop trigger trigger_1");
- statement.execute("drop trigger trigger_2");
-
- // show
- resultSet = statement.executeQuery("show triggers");
- assertFalse(resultSet.next());
- } catch (SQLException | TriggerManagementException throwable) {
- fail(throwable.getMessage());
- }
- }
-
- @Test
- public void testRegisterOnNonMeasurementMNode() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_2 before insert on root.vehicle.d1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- } catch (SQLException throwable) {
- assertTrue(
- throwable.getMessage().contains("MNode [root.vehicle.d1] is not a MeasurementMNode."));
- }
- }
-
- @Test
- public void testRegisterOnNonExistentMNode() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_2 before insert on root.nonexistent.d1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- } catch (SQLException throwable) {
- assertTrue(throwable.getMessage().contains("Path [root.nonexistent.d1] does not exist"));
- }
- }
-
- @Test
- public void testRegisterInvalidClass() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_2 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Nonexistent'");
- } catch (SQLException throwable) {
- assertTrue(throwable.getMessage().contains("Failed to reflect Trigger trigger_2"));
- }
- }
-
- @Test
- public void testRegisterSameTriggers() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute(
- "create trigger trigger_1 after insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- } catch (SQLException throwable) {
- assertTrue(
- throwable
- .getMessage()
- .contains(
- "a trigger with the same trigger name and the class name has already been registered"));
- }
- }
-
- @Test
- public void testRegisterOnSameTimeseries() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
-
- try {
- statement.execute(
- "create trigger trigger_2 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- } catch (SQLException throwable) {
- assertTrue(
- throwable
- .getMessage()
- .contains(
- "because a trigger trigger_1(org.apache.iotdb.db.engine.trigger.example.Accumulator) has already been registered on the timeseries root.vehicle.d1.s1"));
- }
-
- try {
- statement.execute(
- "create trigger trigger_3 after insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- } catch (SQLException throwable) {
- assertTrue(
- throwable
- .getMessage()
- .contains(
- "because a trigger trigger_1(org.apache.iotdb.db.engine.trigger.example.Accumulator) has already been registered on the timeseries root.vehicle.d1.s1"));
- }
- } catch (SQLException throwable) {
- fail(throwable.getMessage());
- }
- }
-
- @Test
- public void testRegisterTriggersWithSameNameButDifferentClasses() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute(
- "create trigger trigger_1 after insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- } catch (SQLException throwable) {
- assertTrue(
- throwable
- .getMessage()
- .contains(
- "with the same trigger name but a different class name has already been registered"));
- }
- }
-
- @Test
- public void testCreateAndDropSeveralTimes() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- statement.execute("drop trigger trigger_1");
- statement.execute("drop trigger trigger_2");
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- statement.execute("drop trigger trigger_1");
- statement.execute("drop trigger trigger_2");
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- ResultSet resultSet = statement.executeQuery("show triggers");
- assertTrue(resultSet.next());
- assertTrue(resultSet.next());
- assertFalse(resultSet.next());
-
- statement.execute("drop trigger trigger_1");
- statement.execute("drop trigger trigger_2");
-
- resultSet = statement.executeQuery("show triggers");
- assertFalse(resultSet.next());
- } catch (SQLException throwable) {
- fail(throwable.getMessage());
- }
- }
-
- @Test
- public void testCreateSeveralTimes() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- ((Accumulator) TriggerRegistrationService.getInstance().getTriggerInstance("trigger_1"))
- .setAccumulator(1234);
-
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute(
- "create trigger trigger_4 after insert on root.vehicle.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
-
- assertEquals(
- 1234,
- ((Accumulator) TriggerRegistrationService.getInstance().getTriggerInstance("trigger_1"))
- .getAccumulator(),
- 0);
- } catch (SQLException | TriggerManagementException throwable) {
- fail(throwable.getMessage());
- }
- }
-
- @Test
- public void testDropNonExistentTrigger() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute("drop trigger trigger_1");
- } catch (SQLException throwable) {
- assertTrue(throwable.getMessage().contains("Trigger trigger_1 does not exist"));
- }
- }
-
- @Test
- public void testStartNonExistentTrigger() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute("start trigger trigger_1");
- } catch (SQLException throwable) {
- assertTrue(throwable.getMessage().contains("Trigger trigger_1 does not exist"));
- }
- }
-
- @Test
- public void testStartStartedTrigger() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute("start trigger trigger_1");
- } catch (SQLException throwable) {
- assertTrue(throwable.getMessage().contains("Trigger trigger_1 has already been started"));
- }
- }
-
- @Test
- public void testStopNonExistentTrigger() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute("stop trigger trigger_1");
- } catch (SQLException throwable) {
- assertTrue(throwable.getMessage().contains("Trigger trigger_1 does not exist"));
- }
- }
-
- @Test
- public void testStopStoppedTrigger() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- statement.execute("stop trigger trigger_1");
- statement.execute("stop trigger trigger_1");
- } catch (SQLException throwable) {
- assertTrue(throwable.getMessage().contains("Trigger trigger_1 has already been stopped"));
- }
- }
-
- @Test
- public void testStopAndStartTriggerMultipleTimesNormally() {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- assertFalse(
- TriggerRegistrationService.getInstance()
- .getRegistrationInformation("trigger_1")
- .isStopped());
-
- statement.execute("stop trigger trigger_1");
- assertTrue(
- TriggerRegistrationService.getInstance()
- .getRegistrationInformation("trigger_1")
- .isStopped());
-
- statement.execute("start trigger trigger_1");
- assertFalse(
- TriggerRegistrationService.getInstance()
- .getRegistrationInformation("trigger_1")
- .isStopped());
-
- statement.execute("stop trigger trigger_1");
- assertTrue(
- TriggerRegistrationService.getInstance()
- .getRegistrationInformation("trigger_1")
- .isStopped());
-
- statement.execute("start trigger trigger_1");
- assertFalse(
- TriggerRegistrationService.getInstance()
- .getRegistrationInformation("trigger_1")
- .isStopped());
- } catch (SQLException | TriggerManagementException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- @SuppressWarnings("squid:S5961")
- public void testRecovery() throws Exception {
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s1 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator' with ('k1'='v1', 'k2'='v2')");
- statement.execute("stop trigger trigger_1");
- statement.execute("start trigger trigger_1");
- statement.execute("drop trigger trigger_1");
-
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Counter' with ('k3'='v3')");
- statement.execute("stop trigger trigger_1");
- statement.execute("start trigger trigger_1");
- statement.execute("drop trigger trigger_1");
-
- statement.execute(
- "create trigger trigger_1 after insert on root.vehicle.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_2 before insert on root.vehicle.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator' with ('k4'='v4')");
- statement.execute("stop trigger trigger_1");
-
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- EnvironmentUtils.restartDaemon();
-
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- TriggerRegistrationInformation trigger1Info =
- TriggerRegistrationService.getInstance().getRegistrationInformation("trigger_1");
- assertEquals("trigger_1", trigger1Info.getTriggerName());
- assertEquals("root.vehicle.d1.s3", trigger1Info.getFullPath().getFullPath());
- assertEquals(TriggerEvent.AFTER_INSERT, trigger1Info.getEvent());
- assertEquals(
- "org.apache.iotdb.db.engine.trigger.example.Counter", trigger1Info.getClassName());
- assertEquals("{}", trigger1Info.getAttributes().toString());
- assertTrue(trigger1Info.isStopped());
-
- TriggerRegistrationInformation trigger2Info =
- TriggerRegistrationService.getInstance().getRegistrationInformation("trigger_2");
- assertEquals("trigger_2", trigger2Info.getTriggerName());
- assertEquals("root.vehicle.d1.s4", trigger2Info.getFullPath().getFullPath());
- assertEquals(TriggerEvent.BEFORE_INSERT, trigger2Info.getEvent());
- assertEquals(
- "org.apache.iotdb.db.engine.trigger.example.Accumulator", trigger2Info.getClassName());
- assertEquals("{k4=v4}", trigger2Info.getAttributes().toString());
- assertFalse(trigger2Info.isStopped());
-
- statement.execute("drop trigger trigger_2");
- statement.execute("drop trigger trigger_1");
- statement.execute(
- "create trigger trigger_2 after insert on root.vehicle.d1.s3 as 'org.apache.iotdb.db.engine.trigger.example.Counter'");
- statement.execute(
- "create trigger trigger_1 before insert on root.vehicle.d1.s4 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator' with ('k5'='v5')");
- statement.execute("stop trigger trigger_2");
- statement.execute(
- "create trigger trigger_3 before insert on root.vehicle.d1.s2 as 'org.apache.iotdb.db.engine.trigger.example.Accumulator'");
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- EnvironmentUtils.restartDaemon();
-
- TriggerRegistrationInformation trigger1Info =
- TriggerRegistrationService.getInstance().getRegistrationInformation("trigger_1");
- assertEquals("trigger_1", trigger1Info.getTriggerName());
- assertEquals("root.vehicle.d1.s4", trigger1Info.getFullPath().getFullPath());
- assertEquals(TriggerEvent.BEFORE_INSERT, trigger1Info.getEvent());
- assertEquals(
- "org.apache.iotdb.db.engine.trigger.example.Accumulator", trigger1Info.getClassName());
- assertEquals("{k5=v5}", trigger1Info.getAttributes().toString());
- assertFalse(trigger1Info.isStopped());
-
- TriggerRegistrationInformation trigger2Info =
- TriggerRegistrationService.getInstance().getRegistrationInformation("trigger_2");
- assertEquals("trigger_2", trigger2Info.getTriggerName());
- assertEquals("root.vehicle.d1.s3", trigger2Info.getFullPath().getFullPath());
- assertEquals(TriggerEvent.AFTER_INSERT, trigger2Info.getEvent());
- assertEquals("org.apache.iotdb.db.engine.trigger.example.Counter", trigger2Info.getClassName());
- assertEquals("{}", trigger2Info.getAttributes().toString());
- assertTrue(trigger2Info.isStopped());
-
- TriggerRegistrationInformation trigger3Info =
- TriggerRegistrationService.getInstance().getRegistrationInformation("trigger_3");
- assertEquals("trigger_3", trigger3Info.getTriggerName());
- assertEquals("root.vehicle.d1.s2", trigger3Info.getFullPath().getFullPath());
- assertEquals(TriggerEvent.BEFORE_INSERT, trigger3Info.getEvent());
- assertEquals(
- "org.apache.iotdb.db.engine.trigger.example.Accumulator", trigger3Info.getClassName());
- assertEquals("{}", trigger3Info.getAttributes().toString());
- assertFalse(trigger3Info.isStopped());
- }
-}
diff --git a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMNode.java b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMNode.java
index b86b80248a..77989f3aa5 100644
--- a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMNode.java
+++ b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMNode.java
@@ -22,7 +22,6 @@ package org.apache.iotdb.db.metadata.schemaregion.rocksdb.mnode;
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerExecutor;
import org.apache.iotdb.db.metadata.mnode.IEntityMNode;
import org.apache.iotdb.db.metadata.mnode.IMNode;
import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
@@ -38,7 +37,6 @@ import org.rocksdb.RocksDBException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
import java.util.Objects;
public abstract class RMNode implements IMNode {
@@ -53,9 +51,6 @@ public abstract class RMNode implements IMNode {
protected static final Logger logger = LoggerFactory.getLogger(RMNode.class);
- /** registered trigger */
- protected TriggerExecutor triggerExecutor;
-
/** Constructor of MNode. */
public RMNode(String fullPath, RSchemaReadWriteHandler readWriteHandler) {
this.fullPath = fullPath.intern();
@@ -225,21 +220,6 @@ public abstract class RMNode implements IMNode {
}
}
- @Override
- public List<TriggerExecutor> getUpperTriggerExecutorList() {
- throw new UnsupportedOperationException("Temporarily unsupported");
- }
-
- @Override
- public TriggerExecutor getTriggerExecutor() {
- return triggerExecutor;
- }
-
- @Override
- public void setTriggerExecutor(TriggerExecutor triggerExecutor) {
- this.triggerExecutor = triggerExecutor;
- }
-
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMeasurementMNode.java b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMeasurementMNode.java
index 07eb8fbeda..b6380cdbaa 100644
--- a/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMeasurementMNode.java
+++ b/schema-engine-rocksdb/src/main/java/org/apache/iotdb/db/metadata/schemaregion/rocksdb/mnode/RMeasurementMNode.java
@@ -21,7 +21,6 @@ package org.apache.iotdb.db.metadata.schemaregion.rocksdb.mnode;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.path.MeasurementPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerExecutor;
import org.apache.iotdb.db.metadata.lastCache.container.ILastCacheContainer;
import org.apache.iotdb.db.metadata.logfile.MLogWriter;
import org.apache.iotdb.db.metadata.mnode.IEntityMNode;
@@ -131,16 +130,6 @@ public class RMeasurementMNode extends RMNode implements IMeasurementMNode {
this.alias = alias;
}
- @Override
- public TriggerExecutor getTriggerExecutor() {
- return null;
- }
-
- @Override
- public void setTriggerExecutor(TriggerExecutor triggerExecutor) {
- throw new UnsupportedOperationException();
- }
-
@Override
public ILastCacheContainer getLastCacheContainer() {
throw new UnsupportedOperationException();
diff --git a/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/visitor/DataExecutionVisitor.java b/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/visitor/DataExecutionVisitor.java
index bc7b8c15c5..2202b4ecad 100644
--- a/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/visitor/DataExecutionVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/visitor/DataExecutionVisitor.java
@@ -23,7 +23,6 @@ import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.StatusUtils;
import org.apache.iotdb.db.engine.storagegroup.DataRegion;
import org.apache.iotdb.db.exception.BatchProcessException;
-import org.apache.iotdb.db.exception.TriggerExecutionException;
import org.apache.iotdb.db.exception.WriteProcessException;
import org.apache.iotdb.db.exception.query.OutOfTTLException;
import org.apache.iotdb.db.mpp.plan.planner.plan.node.PlanNode;
@@ -59,7 +58,7 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
} catch (OutOfTTLException e) {
LOGGER.warn("Error in executing plan node: {}, caused by {}", node, e.getMessage());
return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
- } catch (WriteProcessException | TriggerExecutionException e) {
+ } catch (WriteProcessException e) {
LOGGER.error("Error in executing plan node: {}", node, e);
return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
}
@@ -73,7 +72,7 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
} catch (OutOfTTLException e) {
LOGGER.warn("Error in executing plan node: {}, caused by {}", node, e.getMessage());
return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
- } catch (TriggerExecutionException | WriteProcessException e) {
+ } catch (WriteProcessException e) {
LOGGER.error("Error in executing plan node: {}", node, e);
return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
} catch (BatchProcessException e) {
@@ -143,7 +142,7 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
try {
dataRegion.insert(node);
return StatusUtils.OK;
- } catch (WriteProcessException | TriggerExecutionException e) {
+ } catch (WriteProcessException e) {
LOGGER.error("Error in executing plan node: {}", node, e);
return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
} catch (BatchProcessException e) {
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
index f28627a720..228e6f5233 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
@@ -58,7 +58,6 @@ import org.apache.iotdb.db.exception.BatchProcessException;
import org.apache.iotdb.db.exception.DataRegionException;
import org.apache.iotdb.db.exception.DiskSpaceInsufficientException;
import org.apache.iotdb.db.exception.LoadFileException;
-import org.apache.iotdb.db.exception.TriggerExecutionException;
import org.apache.iotdb.db.exception.TsFileProcessorException;
import org.apache.iotdb.db.exception.WriteProcessException;
import org.apache.iotdb.db.exception.WriteProcessRejectException;
@@ -874,8 +873,7 @@ public class DataRegion {
*
* @param insertRowNode one row of data
*/
- public void insert(InsertRowNode insertRowNode)
- throws WriteProcessException, TriggerExecutionException {
+ public void insert(InsertRowNode insertRowNode) throws WriteProcessException {
// reject insertions that are out of ttl
if (!isAlive(insertRowNode.getTime())) {
throw new OutOfTTLException(insertRowNode.getTime(), (DateTimeUtils.currentTime() - dataTTL));
@@ -925,7 +923,7 @@ public class DataRegion {
*/
@SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
public void insertTablet(InsertTabletNode insertTabletNode)
- throws TriggerExecutionException, BatchProcessException, WriteProcessException {
+ throws BatchProcessException, WriteProcessException {
if (enableMemControl) {
StorageEngineV2.blockInsertionIfReject(null);
}
@@ -3053,7 +3051,7 @@ public class DataRegion {
* @param insertRowsOfOneDeviceNode batch of rows belongs to one device
*/
public void insert(InsertRowsOfOneDeviceNode insertRowsOfOneDeviceNode)
- throws WriteProcessException, TriggerExecutionException, BatchProcessException {
+ throws WriteProcessException, BatchProcessException {
if (enableMemControl) {
StorageEngineV2.blockInsertionIfReject(null);
}
@@ -3135,7 +3133,7 @@ public class DataRegion {
InsertRowNode insertRowNode = insertRowsNode.getInsertRowNodeList().get(i);
try {
insert(insertRowNode);
- } catch (WriteProcessException | TriggerExecutionException e) {
+ } catch (WriteProcessException e) {
insertRowsNode.getResults().put(i, RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
}
}
@@ -3156,7 +3154,7 @@ public class DataRegion {
InsertTabletNode insertTabletNode = insertMultiTabletsNode.getInsertTabletNodeList().get(i);
try {
insertTablet(insertTabletNode);
- } catch (TriggerExecutionException | WriteProcessException | BatchProcessException e) {
+ } catch (WriteProcessException | BatchProcessException e) {
insertMultiTabletsNode
.getResults()
.put(i, RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/builtin/ForwardTrigger.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/builtin/ForwardTrigger.java
index a6df9132a2..9dbd1958fb 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/builtin/ForwardTrigger.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/trigger/builtin/ForwardTrigger.java
@@ -20,6 +20,7 @@
package org.apache.iotdb.db.engine.trigger.builtin;
import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.commons.trigger.exception.TriggerExecutionException;
import org.apache.iotdb.db.engine.trigger.api.Trigger;
import org.apache.iotdb.db.engine.trigger.sink.api.Configuration;
import org.apache.iotdb.db.engine.trigger.sink.api.Event;
@@ -32,7 +33,6 @@ import org.apache.iotdb.db.engine.trigger.sink.forward.mqtt.MQTTForwardConfigura
import org.apache.iotdb.db.engine.trigger.sink.forward.mqtt.MQTTForwardEvent;
import org.apache.iotdb.db.engine.trigger.sink.forward.mqtt.MQTTForwardHandler;
import org.apache.iotdb.db.engine.trigger.utils.BatchHandlerQueue;
-import org.apache.iotdb.db.exception.TriggerExecutionException;
import org.apache.iotdb.trigger.api.TriggerAttributes;
import org.apache.iotdb.tsfile.utils.Binary;
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerEngine.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerEngine.java
deleted file mode 100644
index 96ccf5598a..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerEngine.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.trigger.executor;
-
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationInformation;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
-import org.apache.iotdb.db.qp.physical.sys.DropTriggerPlan;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-public class TriggerEngine {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(TriggerEngine.class);
-
- public static void drop(IMeasurementMNode measurementMNode) {
- TriggerExecutor executor = measurementMNode.getTriggerExecutor();
- if (executor == null) {
- return;
- }
-
- TriggerRegistrationInformation information = executor.getRegistrationInformation();
- try {
- TriggerRegistrationService.getInstance()
- .deregister(new DropTriggerPlan(information.getTriggerName()));
- } catch (TriggerManagementException e) {
- LOGGER.warn(
- "Failed to deregister trigger {}({}) when deleting timeseries ({}).",
- information.getTriggerName(),
- information.getClassName(),
- measurementMNode.getPartialPath().getFullPath(),
- e);
- }
- }
-
- public static void drop(List<IMeasurementMNode> measurementMNodes) {
- for (IMeasurementMNode measurementMNode : measurementMNodes) {
- drop(measurementMNode);
- }
- }
-
- private TriggerEngine() {}
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerEvent.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerEvent.java
deleted file mode 100644
index 2ffb1ee0c0..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerEvent.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.trigger.executor;
-
-public enum TriggerEvent {
- BEFORE_INSERT((byte) 0, "before insert"),
- AFTER_INSERT((byte) 1, "after insert");
-
- private final byte id;
- private final String event;
-
- TriggerEvent(byte id, String event) {
- this.id = id;
- this.event = event;
- }
-
- public byte getId() {
- return id;
- }
-
- @Override
- public String toString() {
- return event;
- }
-
- public static TriggerEvent construct(byte id) {
- switch (id) {
- case 0:
- return BEFORE_INSERT;
- case 1:
- return AFTER_INSERT;
- default:
- throw new IllegalArgumentException(String.format("No such trigger event (id: %d)", id));
- }
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerExecutor.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerExecutor.java
deleted file mode 100644
index b9a4695f59..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/executor/TriggerExecutor.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.trigger.executor;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.utils.TestOnly;
-import org.apache.iotdb.db.engine.trigger.api.Trigger;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationInformation;
-import org.apache.iotdb.db.exception.TriggerExecutionException;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.metadata.mnode.IMNode;
-import org.apache.iotdb.db.trigger.service.TriggerClassLoader;
-import org.apache.iotdb.trigger.api.TriggerAttributes;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.utils.Binary;
-
-import java.lang.reflect.InvocationTargetException;
-
-public class TriggerExecutor {
-
- private final TriggerRegistrationInformation registrationInformation;
- private final TriggerAttributes attributes;
-
- private final TriggerClassLoader classLoader;
-
- private final IMNode imNode;
-
- private final Trigger trigger;
-
- public TriggerExecutor(
- TriggerRegistrationInformation registrationInformation,
- TriggerClassLoader classLoader,
- IMNode imNode)
- throws TriggerManagementException {
- this.registrationInformation = registrationInformation;
- attributes = new TriggerAttributes(registrationInformation.getAttributes());
-
- this.classLoader = classLoader;
-
- this.imNode = imNode;
-
- trigger = constructTriggerInstance();
- }
-
- private Trigger constructTriggerInstance() throws TriggerManagementException {
- try {
- Class<?> triggerClass =
- Class.forName(registrationInformation.getClassName(), true, classLoader);
- return (Trigger) triggerClass.getDeclaredConstructor().newInstance();
- } catch (InstantiationException
- | InvocationTargetException
- | NoSuchMethodException
- | IllegalAccessException
- | ClassNotFoundException e) {
- throw new TriggerManagementException(
- String.format(
- "Failed to reflect Trigger %s(%s) instance, because %s",
- registrationInformation.getTriggerName(), registrationInformation.getClassName(), e));
- }
- }
-
- public void onCreate() throws TriggerExecutionException {
- Thread.currentThread().setContextClassLoader(classLoader);
-
- try {
- trigger.onCreate(attributes);
- } catch (Exception e) {
- onTriggerExecutionError("onConfig(TriggerAttributes)", e);
- }
-
- // The field isStopped in the registrationInformation is volatile, so the method
- // registrationInformation.markAsStarted() is always invoked after the method
- // trigger.onCreate(attributes) is invoked. It guarantees that the trigger will not be triggered
- // before trigger.onCreate(attributes) is called.
- registrationInformation.markAsStarted();
- }
-
- public synchronized void onDrop() throws TriggerExecutionException {
- Thread.currentThread().setContextClassLoader(classLoader);
-
- registrationInformation.markAsStopped();
-
- try {
- trigger.onDrop();
- } catch (Exception e) {
- onTriggerExecutionError("onConfig(TriggerAttributes)", e);
- }
- }
-
- public synchronized void onStart() throws TriggerExecutionException {
- // The execution order of statement here cannot be swapped!
- invokeOnStart();
- registrationInformation.markAsStarted();
- }
-
- private void invokeOnStart() throws TriggerExecutionException {
- Thread.currentThread().setContextClassLoader(classLoader);
-
- try {
- trigger.onStart();
- } catch (Exception e) {
- onTriggerExecutionError("onStart()", e);
- }
- }
-
- public synchronized void onStop() throws TriggerExecutionException {
- // The execution order of statement here cannot be swapped!
- registrationInformation.markAsStopped();
- invokeOnStop();
- }
-
- private void invokeOnStop() throws TriggerExecutionException {
- Thread.currentThread().setContextClassLoader(classLoader);
-
- try {
- trigger.onStop();
- } catch (Exception e) {
- onTriggerExecutionError("onStop()", e);
- }
- }
-
- public void fireIfActivated(
- TriggerEvent event, long timestamp, Object value, TSDataType seriesDataType, PartialPath path)
- throws TriggerExecutionException {
- if (!registrationInformation.isStopped() && event.equals(registrationInformation.getEvent())) {
- fire(timestamp, value, seriesDataType, path);
- }
- }
-
- private synchronized void fire(
- long timestamp, Object value, TSDataType seriesDataType, PartialPath path)
- throws TriggerExecutionException {
- Thread.currentThread().setContextClassLoader(classLoader);
-
- try {
- switch (seriesDataType) {
- case INT32:
- trigger.fire(timestamp, (Integer) value, path);
- break;
- case INT64:
- trigger.fire(timestamp, (Long) value, path);
- break;
- case FLOAT:
- trigger.fire(timestamp, (Float) value, path);
- break;
- case DOUBLE:
- trigger.fire(timestamp, (Double) value, path);
- break;
- case BOOLEAN:
- trigger.fire(timestamp, (Boolean) value, path);
- break;
- case TEXT:
- trigger.fire(timestamp, (Binary) value, path);
- break;
- default:
- throw new TriggerExecutionException("Unsupported series data type.");
- }
- } catch (TriggerExecutionException e) {
- throw e;
- } catch (Exception e) {
- onTriggerExecutionError("fire(long, Object)", e);
- }
- }
-
- public void fireIfActivated(
- TriggerEvent event,
- long[] timestamps,
- Object values,
- TSDataType seriesDataType,
- PartialPath path)
- throws TriggerExecutionException {
- if (!registrationInformation.isStopped() && event.equals(registrationInformation.getEvent())) {
- fire(timestamps, values, seriesDataType, path);
- }
- }
-
- private synchronized void fire(
- long[] timestamps, Object values, TSDataType seriesDataType, PartialPath path)
- throws TriggerExecutionException {
- Thread.currentThread().setContextClassLoader(classLoader);
-
- try {
- switch (seriesDataType) {
- case INT32:
- trigger.fire(timestamps, (int[]) values, path);
- break;
- case INT64:
- trigger.fire(timestamps, (long[]) values, path);
- break;
- case FLOAT:
- trigger.fire(timestamps, (float[]) values, path);
- break;
- case DOUBLE:
- trigger.fire(timestamps, (double[]) values, path);
- break;
- case BOOLEAN:
- trigger.fire(timestamps, (boolean[]) values, path);
- break;
- case TEXT:
- trigger.fire(timestamps, (Binary[]) values, path);
- break;
- default:
- throw new TriggerExecutionException("Unsupported series data type.");
- }
- } catch (TriggerExecutionException e) {
- throw e;
- } catch (Exception e) {
- onTriggerExecutionError("fire(long[], Object)", e);
- }
- }
-
- private void onTriggerExecutionError(String methodName, Exception e)
- throws TriggerExecutionException {
- throw new TriggerExecutionException(
- String.format(
- "Error occurred during executing Trigger#%s: %s",
- methodName, System.lineSeparator())
- + e);
- }
-
- public TriggerRegistrationInformation getRegistrationInformation() {
- return registrationInformation;
- }
-
- public IMNode getIMNode() {
- return imNode;
- }
-
- @TestOnly
- public Trigger getTrigger() {
- return trigger;
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerClassLoaderManager.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerClassLoaderManager.java
deleted file mode 100644
index dd22241f35..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerClassLoaderManager.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.trigger.service;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.trigger.service.TriggerClassLoader;
-import org.apache.iotdb.tsfile.utils.Pair;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/** Note: it is NOT thread safe. */
-public class TriggerClassLoaderManager {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(TriggerClassLoaderManager.class);
-
- private static final String LIB_ROOT = IoTDBDescriptor.getInstance().getConfig().getTriggerDir();
-
- private final Map<String, Pair<TriggerClassLoader, Integer>> classNameToClassLoaderUsagePairMap;
-
- private TriggerClassLoaderManager() {
- classNameToClassLoaderUsagePairMap = new HashMap<>();
- }
-
- public TriggerClassLoader register(String className) throws TriggerManagementException {
- Pair<TriggerClassLoader, Integer> classLoaderUsagePair =
- classNameToClassLoaderUsagePairMap.get(className);
- if (classLoaderUsagePair == null) {
- try {
- TriggerClassLoader classLoader = new TriggerClassLoader(LIB_ROOT);
- classLoaderUsagePair = new Pair<>(classLoader, 0);
- classNameToClassLoaderUsagePairMap.put(className, classLoaderUsagePair);
- LOGGER.info(
- "A new trigger classloader was constructed for managing trigger class {}.", className);
- } catch (IOException e) {
- throw new TriggerManagementException(
- String.format(
- "Failed to construct a new trigger classloader for managing trigger class %s.",
- className),
- e);
- }
- }
- classLoaderUsagePair.right++;
- return classLoaderUsagePair.left;
- }
-
- public void deregister(String className) {
- Pair<TriggerClassLoader, Integer> classLoaderUsagePair =
- classNameToClassLoaderUsagePairMap.get(className);
- classLoaderUsagePair.right--;
- if (classLoaderUsagePair.right == 0) {
- try {
- classLoaderUsagePair.left.close();
- } catch (IOException e) {
- LOGGER.warn("Failed to close a trigger classloader ({}).", className);
- } finally {
- classNameToClassLoaderUsagePairMap.remove(className);
- LOGGER.info("A trigger classloader ({}) was removed.", className);
- }
- }
- }
-
- public static TriggerClassLoaderManager getInstance() {
- return TriggerClassLoaderManager.TriggerClassLoaderManagerHelper.INSTANCE;
- }
-
- private static class TriggerClassLoaderManagerHelper {
-
- private static final TriggerClassLoaderManager INSTANCE = new TriggerClassLoaderManager();
-
- private TriggerClassLoaderManagerHelper() {}
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerLogReader.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerLogReader.java
deleted file mode 100644
index db021344df..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerLogReader.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.trigger.service;
-
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.utils.writelog.SingleFileLogReader;
-
-import java.io.File;
-import java.io.IOException;
-
-public class TriggerLogReader implements AutoCloseable {
-
- private final SingleFileLogReader logReader;
-
- public TriggerLogReader(File logFile) throws IOException {
- logReader = new SingleFileLogReader(logFile);
- }
-
- public boolean hasNext() {
- return !logReader.isFileCorrupted() && logReader.hasNext();
- }
-
- public PhysicalPlan next() {
- return logReader.next();
- }
-
- @Override
- public void close() {
- logReader.close();
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerLogWriter.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerLogWriter.java
deleted file mode 100644
index e2ca8d53ef..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerLogWriter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.trigger.service;
-
-import org.apache.iotdb.commons.file.SystemFileFactory;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.utils.writelog.ILogWriter;
-import org.apache.iotdb.db.utils.writelog.LogWriter;
-
-import org.apache.commons.io.FileUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-public class TriggerLogWriter implements AutoCloseable {
-
- private final ByteBuffer logBuffer;
- private final File logFile;
- private final ILogWriter logWriter;
-
- public TriggerLogWriter(String logFilePath) throws IOException {
- logBuffer = ByteBuffer.allocate(IoTDBDescriptor.getInstance().getConfig().getTlogBufferSize());
- logFile = SystemFileFactory.INSTANCE.getFile(logFilePath);
- logWriter = new LogWriter(logFile, false);
- }
-
- public synchronized void write(PhysicalPlan plan) throws IOException {
- try {
- plan.serialize(logBuffer);
- logWriter.write(logBuffer);
- } catch (BufferOverflowException e) {
- throw new IOException(
- "Current trigger management operation plan is too large to write into buffer, please increase tlog_buffer_size.",
- e);
- } finally {
- logBuffer.clear();
- }
- }
-
- @Override
- public void close() throws IOException {
- logWriter.close();
- }
-
- public void deleteLogFile() throws IOException {
- FileUtils.forceDelete(logFile);
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerRegistrationInformation.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerRegistrationInformation.java
deleted file mode 100644
index 2d6db2cd35..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerRegistrationInformation.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.trigger.service;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerEvent;
-import org.apache.iotdb.db.qp.physical.sys.CreateTriggerPlan;
-
-import java.util.Map;
-
-public class TriggerRegistrationInformation {
-
- private final String triggerName;
- private final TriggerEvent event;
- private final PartialPath fullPath;
- private final String className;
- private final Map<String, String> attributes;
-
- private volatile boolean isStopped;
-
- public TriggerRegistrationInformation(CreateTriggerPlan plan) {
- this.triggerName = plan.getTriggerName();
- this.event = plan.getEvent();
- this.fullPath = plan.getFullPath();
- this.className = plan.getClassName();
- this.attributes = plan.getAttributes();
- this.isStopped = plan.isStopped();
- }
-
- public CreateTriggerPlan convertToCreateTriggerPlan() {
- return new CreateTriggerPlan(triggerName, event, fullPath, className, attributes);
- }
-
- public void markAsStarted() {
- isStopped = false;
- }
-
- public void markAsStopped() {
- isStopped = true;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- public TriggerEvent getEvent() {
- return event;
- }
-
- public PartialPath getFullPath() {
- return fullPath;
- }
-
- public String getClassName() {
- return className;
- }
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
- public boolean isStopped() {
- return isStopped;
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerRegistrationService.java b/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerRegistrationService.java
deleted file mode 100644
index 91caddc384..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/trigger/service/TriggerRegistrationService.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.engine.trigger.service;
-
-import org.apache.iotdb.commons.exception.MetadataException;
-import org.apache.iotdb.commons.exception.StartupException;
-import org.apache.iotdb.commons.file.SystemFileFactory;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.service.IService;
-import org.apache.iotdb.commons.service.ServiceType;
-import org.apache.iotdb.commons.utils.TestOnly;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.engine.trigger.api.Trigger;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerExecutor;
-import org.apache.iotdb.db.exception.TriggerExecutionException;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.metadata.idtable.IDTable;
-import org.apache.iotdb.db.metadata.idtable.IDTableManager;
-import org.apache.iotdb.db.metadata.mnode.IMNode;
-import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTriggerPlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTriggerPlan;
-import org.apache.iotdb.db.qp.physical.sys.StartTriggerPlan;
-import org.apache.iotdb.db.qp.physical.sys.StopTriggerPlan;
-import org.apache.iotdb.db.query.dataset.ListDataSet;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.trigger.service.TriggerClassLoader;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer;
-import org.apache.iotdb.tsfile.read.common.RowRecord;
-import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
-import org.apache.iotdb.tsfile.utils.Binary;
-
-import org.apache.commons.io.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.apache.iotdb.commons.conf.IoTDBConstant.COLUMN_TRIGGER_ATTRIBUTES;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.COLUMN_TRIGGER_CLASS;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.COLUMN_TRIGGER_EVENT;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.COLUMN_TRIGGER_NAME;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.COLUMN_TRIGGER_PATH;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.COLUMN_TRIGGER_STATUS;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.COLUMN_TRIGGER_STATUS_STARTED;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.COLUMN_TRIGGER_STATUS_STOPPED;
-
-public class TriggerRegistrationService implements IService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(TriggerRegistrationService.class);
-
- private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
-
- private static final String LOG_FILE_DIR =
- IoTDBDescriptor.getInstance().getConfig().getSystemDir()
- + File.separator
- + "trigger"
- + File.separator;
- private static final String LOG_FILE_NAME = LOG_FILE_DIR + "tlog.bin";
- private static final String TEMPORARY_LOG_FILE_NAME = LOG_FILE_NAME + ".tmp";
-
- private static final String LIB_ROOT = IoTDBDescriptor.getInstance().getConfig().getTriggerDir();
-
- private final ConcurrentHashMap<String, TriggerExecutor> executors;
-
- private TriggerLogWriter logWriter;
-
- private TriggerRegistrationService() {
- executors = new ConcurrentHashMap<>();
- }
-
- public synchronized void register(CreateTriggerPlan plan)
- throws TriggerManagementException, TriggerExecutionException {
- IMNode imNode = tryGetMNode(plan);
- checkIfRegistered(plan, imNode);
- tryAppendRegistrationLog(plan);
- doRegister(plan, imNode);
- }
-
- private void checkIfRegistered(CreateTriggerPlan plan, IMNode imNode)
- throws TriggerManagementException {
- TriggerExecutor executor = imNode.getTriggerExecutor();
- if (executor != null) {
- TriggerRegistrationInformation information = executor.getRegistrationInformation();
- throw new TriggerManagementException(
- String.format(
- "Failed to register trigger %s(%s), because a trigger %s(%s) has already been registered on the timeseries %s.",
- plan.getTriggerName(),
- plan.getClassName(),
- information.getTriggerName(),
- information.getClassName(),
- imNode.getFullPath()));
- }
-
- executor = executors.get(plan.getTriggerName());
- if (executor != null) {
- TriggerRegistrationInformation information = executor.getRegistrationInformation();
- throw new TriggerManagementException(
- information.getClassName().equals(plan.getClassName())
- ? String.format(
- "Failed to register trigger %s(%s), because a trigger with the same trigger name and the class name has already been registered.",
- plan.getTriggerName(), plan.getClassName())
- : String.format(
- "Failed to register trigger %s(%s), because a trigger %s(%s) with the same trigger name but a different class name has already been registered.",
- plan.getTriggerName(),
- plan.getClassName(),
- information.getTriggerName(),
- information.getClassName()));
- }
- }
-
- private IMNode tryGetMNode(CreateTriggerPlan plan) throws TriggerManagementException {
- try {
- IMNode imNode = IoTDB.schemaProcessor.getMNodeForTrigger(plan.getFullPath());
- if (imNode == null) {
- throw new TriggerManagementException(
- String.format("Path [%s] does not exist", plan.getFullPath().getFullPath()));
- }
- return imNode;
- } catch (MetadataException e) {
- throw new TriggerManagementException(e.getMessage(), e);
- }
- }
-
- private void tryAppendRegistrationLog(CreateTriggerPlan plan) throws TriggerManagementException {
- try {
- logWriter.write(plan);
- } catch (IOException e) {
- throw new TriggerManagementException(
- String.format(
- "Failed to append trigger management operation log when registering trigger %s(%s), because %s",
- plan.getTriggerName(), plan.getClassName(), e));
- }
- }
-
- private void doRegister(CreateTriggerPlan plan, IMNode imNode)
- throws TriggerManagementException, TriggerExecutionException {
- TriggerRegistrationInformation information = new TriggerRegistrationInformation(plan);
- TriggerClassLoader classLoader =
- TriggerClassLoaderManager.getInstance().register(plan.getClassName());
-
- TriggerExecutor executor;
- try {
- executor = new TriggerExecutor(information, classLoader, imNode);
- executor.onCreate();
- } catch (TriggerManagementException | TriggerExecutionException e) {
- TriggerClassLoaderManager.getInstance().deregister(plan.getClassName());
- throw e;
- }
-
- executors.put(plan.getTriggerName(), executor);
- imNode.setTriggerExecutor(executor);
-
- // update id table
- if (CONFIG.isEnableIDTable()) {
- try {
- IDTable idTable =
- IDTableManager.getInstance().getIDTable(plan.getFullPath().getDevicePath());
- if (executor.getIMNode().isMeasurement()) {
- idTable.registerTrigger(plan.getFullPath(), (IMeasurementMNode) imNode);
- }
- } catch (MetadataException e) {
- throw new TriggerManagementException(e.getMessage(), e);
- }
- }
- }
-
- public synchronized void deregister(DropTriggerPlan plan) throws TriggerManagementException {
- getTriggerExecutorWithExistenceCheck(plan.getTriggerName());
- tryAppendDeregistrationLog(plan);
- doDeregister(plan);
- }
-
- private TriggerExecutor getTriggerExecutorWithExistenceCheck(String triggerName)
- throws TriggerManagementException {
- TriggerExecutor executor = executors.get(triggerName);
-
- if (executor == null) {
- throw new TriggerManagementException(
- String.format("Trigger %s does not exist.", triggerName));
- }
-
- return executor;
- }
-
- private void tryAppendDeregistrationLog(DropTriggerPlan plan) throws TriggerManagementException {
- try {
- logWriter.write(plan);
- } catch (IOException e) {
- throw new TriggerManagementException(
- String.format(
- "Failed to drop trigger %s because the operation plan was failed to log: %s",
- plan.getTriggerName(), e));
- }
- }
-
- private void doDeregister(DropTriggerPlan plan) throws TriggerManagementException {
- TriggerExecutor executor = executors.remove(plan.getTriggerName());
-
- IMNode imNode = executor.getIMNode();
- try {
- imNode.setTriggerExecutor(null);
- IoTDB.schemaProcessor.releaseMNodeAfterDropTrigger(imNode);
- } catch (MetadataException e) {
- throw new TriggerManagementException(e.getMessage(), e);
- }
-
- try {
- executor.onDrop();
- } catch (TriggerExecutionException e) {
- LOGGER.warn(e.getMessage(), e);
- }
-
- TriggerClassLoaderManager.getInstance()
- .deregister(executor.getRegistrationInformation().getClassName());
-
- // update id table
- if (CONFIG.isEnableIDTable()) {
- try {
- PartialPath fullPath = executor.getIMNode().getPartialPath();
- IDTable idTable = IDTableManager.getInstance().getIDTable(fullPath.getDevicePath());
- if (executor.getIMNode().isMeasurement()) {
- idTable.deregisterTrigger(fullPath, (IMeasurementMNode) executor.getIMNode());
- }
- } catch (MetadataException e) {
- throw new TriggerManagementException(e.getMessage(), e);
- }
- }
- }
-
- public void activate(StartTriggerPlan plan)
- throws TriggerManagementException, TriggerExecutionException {
- TriggerExecutor executor = getTriggerExecutorWithExistenceCheck(plan.getTriggerName());
-
- if (!executor.getRegistrationInformation().isStopped()) {
- throw new TriggerManagementException(
- String.format("Trigger %s has already been started.", plan.getTriggerName()));
- }
-
- try {
- logWriter.write(plan);
- } catch (IOException e) {
- throw new TriggerManagementException(
- String.format(
- "Failed to append trigger management operation log when starting trigger %s, because %s",
- plan.getTriggerName(), e));
- }
-
- executor.onStart();
- }
-
- public void inactivate(StopTriggerPlan plan) throws TriggerManagementException {
- TriggerExecutor executor = getTriggerExecutorWithExistenceCheck(plan.getTriggerName());
-
- if (executor.getRegistrationInformation().isStopped()) {
- throw new TriggerManagementException(
- String.format("Trigger %s has already been stopped.", plan.getTriggerName()));
- }
-
- try {
- logWriter.write(plan);
- } catch (IOException e) {
- throw new TriggerManagementException(
- String.format(
- "Failed to append trigger management operation log when stopping trigger %s, because %s",
- plan.getTriggerName(), e));
- }
-
- try {
- executor.onStop();
- } catch (TriggerExecutionException e) {
- LOGGER.warn(
- "Failed to stop the executor of trigger {}({})",
- executor.getRegistrationInformation().getTriggerName(),
- executor.getRegistrationInformation().getClassName(),
- e);
- }
- }
-
- public QueryDataSet show() {
- ListDataSet dataSet =
- new ListDataSet(
- Arrays.asList(
- new PartialPath(COLUMN_TRIGGER_NAME, false),
- new PartialPath(COLUMN_TRIGGER_STATUS, false),
- new PartialPath(COLUMN_TRIGGER_EVENT, false),
- new PartialPath(COLUMN_TRIGGER_PATH, false),
- new PartialPath(COLUMN_TRIGGER_CLASS, false),
- new PartialPath(COLUMN_TRIGGER_ATTRIBUTES, false)),
- Arrays.asList(
- TSDataType.TEXT,
- TSDataType.TEXT,
- TSDataType.TEXT,
- TSDataType.TEXT,
- TSDataType.TEXT,
- TSDataType.TEXT));
- putTriggerRecords(dataSet);
- return dataSet;
- }
-
- private void putTriggerRecords(ListDataSet dataSet) {
- for (TriggerExecutor executor : executors.values().toArray(new TriggerExecutor[0])) {
- TriggerRegistrationInformation information = executor.getRegistrationInformation();
-
- RowRecord rowRecord = new RowRecord(0); // ignore timestamp
- rowRecord.addField(Binary.valueOf(information.getTriggerName()), TSDataType.TEXT);
- rowRecord.addField(
- Binary.valueOf(
- information.isStopped()
- ? COLUMN_TRIGGER_STATUS_STOPPED
- : COLUMN_TRIGGER_STATUS_STARTED),
- TSDataType.TEXT);
- rowRecord.addField(Binary.valueOf(information.getEvent().toString()), TSDataType.TEXT);
- rowRecord.addField(Binary.valueOf(information.getFullPath().getFullPath()), TSDataType.TEXT);
- rowRecord.addField(Binary.valueOf(information.getClassName()), TSDataType.TEXT);
- rowRecord.addField(Binary.valueOf(information.getAttributes().toString()), TSDataType.TEXT);
- dataSet.putRecord(rowRecord);
- }
- }
-
- @Override
- public void start() throws StartupException {
- try {
- makeDirIfNecessary(LIB_ROOT);
- makeDirIfNecessary(LOG_FILE_DIR);
- doRecovery();
- logWriter = new TriggerLogWriter(LOG_FILE_NAME);
- } catch (Exception e) {
- throw new StartupException(e);
- }
- }
-
- private static void makeDirIfNecessary(String dir) throws IOException {
- File file = SystemFileFactory.INSTANCE.getFile(dir);
- if (file.exists() && file.isDirectory()) {
- return;
- }
- FileUtils.forceMkdir(file);
- }
-
- private void doRecovery() throws IOException, TriggerManagementException {
- File temporaryLogFile = SystemFileFactory.INSTANCE.getFile(TEMPORARY_LOG_FILE_NAME);
- File logFile = SystemFileFactory.INSTANCE.getFile(LOG_FILE_NAME);
-
- if (temporaryLogFile.exists()) {
- if (logFile.exists()) {
- doRecoveryFromLogFile(logFile);
- FileUtils.deleteQuietly(temporaryLogFile);
- } else {
- doRecoveryFromLogFile(temporaryLogFile);
- FSFactoryProducer.getFSFactory().moveFile(temporaryLogFile, logFile);
- }
- } else if (logFile.exists()) {
- doRecoveryFromLogFile(logFile);
- }
- }
-
- private void doRecoveryFromLogFile(File logFile) throws IOException, TriggerManagementException {
- for (CreateTriggerPlan createTriggerPlan : recoverCreateTriggerPlans(logFile)) {
- try {
- doRegister(createTriggerPlan, tryGetMNode(createTriggerPlan));
- if (createTriggerPlan.isStopped()) {
- executors.get(createTriggerPlan.getTriggerName()).onStop();
- }
- } catch (TriggerExecutionException | TriggerManagementException e) {
- LOGGER.error(
- "Failed to register the trigger {}({}) during recovering.",
- createTriggerPlan.getTriggerName(),
- createTriggerPlan.getClassName());
- }
- }
- }
-
- private Collection<CreateTriggerPlan> recoverCreateTriggerPlans(File logFile)
- throws IOException, TriggerManagementException {
- Map<String, CreateTriggerPlan> recoveredCreateTriggerPlans = new HashMap<>();
-
- try (TriggerLogReader reader = new TriggerLogReader(logFile)) {
- while (reader.hasNext()) {
- PhysicalPlan plan = reader.next();
- CreateTriggerPlan createTriggerPlan;
- switch (plan.getOperatorType()) {
- case CREATE_TRIGGER:
- recoveredCreateTriggerPlans.put(
- ((CreateTriggerPlan) plan).getTriggerName(), (CreateTriggerPlan) plan);
- break;
- case DROP_TRIGGER:
- recoveredCreateTriggerPlans.remove(((DropTriggerPlan) plan).getTriggerName());
- break;
- case START_TRIGGER:
- createTriggerPlan =
- recoveredCreateTriggerPlans.get(((StartTriggerPlan) plan).getTriggerName());
- if (createTriggerPlan != null) {
- createTriggerPlan.markAsStarted();
- }
- break;
- case STOP_TRIGGER:
- createTriggerPlan =
- recoveredCreateTriggerPlans.get(((StopTriggerPlan) plan).getTriggerName());
- if (createTriggerPlan != null) {
- createTriggerPlan.markAsStopped();
- }
- break;
- default:
- throw new TriggerManagementException(
- "Unrecognized trigger management operation plan is recovered.");
- }
- }
- }
-
- return recoveredCreateTriggerPlans.values();
- }
-
- @Override
- public void stop() {
- try {
- writeTemporaryLogFile();
-
- logWriter.close();
- logWriter.deleteLogFile();
-
- File temporaryLogFile = SystemFileFactory.INSTANCE.getFile(TEMPORARY_LOG_FILE_NAME);
- File logFile = SystemFileFactory.INSTANCE.getFile(LOG_FILE_NAME);
- FSFactoryProducer.getFSFactory().moveFile(temporaryLogFile, logFile);
- } catch (IOException ignored) {
- // ignored
- }
- }
-
- private void writeTemporaryLogFile() throws IOException {
- try (TriggerLogWriter temporaryLogWriter = new TriggerLogWriter(TEMPORARY_LOG_FILE_NAME)) {
- for (TriggerExecutor executor : executors.values()) {
- TriggerRegistrationInformation information = executor.getRegistrationInformation();
- temporaryLogWriter.write(information.convertToCreateTriggerPlan());
- if (information.isStopped()) {
- temporaryLogWriter.write(new StopTriggerPlan(information.getTriggerName()));
- }
- }
- }
- }
-
- @TestOnly
- public void deregisterAll() throws TriggerManagementException {
- for (TriggerExecutor executor : executors.values()) {
- deregister(new DropTriggerPlan(executor.getRegistrationInformation().getTriggerName()));
- }
- }
-
- @TestOnly
- public Trigger getTriggerInstance(String triggerName) throws TriggerManagementException {
- return getTriggerExecutorWithExistenceCheck(triggerName).getTrigger();
- }
-
- @TestOnly
- public TriggerRegistrationInformation getRegistrationInformation(String triggerName)
- throws TriggerManagementException {
- return getTriggerExecutorWithExistenceCheck(triggerName).getRegistrationInformation();
- }
-
- @Override
- public ServiceType getID() {
- return ServiceType.TRIGGER_REGISTRATION_SERVICE_OLD;
- }
-
- public int executorSize() {
- return executors.size();
- }
-
- public static TriggerRegistrationService getInstance() {
- return TriggerRegistrationService.TriggerRegistrationServiceHelper.INSTANCE;
- }
-
- private static class TriggerRegistrationServiceHelper {
-
- private static final TriggerRegistrationService INSTANCE = new TriggerRegistrationService();
-
- private TriggerRegistrationServiceHelper() {}
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/exception/TriggerExecutionException.java b/server/src/main/java/org/apache/iotdb/db/exception/TriggerExecutionException.java
deleted file mode 100644
index ac3684be22..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/exception/TriggerExecutionException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.exception;
-
-public class TriggerExecutionException extends StorageEngineException {
-
- public TriggerExecutionException(String message, Throwable cause) {
- super(message);
- this.initCause(cause);
- }
-
- public TriggerExecutionException(String message) {
- super(message);
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/exception/TriggerManagementException.java b/server/src/main/java/org/apache/iotdb/db/exception/TriggerManagementException.java
deleted file mode 100644
index 2565f11382..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/exception/TriggerManagementException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.exception;
-
-public class TriggerManagementException extends StorageEngineException {
-
- public TriggerManagementException(String message, Throwable cause) {
- super(message);
- this.initCause(cause);
- }
-
- public TriggerManagementException(String message) {
- super(message);
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/idtable/entry/InsertMeasurementMNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/idtable/entry/InsertMeasurementMNode.java
index c326c968cd..9c246ac2ec 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/idtable/entry/InsertMeasurementMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/idtable/entry/InsertMeasurementMNode.java
@@ -19,10 +19,8 @@
package org.apache.iotdb.db.metadata.idtable.entry;
-import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.path.MeasurementPath;
import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerExecutor;
import org.apache.iotdb.db.metadata.lastCache.container.ILastCacheContainer;
import org.apache.iotdb.db.metadata.logfile.MLogWriter;
import org.apache.iotdb.db.metadata.mnode.IEntityMNode;
@@ -38,9 +36,6 @@ import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Generated entity implements IMeasurementMNode interface to unify insert logic through id table
* and SchemaProcessor
@@ -48,16 +43,9 @@ import java.util.List;
public class InsertMeasurementMNode implements IMeasurementMNode {
SchemaEntry schemaEntry;
- TriggerExecutor triggerExecutor;
-
IMeasurementSchema schema;
public InsertMeasurementMNode(String measurementId, SchemaEntry schemaEntry) {
- this(measurementId, schemaEntry, null);
- }
-
- public InsertMeasurementMNode(
- String measurementId, SchemaEntry schemaEntry, TriggerExecutor executor) {
this.schemaEntry = schemaEntry;
schema =
new MeasurementSchema(
@@ -65,31 +53,10 @@ public class InsertMeasurementMNode implements IMeasurementMNode {
schemaEntry.getTSDataType(),
schemaEntry.getTSEncoding(),
schemaEntry.getCompressionType());
- triggerExecutor = executor;
}
// region support methods
- @Override
- public List<TriggerExecutor> getUpperTriggerExecutorList() {
- IMNode currentNode = this;
- List<TriggerExecutor> results = new ArrayList<>();
- while (currentNode != null && !IoTDBConstant.PATH_ROOT.equals(currentNode.getName())) {
- TriggerExecutor executor = currentNode.getTriggerExecutor();
- currentNode = currentNode.getParent();
- if (executor == null) {
- continue;
- }
- results.add(executor);
- }
- return results;
- }
-
- @Override
- public TriggerExecutor getTriggerExecutor() {
- return triggerExecutor;
- }
-
@Override
public ILastCacheContainer getLastCacheContainer() {
return schemaEntry;
@@ -337,9 +304,5 @@ public class InsertMeasurementMNode implements IMeasurementMNode {
throw new UnsupportedOperationException("insert measurement mnode doesn't support this method");
}
- @Override
- public void setTriggerExecutor(TriggerExecutor triggerExecutor) {
- throw new UnsupportedOperationException("insert measurement mnode doesn't support this method");
- }
// endregion
}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMNode.java
index 419d9ec8f9..c9e1ce2eb8 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMNode.java
@@ -19,7 +19,6 @@
package org.apache.iotdb.db.metadata.mnode;
import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerExecutor;
import org.apache.iotdb.db.metadata.logfile.MLogWriter;
import org.apache.iotdb.db.metadata.mnode.container.IMNodeContainer;
import org.apache.iotdb.db.metadata.mnode.visitor.MNodeVisitor;
@@ -28,7 +27,6 @@ import org.apache.iotdb.db.metadata.template.Template;
import java.io.IOException;
import java.io.Serializable;
-import java.util.List;
/** This interface defines a MNode's operation interfaces. */
public interface IMNode extends Serializable {
@@ -104,12 +102,6 @@ public interface IMNode extends Serializable {
IMeasurementMNode getAsMeasurementMNode();
- List<TriggerExecutor> getUpperTriggerExecutorList();
-
- TriggerExecutor getTriggerExecutor();
-
- void setTriggerExecutor(TriggerExecutor triggerExecutor);
-
void serializeTo(MLogWriter logWriter) throws IOException;
CacheEntry getCacheEntry();
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMeasurementMNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMeasurementMNode.java
index 3943beed2f..6b52235b40 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMeasurementMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/IMeasurementMNode.java
@@ -19,7 +19,6 @@
package org.apache.iotdb.db.metadata.mnode;
import org.apache.iotdb.commons.path.MeasurementPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerExecutor;
import org.apache.iotdb.db.metadata.lastCache.container.ILastCacheContainer;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
@@ -44,10 +43,6 @@ public interface IMeasurementMNode extends IMNode {
void setOffset(long offset);
- TriggerExecutor getTriggerExecutor();
-
- void setTriggerExecutor(TriggerExecutor triggerExecutor);
-
ILastCacheContainer getLastCacheContainer();
void setLastCacheContainer(ILastCacheContainer lastCacheContainer);
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MNode.java
index 153a13de5e..95cb468267 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MNode.java
@@ -20,7 +20,6 @@ package org.apache.iotdb.db.metadata.mnode;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerExecutor;
import org.apache.iotdb.db.metadata.mtree.store.disk.cache.CacheEntry;
import java.util.ArrayList;
@@ -37,9 +36,6 @@ public abstract class MNode implements IMNode {
/** from root to this node, only be set when used once for InternalMNode */
protected String fullPath;
- /** registered trigger */
- protected TriggerExecutor triggerExecutor;
-
protected CacheEntry cacheEntry;
/** Constructor of MNode. */
@@ -162,31 +158,6 @@ public abstract class MNode implements IMNode {
}
}
- @Override
- public List<TriggerExecutor> getUpperTriggerExecutorList() {
- IMNode currentNode = this;
- List<TriggerExecutor> results = new ArrayList<>();
- while (currentNode != null && !IoTDBConstant.PATH_ROOT.equals(currentNode.getName())) {
- TriggerExecutor executor = currentNode.getTriggerExecutor();
- currentNode = currentNode.getParent();
- if (executor == null) {
- continue;
- }
- results.add(executor);
- }
- return results;
- }
-
- @Override
- public TriggerExecutor getTriggerExecutor() {
- return triggerExecutor;
- }
-
- @Override
- public void setTriggerExecutor(TriggerExecutor triggerExecutor) {
- this.triggerExecutor = triggerExecutor;
- }
-
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
index efe1094ecf..89b9e366a3 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/MeasurementMNode.java
@@ -19,7 +19,6 @@
package org.apache.iotdb.db.metadata.mnode;
import org.apache.iotdb.commons.path.MeasurementPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerExecutor;
import org.apache.iotdb.db.metadata.lastCache.container.ILastCacheContainer;
import org.apache.iotdb.db.metadata.lastCache.container.LastCacheContainer;
import org.apache.iotdb.db.metadata.logfile.MLogWriter;
@@ -124,16 +123,6 @@ public class MeasurementMNode extends MNode implements IMeasurementMNode {
this.alias = alias;
}
- @Override
- public TriggerExecutor getTriggerExecutor() {
- return triggerExecutor;
- }
-
- @Override
- public void setTriggerExecutor(TriggerExecutor triggerExecutor) {
- this.triggerExecutor = triggerExecutor;
- }
-
@Override
public ILastCacheContainer getLastCacheContainer() {
if (lastCacheContainer == null) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
index cf791102ac..0f96d4784f 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
@@ -29,7 +29,6 @@ import org.apache.iotdb.commons.utils.FileUtils;
import org.apache.iotdb.consensus.ConsensusFactory;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerEngine;
import org.apache.iotdb.db.exception.metadata.MeasurementAlreadyExistException;
import org.apache.iotdb.db.exception.metadata.PathAlreadyExistException;
import org.apache.iotdb.db.exception.metadata.PathNotExistException;
@@ -440,8 +439,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
if (seriesNumerMonitor != null) {
seriesNumerMonitor.deleteTimeSeries(seriesCount);
}
- // drop triggers with no exceptions
- TriggerEngine.drop(leafMNodes);
// clear all the components and release all the file handlers
clear();
@@ -909,9 +906,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
removeFromTagInvertedIndex(measurementMNode);
PartialPath storageGroupPath = pair.left;
- // drop trigger with no exceptions
- TriggerEngine.drop(pair.right);
-
IMNode node = measurementMNode.getParent();
if (node.isUseTemplate() && node.getSchemaTemplate().hasSchema(measurementMNode.getName())) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
index 6daed3b6a5..8588f34829 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
@@ -28,7 +28,6 @@ import org.apache.iotdb.commons.path.PathPatternTree;
import org.apache.iotdb.consensus.ConsensusFactory;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerEngine;
import org.apache.iotdb.db.exception.metadata.AliasAlreadyExistException;
import org.apache.iotdb.db.exception.metadata.PathAlreadyExistException;
import org.apache.iotdb.db.exception.metadata.PathNotExistException;
@@ -428,8 +427,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
if (seriesNumerMonitor != null) {
seriesNumerMonitor.deleteTimeSeries(seriesCount);
}
- // drop triggers with no exceptions
- TriggerEngine.drop(leafMNodes);
// clear all the components and release all the file handlers
clear();
@@ -990,9 +987,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
removeFromTagInvertedIndex(measurementMNode);
PartialPath storageGroupPath = pair.left;
- // drop trigger with no exceptions
- TriggerEngine.drop(pair.right);
-
IMNode node = measurementMNode.getParent();
if (node.isUseTemplate() && node.getSchemaTemplate().hasSchema(measurementMNode.getName())) {
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index 9eda4e1d95..05a90db802 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -39,7 +39,6 @@ import org.apache.iotdb.db.engine.cache.BloomFilterCache;
import org.apache.iotdb.db.engine.cache.ChunkCache;
import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache;
import org.apache.iotdb.db.engine.flush.pool.FlushTaskPoolManager;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
import org.apache.iotdb.db.exception.StorageEngineException;
import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
@@ -269,8 +268,6 @@ public class PlanExecutor implements IPlanExecutor {
return processShowQueryProcesslist();
case FUNCTIONS:
return processShowFunctions();
- case TRIGGERS:
- return processShowTriggers();
case CONTINUOUS_QUERY:
throw new UnsupportedOperationException();
case SCHEMA_TEMPLATE:
@@ -731,10 +728,6 @@ public class PlanExecutor implements IPlanExecutor {
}
}
- private QueryDataSet processShowTriggers() {
- return TriggerRegistrationService.getInstance().show();
- }
-
private void addRowRecordForShowQuery(
ListDataSet listDataSet, int timestamp, String item, String value) {
RowRecord rowRecord = new RowRecord(timestamp);
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/CreateTriggerOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/CreateTriggerOperator.java
deleted file mode 100644
index 26a3732d0b..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/CreateTriggerOperator.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.qp.logical.sys;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerEvent;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.qp.logical.Operator;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTriggerPlan;
-import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class CreateTriggerOperator extends Operator {
-
- private String triggerName;
- private TriggerEvent event;
- private PartialPath fullPath;
- private String className;
- private final Map<String, String> attributes;
-
- public CreateTriggerOperator(int tokenIntType) {
- super(tokenIntType);
- operatorType = OperatorType.CREATE_TRIGGER;
- attributes = new HashMap<>();
- }
-
- public void setTriggerName(String triggerName) {
- this.triggerName = triggerName;
- }
-
- public void setEvent(TriggerEvent event) {
- this.event = event;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public void setFullPath(PartialPath fullPath) {
- this.fullPath = fullPath;
- }
-
- public void addAttribute(String key, String value) {
- attributes.put(key, value);
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- public TriggerEvent getEvent() {
- return event;
- }
-
- public String getClassName() {
- return className;
- }
-
- public PartialPath getFullPath() {
- return fullPath;
- }
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
- @Override
- public PhysicalPlan generatePhysicalPlan(PhysicalGenerator generator)
- throws QueryProcessException {
- return new CreateTriggerPlan(triggerName, event, fullPath, className, attributes);
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/DropTriggerOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/DropTriggerOperator.java
deleted file mode 100644
index b6dbddaffe..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/DropTriggerOperator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.qp.logical.sys;
-
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.qp.logical.Operator;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTriggerPlan;
-import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
-
-public class DropTriggerOperator extends Operator {
-
- private String triggerName;
-
- public DropTriggerOperator(int tokenIntType) {
- super(tokenIntType);
- operatorType = OperatorType.DROP_TRIGGER;
- }
-
- public void setTriggerName(String triggerName) {
- this.triggerName = triggerName;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- @Override
- public PhysicalPlan generatePhysicalPlan(PhysicalGenerator generator)
- throws QueryProcessException {
- return new DropTriggerPlan(triggerName);
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/StartTriggerOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/StartTriggerOperator.java
deleted file mode 100644
index 4d18023fe1..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/StartTriggerOperator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.qp.logical.sys;
-
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.qp.logical.Operator;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.StartTriggerPlan;
-import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
-
-public class StartTriggerOperator extends Operator {
-
- private String triggerName;
-
- public StartTriggerOperator(int tokenIntType) {
- super(tokenIntType);
- operatorType = OperatorType.START_TRIGGER;
- }
-
- public void setTriggerName(String triggerName) {
- this.triggerName = triggerName;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- @Override
- public PhysicalPlan generatePhysicalPlan(PhysicalGenerator generator)
- throws QueryProcessException {
- return new StartTriggerPlan(triggerName);
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/StopTriggerOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/StopTriggerOperator.java
deleted file mode 100644
index 73a9fe3966..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/sys/StopTriggerOperator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.qp.logical.sys;
-
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.qp.logical.Operator;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-import org.apache.iotdb.db.qp.physical.sys.StopTriggerPlan;
-import org.apache.iotdb.db.qp.strategy.PhysicalGenerator;
-
-public class StopTriggerOperator extends Operator {
-
- private String triggerName;
-
- public StopTriggerOperator(int tokenIntType) {
- super(tokenIntType);
- operatorType = OperatorType.STOP_TRIGGER;
- }
-
- public void setTriggerName(String triggerName) {
- this.triggerName = triggerName;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- @Override
- public PhysicalPlan generatePhysicalPlan(PhysicalGenerator generator)
- throws QueryProcessException {
- return new StopTriggerPlan(triggerName);
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/PhysicalPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/PhysicalPlan.java
index 52df1bef5f..df59500d86 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/PhysicalPlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/PhysicalPlan.java
@@ -42,7 +42,6 @@ import org.apache.iotdb.db.qp.physical.sys.CreateIndexPlan;
import org.apache.iotdb.db.qp.physical.sys.CreateMultiTimeSeriesPlan;
import org.apache.iotdb.db.qp.physical.sys.CreateTemplatePlan;
import org.apache.iotdb.db.qp.physical.sys.CreateTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.CreateTriggerPlan;
import org.apache.iotdb.db.qp.physical.sys.DataAuthPlan;
import org.apache.iotdb.db.qp.physical.sys.DeleteStorageGroupPlan;
import org.apache.iotdb.db.qp.physical.sys.DeleteTimeSeriesPlan;
@@ -50,7 +49,6 @@ import org.apache.iotdb.db.qp.physical.sys.DropContinuousQueryPlan;
import org.apache.iotdb.db.qp.physical.sys.DropFunctionPlan;
import org.apache.iotdb.db.qp.physical.sys.DropIndexPlan;
import org.apache.iotdb.db.qp.physical.sys.DropTemplatePlan;
-import org.apache.iotdb.db.qp.physical.sys.DropTriggerPlan;
import org.apache.iotdb.db.qp.physical.sys.FlushPlan;
import org.apache.iotdb.db.qp.physical.sys.LoadConfigurationPlan;
import org.apache.iotdb.db.qp.physical.sys.LogPlan;
@@ -66,8 +64,6 @@ import org.apache.iotdb.db.qp.physical.sys.SetTTLPlan;
import org.apache.iotdb.db.qp.physical.sys.SetTemplatePlan;
import org.apache.iotdb.db.qp.physical.sys.ShowDevicesPlan;
import org.apache.iotdb.db.qp.physical.sys.ShowTimeSeriesPlan;
-import org.apache.iotdb.db.qp.physical.sys.StartTriggerPlan;
-import org.apache.iotdb.db.qp.physical.sys.StopTriggerPlan;
import org.apache.iotdb.db.qp.physical.sys.StorageGroupMNodePlan;
import org.apache.iotdb.db.qp.physical.sys.UnsetTemplatePlan;
import org.apache.iotdb.tsfile.utils.PublicBAOS;
@@ -403,18 +399,6 @@ public abstract class PhysicalPlan implements IConsensusRequest {
case STORAGE_GROUP_MNODE:
plan = new StorageGroupMNodePlan();
break;
- case CREATE_TRIGGER:
- plan = new CreateTriggerPlan();
- break;
- case DROP_TRIGGER:
- plan = new DropTriggerPlan();
- break;
- case START_TRIGGER:
- plan = new StartTriggerPlan();
- break;
- case STOP_TRIGGER:
- plan = new StopTriggerPlan();
- break;
case CLUSTER_LOG:
plan = new LogPlan();
break;
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateTriggerPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateTriggerPlan.java
deleted file mode 100644
index 81f8697e68..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateTriggerPlan.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.qp.physical.sys;
-
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerEvent;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
-import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-public class CreateTriggerPlan extends PhysicalPlan {
-
- private String triggerName;
- private TriggerEvent event;
- private PartialPath fullPath;
- private String className;
- private Map<String, String> attributes;
-
- /**
- * This field is mainly used for the stage of recovering trigger registration information, so it
- * will never be serialized into a log file.
- *
- * <p>Note that the status of triggers registered by executing SQL statements is STARTED by
- * default, so this field should be {@code false} by default.
- *
- * @see TriggerRegistrationService
- */
- private boolean isStopped = false;
-
- public CreateTriggerPlan() {
- super(OperatorType.CREATE_TRIGGER);
- canBeSplit = false;
- }
-
- public CreateTriggerPlan(
- String triggerName,
- TriggerEvent event,
- PartialPath fullPath,
- String className,
- Map<String, String> attributes) {
- super(OperatorType.CREATE_TRIGGER);
- this.triggerName = triggerName;
- this.event = event;
- this.fullPath = fullPath;
- this.className = className;
- this.attributes = attributes;
- canBeSplit = false;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- public TriggerEvent getEvent() {
- return event;
- }
-
- public PartialPath getFullPath() {
- return fullPath;
- }
-
- public String getClassName() {
- return className;
- }
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
- public boolean isStopped() {
- return isStopped;
- }
-
- public void markAsStarted() {
- isStopped = false;
- }
-
- public void markAsStopped() {
- isStopped = true;
- }
-
- @Override
- public List<PartialPath> getPaths() {
- return Collections.emptyList();
- }
-
- @Override
- public void serialize(DataOutputStream stream) throws IOException {
- stream.writeByte((byte) PhysicalPlanType.CREATE_TRIGGER.ordinal());
-
- putString(stream, triggerName);
- stream.write(event.getId());
- putString(stream, fullPath.getFullPath());
- putString(stream, className);
-
- stream.writeInt(attributes.size());
- for (Entry<String, String> attribute : attributes.entrySet()) {
- putString(stream, attribute.getKey());
- putString(stream, attribute.getValue());
- }
- }
-
- @Override
- public void serializeImpl(ByteBuffer buffer) {
- buffer.put((byte) PhysicalPlanType.CREATE_TRIGGER.ordinal());
-
- putString(buffer, triggerName);
- buffer.put(event.getId());
- putString(buffer, fullPath.getFullPath());
- putString(buffer, className);
-
- buffer.putInt(attributes.size());
- for (Entry<String, String> attribute : attributes.entrySet()) {
- putString(buffer, attribute.getKey());
- putString(buffer, attribute.getValue());
- }
- }
-
- @Override
- public void deserialize(ByteBuffer buffer) throws IllegalPathException {
- triggerName = readString(buffer);
- event = TriggerEvent.construct(buffer.get());
- fullPath = new PartialPath(readString(buffer));
- className = readString(buffer);
-
- attributes = new HashMap<>();
- int attributeNumber = buffer.getInt();
- for (int i = 0; i < attributeNumber; ++i) {
- String key = readString(buffer);
- String value = readString(buffer);
- attributes.put(key, value);
- }
- }
-
- @Override
- public List<? extends PartialPath> getAuthPaths() {
- return Collections.singletonList(fullPath);
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/DropTriggerPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/DropTriggerPlan.java
deleted file mode 100644
index 0de74fef72..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/DropTriggerPlan.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.qp.physical.sys;
-
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.List;
-
-public class DropTriggerPlan extends PhysicalPlan {
-
- private String triggerName;
-
- private PartialPath authPath;
-
- public DropTriggerPlan() {
- super(OperatorType.DROP_TRIGGER);
- canBeSplit = false;
- }
-
- public DropTriggerPlan(String triggerName) {
- super(OperatorType.DROP_TRIGGER);
- this.triggerName = triggerName;
- canBeSplit = false;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- @Override
- public List<PartialPath> getPaths() {
- return Collections.emptyList();
- }
-
- @Override
- public void serialize(DataOutputStream stream) throws IOException {
- stream.writeByte((byte) PhysicalPlanType.DROP_TRIGGER.ordinal());
-
- putString(stream, triggerName);
- }
-
- @Override
- public void serializeImpl(ByteBuffer buffer) {
- buffer.put((byte) PhysicalPlanType.DROP_TRIGGER.ordinal());
-
- putString(buffer, triggerName);
- }
-
- @Override
- public void deserialize(ByteBuffer buffer) throws IllegalPathException {
- triggerName = readString(buffer);
- }
-
- @Override
- public boolean isAuthenticationRequired() {
- if (authPath == null) {
- try {
- authPath =
- TriggerRegistrationService.getInstance()
- .getRegistrationInformation(triggerName)
- .getFullPath();
- } catch (TriggerManagementException e) {
- // The trigger does not exist.
- return false;
- }
- }
- return true;
- }
-
- @Override
- public List<? extends PartialPath> getAuthPaths() {
- return isAuthenticationRequired()
- ? Collections.singletonList(authPath)
- : Collections.emptyList();
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/StartTriggerPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/StartTriggerPlan.java
deleted file mode 100644
index fad9f0f41b..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/StartTriggerPlan.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.qp.physical.sys;
-
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.List;
-
-public class StartTriggerPlan extends PhysicalPlan {
-
- private String triggerName;
-
- private PartialPath authPath;
-
- public StartTriggerPlan() {
- super(OperatorType.START_TRIGGER);
- canBeSplit = false;
- }
-
- public StartTriggerPlan(String triggerName) {
- super(OperatorType.START_TRIGGER);
- this.triggerName = triggerName;
- canBeSplit = false;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- @Override
- public List<PartialPath> getPaths() {
- return Collections.emptyList();
- }
-
- @Override
- public void serialize(DataOutputStream stream) throws IOException {
- stream.writeByte((byte) PhysicalPlanType.START_TRIGGER.ordinal());
-
- putString(stream, triggerName);
- }
-
- @Override
- public void serializeImpl(ByteBuffer buffer) {
- buffer.put((byte) PhysicalPlanType.START_TRIGGER.ordinal());
-
- putString(buffer, triggerName);
- }
-
- @Override
- public void deserialize(ByteBuffer buffer) throws IllegalPathException {
- triggerName = readString(buffer);
- }
-
- @Override
- public boolean isAuthenticationRequired() {
- if (authPath == null) {
- try {
- authPath =
- TriggerRegistrationService.getInstance()
- .getRegistrationInformation(triggerName)
- .getFullPath();
- } catch (TriggerManagementException e) {
- // The trigger does not exist.
- return false;
- }
- }
- return true;
- }
-
- @Override
- public List<? extends PartialPath> getAuthPaths() {
- return isAuthenticationRequired()
- ? Collections.singletonList(authPath)
- : Collections.emptyList();
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/StopTriggerPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/StopTriggerPlan.java
deleted file mode 100644
index 64e2c02f43..0000000000
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/StopTriggerPlan.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.qp.physical.sys;
-
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
-import org.apache.iotdb.db.exception.TriggerManagementException;
-import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
-import org.apache.iotdb.db.qp.physical.PhysicalPlan;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.List;
-
-public class StopTriggerPlan extends PhysicalPlan {
-
- private String triggerName;
-
- private PartialPath authPath;
-
- public StopTriggerPlan() {
- super(OperatorType.STOP_TRIGGER);
- canBeSplit = false;
- }
-
- public StopTriggerPlan(String triggerName) {
- super(OperatorType.STOP_TRIGGER);
- this.triggerName = triggerName;
- canBeSplit = false;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- @Override
- public List<PartialPath> getPaths() {
- return Collections.emptyList();
- }
-
- @Override
- public void serialize(DataOutputStream stream) throws IOException {
- stream.writeByte((byte) PhysicalPlanType.STOP_TRIGGER.ordinal());
-
- putString(stream, triggerName);
- }
-
- @Override
- public void serializeImpl(ByteBuffer buffer) {
- buffer.put((byte) PhysicalPlanType.STOP_TRIGGER.ordinal());
-
- putString(buffer, triggerName);
- }
-
- @Override
- public void deserialize(ByteBuffer buffer) throws IllegalPathException {
- triggerName = readString(buffer);
- }
-
- @Override
- public boolean isAuthenticationRequired() {
- if (authPath == null) {
- try {
- authPath =
- TriggerRegistrationService.getInstance()
- .getRegistrationInformation(triggerName)
- .getFullPath();
- } catch (TriggerManagementException e) {
- // The trigger does not exist.
- return false;
- }
- }
- return true;
- }
-
- @Override
- public List<? extends PartialPath> getAuthPaths() {
- return isAuthenticationRequired()
- ? Collections.singletonList(authPath)
- : Collections.emptyList();
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
index 2dcc1f6e80..5237b450b1 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
@@ -26,7 +26,6 @@ import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.engine.trigger.executor.TriggerEvent;
import org.apache.iotdb.db.exception.sql.SQLParserException;
import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.mpp.plan.expression.Expression;
@@ -100,7 +99,6 @@ import org.apache.iotdb.db.qp.logical.sys.CreatePipeOperator;
import org.apache.iotdb.db.qp.logical.sys.CreatePipeSinkOperator;
import org.apache.iotdb.db.qp.logical.sys.CreateTemplateOperator;
import org.apache.iotdb.db.qp.logical.sys.CreateTimeSeriesOperator;
-import org.apache.iotdb.db.qp.logical.sys.CreateTriggerOperator;
import org.apache.iotdb.db.qp.logical.sys.DataAuthOperator;
import org.apache.iotdb.db.qp.logical.sys.DeletePartitionOperator;
import org.apache.iotdb.db.qp.logical.sys.DeleteStorageGroupOperator;
@@ -110,7 +108,6 @@ import org.apache.iotdb.db.qp.logical.sys.DropFunctionOperator;
import org.apache.iotdb.db.qp.logical.sys.DropPipeOperator;
import org.apache.iotdb.db.qp.logical.sys.DropPipeSinkOperator;
import org.apache.iotdb.db.qp.logical.sys.DropTemplateOperator;
-import org.apache.iotdb.db.qp.logical.sys.DropTriggerOperator;
import org.apache.iotdb.db.qp.logical.sys.FlushOperator;
import org.apache.iotdb.db.qp.logical.sys.KillQueryOperator;
import org.apache.iotdb.db.qp.logical.sys.LoadConfigurationOperator;
@@ -144,9 +141,7 @@ import org.apache.iotdb.db.qp.logical.sys.ShowTemplatesOperator;
import org.apache.iotdb.db.qp.logical.sys.ShowTimeSeriesOperator;
import org.apache.iotdb.db.qp.logical.sys.ShowTriggersOperator;
import org.apache.iotdb.db.qp.logical.sys.StartPipeOperator;
-import org.apache.iotdb.db.qp.logical.sys.StartTriggerOperator;
import org.apache.iotdb.db.qp.logical.sys.StopPipeOperator;
-import org.apache.iotdb.db.qp.logical.sys.StopTriggerOperator;
import org.apache.iotdb.db.qp.logical.sys.UnSetTTLOperator;
import org.apache.iotdb.db.qp.logical.sys.UnloadFileOperator;
import org.apache.iotdb.db.qp.logical.sys.UnsetTemplateOperator;
@@ -627,33 +622,6 @@ public class IoTDBSqlVisitor extends IoTDBSqlParserBaseVisitor<Operator> {
return createFunctionOperator;
}
- // Create Trigger
-
- @Override
- public Operator visitCreateTrigger(IoTDBSqlParser.CreateTriggerContext ctx) {
- CreateTriggerOperator createTriggerOperator =
- new CreateTriggerOperator(SQLConstant.TOK_TRIGGER_CREATE);
- createTriggerOperator.setTriggerName(parseIdentifier(ctx.triggerName.getText()));
- if (ctx.triggerEventClause().DELETE() != null) {
- throw new SQLParserException("Trigger does not support DELETE as TRIGGER_EVENT for now.");
- }
- createTriggerOperator.setEvent(
- ctx.triggerEventClause().BEFORE() != null
- ? TriggerEvent.BEFORE_INSERT
- : TriggerEvent.AFTER_INSERT);
- createTriggerOperator.setFullPath(parsePrefixPath(ctx.prefixPath()));
- createTriggerOperator.setClassName(parseStringLiteral(ctx.className.getText()));
- if (ctx.triggerAttributeClause() != null) {
- for (IoTDBSqlParser.TriggerAttributeContext triggerAttributeContext :
- ctx.triggerAttributeClause().triggerAttribute()) {
- createTriggerOperator.addAttribute(
- parseAttributeKey(triggerAttributeContext.key),
- parseAttributeValue(triggerAttributeContext.value));
- }
- }
- return createTriggerOperator;
- }
-
// Create Continuous Query
@Override
@@ -925,15 +893,6 @@ public class IoTDBSqlVisitor extends IoTDBSqlParserBaseVisitor<Operator> {
return dropFunctionOperator;
}
- // Drop Trigger
-
- @Override
- public Operator visitDropTrigger(IoTDBSqlParser.DropTriggerContext ctx) {
- DropTriggerOperator dropTriggerOperator = new DropTriggerOperator(SQLConstant.TOK_TRIGGER_DROP);
- dropTriggerOperator.setTriggerName(parseIdentifier(ctx.triggerName.getText()));
- return dropTriggerOperator;
- }
-
// Drop Continuous Query
@Override
@@ -993,25 +952,6 @@ public class IoTDBSqlVisitor extends IoTDBSqlParserBaseVisitor<Operator> {
return operator;
}
- // Start Trigger
-
- @Override
- public Operator visitStartTrigger(IoTDBSqlParser.StartTriggerContext ctx) {
- StartTriggerOperator startTriggerOperator =
- new StartTriggerOperator(SQLConstant.TOK_TRIGGER_START);
- startTriggerOperator.setTriggerName(parseIdentifier(ctx.triggerName.getText()));
- return startTriggerOperator;
- }
-
- // Stop Trigger
-
- @Override
- public Operator visitStopTrigger(IoTDBSqlParser.StopTriggerContext ctx) {
- StopTriggerOperator stopTriggerOperator = new StopTriggerOperator(SQLConstant.TOK_TRIGGER_STOP);
- stopTriggerOperator.setTriggerName(parseIdentifier(ctx.triggerName.getText()));
- return stopTriggerOperator;
- }
-
// SHOW DATABASES
@Override
diff --git a/server/src/main/java/org/apache/iotdb/db/service/DataNode.java b/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
index 4a85a5304e..f2a22b3dd9 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
@@ -57,7 +57,6 @@ import org.apache.iotdb.db.engine.StorageEngineV2;
import org.apache.iotdb.db.engine.cache.CacheHitRatioMonitor;
import org.apache.iotdb.db.engine.compaction.CompactionTaskManager;
import org.apache.iotdb.db.engine.flush.FlushManager;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.metadata.schemaregion.SchemaEngine;
import org.apache.iotdb.db.metadata.template.ClusterTemplateManager;
@@ -363,7 +362,6 @@ public class DataNode implements DataNodeMBean {
// in mpp mode we temporarily don't start settle service because it uses StorageEngine directly
// in itself, but currently we need to use StorageEngineV2 instead of StorageEngine in mpp mode.
// registerManager.register(SettleService.getINSTANCE());
- registerManager.register(TriggerRegistrationService.getInstance());
// start region migrate service
registerManager.register(RegionMigrateService.getInstance());
diff --git a/server/src/main/java/org/apache/iotdb/db/service/IoTDB.java b/server/src/main/java/org/apache/iotdb/db/service/IoTDB.java
index 00bd50dd0b..dfac8a85d4 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/IoTDB.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/IoTDB.java
@@ -35,7 +35,6 @@ import org.apache.iotdb.db.engine.StorageEngine;
import org.apache.iotdb.db.engine.cache.CacheHitRatioMonitor;
import org.apache.iotdb.db.engine.compaction.CompactionTaskManager;
import org.apache.iotdb.db.engine.flush.FlushManager;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.localconfignode.LocalConfigNode;
import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
@@ -174,7 +173,6 @@ public class IoTDB implements IoTDBMBean {
registerManager.register(UpgradeSevice.getINSTANCE());
registerManager.register(SettleService.getINSTANCE());
- registerManager.register(TriggerRegistrationService.getInstance());
registerManager.register(MetricService.getInstance());
// bind predefined metrics
DataNodeMetricsHelper.bind();
diff --git a/server/src/main/java/org/apache/iotdb/db/service/NewIoTDB.java b/server/src/main/java/org/apache/iotdb/db/service/NewIoTDB.java
index 0f1fe3e895..182b043449 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/NewIoTDB.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/NewIoTDB.java
@@ -37,7 +37,6 @@ import org.apache.iotdb.db.engine.StorageEngineV2;
import org.apache.iotdb.db.engine.cache.CacheHitRatioMonitor;
import org.apache.iotdb.db.engine.compaction.CompactionTaskManager;
import org.apache.iotdb.db.engine.flush.FlushManager;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.localconfignode.LocalConfigNode;
import org.apache.iotdb.db.metadata.LocalSchemaProcessor;
@@ -170,7 +169,6 @@ public class NewIoTDB implements NewIoTDBMBean {
}
registerManager.register(UpgradeSevice.getINSTANCE());
- registerManager.register(TriggerRegistrationService.getInstance());
registerManager.register(MetricService.getInstance());
registerManager.register(CompactionTaskManager.getInstance());
// bind predefined metrics
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java
index 3e852fdf91..0f46140d5f 100644
--- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java
@@ -41,7 +41,6 @@ import org.apache.iotdb.db.engine.flush.TsFileFlushPolicy;
import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
import org.apache.iotdb.db.engine.querycontext.ReadOnlyMemChunk;
import org.apache.iotdb.db.exception.DataRegionException;
-import org.apache.iotdb.db.exception.TriggerExecutionException;
import org.apache.iotdb.db.exception.WriteProcessException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.mpp.common.QueryId;
@@ -140,7 +139,7 @@ public class DataRegionTest {
@Test
public void testUnseqUnsealedDelete()
- throws WriteProcessException, IOException, MetadataException, TriggerExecutionException {
+ throws WriteProcessException, IOException, MetadataException {
TSRecord record = new TSRecord(10000, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(1000)));
dataRegion.insert(buildInsertRowNodeByTSRecord(record));
@@ -197,8 +196,7 @@ public class DataRegionTest {
@Test
public void testSequenceSyncClose()
- throws WriteProcessException, QueryProcessException, IllegalPathException,
- TriggerExecutionException {
+ throws WriteProcessException, QueryProcessException, IllegalPathException {
for (int j = 1; j <= 10; j++) {
TSRecord record = new TSRecord(j, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
@@ -227,8 +225,7 @@ public class DataRegionTest {
@Test
public void testInsertDataAndRemovePartitionAndInsert()
- throws WriteProcessException, QueryProcessException, IllegalPathException,
- TriggerExecutionException {
+ throws WriteProcessException, QueryProcessException, IllegalPathException {
for (int j = 0; j < 10; j++) {
TSRecord record = new TSRecord(j, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
@@ -259,8 +256,7 @@ public class DataRegionTest {
@Test
public void testIoTDBTabletWriteAndSyncClose()
- throws QueryProcessException, IllegalPathException, TriggerExecutionException,
- WriteProcessException {
+ throws QueryProcessException, IllegalPathException, WriteProcessException {
String[] measurements = new String[2];
measurements[0] = "s0";
measurements[1] = "s1";
@@ -339,8 +335,7 @@ public class DataRegionTest {
@Test
public void testSeqAndUnSeqSyncClose()
- throws WriteProcessException, QueryProcessException, IllegalPathException,
- TriggerExecutionException {
+ throws WriteProcessException, QueryProcessException, IllegalPathException {
for (int j = 21; j <= 30; j++) {
TSRecord record = new TSRecord(j, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
@@ -377,8 +372,7 @@ public class DataRegionTest {
@Test
public void testEnableDiscardOutOfOrderDataForInsertRowPlan()
- throws WriteProcessException, QueryProcessException, IllegalPathException, IOException,
- TriggerExecutionException {
+ throws WriteProcessException, QueryProcessException, IllegalPathException, IOException {
boolean defaultValue = config.isEnableDiscardOutOfOrderData();
config.setEnableDiscardOutOfOrderData(true);
@@ -424,8 +418,7 @@ public class DataRegionTest {
@Test
public void testEnableDiscardOutOfOrderDataForInsertTablet1()
- throws QueryProcessException, IllegalPathException, IOException, TriggerExecutionException,
- WriteProcessException {
+ throws QueryProcessException, IllegalPathException, IOException, WriteProcessException {
boolean defaultEnableDiscard = config.isEnableDiscardOutOfOrderData();
long defaultTimePartition = config.getTimePartitionInterval();
config.setEnableDiscardOutOfOrderData(true);
@@ -514,8 +507,7 @@ public class DataRegionTest {
@Test
public void testEnableDiscardOutOfOrderDataForInsertTablet2()
- throws QueryProcessException, IllegalPathException, IOException, TriggerExecutionException,
- WriteProcessException {
+ throws QueryProcessException, IllegalPathException, IOException, WriteProcessException {
boolean defaultEnableDiscard = config.isEnableDiscardOutOfOrderData();
long defaultTimePartition = config.getTimePartitionInterval();
config.setEnableDiscardOutOfOrderData(true);
@@ -604,8 +596,7 @@ public class DataRegionTest {
@Test
public void testEnableDiscardOutOfOrderDataForInsertTablet3()
- throws QueryProcessException, IllegalPathException, IOException, TriggerExecutionException,
- WriteProcessException {
+ throws QueryProcessException, IllegalPathException, IOException, WriteProcessException {
boolean defaultEnableDiscard = config.isEnableDiscardOutOfOrderData();
long defaultTimePartition = config.getTimePartitionInterval();
config.setEnableDiscardOutOfOrderData(true);
@@ -695,7 +686,7 @@ public class DataRegionTest {
@Test
public void testSmallReportProportionInsertRow()
throws WriteProcessException, QueryProcessException, IllegalPathException, IOException,
- TriggerExecutionException, DataRegionException {
+ DataRegionException {
double defaultValue = config.getWriteMemoryVariationReportProportion();
config.setWriteMemoryVariationReportProportion(0);
DataRegion dataRegion1 = new DummyDataRegion(systemDir, "root.ln22");
@@ -734,8 +725,7 @@ public class DataRegionTest {
@Test
public void testMerge()
- throws WriteProcessException, QueryProcessException, IllegalPathException,
- TriggerExecutionException {
+ throws WriteProcessException, QueryProcessException, IllegalPathException {
int originCandidateFileNum =
IoTDBDescriptor.getInstance().getConfig().getMaxInnerCompactionCandidateFileNum();
IoTDBDescriptor.getInstance().getConfig().setMaxInnerCompactionCandidateFileNum(9);
@@ -865,8 +855,7 @@ public class DataRegionTest {
@Test
public void testTimedFlushSeqMemTable()
- throws IllegalPathException, InterruptedException, WriteProcessException,
- TriggerExecutionException, ShutdownException {
+ throws IllegalPathException, InterruptedException, WriteProcessException, ShutdownException {
// create one sequence memtable
TSRecord record = new TSRecord(10000, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(1000)));
@@ -913,8 +902,7 @@ public class DataRegionTest {
@Test
public void testTimedFlushUnseqMemTable()
- throws IllegalPathException, InterruptedException, WriteProcessException,
- TriggerExecutionException, ShutdownException {
+ throws IllegalPathException, InterruptedException, WriteProcessException, ShutdownException {
// create one sequence memtable & close
TSRecord record = new TSRecord(10000, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(1000)));
@@ -975,8 +963,7 @@ public class DataRegionTest {
*/
@Test
public void testDeleteDataNotInFile()
- throws IllegalPathException, WriteProcessException, TriggerExecutionException,
- InterruptedException, IOException {
+ throws IllegalPathException, WriteProcessException, InterruptedException, IOException {
for (int i = 0; i < 5; i++) {
if (i % 2 == 0) {
for (int d = 0; d < 2; d++) {
@@ -1039,7 +1026,7 @@ public class DataRegionTest {
@Test
public void testDeleteDataNotInFlushingMemtable()
- throws IllegalPathException, WriteProcessException, TriggerExecutionException, IOException {
+ throws IllegalPathException, WriteProcessException, IOException {
for (int j = 0; j < 100; j++) {
TSRecord record = new TSRecord(j, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
@@ -1061,7 +1048,7 @@ public class DataRegionTest {
@Test
public void testDeleteDataInSeqFlushingMemtable()
- throws IllegalPathException, WriteProcessException, TriggerExecutionException, IOException {
+ throws IllegalPathException, WriteProcessException, IOException {
for (int j = 100; j < 200; j++) {
TSRecord record = new TSRecord(j, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
@@ -1087,7 +1074,7 @@ public class DataRegionTest {
@Test
public void testDeleteDataInUnSeqFlushingMemtable()
- throws IllegalPathException, WriteProcessException, TriggerExecutionException, IOException {
+ throws IllegalPathException, WriteProcessException, IOException {
for (int j = 100; j < 200; j++) {
TSRecord record = new TSRecord(j, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
@@ -1143,7 +1130,7 @@ public class DataRegionTest {
@Test
public void testFlushingEmptyMemtable()
- throws IllegalPathException, WriteProcessException, TriggerExecutionException, IOException {
+ throws IllegalPathException, WriteProcessException, IOException {
for (int j = 100; j < 200; j++) {
TSRecord record = new TSRecord(j, deviceId);
record.addTuple(DataPoint.getDataPoint(TSDataType.INT32, measurementId, String.valueOf(j)));
diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java
index e757777e78..f4013023dc 100644
--- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java
@@ -32,7 +32,6 @@ import org.apache.iotdb.db.engine.flush.TsFileFlushPolicy.DirectFlushPolicy;
import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
import org.apache.iotdb.db.exception.DataRegionException;
import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.TriggerExecutionException;
import org.apache.iotdb.db.exception.WriteProcessException;
import org.apache.iotdb.db.exception.query.OutOfTTLException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
@@ -141,8 +140,7 @@ public class TTLTest {
@Test
public void testTTLWrite()
- throws WriteProcessException, QueryProcessException, IllegalPathException,
- TriggerExecutionException {
+ throws WriteProcessException, QueryProcessException, IllegalPathException {
InsertRowNode node =
new InsertRowNode(
new PlanNodeId("0"),
@@ -173,8 +171,7 @@ public class TTLTest {
dataRegion.insert(node);
}
- private void prepareData()
- throws WriteProcessException, IllegalPathException, TriggerExecutionException {
+ private void prepareData() throws WriteProcessException, IllegalPathException {
InsertRowNode node =
new InsertRowNode(
new PlanNodeId("0"),
@@ -410,8 +407,7 @@ public class TTLTest {
@Test
public void testTTLCleanFile()
- throws WriteProcessException, QueryProcessException, IllegalPathException,
- TriggerExecutionException {
+ throws WriteProcessException, QueryProcessException, IllegalPathException {
prepareData();
dataRegion.syncCloseAllWorkingTsFileProcessors();
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java b/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
index 9dea24d716..f3a7e776ab 100644
--- a/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
+++ b/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
@@ -33,9 +33,7 @@ import org.apache.iotdb.db.engine.cache.BloomFilterCache;
import org.apache.iotdb.db.engine.cache.ChunkCache;
import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache;
import org.apache.iotdb.db.engine.compaction.CompactionTaskManager;
-import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
import org.apache.iotdb.db.exception.StorageEngineException;
-import org.apache.iotdb.db.exception.TriggerManagementException;
import org.apache.iotdb.db.metadata.idtable.IDTableManager;
import org.apache.iotdb.db.metadata.idtable.entry.DeviceIDFactory;
import org.apache.iotdb.db.query.context.QueryContext;
@@ -109,10 +107,7 @@ public class EnvironmentUtils {
if (UDFManagementService.getInstance() != null) {
UDFManagementService.getInstance().deregisterAll();
}
- if (TriggerRegistrationService.getInstance() != null) {
- TriggerRegistrationService.getInstance().deregisterAll();
- }
- } catch (UDFManagementException | TriggerManagementException e) {
+ } catch (UDFManagementException e) {
fail(e.getMessage());
}