You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2025/04/09 03:47:35 UTC
(iotdb-extras) 05/07: refactor
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch sink
in repository https://gitbox.apache.org/repos/asf/iotdb-extras.git
commit da6752467be1e09fe8503e9f635e361ead79e3b9
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Wed Mar 12 14:49:34 2025 +0800
refactor
---
.../apache/iotdb/collector/config/PipeOptions.java | 1 -
.../collector/plugin/builtin/BuiltinPlugin.java | 2 +-
.../thrift => client}/IoTDBClientManager.java | 2 +-
.../IoTDBDataNodeCacheLeaderClientManager.java | 2 +-
.../IoTDBDataNodeSyncClientManager.java | 2 +-
.../thrift => client}/IoTDBSyncClient.java | 4 +-
.../thrift => client}/IoTDBSyncClientManager.java | 3 +-
.../sink/{property => client}/ThriftClient.java | 2 +-
.../{property => client}/ThriftClientProperty.java | 2 +-
.../sink/constant/ColumnHeaderConstant.java | 613 --------------
.../builtin/sink/constant/IoTDBConstant.java | 371 ---------
.../sink/constant/PipeConnectorConstant.java | 21 -
.../sink/constant/PipeExtractorConstant.java | 149 ----
.../builtin/sink/constant/SystemConstant.java | 60 --
.../PipeInsertionEvent.java} | 24 +-
.../sink/event/PipeRawTabletInsertionEvent.java | 62 ++
.../sink/event/PipeTsFileInsertionEvent.java | 54 ++
.../sink/event/row/PipeBinaryTransformer.java | 37 -
.../sink/event/row/PipeDataTypeTransformer.java | 74 --
.../builtin/sink/event/row/PipeResetTabletRow.java | 54 --
.../plugin/builtin/sink/event/row/PipeRow.java | 212 -----
.../builtin/sink/event/row/PipeRowCollector.java | 145 ----
.../event/tablet/PipeRawTabletInsertionEvent.java | 331 --------
.../event/tsfile/PipeTsFileInsertionEvent.java | 647 ---------------
.../PipeRuntimeConnectorCriticalException.java | 74 --
.../pipe/PipeRuntimeCriticalException.java | 69 --
.../sink/exception/pipe/PipeRuntimeException.java | 54 --
.../exception/pipe/PipeRuntimeExceptionType.java | 52 --
.../pipe/PipeRuntimeNonCriticalException.java | 74 --
.../PipeRuntimeOutOfMemoryCriticalException.java | 75 --
.../evolvable/batch/PipeTabletEventBatch.java | 2 +-
.../evolvable/batch/PipeTabletEventPlainBatch.java | 2 +-
.../batch/PipeTabletEventTsFileBatch.java | 3 +-
.../batch/PipeTransferBatchReqBuilder.java | 2 +-
.../builtin/sink/property/ClientPoolProperty.java | 109 ---
.../sink/property/PipeConsensusClientProperty.java | 96 ---
.../builtin/sink/protocol/{demo => }/DemoSink.java | 2 +-
.../sink/protocol/{thrift => }/IoTDBConnector.java | 3 +-
.../{thrift => }/IoTDBDataNodeSyncConnector.java | 5 +-
.../{thrift => }/IoTDBDataRegionSyncConnector.java | 39 +-
.../{thrift => }/IoTDBSslSyncConnector.java | 4 +-
.../{thrift => }/PipeReceiverStatusHandler.java | 2 +-
.../plugin/builtin/sink/utils/DateTimeUtils.java | 895 ---------------------
.../plugin/builtin/sink/utils/MemUtils.java | 242 ------
.../plugin/builtin/sink/utils/NodeUrlUtils.java | 246 ------
.../builtin/sink/utils/PathDeserializeUtil.java | 47 --
.../plugin/builtin/sink/utils/PathUtils.java | 225 ------
.../builtin/sink/utils/PipeMemoryWeightUtil.java | 359 ---------
.../plugin/builtin/sink/utils/RetryUtils.java | 48 --
.../plugin/builtin/sink/utils/TestOnly.java | 34 -
.../sink/utils/TimestampPrecisionUtils.java | 98 ---
.../builtin/sink/utils/TsTableColumnCategory.java | 108 ---
.../plugin/constructor/SinkConstructor.java | 2 +-
53 files changed, 166 insertions(+), 5679 deletions(-)
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/PipeOptions.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/PipeOptions.java
index 69d7cba..d1e6ad4 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/PipeOptions.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/PipeOptions.java
@@ -19,7 +19,6 @@
package org.apache.iotdb.collector.config;
-import org.apache.iotdb.collector.plugin.builtin.sink.constant.IoTDBConstant;
import org.apache.iotdb.rpc.RpcUtils;
import java.io.File;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/BuiltinPlugin.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/BuiltinPlugin.java
index 92a497f..af40866 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/BuiltinPlugin.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/BuiltinPlugin.java
@@ -20,7 +20,7 @@
package org.apache.iotdb.collector.plugin.builtin;
import org.apache.iotdb.collector.plugin.builtin.processor.DoNothingProcessor;
-import org.apache.iotdb.collector.plugin.builtin.sink.protocol.demo.DemoSink;
+import org.apache.iotdb.collector.plugin.builtin.sink.protocol.DemoSink;
import org.apache.iotdb.collector.plugin.builtin.source.HttpPullSource;
import org.apache.iotdb.collector.plugin.builtin.source.HttpPushSource;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBClientManager.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBClientManager.java
similarity index 98%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBClientManager.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBClientManager.java
index d6a1df1..2bfd5c6 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBClientManager.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBClientManager.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.client;
import org.apache.iotdb.collector.config.PipeOptions;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeCacheLeaderClientManager.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBDataNodeCacheLeaderClientManager.java
similarity index 98%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeCacheLeaderClientManager.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBDataNodeCacheLeaderClientManager.java
index 669e65d..945bb8f 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeCacheLeaderClientManager.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBDataNodeCacheLeaderClientManager.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.client;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeSyncClientManager.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBDataNodeSyncClientManager.java
similarity index 98%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeSyncClientManager.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBDataNodeSyncClientManager.java
index 954a1e7..93b7e60 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeSyncClientManager.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBDataNodeSyncClientManager.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.client;
import org.apache.iotdb.collector.config.PipeOptions;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.request.PipeTransferDataNodeHandshakeV1Req;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSyncClient.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBSyncClient.java
similarity index 96%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSyncClient.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBSyncClient.java
index 7ad33a5..2b1b7b9 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSyncClient.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBSyncClient.java
@@ -17,13 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.client;
import org.apache.iotdb.collector.config.PipeOptions;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.thrift.request.IoTDBConnectorRequestVersion;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.thrift.request.PipeTransferSliceReq;
-import org.apache.iotdb.collector.plugin.builtin.sink.property.ThriftClient;
-import org.apache.iotdb.collector.plugin.builtin.sink.property.ThriftClientProperty;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.pipe.api.exception.PipeConnectionException;
import org.apache.iotdb.rpc.DeepCopyRpcTransportFactory;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSyncClientManager.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBSyncClientManager.java
similarity index 98%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSyncClientManager.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBSyncClientManager.java
index 2dd47db..74db57d 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSyncClientManager.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/IoTDBSyncClientManager.java
@@ -17,13 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.client;
import org.apache.iotdb.collector.config.PipeOptions;
import org.apache.iotdb.collector.plugin.builtin.sink.constant.PipeTransferHandshakeConstant;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.thrift.request.PipeTransferHandshakeV1Req;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.thrift.request.PipeTransferHandshakeV2Req;
-import org.apache.iotdb.collector.plugin.builtin.sink.property.ThriftClientProperty;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.pipe.api.exception.PipeConnectionException;
import org.apache.iotdb.rpc.TSStatusCode;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ThriftClient.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/ThriftClient.java
similarity index 98%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ThriftClient.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/ThriftClient.java
index fbc23b0..20061ef 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ThriftClient.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/ThriftClient.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.property;
+package org.apache.iotdb.collector.plugin.builtin.sink.client;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.thrift.TException;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ThriftClientProperty.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/ThriftClientProperty.java
similarity index 98%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ThriftClientProperty.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/ThriftClientProperty.java
index 5eb15d8..b85c273 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ThriftClientProperty.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/client/ThriftClientProperty.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.property;
+package org.apache.iotdb.collector.plugin.builtin.sink.client;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TCompactProtocol;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/ColumnHeaderConstant.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/ColumnHeaderConstant.java
index 4baa3ed..5d4db67 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/ColumnHeaderConstant.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/ColumnHeaderConstant.java
@@ -25,624 +25,11 @@ public class ColumnHeaderConstant {
// forbidding instantiation
}
- // column names for query statement
- public static final String TIME = "Time";
- public static final String ENDTIME = "__endTime";
- public static final String VALUE = "Value";
- public static final String DEVICE = "Device";
- public static final String EXPLAIN_ANALYZE = "Explain Analyze";
-
- // column names for schema statement
public static final String DATABASE = "Database";
- public static final String TIMESERIES = "Timeseries";
- public static final String ALIAS = "Alias";
- public static final String DATATYPE = "DataType";
- public static final String ENCODING = "Encoding";
- public static final String COMPRESSION = "Compression";
- public static final String TAGS = "Tags";
- public static final String ATTRIBUTES = "Attributes";
- public static final String NOTES = "Notes";
- public static final String DEADBAND = "Deadband";
- public static final String DEADBAND_PARAMETERS = "DeadbandParameters";
- public static final String IS_ALIGNED = "IsAligned";
- public static final String TEMPLATE = "Template";
-
- public static final String COUNT = "Count";
- public static final String COLUMN_TTL = "TTL(ms)";
- public static final String SCHEMA_REPLICATION_FACTOR = "SchemaReplicationFactor";
- public static final String DATA_REPLICATION_FACTOR = "DataReplicationFactor";
- public static final String TIME_PARTITION_ORIGIN = "TimePartitionOrigin";
- public static final String TIME_PARTITION_INTERVAL = "TimePartitionInterval";
- public static final String SCHEMA_REGION_GROUP_NUM = "SchemaRegionGroupNum";
- public static final String MIN_SCHEMA_REGION_GROUP_NUM = "MinSchemaRegionGroupNum";
- public static final String MAX_SCHEMA_REGION_GROUP_NUM = "MaxSchemaRegionGroupNum";
- public static final String DATA_REGION_GROUP_NUM = "DataRegionGroupNum";
- public static final String MIN_DATA_REGION_GROUP_NUM = "MinDataRegionGroupNum";
- public static final String MAX_DATA_REGION_GROUP_NUM = "MaxDataRegionGroupNum";
- public static final String CHILD_PATHS = "ChildPaths";
- public static final String NODE_TYPES = "NodeTypes";
- public static final String CHILD_NODES = "ChildNodes";
- public static final String VERSION = "Version";
- public static final String BUILD_INFO = "BuildInfo";
- public static final String PATHS = "Paths";
- public static final String PATH = "Path";
- public static final String VARIABLE = "Variable";
- public static final String SCOPE = "Scope";
-
- // column names for count statement
- public static final String COLUMN = "Column";
- public static final String COUNT_DEVICES = "count(devices)";
- public static final String COUNT_NODES = "count(nodes)";
- public static final String COUNT_TIMESERIES = "count(timeseries)";
- public static final String COUNT_DATABASE = "count(database)";
-
- // column names for show cluster and show cluster details statements
- public static final String NODE_ID = "NodeID";
- public static final String NODE_TYPE = "NodeType";
- public static final String STATUS = "Status";
- public static final String INTERNAL_ADDRESS = "InternalAddress";
- public static final String INTERNAL_PORT = "InternalPort";
- public static final String CONFIG_CONSENSUS_PORT = "ConfigConsensusPort";
- public static final String RPC_ADDRESS = "RpcAddress";
- public static final String RPC_PORT = "RpcPort";
- public static final String DATA_CONSENSUS_PORT = "DataConsensusPort";
- public static final String SCHEMA_CONSENSUS_PORT = "SchemaConsensusPort";
- public static final String MPP_PORT = "MppPort";
-
- // column names for show clusterId statement
- public static final String CLUSTER_ID = "ClusterId";
-
- // column names for verify connection statement
- public static final String SERVICE_PROVIDER = "ServiceProvider";
- public static final String SENDER = "Sender";
- public static final String CONNECTION = "Connection";
- // column names for show functions statement
- public static final String FUNCTION_NAME = "FunctionName";
- public static final String FUNCTION_TYPE = "FunctionType";
- public static final String CLASS_NAME_UDF = "ClassName(UDF)";
- public static final String FUNCTION_STATE = "State";
-
- // column names for show triggers statement
- public static final String TRIGGER_NAME = "TriggerName";
- public static final String EVENT = "Event";
- public static final String STATE = "State";
- public static final String MODEL_TYPE = "ModelType";
- public static final String CONFIGS = "Configs";
public static final String PATH_PATTERN = "PathPattern";
- public static final String CLASS_NAME = "ClassName";
-
- // column names for show pipe plugins statement
- public static final String PLUGIN_NAME = "PluginName";
- public static final String PLUGIN_TYPE = "PluginType";
- public static final String PLUGIN_JAR = "PluginJar";
-
- // column names for show topics statement
- public static final String TOPIC_NAME = "TopicName";
- public static final String TOPIC_CONFIGS = "TopicConfigs";
-
- // column names for show subscriptions statement
- public static final String CONSUMER_GROUP_NAME = "ConsumerGroupName";
- public static final String SUBSCRIBED_CONSUMERS = "SubscribedConsumers";
-
- // show cluster status
- public static final String NODE_TYPE_CONFIG_NODE = "ConfigNode";
- public static final String NODE_TYPE_DATA_NODE = "DataNode";
- public static final String NODE_TYPE_AI_NODE = "AINode";
- public static final String COLUMN_CLUSTER_NAME = "ClusterName";
- public static final String CONFIG_NODE_CONSENSUS_PROTOCOL_CLASS =
- "ConfigNodeConsensusProtocolClass";
- public static final String DATA_REGION_CONSENSUS_PROTOCOL_CLASS =
- "DataRegionConsensusProtocolClass";
- public static final String SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS =
- "SchemaRegionConsensusProtocolClass";
- public static final String SERIES_SLOT_NUM = "SeriesSlotNum";
- public static final String SERIES_SLOT_EXECUTOR_CLASS = "SeriesSlotExecutorClass";
- public static final String SCHEMA_REGION_PER_DATA_NODE = "SchemaRegionPerDataNode";
- public static final String DATA_REGION_PER_DATA_NODE = "DataRegionPerDataNode";
- public static final String READ_CONSISTENCY_LEVEL = "ReadConsistencyLevel";
- public static final String DISK_SPACE_WARNING_THRESHOLD = "DiskSpaceWarningThreshold";
-
- public static final String TIMESTAMP_PRECISION = "TimestampPrecision";
- // column names for show region statement
- public static final String REGION_ID = "RegionId";
public static final String TYPE = "Type";
- public static final String DATA_NODE_ID = "DataNodeId";
- public static final String TIME_SLOT_NUM = "TimeSlotNum";
- public static final String SERIES_SLOT_ID = "SeriesSlotId";
- public static final String TIME_PARTITION = "TimePartition";
- public static final String COUNT_TIME_PARTITION = "count(timePartition)";
- public static final String START_TIME = "StartTime";
- public static final String ROLE = "Role";
- public static final String CREATE_TIME = "CreateTime";
- public static final String TSFILE_SIZE = "TsFileSize";
-
- // column names for show datanodes
- public static final String SCHEMA_REGION_NUM = "SchemaRegionNum";
- public static final String DATA_REGION_NUM = "DataRegionNum";
-
- // column names for show device template statement
- public static final String TEMPLATE_NAME = "TemplateName";
-
- // column names for show pipe sink
- public static final String NAME = "Name";
-
- // column names for show pipe
- public static final String ID = "ID";
- public static final String CREATION_TIME = "CreationTime";
- public static final String PIPE_EXTRACTOR = "PipeSource";
- public static final String PIPE_PROCESSOR = "PipeProcessor";
- public static final String PIPE_CONNECTOR = "PipeSink";
- public static final String EXCEPTION_MESSAGE = "ExceptionMessage";
- public static final String REMAINING_EVENT_COUNT = "RemainingEventCount";
- public static final String ESTIMATED_REMAINING_SECONDS = "EstimatedRemainingSeconds";
-
- // column names for select into
- public static final String SOURCE_DEVICE = "SourceDevice";
- public static final String SOURCE_COLUMN = "SourceColumn";
- public static final String TARGET_TIMESERIES = "TargetTimeseries";
- public static final String WRITTEN = "Written";
-
- // column names for show cq
- public static final String CQID = "CQId";
- public static final String QUERY = "Query";
-
- // column names for show query processlist
- public static final String QUERY_ID = "QueryId";
- public static final String ELAPSED_TIME = "ElapsedTime";
- public static final String STATEMENT = "Statement";
-
- public static final String QUERY_ID_TABLE_MODEL = "query_id";
- public static final String QUERY_ID_START_TIME_TABLE_MODEL = "start_time";
- public static final String DATA_NODE_ID_TABLE_MODEL = "datanode_id";
- public static final String START_TIME_TABLE_MODEL = "start_time";
- public static final String ELAPSED_TIME_TABLE_MODEL = "elapsed_time";
-
- public static final String TABLE_NAME_TABLE_MODEL = "table_name";
- public static final String COLUMN_NAME_TABLE_MODEL = "column_name";
-
- public static final String SCHEMA_REPLICATION_FACTOR_TABLE_MODEL = "schema_replication_factor";
- public static final String DATA_REPLICATION_FACTOR_TABLE_MODEL = "data_replication_factor";
- public static final String TIME_PARTITION_INTERVAL_TABLE_MODEL = "time_partition_interval";
- public static final String SCHEMA_REGION_GROUP_NUM_TABLE_MODEL = "schema_region_group_num";
- public static final String DATA_REGION_GROUP_NUM_TABLE_MODEL = "data_region_group_num";
-
- public static final String REGION_ID_TABLE_MODEL = "region_id";
- public static final String DATANODE_ID_TABLE_MODEL = "datanode_id";
- public static final String SERIES_SLOT_NUM_TABLE_MODEL = "series_slot_num";
- public static final String TIME_SLOT_NUM_TABLE_MODEL = "time_slot_num";
- public static final String RPC_ADDRESS_TABLE_MODEL = "rpc_address";
- public static final String RPC_PORT_TABLE_MODEL = "rpc_port";
- public static final String INTERNAL_ADDRESS_TABLE_MODEL = "internal_address";
- public static final String CREATE_TIME_TABLE_MODEL = "create_time";
- public static final String TS_FILE_SIZE_BYTES_TABLE_MODEL = "tsfile_size_bytes";
-
- public static final String CREATION_TIME_TABLE_MODEL = "creation_time";
- public static final String PIPE_SOURCE_TABLE_MODEL = "pipe_source";
- public static final String PIPE_PROCESSOR_TABLE_MODEL = "pipe_processor";
- public static final String PIPE_SINK_TABLE_MODEL = "pipe_sink";
- public static final String EXCEPTION_MESSAGE_TABLE_MODEL = "exception_message";
- public static final String REMAINING_EVENT_COUNT_TABLE_MODEL = "remaining_event_count";
- public static final String ESTIMATED_REMAINING_SECONDS_TABLE_MODEL =
- "estimated_remaining_seconds";
- public static final String PLUGIN_NAME_TABLE_MODEL = "plugin_name";
- public static final String PLUGIN_TYPE_TABLE_MODEL = "plugin_type";
- public static final String CLASS_NAME_TABLE_MODEL = "class_name";
- public static final String PLUGIN_JAR_TABLE_MODEL = "plugin_jar";
-
- public static final String TOPIC_NAME_TABLE_MODEL = "topic_name";
- public static final String TOPIC_CONFIGS_TABLE_MODEL = "topic_configs";
-
- public static final String CONSUMER_GROUP_NAME_TABLE_MODEL = "consumer_group_name";
- public static final String SUBSCRIBED_CONSUMERS_TABLE_MODEL = "subscribed_consumers";
-
- // column names for show space quota
- public static final String QUOTA_TYPE = "QuotaType";
- public static final String LIMIT = "Limit";
- public static final String USED = "Used";
-
- // column names for show throttle quota
- public static final String USER = "User";
- public static final String READ_WRITE = "Read/Write";
-
- // column names for show models/trials
- public static final String MODEL_ID = "ModelId";
-
- // column names for views (e.g. logical view)
- public static final String VIEW_TYPE = "ViewType";
- public static final String SOURCE = "Source";
-
- // column names for show current timestamp
- public static final String CURRENT_TIMESTAMP = "CurrentTimestamp";
-
- // column names for table query
- public static final String COLUMN_NAME = "ColumnName";
- public static final String COLUMN_DATA_TYPE = "DataType";
- public static final String COLUMN_CATEGORY = "Category";
public static final String TABLE_NAME = "TableName";
- public static final String PRIVILEGES = "Privileges";
-
- public static final String GRANT_OPTION = "GrantOption";
-
- public static final String CURRENT_USER = "CurrentUser";
-
- public static final String CURRENT_DATABASE = "CurrentDatabase";
-
- public static final String CURRENT_SQL_DIALECT = "CurrentSqlDialect";
- /*
- public static final List<ColumnHeader> lastQueryColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TIMESERIES, TSDataType.TEXT),
- new ColumnHeader(VALUE, TSDataType.TEXT),
- new ColumnHeader(DATATYPE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showTimeSeriesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TIMESERIES, TSDataType.TEXT),
- new ColumnHeader(ALIAS, TSDataType.TEXT),
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(DATATYPE, TSDataType.TEXT),
- new ColumnHeader(ENCODING, TSDataType.TEXT),
- new ColumnHeader(COMPRESSION, TSDataType.TEXT),
- new ColumnHeader(TAGS, TSDataType.TEXT),
- new ColumnHeader(ATTRIBUTES, TSDataType.TEXT),
- new ColumnHeader(DEADBAND, TSDataType.TEXT),
- new ColumnHeader(DEADBAND_PARAMETERS, TSDataType.TEXT),
- new ColumnHeader(VIEW_TYPE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showDevicesWithSgColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(DEVICE, TSDataType.TEXT),
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(IS_ALIGNED, TSDataType.TEXT),
- new ColumnHeader(TEMPLATE, TSDataType.TEXT),
- new ColumnHeader(COLUMN_TTL, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showDevicesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(DEVICE, TSDataType.TEXT),
- new ColumnHeader(IS_ALIGNED, TSDataType.TEXT),
- new ColumnHeader(TEMPLATE, TSDataType.TEXT),
- new ColumnHeader(COLUMN_TTL, TSDataType.TEXT));
- public static final List<ColumnHeader> showTTLColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(DEVICE, TSDataType.TEXT), new ColumnHeader(COLUMN_TTL, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showStorageGroupsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(SCHEMA_REPLICATION_FACTOR, TSDataType.INT32),
- new ColumnHeader(DATA_REPLICATION_FACTOR, TSDataType.INT32),
- new ColumnHeader(TIME_PARTITION_ORIGIN, TSDataType.INT64),
- new ColumnHeader(TIME_PARTITION_INTERVAL, TSDataType.INT64));
-
- public static final List<ColumnHeader> showStorageGroupsDetailColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(SCHEMA_REPLICATION_FACTOR, TSDataType.INT32),
- new ColumnHeader(DATA_REPLICATION_FACTOR, TSDataType.INT32),
- new ColumnHeader(TIME_PARTITION_ORIGIN, TSDataType.INT64),
- new ColumnHeader(TIME_PARTITION_INTERVAL, TSDataType.INT64),
- new ColumnHeader(SCHEMA_REGION_GROUP_NUM, TSDataType.INT32),
- new ColumnHeader(MIN_SCHEMA_REGION_GROUP_NUM, TSDataType.INT32),
- new ColumnHeader(MAX_SCHEMA_REGION_GROUP_NUM, TSDataType.INT32),
- new ColumnHeader(DATA_REGION_GROUP_NUM, TSDataType.INT32),
- new ColumnHeader(MIN_DATA_REGION_GROUP_NUM, TSDataType.INT32),
- new ColumnHeader(MAX_DATA_REGION_GROUP_NUM, TSDataType.INT32));
-
- public static final List<ColumnHeader> showChildPathsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(CHILD_PATHS, TSDataType.TEXT),
- new ColumnHeader(NODE_TYPES, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showNodesInSchemaTemplateHeaders =
- ImmutableList.of(
- new ColumnHeader(CHILD_NODES, TSDataType.TEXT),
- new ColumnHeader(DATATYPE, TSDataType.TEXT),
- new ColumnHeader(ENCODING, TSDataType.TEXT),
- new ColumnHeader(COMPRESSION, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showChildNodesColumnHeaders =
- ImmutableList.of(new ColumnHeader(CHILD_NODES, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showVersionColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(VERSION, TSDataType.TEXT),
- new ColumnHeader(BUILD_INFO, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showPathsUsingTemplateHeaders =
- ImmutableList.of(new ColumnHeader(PATHS, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showPathSetTemplateHeaders =
- ImmutableList.of(new ColumnHeader(PATHS, TSDataType.TEXT));
-
- public static final List<ColumnHeader> countDevicesColumnHeaders =
- ImmutableList.of(new ColumnHeader(COUNT_DEVICES, TSDataType.INT64));
-
- public static final List<ColumnHeader> countNodesColumnHeaders =
- ImmutableList.of(new ColumnHeader(COUNT_NODES, TSDataType.INT64));
-
- public static final List<ColumnHeader> countLevelTimeSeriesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(COLUMN, TSDataType.TEXT),
- new ColumnHeader(COUNT_TIMESERIES, TSDataType.INT64));
-
- public static final List<ColumnHeader> countTimeSeriesColumnHeaders =
- ImmutableList.of(new ColumnHeader(COUNT_TIMESERIES, TSDataType.INT64));
-
- public static final List<ColumnHeader> countStorageGroupColumnHeaders =
- ImmutableList.of(new ColumnHeader(COUNT_DATABASE, TSDataType.INT32));
-
- public static final List<ColumnHeader> showRegionColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(REGION_ID, TSDataType.INT32),
- new ColumnHeader(TYPE, TSDataType.TEXT),
- new ColumnHeader(STATUS, TSDataType.TEXT),
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(SERIES_SLOT_NUM, TSDataType.INT32),
- new ColumnHeader(TIME_SLOT_NUM, TSDataType.INT64),
- new ColumnHeader(DATA_NODE_ID, TSDataType.INT32),
- new ColumnHeader(RPC_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(RPC_PORT, TSDataType.INT32),
- new ColumnHeader(INTERNAL_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(ROLE, TSDataType.TEXT),
- new ColumnHeader(CREATE_TIME, TSDataType.TEXT),
- new ColumnHeader(TSFILE_SIZE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showAINodesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(NODE_ID, TSDataType.INT32),
- new ColumnHeader(STATUS, TSDataType.TEXT),
- new ColumnHeader(RPC_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(RPC_PORT, TSDataType.INT32));
-
- public static final List<ColumnHeader> showDataNodesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(NODE_ID, TSDataType.INT32),
- new ColumnHeader(STATUS, TSDataType.TEXT),
- new ColumnHeader(RPC_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(RPC_PORT, TSDataType.INT32),
- new ColumnHeader(DATA_REGION_NUM, TSDataType.INT32),
- new ColumnHeader(SCHEMA_REGION_NUM, TSDataType.INT32));
-
- public static final List<ColumnHeader> showConfigNodesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(NODE_ID, TSDataType.INT32),
- new ColumnHeader(STATUS, TSDataType.TEXT),
- new ColumnHeader(INTERNAL_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(INTERNAL_PORT, TSDataType.INT32),
- new ColumnHeader(ROLE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showClusterColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(NODE_ID, TSDataType.INT32),
- new ColumnHeader(NODE_TYPE, TSDataType.TEXT),
- new ColumnHeader(STATUS, TSDataType.TEXT),
- new ColumnHeader(INTERNAL_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(INTERNAL_PORT, TSDataType.INT32),
- new ColumnHeader(VERSION, TSDataType.TEXT),
- new ColumnHeader(BUILD_INFO, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showClusterDetailsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(NODE_ID, TSDataType.INT32),
- new ColumnHeader(NODE_TYPE, TSDataType.TEXT),
- new ColumnHeader(STATUS, TSDataType.TEXT),
- new ColumnHeader(INTERNAL_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(INTERNAL_PORT, TSDataType.INT32),
- new ColumnHeader(CONFIG_CONSENSUS_PORT, TSDataType.TEXT),
- new ColumnHeader(RPC_ADDRESS, TSDataType.TEXT),
- new ColumnHeader(RPC_PORT, TSDataType.TEXT),
- new ColumnHeader(MPP_PORT, TSDataType.TEXT),
- new ColumnHeader(SCHEMA_CONSENSUS_PORT, TSDataType.TEXT),
- new ColumnHeader(DATA_CONSENSUS_PORT, TSDataType.TEXT),
- new ColumnHeader(VERSION, TSDataType.TEXT),
- new ColumnHeader(BUILD_INFO, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showClusterIdColumnHeaders =
- ImmutableList.of(new ColumnHeader(CLUSTER_ID, TSDataType.TEXT));
-
- public static final List<ColumnHeader> testConnectionColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(SERVICE_PROVIDER, TSDataType.TEXT),
- new ColumnHeader(SENDER, TSDataType.TEXT),
- new ColumnHeader(CONNECTION, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showVariablesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(VARIABLE, TSDataType.TEXT), new ColumnHeader(VALUE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showFunctionsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(FUNCTION_NAME, TSDataType.TEXT),
- new ColumnHeader(FUNCTION_TYPE, TSDataType.TEXT),
- new ColumnHeader(CLASS_NAME_UDF, TSDataType.TEXT),
- new ColumnHeader(FUNCTION_STATE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showTriggersColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TRIGGER_NAME, TSDataType.TEXT),
- new ColumnHeader(EVENT, TSDataType.TEXT),
- new ColumnHeader(TYPE, TSDataType.TEXT),
- new ColumnHeader(STATE, TSDataType.TEXT),
- new ColumnHeader(PATH_PATTERN, TSDataType.TEXT),
- new ColumnHeader(CLASS_NAME, TSDataType.TEXT),
- new ColumnHeader(NODE_ID, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showPipePluginsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(PLUGIN_NAME, TSDataType.TEXT),
- new ColumnHeader(PLUGIN_TYPE, TSDataType.TEXT),
- new ColumnHeader(CLASS_NAME, TSDataType.TEXT),
- new ColumnHeader(PLUGIN_JAR, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showSchemaTemplateHeaders =
- ImmutableList.of(new ColumnHeader(TEMPLATE_NAME, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showPipeSinkTypeColumnHeaders =
- ImmutableList.of(new ColumnHeader(TYPE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showPipeSinkColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(NAME, TSDataType.TEXT),
- new ColumnHeader(TYPE, TSDataType.TEXT),
- new ColumnHeader(ATTRIBUTES, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showPipeColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(ID, TSDataType.TEXT),
- new ColumnHeader(CREATION_TIME, TSDataType.TEXT),
- new ColumnHeader(STATE, TSDataType.TEXT),
- new ColumnHeader(PIPE_EXTRACTOR, TSDataType.TEXT),
- new ColumnHeader(PIPE_PROCESSOR, TSDataType.TEXT),
- new ColumnHeader(PIPE_CONNECTOR, TSDataType.TEXT),
- new ColumnHeader(EXCEPTION_MESSAGE, TSDataType.TEXT),
- new ColumnHeader(REMAINING_EVENT_COUNT, TSDataType.TEXT),
- new ColumnHeader(ESTIMATED_REMAINING_SECONDS, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showTopicColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TOPIC_NAME, TSDataType.TEXT),
- new ColumnHeader(TOPIC_CONFIGS, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showSubscriptionColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TOPIC_NAME, TSDataType.TEXT),
- new ColumnHeader(CONSUMER_GROUP_NAME, TSDataType.TEXT),
- new ColumnHeader(SUBSCRIBED_CONSUMERS, TSDataType.TEXT));
-
- public static final List<ColumnHeader> selectIntoColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(SOURCE_COLUMN, TSDataType.TEXT),
- new ColumnHeader(TARGET_TIMESERIES, TSDataType.TEXT),
- new ColumnHeader(WRITTEN, TSDataType.INT32));
-
- public static final List<ColumnHeader> selectIntoAlignByDeviceColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(SOURCE_DEVICE, TSDataType.TEXT),
- new ColumnHeader(SOURCE_COLUMN, TSDataType.TEXT),
- new ColumnHeader(TARGET_TIMESERIES, TSDataType.TEXT),
- new ColumnHeader(WRITTEN, TSDataType.INT32));
-
- public static final List<ColumnHeader> getRegionIdColumnHeaders =
- ImmutableList.of(new ColumnHeader(REGION_ID, TSDataType.INT32));
-
- public static final List<ColumnHeader> getTimeSlotListColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TIME_PARTITION, TSDataType.INT64),
- new ColumnHeader(START_TIME, TSDataType.TEXT));
-
- public static final List<ColumnHeader> countTimeSlotListColumnHeaders =
- ImmutableList.of(new ColumnHeader(COUNT_TIME_PARTITION, TSDataType.INT64));
-
- public static final List<ColumnHeader> getSeriesSlotListColumnHeaders =
- ImmutableList.of(new ColumnHeader(SERIES_SLOT_ID, TSDataType.INT32));
-
- public static final List<ColumnHeader> showContinuousQueriesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(CQID, TSDataType.TEXT),
- new ColumnHeader(QUERY, TSDataType.TEXT),
- new ColumnHeader(STATE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showQueriesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(QUERY_ID, TSDataType.TEXT),
- new ColumnHeader(DATA_NODE_ID, TSDataType.INT32),
- new ColumnHeader(ELAPSED_TIME, TSDataType.FLOAT),
- new ColumnHeader(STATEMENT, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showSpaceQuotaColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(QUOTA_TYPE, TSDataType.TEXT),
- new ColumnHeader(LIMIT, TSDataType.TEXT),
- new ColumnHeader(USED, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showThrottleQuotaColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(USER, TSDataType.TEXT),
- new ColumnHeader(QUOTA_TYPE, TSDataType.TEXT),
- new ColumnHeader(LIMIT, TSDataType.TEXT),
- new ColumnHeader(READ_WRITE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showModelsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(MODEL_ID, TSDataType.TEXT),
- new ColumnHeader(MODEL_TYPE, TSDataType.TEXT),
- new ColumnHeader(STATE, TSDataType.TEXT),
- new ColumnHeader(CONFIGS, TSDataType.TEXT),
- new ColumnHeader(NOTES, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showLogicalViewColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TIMESERIES, TSDataType.TEXT),
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(DATATYPE, TSDataType.TEXT),
- new ColumnHeader(TAGS, TSDataType.TEXT),
- new ColumnHeader(ATTRIBUTES, TSDataType.TEXT),
- new ColumnHeader(VIEW_TYPE, TSDataType.TEXT),
- new ColumnHeader(SOURCE, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showDBColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(COLUMN_TTL, TSDataType.TEXT),
- new ColumnHeader(SCHEMA_REPLICATION_FACTOR, TSDataType.INT32),
- new ColumnHeader(DATA_REPLICATION_FACTOR, TSDataType.INT32),
- new ColumnHeader(TIME_PARTITION_INTERVAL, TSDataType.INT64));
-
- public static final List<ColumnHeader> showDBDetailsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(DATABASE, TSDataType.TEXT),
- new ColumnHeader(COLUMN_TTL, TSDataType.TEXT),
- new ColumnHeader(SCHEMA_REPLICATION_FACTOR, TSDataType.INT32),
- new ColumnHeader(DATA_REPLICATION_FACTOR, TSDataType.INT32),
- new ColumnHeader(TIME_PARTITION_INTERVAL, TSDataType.INT64),
- new ColumnHeader(SCHEMA_REGION_GROUP_NUM, TSDataType.INT32),
- new ColumnHeader(DATA_REGION_GROUP_NUM, TSDataType.INT32));
-
- public static final List<ColumnHeader> describeTableColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(COLUMN_NAME, TSDataType.TEXT),
- new ColumnHeader(COLUMN_DATA_TYPE, TSDataType.TEXT),
- new ColumnHeader(COLUMN_CATEGORY, TSDataType.TEXT));
-
- public static final List<ColumnHeader> describeTableDetailsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(COLUMN_NAME, TSDataType.TEXT),
- new ColumnHeader(COLUMN_DATA_TYPE, TSDataType.TEXT),
- new ColumnHeader(COLUMN_CATEGORY, TSDataType.TEXT),
- new ColumnHeader(STATUS, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showTablesColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TABLE_NAME, TSDataType.TEXT),
- new ColumnHeader(COLUMN_TTL, TSDataType.TEXT));
-
- public static final List<ColumnHeader> showTablesDetailsColumnHeaders =
- ImmutableList.of(
- new ColumnHeader(TABLE_NAME, TSDataType.TEXT),
- new ColumnHeader(COLUMN_TTL, TSDataType.TEXT),
- new ColumnHeader(STATUS, TSDataType.TEXT));
-
- public static final List<ColumnHeader> LIST_USER_OR_ROLE_PRIVILEGES_COLUMN_HEADERS =
- ImmutableList.of(
- new ColumnHeader(ROLE, TSDataType.TEXT),
- new ColumnHeader(SCOPE, TSDataType.TEXT),
- new ColumnHeader(PRIVILEGES, TSDataType.TEXT),
- new ColumnHeader(GRANT_OPTION, TSDataType.BOOLEAN));
-
- public static final List<ColumnHeader> SHOW_CURRENT_USER_COLUMN_HEADERS =
- ImmutableList.of(new ColumnHeader(CURRENT_USER, TSDataType.STRING));
-
- public static final List<ColumnHeader> SHOW_CURRENT_DATABASE_COLUMN_HEADERS =
- ImmutableList.of(new ColumnHeader(CURRENT_DATABASE, TSDataType.STRING));
-
- public static final List<ColumnHeader> SHOW_CURRENT_SQL_DIALECT_COLUMN_HEADERS =
- ImmutableList.of(new ColumnHeader(CURRENT_SQL_DIALECT, TSDataType.STRING));
-
- public static final List<ColumnHeader> SHOW_CURRENT_TIMESTAMP_COLUMN_HEADERS =
- ImmutableList.of(new ColumnHeader(CURRENT_TIMESTAMP, TSDataType.TIMESTAMP));*/
}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/IoTDBConstant.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/IoTDBConstant.java
deleted file mode 100644
index 03aabc9..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/IoTDBConstant.java
+++ /dev/null
@@ -1,371 +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.collector.plugin.builtin.sink.constant;
-
-import java.io.File;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-public class IoTDBConstant {
-
- private IoTDBConstant() {}
-
- static {
- Properties prop = new Properties();
- String finalBuildInfo = "UNKNOWN";
- try {
- prop.load(
- new InputStreamReader(
- Objects.requireNonNull(IoTDBConstant.class.getResourceAsStream("/git.properties")),
- StandardCharsets.UTF_8));
- finalBuildInfo = prop.getProperty("git.commit.id.abbrev", "UNKNOWN");
- String isDirty = prop.getProperty("git.dirty", "false");
- if (isDirty.equalsIgnoreCase("true")) {
- finalBuildInfo += "-dev";
- }
- } catch (Exception e) {
- System.err.println("get git.properties error: " + e.getMessage());
- }
- BUILD_INFO = finalBuildInfo;
- }
-
- public static final String BUILD_INFO;
-
- public static final String DN_ENV_FILE_NAME = "datanode-env";
- public static final String CN_ENV_FILE_NAME = "confignode-env";
- public static final String IOTDB_CONF = "IOTDB_CONF";
- public static final String GLOBAL_DB_NAME = "IoTDB";
- public static final String CN_ROLE = "confignode";
- public static final String DN_ROLE = "datanode";
-
- public static final String DATA_NODE_CONF_FILE_NAME = "iotdb-datanode.properties";
-
- public static final String DN_RPC_ADDRESS = "dn_rpc_address";
- public static final String DN_RPC_PORT = "dn_rpc_port";
-
- public static final String CN_INTERNAL_ADDRESS = "cn_internal_address";
- public static final String DN_INTERNAL_ADDRESS = "dn_internal_address";
-
- public static final String CN_METRIC_PROMETHEUS_REPORTER_PORT =
- "cn_metric_prometheus_reporter_port";
- public static final String DN_METRIC_PROMETHEUS_REPORTER_PORT =
- "dn_metric_prometheus_reporter_port";
-
- public static final String CN_INTERNAL_PORT = "cn_internal_port";
- public static final String DN_INTERNAL_PORT = "dn_internal_port";
- public static final String CN_CONSENSUS_PORT = "cn_consensus_port";
-
- public static final String CN_SEED_CONFIG_NODE = "cn_seed_config_node";
- public static final String CN_TARGET_CONFIG_NODE_LIST = "cn_target_config_node_list";
- public static final String DN_SEED_CONFIG_NODE = "dn_seed_config_node";
- public static final String DN_TARGET_CONFIG_NODE_LIST = "dn_target_config_node_list";
-
- public static final String CLUSTER_NAME = "cluster_name";
- public static final String DEFAULT_CLUSTER_NAME = "defaultCluster";
- public static final String LOGO =
- ""
- + " _____ _________ ______ ______ \n"
- + "|_ _| | _ _ ||_ _ `.|_ _ \\ \n"
- + " | | .--.|_/ | | \\_| | | `. \\ | |_) | \n"
- + " | | / .'`\\ \\ | | | | | | | __'. \n"
- + " _| |_| \\__. | _| |_ _| |_.' /_| |__) | \n"
- + "|_____|'.__.' |_____| |______.'|_______/ ";
-
- // when running the program in IDE, we can not get the version info using
- // getImplementationVersion()
- public static final String VERSION =
- IoTDBConstant.class.getPackage().getImplementationVersion() != null
- ? IoTDBConstant.class.getPackage().getImplementationVersion()
- : "UNKNOWN";
- public static final String MAJOR_VERSION =
- "UNKNOWN".equals(VERSION)
- ? "UNKNOWN"
- : VERSION.split("\\.")[0] + "." + VERSION.split("\\.")[1];
- public static final String VERSION_WITH_BUILD = VERSION + " (Build: " + BUILD_INFO + ")";
-
- public static final String AUDIT_LOGGER_NAME = "IoTDB_AUDIT_LOGGER";
- public static final String SLOW_SQL_LOGGER_NAME = "SLOW_SQL";
- public static final String SAMPLED_QUERIES_LOGGER_NAME = "SAMPLED_QUERIES";
-
- public static final String COMPACTION_LOGGER_NAME = "COMPACTION";
- public static final String EXPLAIN_ANALYZE_LOGGER_NAME = "EXPLAIN_ANALYZE";
-
- public static final String IOTDB_JMX_LOCAL = "iotdb.jmx.local";
- public static final String IOTDB_JMX_PORT = "com.sun.management.jmxremote.port";
-
- public static final String IOTDB_SERVICE_JMX_NAME = "org.apache.iotdb.service";
- public static final String IOTDB_THREADPOOL_JMX_NAME = "org.apache.iotdb.threadpool";
- public static final String JMX_TYPE = "type";
-
- public static final long PB = 1L << 50;
- public static final long TB = 1L << 40;
- public static final long GB = 1L << 30;
- public static final long MB = 1L << 20;
- public static final long KB = 1L << 10;
-
- public static final String IOTDB_HOME = "IOTDB_HOME";
-
- public static final String IOTDB_DATA_HOME = "IOTDB_DATA_HOME";
-
- public static final String SEQFILE_LOG_NODE_SUFFIX = "-seq";
- public static final String UNSEQFILE_LOG_NODE_SUFFIX = "-unseq";
-
- public static final String PATH_ROOT = "root";
- public static final char PATH_SEPARATOR = '.';
- public static final String PROFILE_SUFFIX = ".profile";
- public static final String MAX_TIME = "max_time";
- public static final String MIN_TIME = "min_time";
- public static final String LAST_VALUE = "last_value";
- public static final int MIN_SUPPORTED_JDK_VERSION = 8;
- public static final Set<String> reservedWords = new HashSet<>();
-
- static {
- reservedWords.add("TIME");
- reservedWords.add("TIMESTAMP");
- reservedWords.add("ROOT");
- }
-
- // show info
- public static final String COLUMN_ITEM = " item";
- public static final String COLUMN_VALUE = "value";
- public static final String COLUMN_VERSION = "version";
- public static final String COLUMN_BUILD_INFO = "build info";
- public static final String COLUMN_TIMESERIES = "timeseries";
- public static final String COLUMN_TIMESERIES_ALIAS = "alias";
- public static final String COLUMN_TIMESERIES_DATATYPE = "dataType";
- public static final String COLUMN_TIMESERIES_ENCODING = "encoding";
- public static final String COLUMN_TIMESERIES_COMPRESSION = "compression";
- public static final String COLUMN_TIMESERIES_COMPRESSOR = "compressor";
- public static final String COLUMN_CHILD_PATHS = "child paths";
- public static final String COLUMN_CHILD_PATHS_TYPES = "node types";
- public static final String COLUMN_CHILD_NODES = "child nodes";
- public static final String COLUMN_DEVICES = "devices";
- public static final String COLUMN_DELETED_DEVICE_NUM = "num_of_deleted_devices";
- public static final String COLUMN_COLUMN = "column";
- public static final String COLUMN_COUNT = "count";
- public static final String COLUMN_TAGS = "tags";
- public static final String COLUMN_ATTRIBUTES = "attributes";
- public static final String COLUMN_IS_ALIGNED = "isAligned";
- public static final String COLUMN_DISTRIBUTION_PLAN = "distribution plan";
- public static final String QUERY_ID = "queryId";
- public static final String STATEMENT = "statement";
-
- public static final String COLUMN_DATABASE = "database";
-
- public static final String COLUMN_FUNCTION_NAME = "function name";
- public static final String COLUMN_FUNCTION_TYPE = "function type";
- public static final String COLUMN_FUNCTION_CLASS = "class name (UDF)";
-
- public static final String COLUMN_SCHEMA_TEMPLATE = "template name";
-
- // for tree model
- public static final String FUNCTION_TYPE_NATIVE = "native";
- public static final String FUNCTION_TYPE_BUILTIN_SCALAR = "built-in scalar";
- public static final String FUNCTION_TYPE_BUILTIN_UDAF = "built-in UDAF";
- public static final String FUNCTION_TYPE_BUILTIN_UDTF = "built-in UDTF";
- public static final String FUNCTION_TYPE_EXTERNAL_UDAF = "external UDAF";
- public static final String FUNCTION_TYPE_EXTERNAL_UDTF = "external UDTF";
- // for table model
- public static final String FUNCTION_TYPE_BUILTIN_SCALAR_FUNC = "built-in scalar function";
- public static final String FUNCTION_TYPE_BUILTIN_AGG_FUNC = "built-in aggregate function";
- public static final String FUNCTION_TYPE_BUILTIN_TABLE_FUNC = "built-in table function";
- public static final String FUNCTION_TYPE_USER_DEFINED_SCALAR_FUNC =
- "user-defined scalar function";
- public static final String FUNCTION_TYPE_USER_DEFINED_AGG_FUNC =
- "user-defined aggregate function";
- public static final String FUNCTION_TYPE_USER_DEFINED_TABLE_FUNC = "user-defined table function";
- // common
- public static final String FUNCTION_TYPE_UNKNOWN = "UNKNOWN";
- public static final String FUNCTION_STATE_AVAILABLE = "AVAILABLE";
- public static final String FUNCTION_STATE_UNAVAILABLE = "UNAVAILABLE";
-
- public static final String COLUMN_TRIGGER_NAME = "trigger name";
- public static final String COLUMN_TRIGGER_STATUS = "status";
- public static final String COLUMN_TRIGGER_EVENT = "event";
- public static final String COLUMN_TRIGGER_PATH = "path";
- public static final String COLUMN_TRIGGER_CLASS = "class name";
- public static final String COLUMN_TRIGGER_ATTRIBUTES = "attributes";
-
- public static final String COLUMN_TRIGGER_STATUS_STARTED = "started";
- public static final String COLUMN_TRIGGER_STATUS_STOPPED = "stopped";
-
- public static final String ONE_LEVEL_PATH_WILDCARD = "*";
- public static final String MULTI_LEVEL_PATH_WILDCARD = "**";
- public static final String TIME = "time";
-
- // sdt parameters
- public static final String LOSS = "loss";
- public static final String SDT = "sdt";
- public static final String SDT_COMP_DEV = "compdev";
- public static final String SDT_COMP_MIN_TIME = "compmintime";
- public static final String SDT_COMP_MAX_TIME = "compmaxtime";
- public static final String[] SDT_PARAMETERS =
- new String[] {SDT_COMP_DEV, SDT_COMP_MIN_TIME, SDT_COMP_MAX_TIME};
-
- public static final String DEADBAND = "deadband";
- public static final String MAX_POINT_NUMBER = "max_point_number";
- public static final String MAX_STRING_LENGTH = "max_string_length";
- public static final Set<String> ALLOWED_SCHEMA_PROPS =
- new HashSet<>(
- Arrays.asList(
- DEADBAND,
- LOSS,
- SDT,
- SDT_COMP_DEV,
- SDT_COMP_MIN_TIME,
- SDT_COMP_MAX_TIME,
- MAX_POINT_NUMBER,
- MAX_STRING_LENGTH));
-
- // default base dir, stores all IoTDB runtime files
- public static final String CN_DEFAULT_DATA_DIR = "data" + File.separator + CN_ROLE;
- public static final String DN_DEFAULT_DATA_DIR = "data" + File.separator + DN_ROLE;
-
- // data folder name
- public static final String DATA_FOLDER_NAME = "data";
- public static final String SEQUENCE_FOLDER_NAME = "sequence";
- public static final String UNSEQUENCE_FOLDER_NAME = "unsequence";
- public static final String FILE_NAME_SEPARATOR = "-";
- public static final String CONSENSUS_FOLDER_NAME = "consensus";
- public static final String DATA_REGION_FOLDER_NAME = "data_region";
- public static final String INVALID_DATA_REGION_FOLDER_NAME = "invalid_data_region";
- public static final String SCHEMA_REGION_FOLDER_NAME = "schema_region";
- public static final String SNAPSHOT_FOLDER_NAME = "snapshot";
-
- // system folder name
- public static final String SYSTEM_FOLDER_NAME = "system";
- public static final String SCHEMA_FOLDER_NAME = "schema";
- public static final String LOAD_TSFILE_FOLDER_NAME = "load";
- public static final String LOAD_TSFILE_ACTIVE_LISTENING_PENDING_FOLDER_NAME = "pending";
- public static final String LOAD_TSFILE_ACTIVE_LISTENING_FAILED_FOLDER_NAME = "failed";
- public static final String SYNC_FOLDER_NAME = "sync";
- public static final String QUERY_FOLDER_NAME = "query";
- public static final String EXT_FOLDER_NAME = "ext";
- public static final String UDF_FOLDER_NAME = "udf";
- public static final String TRIGGER_FOLDER_NAME = "trigger";
- public static final String PIPE_FOLDER_NAME = "pipe";
- public static final String TMP_FOLDER_NAME = "tmp";
- public static final String DELETION_FOLDER_NAME = "deletion";
-
- public static final String MQTT_FOLDER_NAME = "mqtt";
- public static final String WAL_FOLDER_NAME = "wal";
- public static final String EXT_PIPE_FOLDER_NAME = "extPipe";
-
- // mqtt
- public static final String ENABLE_MQTT = "enable_mqtt_service";
- public static final String MQTT_HOST_NAME = "mqtt_host";
- public static final String MQTT_PORT_NAME = "mqtt_port";
- public static final String MQTT_HANDLER_POOL_SIZE_NAME = "mqtt_handler_pool_size";
- public static final String MQTT_PAYLOAD_FORMATTER_NAME = "mqtt_payload_formatter";
- public static final String MQTT_DATA_PATH = "mqtt_data_path";
- public static final String MQTT_MAX_MESSAGE_SIZE = "mqtt_max_message_size";
-
- // thrift
- public static final int LEFT_SIZE_IN_REQUEST = 4 * 1024 * 1024;
- public static final int DEFAULT_FETCH_SIZE = 5000;
- public static final int DEFAULT_CONNECTION_TIMEOUT_MS = 0;
-
- // ratis
- public static final int RAFT_LOG_BASIC_SIZE = 48;
-
- // inner space compaction
- public static final String INNER_COMPACTION_TMP_FILE_SUFFIX = ".inner";
-
- // cross space compaction
- public static final String CROSS_COMPACTION_TMP_FILE_SUFFIX = ".cross";
-
- public static final String SETTLE_SUFFIX = ".settle";
- public static final String MODS_SETTLE_FILE_SUFFIX = ".mods.settle";
- public static final String BLANK = "";
-
- // write ahead log
- public static final String WAL_FILE_PREFIX = "_";
- public static final String WAL_FILE_SUFFIX = ".wal";
- public static final String WAL_CHECKPOINT_FILE_SUFFIX = ".checkpoint";
- public static final String WAL_VERSION_ID = "versionId";
- public static final String WAL_START_SEARCH_INDEX = "startSearchIndex";
- public static final String WAL_STATUS_CODE = "statusCode";
-
- public static final String IOTDB_FOREGROUND = "iotdb-foreground";
- public static final String IOTDB_PIDFILE = "iotdb-pidfile";
-
- // quota
- public static final String SPACE_QUOTA_DISK = "disk";
- public static final String QUOTA_UNLIMITED = "unlimited";
- public static final String REQUEST_NUM_PER_UNIT_TIME = "request";
- public static final String REQUEST_SIZE_PER_UNIT_TIME = "size";
- public static final String MEMORY_SIZE_PER_READ = "mem";
- public static final String CPU_NUMBER_PER_READ = "cpu";
- public static final String REQUEST_TYPE = "type";
- public static final String REQUEST_TYPE_READ = "read";
- public static final String REQUEST_TYPE_WRITE = "write";
- public static final String REQ_UNIT = "req";
- public static final String REQ_SPLIT_UNIT = "req/";
- public static final int UNLIMITED_VALUE = -1;
- public static final int DEFAULT_VALUE = 0;
- public static final float B_FLOAT = 1024.0F;
-
- // SizeUnit
- public static final String B_UNIT = "B";
- public static final String KB_UNIT = "K";
- public static final String MB_UNIT = "M";
- public static final String GB_UNIT = "G";
- public static final String TB_UNIT = "T";
- public static final String PB_UNIT = "P";
-
- // Time
- public static final int SEC = 1000;
- public static final int MIN = 60 * 1000;
- public static final int HOUR = 60 * 60 * 1000;
- public static final int DAY = 24 * 60 * 60 * 1000;
-
- // TimeUnit
- public static final String SEC_UNIT = "sec";
- public static final String MIN_UNIT = "min";
- public static final String HOUR_UNIT = "hour";
- public static final String DAY_UNIT = "day";
-
- // client version number
- public enum ClientVersion {
- V_0_12,
- V_0_13,
- V_1_0
- }
-
- // select into
- public static final Pattern LEVELED_PATH_TEMPLATE_PATTERN = Pattern.compile("\\$\\{\\w+}");
- public static final String DOUBLE_COLONS = "::";
-
- public static final int MAX_DATABASE_NAME_LENGTH = 64;
-
- public static final String TIER_SEPARATOR = ";";
-
- public static final String OBJECT_STORAGE_DIR = "object_storage";
-
- public static final String TTL_INFINITE = "INF";
-
- public static final String INTEGRATION_TEST_KILL_POINTS = "integrationTestKillPoints";
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/PipeConnectorConstant.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/PipeConnectorConstant.java
index 08182eb..314d167 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/PipeConnectorConstant.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/PipeConnectorConstant.java
@@ -23,7 +23,6 @@ import org.apache.iotdb.collector.config.PipeOptions;
import com.github.luben.zstd.Zstd;
-import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -153,13 +152,6 @@ public class PipeConnectorConstant {
public static final String SINK_OPC_UA_HTTPS_BIND_PORT_KEY = "sink.opcua.https.port";
public static final int CONNECTOR_OPC_UA_HTTPS_BIND_PORT_DEFAULT_VALUE = 8443;
- public static final String CONNECTOR_OPC_UA_SECURITY_DIR_KEY = "connector.opcua.security.dir";
- public static final String SINK_OPC_UA_SECURITY_DIR_KEY = "sink.opcua.security.dir";
- public static final String CONNECTOR_OPC_UA_SECURITY_DIR_DEFAULT_VALUE =
- getConfDir() != null
- ? getConfDir() + File.separatorChar + "opc_security"
- : System.getProperty("user.home") + File.separatorChar + "iotdb_opc_security";
-
public static final String CONNECTOR_OPC_UA_ENABLE_ANONYMOUS_ACCESS_KEY =
"connector.opcua.enable-anonymous-access";
public static final String SINK_OPC_UA_ENABLE_ANONYMOUS_ACCESS_KEY =
@@ -256,19 +248,6 @@ public class PipeConnectorConstant {
public static final String CONNECTOR_OPC_DA_PROGID_KEY = "connector.opcda.progid";
public static final String SINK_OPC_DA_PROGID_KEY = "sink.opcda.progid";
- public static String getConfDir() {
- // Check if a config-directory was specified first.
- String confString = System.getProperty(IoTDBConstant.IOTDB_CONF, null);
- // If it wasn't, check if a home directory was provided (This usually contains a config)
- if (confString == null) {
- confString = System.getProperty(IoTDBConstant.IOTDB_HOME, null);
- if (confString != null) {
- confString = confString + File.separatorChar + "conf";
- }
- }
- return confString;
- }
-
private PipeConnectorConstant() {
throw new IllegalStateException("Utility class");
}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/PipeExtractorConstant.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/PipeExtractorConstant.java
deleted file mode 100644
index 10b0e4c..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/PipeExtractorConstant.java
+++ /dev/null
@@ -1,149 +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.collector.plugin.builtin.sink.constant;
-
-public class PipeExtractorConstant {
-
- public static final String EXTRACTOR_KEY = "extractor";
- public static final String SOURCE_KEY = "source";
-
- public static final String EXTRACTOR_CAPTURE_TREE_KEY = "extractor.capture.tree";
- public static final String SOURCE_CAPTURE_TREE_KEY = "source.capture.tree";
- public static final String EXTRACTOR_CAPTURE_TABLE_KEY = "extractor.capture.table";
- public static final String SOURCE_CAPTURE_TABLE_KEY = "source.capture.table";
-
- public static final String EXTRACTOR_INCLUSION_KEY = "extractor.inclusion";
- public static final String SOURCE_INCLUSION_KEY = "source.inclusion";
- public static final String EXTRACTOR_INCLUSION_DEFAULT_VALUE = "data.insert";
-
- public static final String EXTRACTOR_EXCLUSION_KEY = "extractor.inclusion.exclusion";
- public static final String SOURCE_EXCLUSION_KEY = "source.inclusion.exclusion";
- public static final String EXTRACTOR_EXCLUSION_DEFAULT_VALUE = "";
-
- public static final String EXTRACTOR_MODE_KEY = "extractor.mode";
- public static final String SOURCE_MODE_KEY = "source.mode";
- public static final String EXTRACTOR_MODE_QUERY_VALUE = "query";
- public static final String EXTRACTOR_MODE_SNAPSHOT_VALUE = "snapshot";
- public static final String EXTRACTOR_MODE_SUBSCRIBE_VALUE = "subscribe";
- public static final String EXTRACTOR_MODE_LIVE_VALUE = "live";
- public static final String EXTRACTOR_MODE_DEFAULT_VALUE = EXTRACTOR_MODE_LIVE_VALUE;
-
- public static final String EXTRACTOR_PATTERN_KEY = "extractor.pattern";
- public static final String SOURCE_PATTERN_KEY = "source.pattern";
- public static final String EXTRACTOR_PATH_KEY = "extractor.path";
- public static final String SOURCE_PATH_KEY = "source.path";
- public static final String EXTRACTOR_PATTERN_FORMAT_KEY = "extractor.pattern.format";
- public static final String SOURCE_PATTERN_FORMAT_KEY = "source.pattern.format";
- public static final String EXTRACTOR_PATTERN_FORMAT_PREFIX_VALUE = "prefix";
- public static final String EXTRACTOR_PATTERN_FORMAT_IOTDB_VALUE = "iotdb";
- public static final String EXTRACTOR_PATTERN_PREFIX_DEFAULT_VALUE = "root";
- public static final String EXTRACTOR_PATTERN_IOTDB_DEFAULT_VALUE = "root.**";
- public static final String EXTRACTOR_DATABASE_NAME_KEY = "extractor.database-name";
- public static final String SOURCE_DATABASE_NAME_KEY = "source.database-name";
- public static final String EXTRACTOR_TABLE_NAME_KEY = "extractor.table-name";
- public static final String SOURCE_TABLE_NAME_KEY = "source.table-name";
- public static final String EXTRACTOR_DATABASE_NAME_DEFAULT_VALUE = ".*";
- public static final String EXTRACTOR_TABLE_NAME_DEFAULT_VALUE = ".*";
- public static final String EXTRACTOR_DATABASE_KEY = "extractor.database";
- public static final String SOURCE_DATABASE_KEY = "source.database";
- public static final String EXTRACTOR_TABLE_KEY = "extractor.table";
- public static final String SOURCE_TABLE_KEY = "source.table";
-
- public static final String EXTRACTOR_FORWARDING_PIPE_REQUESTS_KEY =
- "extractor.forwarding-pipe-requests";
- public static final String SOURCE_FORWARDING_PIPE_REQUESTS_KEY =
- "source.forwarding-pipe-requests";
- public static final boolean EXTRACTOR_FORWARDING_PIPE_REQUESTS_DEFAULT_VALUE = true;
-
- public static final String EXTRACTOR_HISTORY_ENABLE_KEY = "extractor.history.enable";
- public static final String SOURCE_HISTORY_ENABLE_KEY = "source.history.enable";
- public static final boolean EXTRACTOR_HISTORY_ENABLE_DEFAULT_VALUE = true;
- public static final String EXTRACTOR_HISTORY_START_TIME_KEY = "extractor.history.start-time";
- public static final String SOURCE_HISTORY_START_TIME_KEY = "source.history.start-time";
- public static final String EXTRACTOR_HISTORY_END_TIME_KEY = "extractor.history.end-time";
- public static final String SOURCE_HISTORY_END_TIME_KEY = "source.history.end-time";
- public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_KEY = "extractor.history.loose-range";
- public static final String SOURCE_HISTORY_LOOSE_RANGE_KEY = "source.history.loose-range";
- public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_TIME_VALUE = "time";
- public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_PATH_VALUE = "path";
- public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_ALL_VALUE = "all";
- public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_DEFAULT_VALUE = "";
- public static final String EXTRACTOR_MODS_ENABLE_KEY = "extractor.mods.enable";
- public static final String SOURCE_MODS_ENABLE_KEY = "source.mods.enable";
- public static final boolean EXTRACTOR_MODS_ENABLE_DEFAULT_VALUE = false;
- public static final String EXTRACTOR_MODS_KEY = "extractor.mods";
- public static final String SOURCE_MODS_KEY = "source.mods";
- public static final boolean EXTRACTOR_MODS_DEFAULT_VALUE = EXTRACTOR_MODS_ENABLE_DEFAULT_VALUE;
-
- public static final String EXTRACTOR_REALTIME_ENABLE_KEY = "extractor.realtime.enable";
- public static final String SOURCE_REALTIME_ENABLE_KEY = "source.realtime.enable";
- public static final boolean EXTRACTOR_REALTIME_ENABLE_DEFAULT_VALUE = true;
- public static final String EXTRACTOR_REALTIME_MODE_KEY = "extractor.realtime.mode";
- public static final String SOURCE_REALTIME_MODE_KEY = "source.realtime.mode";
- public static final String EXTRACTOR_REALTIME_MODE_HYBRID_VALUE = "hybrid";
- public static final String EXTRACTOR_REALTIME_MODE_FILE_VALUE = "file";
- public static final String EXTRACTOR_REALTIME_MODE_LOG_VALUE = "log";
- public static final String EXTRACTOR_REALTIME_MODE_FORCED_LOG_VALUE = "forced-log";
- public static final String EXTRACTOR_REALTIME_MODE_STREAM_MODE_VALUE = "stream";
- public static final String EXTRACTOR_REALTIME_MODE_BATCH_MODE_VALUE = "batch";
- public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_KEY = "extractor.realtime.loose-range";
- public static final String SOURCE_REALTIME_LOOSE_RANGE_KEY = "source.realtime.loose-range";
- public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_TIME_VALUE = "time";
- public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_PATH_VALUE = "path";
- public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_ALL_VALUE = "all";
- public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_DEFAULT_VALUE = "";
-
- public static final String EXTRACTOR_MODE_STREAMING_KEY = "extractor.mode.streaming";
- public static final String SOURCE_MODE_STREAMING_KEY = "source.mode.streaming";
- public static final boolean EXTRACTOR_MODE_STREAMING_DEFAULT_VALUE = true;
- public static final String EXTRACTOR_MODE_STRICT_KEY = "extractor.mode.strict";
- public static final String SOURCE_MODE_STRICT_KEY = "source.mode.strict";
- public static final boolean EXTRACTOR_MODE_STRICT_DEFAULT_VALUE = true;
- public static final String EXTRACTOR_MODE_SNAPSHOT_KEY = "extractor.mode.snapshot";
- public static final String SOURCE_MODE_SNAPSHOT_KEY = "source.mode.snapshot";
- public static final boolean EXTRACTOR_MODE_SNAPSHOT_DEFAULT_VALUE = false;
- public static final String EXTRACTOR_MODE_DOUBLE_LIVING_KEY = "extractor.mode.double-living";
- public static final String SOURCE_MODE_DOUBLE_LIVING_KEY = "source.mode.double-living";
- public static final boolean EXTRACTOR_MODE_DOUBLE_LIVING_DEFAULT_VALUE = false;
-
- public static final String EXTRACTOR_START_TIME_KEY = "extractor.start-time";
- public static final String SOURCE_START_TIME_KEY = "source.start-time";
- public static final String EXTRACTOR_END_TIME_KEY = "extractor.end-time";
- public static final String SOURCE_END_TIME_KEY = "source.end-time";
- public static final String NOW_TIME_VALUE = "now";
-
- public static final String _EXTRACTOR_WATERMARK_INTERVAL_KEY = "extractor.watermark-interval-ms";
- public static final String _SOURCE_WATERMARK_INTERVAL_KEY = "source.watermark-interval-ms";
- public static final long EXTRACTOR_WATERMARK_INTERVAL_DEFAULT_VALUE = -1; // -1 means no watermark
- public static final String EXTRACTOR_WATERMARK_INTERVAL_KEY = "extractor.watermark.interval-ms";
- public static final String SOURCE_WATERMARK_INTERVAL_KEY = "source.watermark.interval-ms";
-
- ///////////////////// pipe consensus /////////////////////
-
- public static final String EXTRACTOR_CONSENSUS_GROUP_ID_KEY = "extractor.consensus.group-id";
- public static final String EXTRACTOR_CONSENSUS_SENDER_DATANODE_ID_KEY =
- "extractor.consensus.sender-dn-id";
- public static final String EXTRACTOR_CONSENSUS_RECEIVER_DATANODE_ID_KEY =
- "extractor.consensus.receiver-dn-id";
-
- private PipeExtractorConstant() {
- throw new IllegalStateException("Utility class");
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/SystemConstant.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/SystemConstant.java
deleted file mode 100644
index c196336..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/constant/SystemConstant.java
+++ /dev/null
@@ -1,60 +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.collector.plugin.builtin.sink.constant;
-
-import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameters;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-public class SystemConstant {
-
- public static final String SYSTEM_PREFIX_KEY = "__system";
-
- public static final String RESTART_KEY = "__system.restart";
- public static final boolean RESTART_DEFAULT_VALUE = false;
-
- public static final String SQL_DIALECT_KEY = "__system.sql-dialect";
- public static final String SQL_DIALECT_TREE_VALUE = "tree";
- public static final String SQL_DIALECT_TABLE_VALUE = "table";
-
- /////////////////////////////////// Utility ///////////////////////////////////
-
- public static final Set<String> SYSTEM_KEYS = new HashSet<>();
-
- static {
- SYSTEM_KEYS.add(RESTART_KEY);
- SYSTEM_KEYS.add(SQL_DIALECT_KEY);
- }
-
- public static PipeParameters addSystemKeysIfNecessary(final PipeParameters givenPipeParameters) {
- final Map<String, String> attributes = new HashMap<>(givenPipeParameters.getAttribute());
- attributes.putIfAbsent(SQL_DIALECT_KEY, SQL_DIALECT_TREE_VALUE);
- return new PipeParameters(attributes);
- }
-
- /////////////////////////////////// Private Constructor ///////////////////////////////////
-
- private SystemConstant() {
- throw new IllegalStateException("Utility class");
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeConnectorRetryTimesConfigurableException.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeInsertionEvent.java
similarity index 64%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeConnectorRetryTimesConfigurableException.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeInsertionEvent.java
index 786be00..1027ece 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeConnectorRetryTimesConfigurableException.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeInsertionEvent.java
@@ -17,20 +17,24 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.exception.pipe;
+package org.apache.iotdb.collector.plugin.builtin.sink.event;
-public class PipeRuntimeConnectorRetryTimesConfigurableException
- extends PipeRuntimeConnectorCriticalException {
+public abstract class PipeInsertionEvent {
- private final int retryTimes;
+ protected Boolean isTableModelEvent;
- public PipeRuntimeConnectorRetryTimesConfigurableException(
- final String message, final int retryTimes) {
- super(message);
- this.retryTimes = retryTimes;
+ protected String treeModelDatabaseName;
+ protected String tableModelDatabaseName;
+
+ public boolean isTableModelEvent() {
+ return isTableModelEvent;
+ }
+
+ public String getTreeModelDatabaseName() {
+ return treeModelDatabaseName;
}
- public int getRetryTimes() {
- return retryTimes;
+ public String getTableModelDatabaseName() {
+ return tableModelDatabaseName;
}
}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeRawTabletInsertionEvent.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeRawTabletInsertionEvent.java
new file mode 100644
index 0000000..c6a9e27
--- /dev/null
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeRawTabletInsertionEvent.java
@@ -0,0 +1,62 @@
+/*
+ * 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.collector.plugin.builtin.sink.event;
+
+import org.apache.iotdb.pipe.api.access.Row;
+import org.apache.iotdb.pipe.api.collector.RowCollector;
+import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
+
+import org.apache.tsfile.write.record.Tablet;
+
+import java.util.function.BiConsumer;
+
+public class PipeRawTabletInsertionEvent extends PipeInsertionEvent
+ implements TabletInsertionEvent, AutoCloseable {
+
+ private Tablet tablet;
+ private boolean isAligned;
+
+ @Override
+ public Iterable<TabletInsertionEvent> processRowByRow(
+ final BiConsumer<Row, RowCollector> consumer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Iterable<TabletInsertionEvent> processTablet(
+ final BiConsumer<Tablet, RowCollector> consumer) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAligned() {
+ return isAligned;
+ }
+
+ public boolean isTableModelEvent() {
+ return false;
+ }
+
+ public String getTableModelDatabaseName() {
+ return null;
+ }
+
+ @Override
+ public void close() {}
+}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeTsFileInsertionEvent.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeTsFileInsertionEvent.java
new file mode 100644
index 0000000..a134208
--- /dev/null
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/PipeTsFileInsertionEvent.java
@@ -0,0 +1,54 @@
+/*
+ * 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.collector.plugin.builtin.sink.event;
+
+import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
+import org.apache.iotdb.pipe.api.event.dml.insertion.TsFileInsertionEvent;
+import org.apache.iotdb.pipe.api.exception.PipeException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+
+public class PipeTsFileInsertionEvent extends PipeInsertionEvent implements TsFileInsertionEvent {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PipeTsFileInsertionEvent.class);
+
+ private File tsFile;
+
+ @Override
+ public boolean isTableModelEvent() {
+ throw new PipeException("");
+ }
+
+ @Override
+ public Iterable<TabletInsertionEvent> toTabletInsertionEvents() throws PipeException {
+ return toTabletInsertionEvents(Long.MAX_VALUE);
+ }
+
+ public Iterable<TabletInsertionEvent> toTabletInsertionEvents(final long timeoutMs)
+ throws PipeException {
+ return null;
+ }
+
+ @Override
+ public void close() throws Exception {}
+}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeBinaryTransformer.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeBinaryTransformer.java
deleted file mode 100644
index 06c3fdc..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeBinaryTransformer.java
+++ /dev/null
@@ -1,37 +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.collector.plugin.builtin.sink.event.row;
-
-public class PipeBinaryTransformer {
-
- public static org.apache.tsfile.utils.Binary transformToBinary(
- org.apache.iotdb.pipe.api.type.Binary binary) {
- return binary == null ? null : new org.apache.tsfile.utils.Binary(binary.getValues());
- }
-
- public static org.apache.iotdb.pipe.api.type.Binary transformToPipeBinary(
- org.apache.tsfile.utils.Binary binary) {
- return binary == null ? null : new org.apache.iotdb.pipe.api.type.Binary(binary.getValues());
- }
-
- private PipeBinaryTransformer() {
- // util class
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeDataTypeTransformer.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeDataTypeTransformer.java
deleted file mode 100644
index 85883ff..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeDataTypeTransformer.java
+++ /dev/null
@@ -1,74 +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.collector.plugin.builtin.sink.event.row;
-
-import org.apache.iotdb.pipe.api.type.Type;
-
-import org.apache.tsfile.enums.TSDataType;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-/** Transform between {@link TSDataType} and {@link Type}. */
-public class PipeDataTypeTransformer {
-
- public static List<Type> transformToPipeDataTypeList(final List<TSDataType> tsDataTypeList) {
- return tsDataTypeList == null
- ? null
- : tsDataTypeList.stream()
- .map(PipeDataTypeTransformer::transformToPipeDataType)
- .collect(Collectors.toList());
- }
-
- public static Type transformToPipeDataType(final TSDataType tsDataType) {
- return tsDataType == null ? null : getPipeDataType(tsDataType.getType());
- }
-
- private static Type getPipeDataType(final byte type) {
- switch (type) {
- case 0:
- return Type.BOOLEAN;
- case 1:
- return Type.INT32;
- case 2:
- return Type.INT64;
- case 3:
- return Type.FLOAT;
- case 4:
- return Type.DOUBLE;
- case 5:
- return Type.TEXT;
- case 8:
- return Type.TIMESTAMP;
- case 9:
- return Type.DATE;
- case 10:
- return Type.BLOB;
- case 11:
- return Type.STRING;
- default:
- throw new IllegalArgumentException("Invalid input: " + type);
- }
- }
-
- private PipeDataTypeTransformer() {
- // util class
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeResetTabletRow.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeResetTabletRow.java
deleted file mode 100644
index a30aca1..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeResetTabletRow.java
+++ /dev/null
@@ -1,54 +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.collector.plugin.builtin.sink.event.row;
-
-import org.apache.tsfile.enums.TSDataType;
-import org.apache.tsfile.utils.BitMap;
-import org.apache.tsfile.write.record.Tablet;
-import org.apache.tsfile.write.schema.MeasurementSchema;
-
-/**
- * The pipe framework will reset a new {@link Tablet} when this kind of {@link PipeRow} is
- * encountered.
- */
-public class PipeResetTabletRow extends PipeRow {
-
- public PipeResetTabletRow(
- int rowIndex,
- String deviceId,
- boolean isAligned,
- MeasurementSchema[] measurementSchemaList,
- long[] timestampColumn,
- TSDataType[] valueColumnTypes,
- Object[] valueColumns,
- BitMap[] bitMaps,
- String[] columnNameStringList) {
- super(
- rowIndex,
- deviceId,
- isAligned,
- measurementSchemaList,
- timestampColumn,
- valueColumnTypes,
- valueColumns,
- bitMaps,
- columnNameStringList);
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeRow.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeRow.java
deleted file mode 100644
index ad123a9..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeRow.java
+++ /dev/null
@@ -1,212 +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.collector.plugin.builtin.sink.event.row;
-
-import org.apache.iotdb.pipe.api.access.Row;
-import org.apache.iotdb.pipe.api.exception.PipeParameterNotValidException;
-import org.apache.iotdb.pipe.api.type.Binary;
-import org.apache.iotdb.pipe.api.type.Type;
-
-import org.apache.tsfile.common.conf.TSFileConfig;
-import org.apache.tsfile.enums.TSDataType;
-import org.apache.tsfile.read.common.Path;
-import org.apache.tsfile.utils.BitMap;
-import org.apache.tsfile.write.schema.IMeasurementSchema;
-
-import java.time.LocalDate;
-import java.util.Arrays;
-import java.util.List;
-
-public class PipeRow implements Row {
-
- protected final int rowIndex;
-
- protected final String deviceId;
- protected final boolean isAligned;
- protected final IMeasurementSchema[] measurementSchemaList;
-
- protected final long[] timestampColumn;
- protected final TSDataType[] valueColumnTypes;
- protected final Object[] valueColumns;
- protected final BitMap[] bitMaps;
-
- protected final String[] columnNameStringList;
-
- public PipeRow(
- final int rowIndex,
- final String deviceId,
- final boolean isAligned,
- final IMeasurementSchema[] measurementSchemaList,
- final long[] timestampColumn,
- final TSDataType[] valueColumnTypes,
- final Object[] valueColumns,
- final BitMap[] bitMaps,
- final String[] columnNameStringList) {
- this.rowIndex = rowIndex;
- this.deviceId = deviceId;
- this.isAligned = isAligned;
- this.measurementSchemaList = measurementSchemaList;
- this.timestampColumn = timestampColumn;
- this.valueColumnTypes = valueColumnTypes;
- this.valueColumns = valueColumns;
- this.bitMaps = bitMaps;
- this.columnNameStringList = columnNameStringList;
- }
-
- @Override
- public long getTime() {
- return timestampColumn[rowIndex];
- }
-
- @Override
- public int getInt(final int columnIndex) {
- return ((int[]) valueColumns[columnIndex])[rowIndex];
- }
-
- @Override
- public LocalDate getDate(final int columnIndex) {
- return ((LocalDate[]) valueColumns[columnIndex])[rowIndex];
- }
-
- @Override
- public long getLong(final int columnIndex) {
- return ((long[]) valueColumns[columnIndex])[rowIndex];
- }
-
- @Override
- public float getFloat(final int columnIndex) {
- return ((float[]) valueColumns[columnIndex])[rowIndex];
- }
-
- @Override
- public double getDouble(final int columnIndex) {
- return ((double[]) valueColumns[columnIndex])[rowIndex];
- }
-
- @Override
- public boolean getBoolean(final int columnIndex) {
- return ((boolean[]) valueColumns[columnIndex])[rowIndex];
- }
-
- @Override
- public Binary getBinary(final int columnIndex) {
- return PipeBinaryTransformer.transformToPipeBinary(
- ((org.apache.tsfile.utils.Binary[]) valueColumns[columnIndex])[rowIndex]);
- }
-
- @Override
- public String getString(final int columnIndex) {
- final org.apache.tsfile.utils.Binary binary =
- ((org.apache.tsfile.utils.Binary[]) valueColumns[columnIndex])[rowIndex];
- return binary == null ? null : binary.getStringValue(TSFileConfig.STRING_CHARSET);
- }
-
- @Override
- public Object getObject(final int columnIndex) {
- switch (getDataType(columnIndex)) {
- case INT32:
- return getInt(columnIndex);
- case DATE:
- return getDate(columnIndex);
- case INT64:
- case TIMESTAMP:
- return getLong(columnIndex);
- case FLOAT:
- return getFloat(columnIndex);
- case DOUBLE:
- return getDouble(columnIndex);
- case BOOLEAN:
- return getBoolean(columnIndex);
- case TEXT:
- case BLOB:
- case STRING:
- return getBinary(columnIndex);
- default:
- throw new UnsupportedOperationException(
- String.format(
- "unsupported data type %s for column %s",
- getDataType(columnIndex), columnNameStringList[columnIndex]));
- }
- }
-
- @Override
- public Type getDataType(final int columnIndex) {
- return PipeDataTypeTransformer.transformToPipeDataType(valueColumnTypes[columnIndex]);
- }
-
- @Override
- public boolean isNull(final int columnIndex) {
- return bitMaps[columnIndex].isMarked(rowIndex);
- }
-
- @Override
- public int size() {
- return valueColumns.length;
- }
-
- @Override
- public int getColumnIndex(final Path columnName) throws PipeParameterNotValidException {
- for (int i = 0; i < columnNameStringList.length; i++) {
- if (columnNameStringList[i].equals(columnName.getFullPath())) {
- return i;
- }
- }
- throw new PipeParameterNotValidException(
- String.format("column %s not found", columnName.getFullPath()));
- }
-
- @Override
- public String getColumnName(final int columnIndex) {
- return columnNameStringList[columnIndex];
- }
-
- @Override
- public List<Type> getColumnTypes() {
- return PipeDataTypeTransformer.transformToPipeDataTypeList(Arrays.asList(valueColumnTypes));
- }
-
- @Override
- public String getDeviceId() {
- return deviceId;
- }
-
- public boolean isAligned() {
- return isAligned;
- }
-
- public int getCurrentRowSize() {
- int rowSize = 0;
- rowSize += 8; // timestamp
- for (int i = 0; i < valueColumnTypes.length; i++) {
- if (valueColumnTypes[i] != null) {
- if (valueColumnTypes[i].isBinary()) {
- rowSize += getBinary(i) != null ? getBinary(i).getLength() : 0;
- } else {
- rowSize += valueColumnTypes[i].getDataTypeSize();
- }
- }
- }
- return rowSize;
- }
-
- public IMeasurementSchema[] getMeasurementSchemaList() {
- return measurementSchemaList;
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeRowCollector.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeRowCollector.java
deleted file mode 100644
index 73e86ef..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/row/PipeRowCollector.java
+++ /dev/null
@@ -1,145 +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.collector.plugin.builtin.sink.event.row;
-
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.PipeRawTabletInsertionEvent;
-import org.apache.iotdb.collector.plugin.builtin.sink.utils.PipeMemoryWeightUtil;
-import org.apache.iotdb.pipe.api.access.Row;
-import org.apache.iotdb.pipe.api.collector.RowCollector;
-import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
-import org.apache.iotdb.pipe.api.exception.PipeException;
-import org.apache.iotdb.pipe.api.type.Binary;
-
-import org.apache.tsfile.utils.Pair;
-import org.apache.tsfile.write.record.Tablet;
-import org.apache.tsfile.write.schema.IMeasurementSchema;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class PipeRowCollector implements RowCollector {
-
- private final List<TabletInsertionEvent> tabletInsertionEventList = new ArrayList<>();
- private Tablet tablet = null;
- private boolean isAligned = false;
- private final PipeRawTabletInsertionEvent sourceEvent; // Used to report progress
- private final String sourceEventDataBaseName;
- private final Boolean isTableModel;
-
- public PipeRowCollector(PipeRawTabletInsertionEvent sourceEvent) {
- this.sourceEvent = sourceEvent;
- if (sourceEvent instanceof PipeInsertionEvent) {
- sourceEventDataBaseName =
- ((PipeInsertionEvent) sourceEvent).getSourceDatabaseNameFromDataRegion();
- isTableModel = ((PipeInsertionEvent) sourceEvent).getRawIsTableModelEvent();
- } else {
- sourceEventDataBaseName = null;
- isTableModel = null;
- }
- }
-
- public PipeRowCollector(
- PipeRawTabletInsertionEvent sourceEvent, String sourceEventDataBase, Boolean isTableModel) {
- this.sourceEvent = sourceEvent;
- this.sourceEventDataBaseName = sourceEventDataBase;
- this.isTableModel = isTableModel;
- }
-
- @Override
- public void collectRow(Row row) {
- if (!(row instanceof PipeRow)) {
- throw new PipeException("Row can not be customized");
- }
-
- final PipeRow pipeRow = (PipeRow) row;
- final IMeasurementSchema[] measurementSchemaArray = pipeRow.getMeasurementSchemaList();
-
- // Trigger collection when a PipeResetTabletRow is encountered
- if (row instanceof PipeResetTabletRow) {
- collectTabletInsertionEvent();
- }
-
- if (tablet == null) {
- final String deviceId = pipeRow.getDeviceId();
- final List<IMeasurementSchema> measurementSchemaList =
- new ArrayList<>(Arrays.asList(measurementSchemaArray));
- // Calculate row count and memory size of the tablet based on the first row
- Pair<Integer, Integer> rowCountAndMemorySize =
- PipeMemoryWeightUtil.calculateTabletRowCountAndMemory(pipeRow);
- tablet = new Tablet(deviceId, measurementSchemaList, rowCountAndMemorySize.getLeft());
- tablet.initBitMaps();
- isAligned = pipeRow.isAligned();
- }
-
- final int rowIndex = tablet.getRowSize();
- tablet.addTimestamp(rowIndex, row.getTime());
- for (int i = 0; i < row.size(); i++) {
- final Object value = row.getObject(i);
- if (value instanceof Binary) {
- tablet.addValue(
- measurementSchemaArray[i].getMeasurementName(),
- rowIndex,
- PipeBinaryTransformer.transformToBinary((Binary) value));
- } else {
- tablet.addValue(measurementSchemaArray[i].getMeasurementName(), rowIndex, value);
- }
- if (row.isNull(i)) {
- tablet.getBitMaps()[i].mark(rowIndex);
- }
- }
-
- if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
- collectTabletInsertionEvent();
- }
- }
-
- private void collectTabletInsertionEvent() {
- if (tablet != null) {
- // TODO: non-PipeInsertionEvent sourceEvent is not supported?
- final PipeInsertionEvent pipeInsertionEvent =
- sourceEvent instanceof PipeInsertionEvent ? ((PipeInsertionEvent) sourceEvent) : null;
- tabletInsertionEventList.add(
- new PipeRawTabletInsertionEvent(
- isTableModel,
- sourceEventDataBaseName,
- pipeInsertionEvent == null ? null : pipeInsertionEvent.getRawTableModelDataBase(),
- pipeInsertionEvent == null ? null : pipeInsertionEvent.getRawTreeModelDataBase(),
- tablet,
- isAligned,
- sourceEvent == null ? null : sourceEvent.getPipeName(),
- sourceEvent == null ? 0 : sourceEvent.getCreationTime(),
- sourceEvent,
- false));
- }
- this.tablet = null;
- }
-
- public List<TabletInsertionEvent> convertToTabletInsertionEvents(final boolean shouldReport) {
- collectTabletInsertionEvent();
-
- final int eventListSize = tabletInsertionEventList.size();
- if (eventListSize > 0 && shouldReport) { // The last event should report progress
- ((PipeRawTabletInsertionEvent) tabletInsertionEventList.get(eventListSize - 1))
- .markAsNeedToReport();
- }
- return tabletInsertionEventList;
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/tablet/PipeRawTabletInsertionEvent.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/tablet/PipeRawTabletInsertionEvent.java
deleted file mode 100644
index 18132fc..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/tablet/PipeRawTabletInsertionEvent.java
+++ /dev/null
@@ -1,331 +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.collector.plugin.builtin.sink.event.tablet;
-
-import org.apache.iotdb.collector.plugin.builtin.sink.datastructure.pattern.TablePattern;
-import org.apache.iotdb.collector.plugin.builtin.sink.datastructure.pattern.TreePattern;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.parser.TabletInsertionEventParser;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.parser.TabletInsertionEventTablePatternParser;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.parser.TabletInsertionEventTreePatternParser;
-import org.apache.iotdb.collector.plugin.builtin.sink.resource.ref.PipePhantomReferenceManager;
-import org.apache.iotdb.pipe.api.access.Row;
-import org.apache.iotdb.pipe.api.collector.RowCollector;
-import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
-
-import org.apache.tsfile.utils.RamUsageEstimator;
-import org.apache.tsfile.write.record.Tablet;
-
-import java.util.Objects;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.BiConsumer;
-
-public class PipeRawTabletInsertionEvent extends PipeInsertionEvent
- implements TabletInsertionEvent, ReferenceTrackableEvent, AutoCloseable {
-
- // For better calculation
- private static final long INSTANCE_SIZE =
- RamUsageEstimator.shallowSizeOfInstance(PipeRawTabletInsertionEvent.class);
- private Tablet tablet;
- private String deviceId; // Only used when the tablet is released.
- private final boolean isAligned;
-
- private final PipeRawTabletInsertionEvent sourceEvent;
- private boolean needToReport;
-
- private PipeRawTabletInsertionEvent(
- final Boolean isTableModelEvent,
- final String databaseName,
- final String tableModelDataBaseName,
- final String treeModelDataBaseName,
- final Tablet tablet,
- final boolean isAligned,
- final PipeRawTabletInsertionEvent sourceEvent,
- final boolean needToReport,
- final String pipeName,
- final long creationTime,
- final TreePattern treePattern,
- final TablePattern tablePattern,
- final long startTime,
- final long endTime) {
- super(
- pipeName,
- creationTime,
- treePattern,
- tablePattern,
- startTime,
- endTime,
- isTableModelEvent,
- databaseName,
- tableModelDataBaseName,
- treeModelDataBaseName);
- this.tablet = Objects.requireNonNull(tablet);
- this.isAligned = isAligned;
- this.sourceEvent = sourceEvent;
- this.needToReport = needToReport;
-
- // Allocate empty memory block, will be resized later.
- // this.allocatedMemoryBlock =
- // PipeDataNodeResourceManager.memory().forceAllocateForTabletWithRetry(0);
- }
-
- public PipeRawTabletInsertionEvent(
- final Boolean isTableModelEvent,
- final String databaseName,
- final String tableModelDataBaseName,
- final String treeModelDataBaseName,
- final Tablet tablet,
- final boolean isAligned,
- final String pipeName,
- final long creationTime,
- final PipeRawTabletInsertionEvent sourceEvent,
- final boolean needToReport) {
- this(
- isTableModelEvent,
- databaseName,
- tableModelDataBaseName,
- treeModelDataBaseName,
- tablet,
- isAligned,
- sourceEvent,
- needToReport,
- pipeName,
- creationTime,
- null,
- null,
- Long.MIN_VALUE,
- Long.MAX_VALUE);
- }
-
- @Override
- public boolean internallyIncreaseResourceReferenceCount(final String holderMessage) {
- // PipeDataNodeResourceManager.memory()
- // .forceResize(
- // allocatedMemoryBlock,
- // PipeMemoryWeightUtil.calculateTabletSizeInBytes(tablet) + INSTANCE_SIZE);
- return true;
- }
-
- @Override
- public boolean internallyDecreaseResourceReferenceCount(final String holderMessage) {
- // allocatedMemoryBlock.close();
-
- // Record the deviceId before the memory is released,
- // for later possibly updating the leader cache.
- deviceId = tablet.getDeviceId();
-
- // Actually release the occupied memory.
- tablet = null;
- eventParser = null;
- return true;
- }
-
- @Override
- public PipeRawTabletInsertionEvent shallowCopySelfAndBindPipeTaskMetaForProgressReport(
- final String pipeName,
- final long creationTime,
- final TreePattern treePattern,
- final TablePattern tablePattern,
- final long startTime,
- final long endTime) {
- return new PipeRawTabletInsertionEvent(
- getRawIsTableModelEvent(),
- getSourceDatabaseNameFromDataRegion(),
- getRawTableModelDataBase(),
- getRawTreeModelDataBase(),
- tablet,
- isAligned,
- sourceEvent,
- needToReport,
- pipeName,
- creationTime,
- treePattern,
- tablePattern,
- startTime,
- endTime);
- }
-
- @Override
- public boolean isGeneratedByPipe() {
- throw new UnsupportedOperationException("isGeneratedByPipe() is not supported!");
- }
-
- @Override
- public boolean mayEventTimeOverlappedWithTimeRange() {
- final long[] timestamps = tablet.getTimestamps();
- if (Objects.isNull(timestamps) || timestamps.length == 0) {
- return false;
- }
- // We assume that `timestamps` is ordered.
- return startTime <= timestamps[timestamps.length - 1] && timestamps[0] <= endTime;
- }
-
- @Override
- public boolean mayEventPathsOverlappedWithPattern() {
- return sourceEvent == null || sourceEvent.mayEventPathsOverlappedWithPattern();
- }
-
- public void markAsNeedToReport() {
- this.needToReport = true;
- }
-
- public String getDeviceId() {
- // NonNull indicates that the internallyDecreaseResourceReferenceCount has not been called.
- return Objects.nonNull(tablet) ? tablet.getDeviceId() : deviceId;
- }
-
- public PipeRawTabletInsertionEvent getSourceEvent() {
- return sourceEvent;
- }
-
- /////////////////////////// TabletInsertionEvent ///////////////////////////
-
- @Override
- public Iterable<TabletInsertionEvent> processRowByRow(
- final BiConsumer<Row, RowCollector> consumer) {
- return initEventParser().processRowByRow(consumer);
- }
-
- @Override
- public Iterable<TabletInsertionEvent> processTablet(
- final BiConsumer<Tablet, RowCollector> consumer) {
- return initEventParser().processTablet(consumer);
- }
-
- /////////////////////////// convertToTablet ///////////////////////////
-
- public boolean isAligned() {
- return isAligned;
- }
-
- public Tablet convertToTablet() {
- if (!shouldParseTimeOrPattern()) {
- return tablet;
- }
- return initEventParser().convertToTablet();
- }
-
- /////////////////////////// event parser ///////////////////////////
-
- private TabletInsertionEventParser initEventParser() {
- if (eventParser == null) {
- eventParser =
- tablet.getDeviceId().startsWith("root.")
- ? new TabletInsertionEventTreePatternParser(this, tablet, isAligned, treePattern)
- : new TabletInsertionEventTablePatternParser(this, tablet, isAligned, tablePattern);
- }
- return eventParser;
- }
-
- public long count() {
- final Tablet covertedTablet = shouldParseTimeOrPattern() ? convertToTablet() : tablet;
- return (long) covertedTablet.getRowSize() * covertedTablet.getSchemas().size();
- }
-
- /////////////////////////// parsePatternOrTime ///////////////////////////
-
- public PipeRawTabletInsertionEvent parseEventWithPatternOrTime() {
- return new PipeRawTabletInsertionEvent(
- getRawIsTableModelEvent(),
- getSourceDatabaseNameFromDataRegion(),
- getRawTableModelDataBase(),
- getRawTreeModelDataBase(),
- convertToTablet(),
- isAligned,
- pipeName,
- creationTime,
- this,
- needToReport);
- }
-
- public boolean hasNoNeedParsingAndIsEmpty() {
- return !shouldParseTimeOrPattern() && isTabletEmpty(tablet);
- }
-
- public static boolean isTabletEmpty(final Tablet tablet) {
- return Objects.isNull(tablet)
- || tablet.getRowSize() == 0
- || Objects.isNull(tablet.getSchemas())
- || tablet.getSchemas().isEmpty();
- }
-
- /////////////////////////// Object ///////////////////////////
-
- @Override
- public String toString() {
- return String.format(
- "PipeRawTabletInsertionEvent{tablet=%s, isAligned=%s, sourceEvent=%s, needToReport=%s, eventParser=%s}",
- tablet, isAligned, sourceEvent, needToReport, eventParser)
- + " - "
- + super.toString();
- }
-
- @Override
- public String coreReportMessage() {
- return String.format(
- "PipeRawTabletInsertionEvent{tablet=%s, isAligned=%s, sourceEvent=%s, needToReport=%s}",
- tablet,
- isAligned,
- sourceEvent == null ? "null" : sourceEvent.coreReportMessage(),
- needToReport)
- + " - "
- + super.coreReportMessage();
- }
-
- /////////////////////////// ReferenceTrackableEvent ///////////////////////////
-
- @Override
- protected void trackResource() {
- // PipeDataNodeResourceManager.ref().trackPipeEventResource(this, eventResourceBuilder());
- }
-
- @Override
- public PipePhantomReferenceManager.PipeEventResource eventResourceBuilder() {
- return new PipeRawTabletInsertionEventResource(this.isReleased, this.referenceCount);
- }
-
- private static class PipeRawTabletInsertionEventResource
- extends PipePhantomReferenceManager.PipeEventResource {
-
- // private final PipeTabletMemoryBlock allocatedMemoryBlock;
-
- private PipeRawTabletInsertionEventResource(
- final AtomicBoolean isReleased, final AtomicInteger referenceCount) {
- super(isReleased, referenceCount);
- }
-
- @Override
- protected void finalizeResource() {
- // allocatedMemoryBlock.close();
- }
- }
-
- /////////////////////////// AutoCloseable ///////////////////////////
-
- @Override
- public void close() {
- // The semantic of close is to release the memory occupied by parsing, this method does nothing
- // to unify the external close semantic:
- // 1. PipeRawTabletInsertionEvent: the tablet occupying memory upon construction, even when
- // parsing is involved.
- // 2. PipeInsertNodeTabletInsertionEvent: the tablet is only constructed when it's actually
- // involved in parsing.
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/tsfile/PipeTsFileInsertionEvent.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/tsfile/PipeTsFileInsertionEvent.java
deleted file mode 100644
index fcc64c2..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/event/tsfile/PipeTsFileInsertionEvent.java
+++ /dev/null
@@ -1,647 +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.collector.plugin.builtin.sink.event.tsfile;
-
-import org.apache.iotdb.collector.plugin.builtin.sink.datastructure.pattern.TablePattern;
-import org.apache.iotdb.collector.plugin.builtin.sink.datastructure.pattern.TreePattern;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.PipeRawTabletInsertionEvent;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tsfile.aggregator.TsFileInsertionPointCounter;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tsfile.parser.TsFileInsertionEventParser;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tsfile.parser.TsFileInsertionEventParserProvider;
-import org.apache.iotdb.collector.plugin.builtin.sink.resource.ref.PipePhantomReferenceManager.PipeEventResource;
-import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
-import org.apache.iotdb.pipe.api.event.dml.insertion.TsFileInsertionEvent;
-import org.apache.iotdb.pipe.api.exception.PipeException;
-
-import org.apache.tsfile.file.metadata.IDeviceID;
-import org.apache.tsfile.file.metadata.PlainDeviceID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.apache.tsfile.common.constant.TsFileConstant.PATH_ROOT;
-import static org.apache.tsfile.common.constant.TsFileConstant.PATH_SEPARATOR;
-
-public class PipeTsFileInsertionEvent extends PipeInsertionEvent
- implements TsFileInsertionEvent, ReferenceTrackableEvent {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PipeTsFileInsertionEvent.class);
-
- private static final String TREE_MODEL_EVENT_TABLE_NAME_PREFIX = PATH_ROOT + PATH_SEPARATOR;
-
- private final TsFileResource resource;
- private File tsFile;
-
- // This is true iff the modFile exists and should be transferred
- private boolean isWithMod;
- private File modFile;
- private final File sharedModFile;
-
- private final boolean isLoaded;
- private final boolean isGeneratedByPipe;
- private final boolean isGeneratedByPipeConsensus;
- private final boolean isGeneratedByHistoricalExtractor;
-
- private final AtomicBoolean isClosed;
- private final AtomicReference<TsFileInsertionEventParser> eventParser;
-
- // The point count of the TsFile. Used for metrics on PipeConsensus' receiver side.
- // May be updated after it is flushed. Should be negative if not set.
- // private long flushPointCount = TsFileProcessor.FLUSH_POINT_COUNT_NOT_SET;
-
- // public PipeTsFileInsertionEvent(
- // final Boolean isTableModelEvent,
- // final String databaseNameFromDataRegion,
- // final TsFileResource resource,
- // final boolean isLoaded,
- // final boolean isGeneratedByPipe,
- // final boolean isGeneratedByHistoricalExtractor) {
- // // The modFile must be copied before the event is assigned to the listening pipes
- // this(
- // isTableModelEvent,
- // databaseNameFromDataRegion,
- // resource,
- // true,
- // isLoaded,
- // isGeneratedByPipe,
- // isGeneratedByHistoricalExtractor,
- // null,
- // 0,
- // null,
- // null,
- // Long.MIN_VALUE,
- // Long.MAX_VALUE);
- // }
-
- public PipeTsFileInsertionEvent(
- final Boolean isTableModelEvent,
- final String databaseNameFromDataRegion,
- final TsFileResource resource,
- final boolean isWithMod,
- final boolean isLoaded,
- final boolean isGeneratedByPipe,
- final boolean isGeneratedByHistoricalExtractor,
- final String pipeName,
- final long creationTime,
- final TreePattern treePattern,
- final TablePattern tablePattern,
- final long startTime,
- final long endTime) {
- super(
- pipeName,
- creationTime,
- treePattern,
- tablePattern,
- startTime,
- endTime,
- isTableModelEvent,
- databaseNameFromDataRegion);
-
- this.resource = resource;
- tsFile = resource.getTsFile();
-
- this.isWithMod = isWithMod && resource.anyModFileExists();
- this.modFile = this.isWithMod ? resource.getExclusiveModFile().getFile() : null;
- // TODO: process the shared mod file
- this.sharedModFile =
- resource.getSharedModFile() != null ? resource.getSharedModFile().getFile() : null;
-
- this.isLoaded = isLoaded;
- this.isGeneratedByPipe = isGeneratedByPipe;
- this.isGeneratedByPipeConsensus = resource.isGeneratedByPipeConsensus();
- this.isGeneratedByHistoricalExtractor = isGeneratedByHistoricalExtractor;
-
- isClosed = new AtomicBoolean(resource.isClosed());
- // Register close listener if TsFile is not closed
- // if (!isClosed.get()) {
- // final TsFileProcessor processor = resource.getProcessor();
- // if (processor != null) {
- // processor.addCloseFileListener(
- // o -> {
- // synchronized (isClosed) {
- // isClosed.set(true);
- // isClosed.notifyAll();
- // // Update flushPointCount after TsFile is closed
- // flushPointCount = processor.getMemTableFlushPointCount();
- // }
- // });
- // }
- // }
- // Check again after register close listener in case TsFile is closed during the process
- // TsFile flushing steps:
- // 1. Flush tsFile
- // 2. First listener (Set resource status "closed" -> Set processor == null -> processor == null
- // is seen)
- // 3. Other listeners (Set "closed" status for events)
- // Then we can imply that:
- // 1. If the listener cannot be executed because all listeners passed, then resources status is
- // set "closed" and can be set here
- // 2. If the listener cannot be executed because processor == null is seen, then resources
- // status is set "closed" and can be set here
- // Then we know:
- // 1. The status in the event can be closed eventually.
- // 2. If the status is "closed", then the resource status is "closed".
- // Then we know:
- // If the status is "closed", then the resource status is "closed", the tsFile won't be altered
- // and can be sent.
- isClosed.set(resource.isClosed());
-
- this.eventParser = new AtomicReference<>(null);
- }
-
- /**
- * @return {@code false} if this file can't be sent by pipe because it is empty. {@code true}
- * otherwise.
- */
- public boolean waitForTsFileClose() throws InterruptedException {
- if (!isClosed.get()) {
- isClosed.set(resource.isClosed());
-
- synchronized (isClosed) {
- while (!isClosed.get()) {
- isClosed.wait(100);
-
- final boolean isClosedNow = resource.isClosed();
- if (isClosedNow) {
- isClosed.set(true);
- isClosed.notifyAll();
-
- // Update flushPointCount after TsFile is closed
- // final TsFileProcessor processor = resource.getProcessor();
- // if (processor != null) {
- // flushPointCount = processor.getMemTableFlushPointCount();
- // }
-
- break;
- }
- }
- }
- }
-
- // From illustrations above we know If the status is "closed", then the tsFile is flushed
- // And here we guarantee that the isEmpty() is set before flushing if tsFile is empty
- // Then we know: "isClosed" --> tsFile flushed --> (isEmpty() <--> tsFile is empty)
- return !resource.isEmpty();
- }
-
- public File getTsFile() {
- return tsFile;
- }
-
- public File getModFile() {
- return modFile;
- }
-
- public File getSharedModFile() {
- return sharedModFile;
- }
-
- public boolean isWithMod() {
- return isWithMod;
- }
-
- // If the previous "isWithMod" is false, the modFile has been set to "null", then the isWithMod
- // can't be set to true
- public void disableMod4NonTransferPipes(final boolean isWithMod) {
- this.isWithMod = isWithMod && this.isWithMod;
- }
-
- public boolean isLoaded() {
- return isLoaded;
- }
-
- public long getFileStartTime() {
- return resource.getFileStartTime();
- }
-
- /**
- * Only used for metrics on PipeConsensus' receiver side. If the event is recovered after data
- * node's restart, the flushPointCount can be not set. It's totally fine for the PipeConsensus'
- * receiver side. The receiver side will count the actual point count from the TsFile.
- *
- * <p>If you want to get the actual point count with no risk, you can call {@link
- * #count(boolean)}.
- */
- // public long getFlushPointCount() {
- // return flushPointCount;
- // }
-
- public long getTimePartitionId() {
- return resource.getTimePartition();
- }
-
- /////////////////////////// PipeRawTabletInsertionEvent ///////////////////////////
-
- @Override
- public boolean internallyIncreaseResourceReferenceCount(final String holderMessage) {
- try {
- // tsFile = PipeDataNodeResourceManager.tsfile().increaseFileReference(tsFile, true,
- // resource);
- // if (isWithMod) {
- // modFile = PipeDataNodeResourceManager.tsfile().increaseFileReference(modFile, false,
- // null);
- // }
- return true;
- } catch (final Exception e) {
- LOGGER.warn(
- String.format(
- "Increase reference count for TsFile %s or modFile %s error. Holder Message: %s",
- tsFile, modFile, holderMessage),
- e);
- return false;
- }
- }
-
- @Override
- public boolean internallyDecreaseResourceReferenceCount(final String holderMessage) {
- try {
- // PipeDataNodeResourceManager.tsfile().decreaseFileReference(tsFile);
- // if (isWithMod) {
- // PipeDataNodeResourceManager.tsfile().decreaseFileReference(modFile);
- // }
- close();
- return true;
- } catch (final Exception e) {
- LOGGER.warn(
- String.format(
- "Decrease reference count for TsFile %s error. Holder Message: %s",
- tsFile.getPath(), holderMessage),
- e);
- return false;
- }
- }
-
- @Override
- public PipeTsFileInsertionEvent shallowCopySelfAndBindPipeTaskMetaForProgressReport(
- final String pipeName,
- final long creationTime,
- final TreePattern treePattern,
- final TablePattern tablePattern,
- final long startTime,
- final long endTime) {
- return new PipeTsFileInsertionEvent(
- getRawIsTableModelEvent(),
- getSourceDatabaseNameFromDataRegion(),
- resource,
- isWithMod,
- isLoaded,
- isGeneratedByPipe,
- isGeneratedByHistoricalExtractor,
- pipeName,
- creationTime,
- treePattern,
- tablePattern,
- startTime,
- endTime);
- }
-
- @Override
- public boolean isGeneratedByPipe() {
- return isGeneratedByPipe;
- }
-
- @Override
- public boolean mayEventTimeOverlappedWithTimeRange() {
- // If the tsFile is not closed the resource.getFileEndTime() will be Long.MIN_VALUE
- // In that case we only judge the resource.getFileStartTime() to avoid losing data
- return isClosed.get()
- ? startTime <= resource.getFileEndTime() && resource.getFileStartTime() <= endTime
- : resource.getFileStartTime() <= endTime;
- }
-
- @Override
- public boolean mayEventPathsOverlappedWithPattern() {
- if (!resource.isClosed()) {
- return true;
- }
-
- try {
- final Map<IDeviceID, Boolean> deviceIsAlignedMap = null;
- // PipeDataNodeResourceManager.tsfile()
- // .getDeviceIsAlignedMapFromCache(
- // PipeTsFileResourceManager.getHardlinkOrCopiedFileInPipeDir(resource.getTsFile()),
- // false);
- final Set<IDeviceID> deviceSet =
- Objects.nonNull(deviceIsAlignedMap) ? deviceIsAlignedMap.keySet() : resource.getDevices();
- return deviceSet.stream()
- .anyMatch(
- deviceID -> {
- // Tree model
- if (Boolean.FALSE.equals(getRawIsTableModelEvent())
- || deviceID instanceof PlainDeviceID
- || deviceID.getTableName().startsWith(TREE_MODEL_EVENT_TABLE_NAME_PREFIX)
- || deviceID.getTableName().equals(PATH_ROOT)) {
- markAsTreeModelEvent();
- return treePattern.mayOverlapWithDevice(deviceID);
- }
-
- // Table model
- markAsTableModelEvent();
- return true;
- });
- } catch (final Exception e) {
- LOGGER.warn(
- "Pipe {}: failed to get devices from TsFile {}, extract it anyway",
- pipeName,
- resource.getTsFilePath(),
- e);
- return true;
- }
- }
-
- /////////////////////////// PipeInsertionEvent ///////////////////////////
-
- @Override
- public boolean isTableModelEvent() {
- if (getRawIsTableModelEvent() == null) {
- if (getSourceDatabaseNameFromDataRegion() != null) {
- return super.isTableModelEvent();
- }
-
- try {
- final Map<IDeviceID, Boolean> deviceIsAlignedMap = null;
- // PipeDataNodeResourceManager.tsfile()
- // .getDeviceIsAlignedMapFromCache(
- // PipeTsFileResourceManager.getHardlinkOrCopiedFileInPipeDir(
- // resource.getTsFile()),
- // false);
- final Set<IDeviceID> deviceSet =
- Objects.nonNull(deviceIsAlignedMap)
- ? deviceIsAlignedMap.keySet()
- : resource.getDevices();
- for (final IDeviceID deviceID : deviceSet) {
- if (deviceID instanceof PlainDeviceID
- || deviceID.getTableName().startsWith(TREE_MODEL_EVENT_TABLE_NAME_PREFIX)
- || deviceID.getTableName().equals(PATH_ROOT)) {
- markAsTreeModelEvent();
- } else {
- markAsTableModelEvent();
- }
- break;
- }
- } catch (final Exception e) {
- throw new PipeException(
- String.format(
- "Pipe %s: failed to judge whether TsFile %s is table model or tree model",
- pipeName, resource.getTsFilePath()),
- e);
- }
- }
-
- return getRawIsTableModelEvent();
- }
-
- /////////////////////////// TsFileInsertionEvent ///////////////////////////
-
- @Override
- public Iterable<TabletInsertionEvent> toTabletInsertionEvents() throws PipeException {
- return toTabletInsertionEvents(Long.MAX_VALUE);
- }
-
- public Iterable<TabletInsertionEvent> toTabletInsertionEvents(final long timeoutMs)
- throws PipeException {
- try {
- if (!waitForTsFileClose()) {
- LOGGER.warn(
- "Pipe skipping temporary TsFile's parsing which shouldn't be transferred: {}", tsFile);
- return Collections.emptyList();
- }
- waitForResourceEnough4Parsing(timeoutMs);
- return initEventParser().toTabletInsertionEvents();
- } catch (final Exception e) {
- close();
-
- // close() should be called before re-interrupting the thread
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
-
- final String errorMsg =
- e instanceof InterruptedException
- ? String.format(
- "Interrupted when waiting for closing TsFile %s.", resource.getTsFilePath())
- : String.format(
- "Parse TsFile %s error. Because: %s", resource.getTsFilePath(), e.getMessage());
- LOGGER.warn(errorMsg, e);
- throw new PipeException(errorMsg);
- }
- }
-
- private void waitForResourceEnough4Parsing(final long timeoutMs) throws InterruptedException {
- // final PipeMemoryManager memoryManager = PipeDataNodeResourceManager.memory();
- // if (memoryManager.isEnough4TabletParsing()) {
- // return;
- // }
-
- final long startTime = System.currentTimeMillis();
- // long lastRecordTime = startTime;
- //
- // final long memoryCheckIntervalMs = PipeOptions.PIPE_CHECK_MEMORY_ENOUGH_INTERVAL_MS.value();
- // while (!memoryManager.isEnough4TabletParsing()) {
- // Thread.sleep(memoryCheckIntervalMs);
- //
- // final long currentTime = System.currentTimeMillis();
- // final double elapsedRecordTimeSeconds = (currentTime - lastRecordTime) / 1000.0;
- // final double waitTimeSeconds = (currentTime - startTime) / 1000.0;
- // if (elapsedRecordTimeSeconds > 10.0) {
- // LOGGER.info(
- // "Wait for resource enough for parsing {} for {} seconds.",
- // resource != null ? resource.getTsFilePath() : "tsfile",
- // waitTimeSeconds);
- // lastRecordTime = currentTime;
- // } else if (LOGGER.isDebugEnabled()) {
- // LOGGER.debug(
- // "Wait for resource enough for parsing {} for {} seconds.",
- // resource != null ? resource.getTsFilePath() : "tsfile",
- // waitTimeSeconds);
- // }
- //
- // if (waitTimeSeconds * 1000 > timeoutMs) {
- // // should contain 'TimeoutException' in exception message
- // throw new PipeException(
- // String.format("TimeoutException: Waited %s seconds", waitTimeSeconds));
- // }
- // }
-
- final long currentTime = System.currentTimeMillis();
- final double waitTimeSeconds = (currentTime - startTime) / 1000.0;
- LOGGER.info(
- "Wait for resource enough for parsing {} for {} seconds.",
- resource != null ? resource.getTsFilePath() : "tsfile",
- waitTimeSeconds);
- }
-
- /** The method is used to prevent circular replication in PipeConsensus */
- public boolean isGeneratedByPipeConsensus() {
- return isGeneratedByPipeConsensus;
- }
-
- public boolean isGeneratedByHistoricalExtractor() {
- return isGeneratedByHistoricalExtractor;
- }
-
- private TsFileInsertionEventParser initEventParser() {
- try {
- eventParser.compareAndSet(
- null,
- new TsFileInsertionEventParserProvider(
- tsFile, treePattern, tablePattern, startTime, endTime, this)
- .provide());
- return eventParser.get();
- } catch (final IOException e) {
- close();
-
- final String errorMsg = String.format("Read TsFile %s error.", resource.getTsFilePath());
- LOGGER.warn(errorMsg, e);
- throw new PipeException(errorMsg);
- }
- }
-
- public long count(final boolean skipReportOnCommit) throws IOException {
- long count = 0;
-
- if (shouldParseTime()) {
- try {
- for (final TabletInsertionEvent event : toTabletInsertionEvents()) {
- final PipeRawTabletInsertionEvent rawEvent = ((PipeRawTabletInsertionEvent) event);
- count += rawEvent.count();
- // if (skipReportOnCommit) {
- // rawEvent.skipReportOnCommit();
- // }
- }
- return count;
- } finally {
- close();
- }
- }
-
- try (final TsFileInsertionPointCounter counter =
- new TsFileInsertionPointCounter(tsFile, treePattern)) {
- return counter.count();
- }
- }
-
- /** Release the resource of {@link TsFileInsertionEventParser}. */
- @Override
- public void close() {
- eventParser.getAndUpdate(
- parser -> {
- if (Objects.nonNull(parser)) {
- parser.close();
- }
- return null;
- });
- }
-
- /////////////////////////// Object ///////////////////////////
-
- @Override
- public String toString() {
- return String.format(
- "PipeTsFileInsertionEvent{resource=%s, tsFile=%s, isLoaded=%s, isGeneratedByPipe=%s, isClosed=%s, eventParser=%s}",
- resource, tsFile, isLoaded, isGeneratedByPipe, isClosed.get(), eventParser)
- + " - "
- + super.toString();
- }
-
- @Override
- public String coreReportMessage() {
- return String.format(
- "PipeTsFileInsertionEvent{resource=%s, tsFile=%s, isLoaded=%s, isGeneratedByPipe=%s, isClosed=%s}",
- resource, tsFile, isLoaded, isGeneratedByPipe, isClosed.get())
- + " - "
- + super.coreReportMessage();
- }
-
- /////////////////////////// ReferenceTrackableEvent ///////////////////////////
-
- @Override
- public void trackResource() {
- // PipeDataNodeResourceManager.ref().trackPipeEventResource(this, eventResourceBuilder());
- }
-
- @Override
- public PipeEventResource eventResourceBuilder() {
- return new PipeTsFileInsertionEventResource(
- this.isReleased,
- this.referenceCount,
- this.tsFile,
- this.isWithMod,
- this.modFile,
- this.sharedModFile,
- this.eventParser);
- }
-
- private static class PipeTsFileInsertionEventResource extends PipeEventResource {
-
- private final File tsFile;
- private final boolean isWithMod;
- private final File modFile;
- private final File sharedModFile; // unused now
- private final AtomicReference<TsFileInsertionEventParser> eventParser;
-
- private PipeTsFileInsertionEventResource(
- final AtomicBoolean isReleased,
- final AtomicInteger referenceCount,
- final File tsFile,
- final boolean isWithMod,
- final File modFile,
- final File sharedModFile,
- final AtomicReference<TsFileInsertionEventParser> eventParser) {
- super(isReleased, referenceCount);
- this.tsFile = tsFile;
- this.isWithMod = isWithMod;
- this.modFile = modFile;
- this.sharedModFile = sharedModFile;
- this.eventParser = eventParser;
- }
-
- @Override
- protected void finalizeResource() {
- try {
- // decrease reference count
- // PipeDataNodeResourceManager.tsfile().decreaseFileReference(tsFile);
- // if (isWithMod) {
- // PipeDataNodeResourceManager.tsfile().decreaseFileReference(modFile);
- // }
-
- // close event parser
- eventParser.getAndUpdate(
- parser -> {
- if (Objects.nonNull(parser)) {
- parser.close();
- }
- return null;
- });
- } catch (final Exception e) {
- LOGGER.warn("Decrease reference count for TsFile {} error.", tsFile.getPath(), e);
- }
- }
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeConnectorCriticalException.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeConnectorCriticalException.java
deleted file mode 100644
index f84a263..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeConnectorCriticalException.java
+++ /dev/null
@@ -1,74 +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.collector.plugin.builtin.sink.exception.pipe;
-
-import org.apache.tsfile.utils.ReadWriteIOUtils;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-public class PipeRuntimeConnectorCriticalException extends PipeRuntimeCriticalException {
-
- public PipeRuntimeConnectorCriticalException(final String message) {
- super(message);
- }
-
- public PipeRuntimeConnectorCriticalException(final String message, final long timeStamp) {
- super(message, timeStamp);
- }
-
- @Override
- public boolean equals(final Object obj) {
- return obj instanceof PipeRuntimeConnectorCriticalException
- && Objects.equals(getMessage(), ((PipeRuntimeConnectorCriticalException) obj).getMessage())
- && Objects.equals(getTimeStamp(), ((PipeRuntimeException) obj).getTimeStamp());
- }
-
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public void serialize(final ByteBuffer byteBuffer) {
- PipeRuntimeExceptionType.CONNECTOR_CRITICAL_EXCEPTION.serialize(byteBuffer);
- ReadWriteIOUtils.write(getMessage(), byteBuffer);
- ReadWriteIOUtils.write(getTimeStamp(), byteBuffer);
- }
-
- @Override
- public void serialize(final OutputStream stream) throws IOException {
- PipeRuntimeExceptionType.CONNECTOR_CRITICAL_EXCEPTION.serialize(stream);
- ReadWriteIOUtils.write(getMessage(), stream);
- ReadWriteIOUtils.write(getTimeStamp(), stream);
- }
-
- @Override
- public String toString() {
- return "PipeRuntimeConnectorCriticalException{"
- + "message='"
- + getMessage()
- + "', timeStamp="
- + getTimeStamp()
- + "}";
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeCriticalException.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeCriticalException.java
deleted file mode 100644
index 4fe301a..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeCriticalException.java
+++ /dev/null
@@ -1,69 +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.collector.plugin.builtin.sink.exception.pipe;
-
-import org.apache.tsfile.utils.ReadWriteIOUtils;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-public class PipeRuntimeCriticalException extends PipeRuntimeException {
-
- public PipeRuntimeCriticalException(final String message) {
- super(message);
- }
-
- public PipeRuntimeCriticalException(final String message, final long timeStamp) {
- super(message, timeStamp);
- }
-
- @Override
- public boolean equals(final Object obj) {
- return obj instanceof PipeRuntimeCriticalException
- && Objects.equals(getMessage(), ((PipeRuntimeCriticalException) obj).getMessage())
- && Objects.equals(getTimeStamp(), ((PipeRuntimeException) obj).getTimeStamp());
- }
-
- @Override
- public void serialize(final ByteBuffer byteBuffer) {
- PipeRuntimeExceptionType.CRITICAL_EXCEPTION.serialize(byteBuffer);
- ReadWriteIOUtils.write(getMessage(), byteBuffer);
- ReadWriteIOUtils.write(getTimeStamp(), byteBuffer);
- }
-
- @Override
- public void serialize(final OutputStream stream) throws IOException {
- PipeRuntimeExceptionType.CRITICAL_EXCEPTION.serialize(stream);
- ReadWriteIOUtils.write(getMessage(), stream);
- ReadWriteIOUtils.write(getTimeStamp(), stream);
- }
-
- @Override
- public String toString() {
- return "PipeRuntimeCriticalException{"
- + "message='"
- + getMessage()
- + "', timeStamp="
- + getTimeStamp()
- + "}";
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeException.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeException.java
deleted file mode 100644
index 8e85ce8..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeException.java
+++ /dev/null
@@ -1,54 +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.collector.plugin.builtin.sink.exception.pipe;
-
-import org.apache.iotdb.pipe.api.exception.PipeException;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-public abstract class PipeRuntimeException extends PipeException {
-
- protected PipeRuntimeException(final String message) {
- super(message);
- }
-
- protected PipeRuntimeException(final String message, final long timeStamp) {
- super(message, timeStamp);
- }
-
- @Override
- public boolean equals(final Object obj) {
- return obj instanceof PipeRuntimeException
- && Objects.equals(getMessage(), ((PipeRuntimeException) obj).getMessage())
- && Objects.equals(getTimeStamp(), ((PipeRuntimeException) obj).getTimeStamp());
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(getMessage(), getTimeStamp());
- }
-
- public abstract void serialize(final ByteBuffer byteBuffer);
-
- public abstract void serialize(final OutputStream stream) throws IOException;
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeExceptionType.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeExceptionType.java
deleted file mode 100644
index fdc38c8..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeExceptionType.java
+++ /dev/null
@@ -1,52 +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.collector.plugin.builtin.sink.exception.pipe;
-
-import org.apache.tsfile.utils.ReadWriteIOUtils;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-
-public enum PipeRuntimeExceptionType {
- NON_CRITICAL_EXCEPTION((short) 1),
- CRITICAL_EXCEPTION((short) 2),
- CONNECTOR_CRITICAL_EXCEPTION((short) 3),
- OUT_OF_MEMORY_CRITICAL_EXCEPTION((short) 4),
- ;
-
- private final short type;
-
- PipeRuntimeExceptionType(short type) {
- this.type = type;
- }
-
- public short getType() {
- return type;
- }
-
- public void serialize(ByteBuffer byteBuffer) {
- ReadWriteIOUtils.write(type, byteBuffer);
- }
-
- public void serialize(OutputStream stream) throws IOException {
- ReadWriteIOUtils.write(type, stream);
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeNonCriticalException.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeNonCriticalException.java
deleted file mode 100644
index 92ebff1..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeNonCriticalException.java
+++ /dev/null
@@ -1,74 +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.collector.plugin.builtin.sink.exception.pipe;
-
-import org.apache.tsfile.utils.ReadWriteIOUtils;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-public class PipeRuntimeNonCriticalException extends PipeRuntimeException {
-
- public PipeRuntimeNonCriticalException(String message) {
- super(message);
- }
-
- public PipeRuntimeNonCriticalException(String message, long timeStamp) {
- super(message, timeStamp);
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof PipeRuntimeNonCriticalException
- && Objects.equals(getMessage(), ((PipeRuntimeNonCriticalException) obj).getMessage())
- && Objects.equals(getTimeStamp(), ((PipeRuntimeException) obj).getTimeStamp());
- }
-
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public void serialize(ByteBuffer byteBuffer) {
- PipeRuntimeExceptionType.NON_CRITICAL_EXCEPTION.serialize(byteBuffer);
- ReadWriteIOUtils.write(getMessage(), byteBuffer);
- ReadWriteIOUtils.write(getTimeStamp(), byteBuffer);
- }
-
- @Override
- public void serialize(OutputStream stream) throws IOException {
- PipeRuntimeExceptionType.NON_CRITICAL_EXCEPTION.serialize(stream);
- ReadWriteIOUtils.write(getMessage(), stream);
- ReadWriteIOUtils.write(getTimeStamp(), stream);
- }
-
- @Override
- public String toString() {
- return "PipeRuntimeNonCriticalException{"
- + "message='"
- + getMessage()
- + "', timeStamp="
- + getTimeStamp()
- + "}";
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeOutOfMemoryCriticalException.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeOutOfMemoryCriticalException.java
deleted file mode 100644
index bca4676..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/exception/pipe/PipeRuntimeOutOfMemoryCriticalException.java
+++ /dev/null
@@ -1,75 +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.collector.plugin.builtin.sink.exception.pipe;
-
-import org.apache.tsfile.utils.ReadWriteIOUtils;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-public class PipeRuntimeOutOfMemoryCriticalException extends PipeRuntimeCriticalException {
-
- public PipeRuntimeOutOfMemoryCriticalException(String message) {
- super(message);
- }
-
- public PipeRuntimeOutOfMemoryCriticalException(String message, long timeStamp) {
- super(message, timeStamp);
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof PipeRuntimeOutOfMemoryCriticalException
- && Objects.equals(
- getMessage(), ((PipeRuntimeOutOfMemoryCriticalException) obj).getMessage())
- && Objects.equals(getTimeStamp(), ((PipeRuntimeException) obj).getTimeStamp());
- }
-
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public void serialize(ByteBuffer byteBuffer) {
- PipeRuntimeExceptionType.OUT_OF_MEMORY_CRITICAL_EXCEPTION.serialize(byteBuffer);
- ReadWriteIOUtils.write(getMessage(), byteBuffer);
- ReadWriteIOUtils.write(getTimeStamp(), byteBuffer);
- }
-
- @Override
- public void serialize(OutputStream stream) throws IOException {
- PipeRuntimeExceptionType.OUT_OF_MEMORY_CRITICAL_EXCEPTION.serialize(stream);
- ReadWriteIOUtils.write(getMessage(), stream);
- ReadWriteIOUtils.write(getTimeStamp(), stream);
- }
-
- @Override
- public String toString() {
- return "PipeRuntimeOutOfMemoryException{"
- + "message='"
- + getMessage()
- + "', timeStamp="
- + getTimeStamp()
- + "}";
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventBatch.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventBatch.java
index 3d8d477..859969e 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventBatch.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventBatch.java
@@ -19,7 +19,7 @@
package org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.batch;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.PipeRawTabletInsertionEvent;
+import org.apache.iotdb.collector.plugin.builtin.sink.event.PipeRawTabletInsertionEvent;
import org.apache.iotdb.pipe.api.event.Event;
import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java
index ad9a1ad..8525f57 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java
@@ -19,7 +19,7 @@
package org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.batch;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.PipeRawTabletInsertionEvent;
+import org.apache.iotdb.collector.plugin.builtin.sink.event.PipeRawTabletInsertionEvent;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.request.PipeTransferTabletBatchReqV2;
import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventTsFileBatch.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventTsFileBatch.java
index fcb577d..903008b 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventTsFileBatch.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTabletEventTsFileBatch.java
@@ -19,8 +19,7 @@
package org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.batch;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.PipeRawTabletInsertionEvent;
-import org.apache.iotdb.collector.plugin.builtin.sink.utils.PipeMemoryWeightUtil;
+import org.apache.iotdb.collector.plugin.builtin.sink.event.PipeRawTabletInsertionEvent;
import org.apache.iotdb.collector.plugin.builtin.sink.utils.builder.PipeTableModeTsFileBuilder;
import org.apache.iotdb.collector.plugin.builtin.sink.utils.builder.PipeTreeModelTsFileBuilder;
import org.apache.iotdb.collector.plugin.builtin.sink.utils.builder.PipeTsFileBuilder;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTransferBatchReqBuilder.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTransferBatchReqBuilder.java
index f953929..4bc8789 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTransferBatchReqBuilder.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/payload/evolvable/batch/PipeTransferBatchReqBuilder.java
@@ -19,7 +19,7 @@
package org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.batch;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.PipeRawTabletInsertionEvent;
+import org.apache.iotdb.collector.plugin.builtin.sink.event.PipeRawTabletInsertionEvent;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameters;
import org.apache.iotdb.pipe.api.event.Event;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ClientPoolProperty.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ClientPoolProperty.java
deleted file mode 100644
index 359bfe3..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/ClientPoolProperty.java
+++ /dev/null
@@ -1,109 +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.collector.plugin.builtin.sink.property;
-
-import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
-
-import java.time.Duration;
-import java.util.concurrent.TimeUnit;
-
-public class ClientPoolProperty<V> {
-
- private final GenericKeyedObjectPoolConfig<V> config;
-
- private ClientPoolProperty(GenericKeyedObjectPoolConfig<V> config) {
- this.config = config;
- }
-
- public GenericKeyedObjectPoolConfig<V> getConfig() {
- return config;
- }
-
- public static class Builder<V> {
-
- /**
- * when the number of the client to a single node exceeds maxClientNumForEachNode, the thread
- * for applying for a client will be blocked for waitClientTimeoutMs, then ClientManager will
- * throw ClientManagerException if there are no clients after the block time.
- */
- private long waitClientTimeoutMs = DefaultProperty.WAIT_CLIENT_TIMEOUT_MS;
-
- /**
- * the maximum number of clients that can be allocated for a node. When some clients are idle
- * for more than {@code maxIdleTimeForClient}, they will be cleaned up.
- */
- private int maxClientNumForEachNode = DefaultProperty.MAX_CLIENT_NUM_FOR_EACH_NODE;
-
- /**
- * the minimum amount of time a client may sit idle in the pool before it is eligible for
- * eviction by the idle object evictor.
- */
- private long minIdleTimeForClient = DefaultProperty.MIN_IDLE_TIME_FOR_CLIENT_MS;
-
- /**
- * the duration to sleep between runs of the idle object evictor thread. When non-positive, no
- * idle object evictor thread will be run, which means clients that are idle for more than
- * {@code minIdleTimeForClient} will never be cleaned up.
- */
- private long timeBetweenEvictionRuns = DefaultProperty.TIME_BETWEEN_EVICTION_RUNS_MS;
-
- public Builder<V> setWaitClientTimeoutMs(long waitClientTimeoutMs) {
- this.waitClientTimeoutMs = waitClientTimeoutMs;
- return this;
- }
-
- public Builder<V> setMaxClientNumForEachNode(int maxClientNumForEachNode) {
- this.maxClientNumForEachNode = maxClientNumForEachNode;
- return this;
- }
-
- public Builder<V> setMinIdleTimeForClient(long minIdleTimeForClient) {
- this.minIdleTimeForClient = minIdleTimeForClient;
- return this;
- }
-
- public Builder<V> setTimeBetweenEvictionRuns(long timeBetweenEvictionRuns) {
- this.timeBetweenEvictionRuns = timeBetweenEvictionRuns;
- return this;
- }
-
- public ClientPoolProperty<V> build() {
- GenericKeyedObjectPoolConfig<V> poolConfig = new GenericKeyedObjectPoolConfig<>();
- poolConfig.setMaxTotalPerKey(maxClientNumForEachNode);
- poolConfig.setMaxIdlePerKey(maxClientNumForEachNode);
- poolConfig.setTimeBetweenEvictionRuns(Duration.ofMillis(timeBetweenEvictionRuns));
- poolConfig.setMinEvictableIdleTime(Duration.ofMillis(minIdleTimeForClient));
- poolConfig.setMaxWait(Duration.ofMillis(waitClientTimeoutMs));
- poolConfig.setTestOnReturn(true);
- poolConfig.setTestOnBorrow(true);
- return new ClientPoolProperty<>(poolConfig);
- }
- }
-
- public static class DefaultProperty {
-
- private DefaultProperty() {}
-
- public static final long WAIT_CLIENT_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(30);
- public static final long MIN_IDLE_TIME_FOR_CLIENT_MS = TimeUnit.MINUTES.toMillis(1);
- public static final long TIME_BETWEEN_EVICTION_RUNS_MS = TimeUnit.MINUTES.toMillis(1);
- public static final int MAX_CLIENT_NUM_FOR_EACH_NODE = 1000;
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/PipeConsensusClientProperty.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/PipeConsensusClientProperty.java
deleted file mode 100644
index e3cfe5b..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/property/PipeConsensusClientProperty.java
+++ /dev/null
@@ -1,96 +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.collector.plugin.builtin.sink.property;
-
-/** This class defines the configurations used by the PipeConsensus Client. */
-public class PipeConsensusClientProperty {
- private final boolean isRpcThriftCompressionEnabled;
- private final int selectorNumOfClientManager;
- private final boolean printLogWhenThriftClientEncounterException;
- private final int maxClientNumForEachNode;
-
- public PipeConsensusClientProperty(
- boolean isRpcThriftCompressionEnabled,
- int selectorNumOfClientManager,
- boolean printLogWhenThriftClientEncounterException,
- int maxClientNumForEachNode) {
- this.isRpcThriftCompressionEnabled = isRpcThriftCompressionEnabled;
- this.selectorNumOfClientManager = selectorNumOfClientManager;
- this.printLogWhenThriftClientEncounterException = printLogWhenThriftClientEncounterException;
- this.maxClientNumForEachNode = maxClientNumForEachNode;
- }
-
- public boolean isRpcThriftCompressionEnabled() {
- return isRpcThriftCompressionEnabled;
- }
-
- public int getSelectorNumOfClientManager() {
- return selectorNumOfClientManager;
- }
-
- public boolean isPrintLogWhenThriftClientEncounterException() {
- return printLogWhenThriftClientEncounterException;
- }
-
- public int getMaxClientNumForEachNode() {
- return maxClientNumForEachNode;
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public static class Builder {
- private boolean isRpcThriftCompressionEnabled = false;
- private int selectorNumOfClientManager = 1;
- private boolean printLogWhenThriftClientEncounterException = true;
- private int maxClientNumForEachNode =
- ClientPoolProperty.DefaultProperty.MAX_CLIENT_NUM_FOR_EACH_NODE;
-
- public Builder setIsRpcThriftCompressionEnabled(boolean isRpcThriftCompressionEnabled) {
- this.isRpcThriftCompressionEnabled = isRpcThriftCompressionEnabled;
- return this;
- }
-
- public Builder setSelectorNumOfClientManager(int selectorNumOfClientManager) {
- this.selectorNumOfClientManager = selectorNumOfClientManager;
- return this;
- }
-
- public Builder setPrintLogWhenThriftClientEncounterException(
- boolean printLogWhenThriftClientEncounterException) {
- this.printLogWhenThriftClientEncounterException = printLogWhenThriftClientEncounterException;
- return this;
- }
-
- public Builder setMaxClientNumForEachNode(int maxClientNumForEachNode) {
- this.maxClientNumForEachNode = maxClientNumForEachNode;
- return this;
- }
-
- public PipeConsensusClientProperty build() {
- return new PipeConsensusClientProperty(
- isRpcThriftCompressionEnabled,
- selectorNumOfClientManager,
- printLogWhenThriftClientEncounterException,
- maxClientNumForEachNode);
- }
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/demo/DemoSink.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/DemoSink.java
similarity index 97%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/demo/DemoSink.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/DemoSink.java
index 9205cc4..d5b8bec 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/demo/DemoSink.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/DemoSink.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.demo;
+package org.apache.iotdb.collector.plugin.builtin.sink.protocol;
import org.apache.iotdb.pipe.api.PipeSink;
import org.apache.iotdb.pipe.api.customizer.configuration.PipeConnectorRuntimeConfiguration;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBConnector.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBConnector.java
similarity index 99%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBConnector.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBConnector.java
index df12205..141bd64 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBConnector.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBConnector.java
@@ -17,13 +17,12 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.protocol;
import org.apache.iotdb.collector.plugin.builtin.sink.compressor.PipeCompressor;
import org.apache.iotdb.collector.plugin.builtin.sink.compressor.PipeCompressorConfig;
import org.apache.iotdb.collector.plugin.builtin.sink.compressor.PipeCompressorFactory;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.thrift.request.PipeTransferCompressedReq;
-import org.apache.iotdb.collector.plugin.builtin.sink.utils.NodeUrlUtils;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.pipe.api.PipeConnector;
import org.apache.iotdb.pipe.api.customizer.configuration.PipeConnectorRuntimeConfiguration;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeSyncConnector.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBDataNodeSyncConnector.java
similarity index 93%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeSyncConnector.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBDataNodeSyncConnector.java
index 1d33bf5..d7c0a77 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataNodeSyncConnector.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBDataNodeSyncConnector.java
@@ -17,10 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.protocol;
import org.apache.iotdb.collector.config.PipeOptions;
-import org.apache.iotdb.collector.plugin.builtin.sink.utils.NodeUrlUtils;
+import org.apache.iotdb.collector.plugin.builtin.sink.client.IoTDBDataNodeSyncClientManager;
+import org.apache.iotdb.collector.plugin.builtin.sink.client.IoTDBSyncClientManager;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameterValidator;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataRegionSyncConnector.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBDataRegionSyncConnector.java
similarity index 92%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataRegionSyncConnector.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBDataRegionSyncConnector.java
index 57319b7..9380757 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBDataRegionSyncConnector.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBDataRegionSyncConnector.java
@@ -17,10 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.protocol;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tablet.PipeRawTabletInsertionEvent;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.tsfile.PipeTsFileInsertionEvent;
+import org.apache.iotdb.collector.plugin.builtin.sink.client.IoTDBSyncClient;
+import org.apache.iotdb.collector.plugin.builtin.sink.event.PipeRawTabletInsertionEvent;
+import org.apache.iotdb.collector.plugin.builtin.sink.event.PipeTsFileInsertionEvent;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.batch.PipeTabletEventBatch;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.batch.PipeTabletEventPlainBatch;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.batch.PipeTabletEventTsFileBatch;
@@ -30,7 +31,6 @@ import org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.request.
import org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.request.PipeTransferTsFilePieceWithModReq;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.evolvable.request.PipeTransferTsFileSealWithModReq;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.thrift.request.PipeTransferFilePieceReq;
-import org.apache.iotdb.collector.plugin.builtin.sink.utils.RetryUtils;
import org.apache.iotdb.collector.plugin.builtin.sink.utils.cacher.LeaderCacheUtils;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
@@ -282,27 +282,16 @@ public class IoTDBDataRegionSyncConnector extends IoTDBDataNodeSyncConnector {
private void doTransferWrapper(final PipeTsFileInsertionEvent pipeTsFileInsertionEvent)
throws PipeException, IOException {
- // We increase the reference count for this event to determine if the event may be released.
- if (!pipeTsFileInsertionEvent.increaseReferenceCount(
- IoTDBDataRegionSyncConnector.class.getName())) {
- return;
- }
- try {
- doTransfer(
- Collections.singletonMap(
- new Pair<>(
- pipeTsFileInsertionEvent.getPipeName(),
- pipeTsFileInsertionEvent.getCreationTime()),
- 1.0),
- pipeTsFileInsertionEvent.getTsFile(),
- pipeTsFileInsertionEvent.isWithMod() ? pipeTsFileInsertionEvent.getModFile() : null,
- pipeTsFileInsertionEvent.isTableModelEvent()
- ? pipeTsFileInsertionEvent.getTableModelDatabaseName()
- : null);
- } finally {
- pipeTsFileInsertionEvent.decreaseReferenceCount(
- IoTDBDataRegionSyncConnector.class.getName(), false);
- }
+ doTransfer(
+ Collections.singletonMap(
+ new Pair<>(
+ pipeTsFileInsertionEvent.getPipeName(), pipeTsFileInsertionEvent.getCreationTime()),
+ 1.0),
+ pipeTsFileInsertionEvent.getTsFile(),
+ pipeTsFileInsertionEvent.isWithMod() ? pipeTsFileInsertionEvent.getModFile() : null,
+ pipeTsFileInsertionEvent.isTableModelEvent()
+ ? pipeTsFileInsertionEvent.getTableModelDatabaseName()
+ : null);
}
private void doTransfer(
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSslSyncConnector.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBSslSyncConnector.java
similarity index 97%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSslSyncConnector.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBSslSyncConnector.java
index 1b93fb1..b1920d6 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/IoTDBSslSyncConnector.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/IoTDBSslSyncConnector.java
@@ -17,9 +17,11 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.protocol;
import org.apache.iotdb.collector.config.PipeOptions;
+import org.apache.iotdb.collector.plugin.builtin.sink.client.IoTDBSyncClient;
+import org.apache.iotdb.collector.plugin.builtin.sink.client.IoTDBSyncClientManager;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.thrift.request.PipeTransferFilePieceReq;
import org.apache.iotdb.collector.plugin.builtin.sink.payload.thrift.response.PipeTransferFilePieceResp;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/PipeReceiverStatusHandler.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/PipeReceiverStatusHandler.java
similarity index 99%
rename from iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/PipeReceiverStatusHandler.java
rename to iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/PipeReceiverStatusHandler.java
index ac9f889..477dc64 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/thrift/PipeReceiverStatusHandler.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/protocol/PipeReceiverStatusHandler.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.collector.plugin.builtin.sink.protocol.thrift;
+package org.apache.iotdb.collector.plugin.builtin.sink.protocol;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.pipe.api.event.Event;
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/DateTimeUtils.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/DateTimeUtils.java
deleted file mode 100644
index 103e09c..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/DateTimeUtils.java
+++ /dev/null
@@ -1,895 +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.collector.plugin.builtin.sink.utils;
-
-import org.apache.iotdb.collector.config.PipeOptions;
-
-import org.apache.tsfile.utils.DateUtils;
-import org.apache.tsfile.utils.TimeDuration;
-
-import java.time.DateTimeException;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeFormatterBuilder;
-import java.time.format.DateTimeParseException;
-import java.time.format.ResolverStyle;
-import java.time.format.SignStyle;
-import java.time.temporal.ChronoField;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Function;
-
-public class DateTimeUtils {
-
- private DateTimeUtils() {
- // forbidding instantiation
- }
-
- public static final String TIMESTAMP_PRECISION = PipeOptions.TIMESTAMP_PRECISION.value();
-
- public static long correctPrecision(long millis) {
- try {
- switch (TIMESTAMP_PRECISION) {
- case "us":
- case "microsecond":
- return Math.multiplyExact(millis, 1_000L);
- case "ns":
- case "nanosecond":
- return Math.multiplyExact(millis, 1_000_000L);
- case "ms":
- case "millisecond":
- default:
- return millis;
- }
- } catch (ArithmeticException e) {
- throw new RuntimeException(
- String.format(
- "Timestamp overflow, Millisecond: %s , Timestamp precision: %s",
- millis, TIMESTAMP_PRECISION));
- }
- }
-
- private static Function<Long, Long> CAST_TIMESTAMP_TO_MS;
-
- static {
- switch (PipeOptions.TIMESTAMP_PRECISION.value()) {
- case "us":
- case "microsecond":
- CAST_TIMESTAMP_TO_MS = timestamp -> timestamp / 1000;
- break;
- case "ns":
- case "nanosecond":
- CAST_TIMESTAMP_TO_MS = timestamp -> timestamp / 1000000;
- break;
- case "ms":
- case "millisecond":
- default:
- CAST_TIMESTAMP_TO_MS = timestamp -> timestamp;
- break;
- }
- }
-
- private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- public static final DateTimeFormatter ISO_LOCAL_DATE_WIDTH_1_2;
-
- static {
- ISO_LOCAL_DATE_WIDTH_1_2 =
- new DateTimeFormatterBuilder()
- .appendValue(ChronoField.YEAR, 4, 19, SignStyle.NEVER)
- .appendLiteral('-')
- .appendValue(ChronoField.MONTH_OF_YEAR, 1, 2, SignStyle.NEVER)
- .appendLiteral('-')
- .appendValue(ChronoField.DAY_OF_MONTH, 1, 2, SignStyle.NEVER)
- .toFormatter();
- }
-
- /** such as '2011/12/03'. */
- public static final DateTimeFormatter ISO_LOCAL_DATE_WITH_SLASH;
-
- static {
- ISO_LOCAL_DATE_WITH_SLASH =
- new DateTimeFormatterBuilder()
- .appendValue(ChronoField.YEAR, 4, 19, SignStyle.NEVER)
- .appendLiteral('/')
- .appendValue(ChronoField.MONTH_OF_YEAR, 1, 2, SignStyle.NEVER)
- .appendLiteral('/')
- .appendValue(ChronoField.DAY_OF_MONTH, 1, 2, SignStyle.NEVER)
- .toFormatter();
- }
-
- /** such as '2011.12.03'. */
- public static final DateTimeFormatter ISO_LOCAL_DATE_WITH_DOT;
-
- static {
- ISO_LOCAL_DATE_WITH_DOT =
- new DateTimeFormatterBuilder()
- .appendValue(ChronoField.YEAR, 4, 19, SignStyle.NEVER)
- .appendLiteral('.')
- .appendValue(ChronoField.MONTH_OF_YEAR, 1, 2, SignStyle.NEVER)
- .appendLiteral('.')
- .appendValue(ChronoField.DAY_OF_MONTH, 1, 2, SignStyle.NEVER)
- .toFormatter();
- }
-
- /** such as '10:15:30' or '10:15:30.123'. */
- public static final DateTimeFormatter ISO_LOCAL_TIME_WITH_MS;
-
- static {
- ISO_LOCAL_TIME_WITH_MS =
- new DateTimeFormatterBuilder()
- .appendValue(ChronoField.HOUR_OF_DAY, 2)
- .appendLiteral(':')
- .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
- .appendLiteral(':')
- .appendValue(ChronoField.SECOND_OF_MINUTE, 2)
- .optionalStart()
- .appendFraction(ChronoField.MILLI_OF_SECOND, 0, 3, true)
- .toFormatter();
- }
-
- /** such as '10:15:30' or '10:15:30.123456'. */
- public static final DateTimeFormatter ISO_LOCAL_TIME_WITH_US;
-
- static {
- ISO_LOCAL_TIME_WITH_US =
- new DateTimeFormatterBuilder()
- .appendValue(ChronoField.HOUR_OF_DAY, 2)
- .appendLiteral(':')
- .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
- .appendLiteral(':')
- .appendValue(ChronoField.SECOND_OF_MINUTE, 2)
- .optionalStart()
- .appendFraction(ChronoField.MICRO_OF_SECOND, 0, 6, true)
- .toFormatter();
- }
-
- /** such as '10:15:30' or '10:15:30.123456789'. */
- public static final DateTimeFormatter ISO_LOCAL_TIME_WITH_NS;
-
- static {
- ISO_LOCAL_TIME_WITH_NS =
- new DateTimeFormatterBuilder()
- .appendValue(ChronoField.HOUR_OF_DAY, 2)
- .appendLiteral(':')
- .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
- .appendLiteral(':')
- .appendValue(ChronoField.SECOND_OF_MINUTE, 2)
- .optionalStart()
- .appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true)
- .optionalEnd()
- .toFormatter();
- }
-
- /** such as '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30.123+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_MS;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_MS =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WIDTH_1_2)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_MS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30.123456+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_US;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_US =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WIDTH_1_2)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_US)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30.123456789+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_NS;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_NS =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WIDTH_1_2)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_NS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011/12/03T10:15:30+01:00' or '2011/12/03T10:15:30.123+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SLASH;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SLASH =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_SLASH)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_MS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011/12/03T10:15:30+01:00' or '2011/12/03T10:15:30.123456+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SLASH_US;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SLASH_US =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_SLASH)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_US)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011/12/03T10:15:30+01:00' or '2011/12/03T10:15:30.123456789+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SLASH_NS;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SLASH_NS =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_SLASH)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_NS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011.12.03T10:15:30+01:00' or '2011.12.03T10:15:30.123+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_DOT;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_DOT =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_DOT)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_MS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011.12.03T10:15:30+01:00' or '2011.12.03T10:15:30.123456+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_DOT_US;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_DOT_US =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_DOT)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_US)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011.12.03T10:15:30+01:00' or '2011.12.03T10:15:30.123456789+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_DOT_NS;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_DOT_NS =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_DOT)
- .appendLiteral('T')
- .append(ISO_LOCAL_TIME_WITH_NS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011-12-03 10:15:30+01:00' or '2011-12-03 10:15:30.123+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SPACE;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SPACE =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(DateTimeFormatter.ISO_LOCAL_DATE)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_MS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011-12-03 10:15:30+01:00' or '2011-12-03 10:15:30.123456+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SPACE_US;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SPACE_US =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(DateTimeFormatter.ISO_LOCAL_DATE)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_US)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011-12-03 10:15:30+01:00' or '2011-12-03 10:15:30.123456789+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SPACE_NS;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SPACE_NS =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(DateTimeFormatter.ISO_LOCAL_DATE)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_NS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011/12/03 10:15:30+01:00' or '2011/12/03 10:15:30.123+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_SLASH)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_MS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011/12/03 10:15:30+01:00' or '2011/12/03 10:15:30.123456+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE_US;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE_US =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_SLASH)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_US)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011/12/03 10:15:30+01:00' or '2011/12/03 10:15:30.123456789+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE_NS;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE_NS =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_SLASH)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_NS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011.12.03 10:15:30+01:00' or '2011.12.03 10:15:30.123+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_DOT)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_MS)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011.12.03 10:15:30+01:00' or '2011.12.03 10:15:30.123456+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE_US;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE_US =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_DOT)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_US)
- .appendOffsetId()
- .toFormatter();
- }
-
- /** such as '2011.12.03 10:15:30+01:00' or '2011.12.03 10:15:30.123456789+01:00'. */
- public static final DateTimeFormatter ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE_NS;
-
- static {
- ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE_NS =
- new DateTimeFormatterBuilder()
- .parseCaseInsensitive()
- .append(ISO_LOCAL_DATE_WITH_DOT)
- .appendLiteral(' ')
- .append(ISO_LOCAL_TIME_WITH_NS)
- .appendOffsetId()
- .toFormatter();
- }
-
- public static final DateTimeFormatter formatter =
- new DateTimeFormatterBuilder()
- /**
- * The ISO date-time formatter that formats or parses a date-time with an offset, such as
- * '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30.123+01:00'.
- */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_MS)
-
- /** such as '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30.123456+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_US)
-
- /** such as '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30.123456789+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_NS)
-
- /** such as '2011/12/03T10:15:30+01:00' or '2011/12/03T10:15:30.123+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SLASH)
-
- /** such as '2011/12/03T10:15:30+01:00' or '2011/12/03T10:15:30.123456+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SLASH_US)
-
- /** such as '2011/12/03T10:15:30+01:00' or '2011/12/03T10:15:30.123456789+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SLASH_NS)
-
- /** such as '2011.12.03T10:15:30+01:00' or '2011.12.03T10:15:30.123+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_DOT)
-
- /** such as '2011.12.03T10:15:30+01:00' or '2011.12.03T10:15:30.123456+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_DOT_US)
-
- /** such as '2011.12.03T10:15:30+01:00' or '2011.12.03T10:15:30.123456789+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_DOT_NS)
-
- /** such as '2011-12-03 10:15:30+01:00' or '2011-12-03 10:15:30.123+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SPACE)
-
- /** such as '2011-12-03 10:15:30+01:00' or '2011-12-03 10:15:30.123456+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SPACE_US)
-
- /** such as '2011-12-03 10:15:30+01:00' or '2011-12-03 10:15:30.123456789+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SPACE_NS)
-
- /** such as '2011/12/03 10:15:30+01:00' or '2011/12/03 10:15:30.123+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE)
-
- /** such as '2011/12/03 10:15:30+01:00' or '2011/12/03 10:15:30.123456+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE_US)
-
- /** such as '2011/12/03 10:15:30+01:00' or '2011/12/03 10:15:30.123456789+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_SLASH_WITH_SPACE_NS)
-
- /** such as '2011.12.03 10:15:30+01:00' or '2011.12.03 10:15:30.123+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE)
-
- /** such as '2011.12.03 10:15:30+01:00' or '2011.12.03 10:15:30.123456+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE_US)
-
- /** such as '2011.12.03 10:15:30+01:00' or '2011.12.03 10:15:30.123456789+01:00'. */
- .appendOptional(ISO_OFFSET_DATE_TIME_WITH_DOT_WITH_SPACE_NS)
- .toFormatter()
- .withResolverStyle(ResolverStyle.STRICT);
-
- public static long convertTimestampOrDatetimeStrToLongWithDefaultZone(String timeStr) {
- try {
- return Long.parseLong(timeStr);
- } catch (NumberFormatException e) {
- return DateTimeUtils.convertDatetimeStrToLong(timeStr, ZoneId.systemDefault());
- }
- }
-
- public static long convertDatetimeStrToLong(String str, ZoneId zoneId) {
- return convertDatetimeStrToLong(
- str, toZoneOffset(zoneId), 0, PipeOptions.TIMESTAMP_PRECISION.value());
- }
-
- public static long convertDatetimeStrToLong(
- String str, ZoneId zoneId, String timestampPrecision) {
- return convertDatetimeStrToLong(str, toZoneOffset(zoneId), 0, timestampPrecision);
- }
-
- public static long getInstantWithPrecision(String str, String timestampPrecision) {
- try {
- ZonedDateTime zonedDateTime = ZonedDateTime.parse(str, formatter);
- Instant instant = zonedDateTime.toInstant();
- if ("us".equals(timestampPrecision) || "microsecond".equals(timestampPrecision)) {
- if (instant.getEpochSecond() < 0 && instant.getNano() > 0) {
- // adjustment can reduce the loss of the division
- long millis = Math.multiplyExact(instant.getEpochSecond() + 1, 1000_000L);
- long adjustment = instant.getNano() / 1000 - 1L;
- return Math.addExact(millis, adjustment);
- } else {
- long millis = Math.multiplyExact(instant.getEpochSecond(), 1000_000L);
- return Math.addExact(millis, instant.getNano() / 1000);
- }
- } else if ("ns".equals(timestampPrecision) || "nanosecond".equals(timestampPrecision)) {
- long millis = Math.multiplyExact(instant.getEpochSecond(), 1000_000_000L);
- return Math.addExact(millis, instant.getNano());
- }
- return instant.toEpochMilli();
- } catch (DateTimeParseException e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- /** convert date time string to millisecond, microsecond or nanosecond. */
- public static long convertDatetimeStrToLong(
- String str, ZoneOffset offset, int depth, String timestampPrecision) {
- if (depth >= 2) {
- throw new DateTimeException(
- String.format(
- "Failed to convert %s to millisecond, zone offset is %s, "
- + "please input like 2011-12-03T10:15:30 or 2011-12-03T10:15:30+01:00",
- str, offset));
- }
- if (str.contains("Z")) {
- return convertDatetimeStrToLong(
- str.substring(0, str.indexOf('Z')) + "+00:00", offset, depth, timestampPrecision);
- } else if (str.length() == 10) {
- return convertDatetimeStrToLong(str + "T00:00:00", offset, depth, timestampPrecision);
- } else if (str.length() - str.lastIndexOf('+') != 6
- && str.length() - str.lastIndexOf('-') != 6) {
- return convertDatetimeStrToLong(str + offset, offset, depth + 1, timestampPrecision);
- } else if (str.contains("[") || str.contains("]")) {
- throw new DateTimeException(
- String.format(
- "%s with [time-region] at end is not supported now, "
- + "please input like 2011-12-03T10:15:30 or 2011-12-03T10:15:30+01:00",
- str));
- }
- return getInstantWithPrecision(str, timestampPrecision);
- }
-
- /**
- * Convert duration string to time value. CurrentTime is used to calculate the days of natural
- * month. If it's set as -1, which means a context free situation, then '1mo' will be thought as
- * 30 days.
- *
- * @param duration represent duration string like: 12d8m9ns, 1y1mo, etc.
- * @return time in milliseconds, microseconds, or nanoseconds depending on the profile
- */
- public static long convertDurationStrToLong(String duration) {
- return convertDurationStrToLong(-1, duration, false);
- }
-
- public static long convertDurationStrToLong(String duration, boolean convertYearToMonth) {
- return convertDurationStrToLong(-1, duration, convertYearToMonth);
- }
-
- public static long convertDurationStrToLong(
- String duration, String timestampPrecision, boolean convertYearToMonth) {
- return convertDurationStrToLong(-1, duration, timestampPrecision, convertYearToMonth);
- }
-
- public static long convertDurationStrToLong(
- long currentTime, String duration, boolean convertYearToMonth) {
- return convertDurationStrToLong(
- currentTime, duration, PipeOptions.TIMESTAMP_PRECISION.value(), convertYearToMonth);
- }
-
- /**
- * convert duration string to time value.
- *
- * @param duration represent duration string like: 12d8m9ns, 1y1mo, etc.
- * @param convertYearToMonth if we need convert year to month. eg: 1y -> 12mo
- * @return time in milliseconds, microseconds, or nanoseconds depending on the profile
- */
- public static long convertDurationStrToLong(
- long currentTime, String duration, String timestampPrecision, boolean convertYearToMonth) {
- long total = 0;
- long temp = 0;
- for (int i = 0; i < duration.length(); i++) {
- char ch = duration.charAt(i);
- if (Character.isDigit(ch)) {
- temp *= 10;
- temp += (ch - '0');
- } else {
- String unit = String.valueOf(duration.charAt(i));
- // This is to identify units with two letters.
- if (i + 1 < duration.length() && !Character.isDigit(duration.charAt(i + 1))) {
- i++;
- unit += duration.charAt(i);
- }
- unit = unit.toLowerCase();
- if (convertYearToMonth && unit.equals("y")) {
- temp *= 12;
- unit = "mo";
- }
- total +=
- DateTimeUtils.convertDurationStrToLong(
- currentTime == -1 ? -1 : currentTime + total, temp, unit, timestampPrecision);
- temp = 0;
- }
- }
- return total;
- }
-
- /** convert duration string to millisecond, microsecond or nanosecond. */
- public static long convertDurationStrToLong(
- long currentTime, long value, String unit, String timestampPrecision) {
- DurationUnit durationUnit = DurationUnit.valueOf(unit);
- long res = value;
- switch (durationUnit) {
- case y:
- case year:
- res *= 365 * 86_400_000L;
- break;
- case mo:
- case month:
- if (currentTime == -1) {
- res *= 30 * 86_400_000L;
- } else {
- Calendar calendar = Calendar.getInstance();
- // calendar.setTimeZone(SessionManager.getInstance().getSessionTimeZone());
- calendar.setTimeInMillis(currentTime);
- calendar.add(Calendar.MONTH, (int) (value));
- res = calendar.getTimeInMillis() - currentTime;
- }
- break;
- case w:
- case week:
- res *= 7 * 86_400_000L;
- break;
- case d:
- case day:
- res *= 86_400_000L;
- break;
- case h:
- case hour:
- res *= 3_600_000L;
- break;
- case m:
- case minute:
- res *= 60_000L;
- break;
- case s:
- case second:
- res *= 1_000L;
- break;
- default:
- break;
- }
-
- if ("us".equals(timestampPrecision) || "microsecond".equals(timestampPrecision)) {
- if (unit.equals(DurationUnit.ns.toString())
- || unit.equals(DurationUnit.nanosecond.toString())) {
- return value / 1000;
- } else if (unit.equals(DurationUnit.us.toString())
- || unit.equals(DurationUnit.microsecond.toString())) {
- return value;
- } else {
- return res * 1000;
- }
- } else if ("ns".equals(timestampPrecision) || "nanosecond".equals(timestampPrecision)) {
- if (unit.equals(DurationUnit.ns.toString())
- || unit.equals(DurationUnit.nanosecond.toString())) {
- return value;
- } else if (unit.equals(DurationUnit.us.toString())
- || unit.equals(DurationUnit.microsecond.toString())) {
- return value * 1000;
- } else {
- return res * 1000_000;
- }
- } else {
- if (unit.equals(DurationUnit.ns.toString())
- || unit.equals(DurationUnit.nanosecond.toString())) {
- return value / 1000_000;
- } else if (unit.equals(DurationUnit.us.toString())
- || unit.equals(DurationUnit.microsecond.toString())) {
- return value / 1000;
- } else {
- return res;
- }
- }
- }
-
- public static TimeUnit timestampPrecisionStringToTimeUnit(String timestampPrecision) {
- if ("us".equals(timestampPrecision) || "microsecond".equals(timestampPrecision)) {
- return TimeUnit.MICROSECONDS;
- } else if ("ns".equals(timestampPrecision) || "nanosecond".equals(timestampPrecision)) {
- return TimeUnit.NANOSECONDS;
- } else {
- return TimeUnit.MILLISECONDS;
- }
- }
-
- public static String convertLongToDate(long timestamp) {
- return convertLongToDate(
- timestamp, PipeOptions.TIMESTAMP_PRECISION.value(), ZoneId.systemDefault());
- }
-
- public static String convertLongToDate(final long timestamp, final ZoneId zoneId) {
- return convertLongToDate(timestamp, PipeOptions.TIMESTAMP_PRECISION.value(), zoneId);
- }
-
- public static String convertLongToDate(final long timestamp, final String sourcePrecision) {
- return convertLongToDate(timestamp, sourcePrecision, ZoneId.systemDefault());
- }
-
- public static String convertLongToDate(
- long timestamp, final String sourcePrecision, final ZoneId zoneId) {
- switch (sourcePrecision) {
- case "ns":
- case "nanosecond":
- timestamp /= 1000_000;
- break;
- case "us":
- case "microsecond":
- timestamp /= 1000;
- break;
- default:
- break;
- }
- return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), zoneId).toString();
- }
-
- public static LocalDate convertToLocalDate(long timestamp, ZoneId zoneId) {
- timestamp = CAST_TIMESTAMP_TO_MS.apply(timestamp);
- return Instant.ofEpochMilli(timestamp).atZone(zoneId).toLocalDate();
- }
-
- public static ZonedDateTime convertToZonedDateTime(long timestamp, ZoneId zoneId) {
- timestamp = CAST_TIMESTAMP_TO_MS.apply(timestamp);
- return ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), zoneId);
- }
-
- public static ZoneOffset toZoneOffset(ZoneId zoneId) {
- return zoneId.getRules().getOffset(Instant.now());
- }
-
- public static ZonedDateTime convertMillsecondToZonedDateTime(long millisecond) {
- return ZonedDateTime.ofInstant(Instant.ofEpochMilli(millisecond), ZoneId.systemDefault());
- }
-
- public enum DurationUnit {
- y,
- year,
- mo,
- month,
- w,
- week,
- d,
- day,
- h,
- hour,
- m,
- minute,
- s,
- second,
- ms,
- millisecond,
- us,
- microsecond,
- ns,
- nanosecond
- }
-
- public static TimeUnit toTimeUnit(String t) {
- switch (t) {
- case "h":
- case "hour":
- return TimeUnit.HOURS;
- case "m":
- case "minute":
- return TimeUnit.MINUTES;
- case "s":
- case "second":
- return TimeUnit.SECONDS;
- case "ms":
- case "millisecond":
- return TimeUnit.MILLISECONDS;
- case "u":
- case "microsecond":
- return TimeUnit.MICROSECONDS;
- case "n":
- case "nanosecond":
- return TimeUnit.NANOSECONDS;
- default:
- throw new IllegalArgumentException("time precision must be one of: h,m,s,ms,u,n");
- }
- }
-
- public static final long MS_TO_MONTH = 30 * 86400_000L;
-
- public static long calcPositiveIntervalByMonth(
- long startTime, TimeDuration duration, ZoneId zoneId) {
- return TimeDuration.calcPositiveIntervalByMonth(
- startTime, duration, TimeZone.getTimeZone(zoneId), TimestampPrecisionUtils.currPrecision);
- }
-
- /**
- * Storage the duration into two parts: month part and non-month part, the non-month part's
- * precision is depended on current time precision. e.g. ms precision: '1y1mo1ms' -> monthDuration
- * = 13, nonMonthDuration = 1, ns precision: '1y1mo1ms' -> monthDuration = 13, nonMonthDuration =
- * 1000_000.
- *
- * @param duration the input duration string
- * @return the TimeDuration instance contains month part and non-month part
- */
- public static TimeDuration constructTimeDuration(String duration) {
- duration = duration.toLowerCase();
- String currTimePrecision = PipeOptions.TIMESTAMP_PRECISION.value();
- long temp = 0;
- long monthDuration = 0;
- long nonMonthDuration = 0;
- int i = 0;
- for (; i < duration.length(); i++) {
- char ch = duration.charAt(i);
- if (Character.isDigit(ch)) {
- temp *= 10;
- temp += (ch - '0');
- } else {
- StringBuilder unit = new StringBuilder(String.valueOf(duration.charAt(i)));
- i++;
- // This is to identify units.
- while (i < duration.length() && !Character.isDigit(duration.charAt(i))) {
- unit.append(duration.charAt(i));
- i++;
- }
- i--;
- if ("y".contentEquals(unit) || "year".contentEquals(unit)) {
- monthDuration += temp * 12;
- temp = 0;
- continue;
- }
- if ("mo".contentEquals(unit) || "month".contentEquals(unit)) {
- monthDuration += temp;
- temp = 0;
- continue;
- }
- nonMonthDuration +=
- DateTimeUtils.convertDurationStrToLong(-1, temp, unit.toString(), currTimePrecision);
- temp = 0;
- }
- }
- return new TimeDuration((int) monthDuration, nonMonthDuration);
- }
-
- // public static Long parseDateTimeExpressionToLong(String dateExpression, ZoneId zoneId) {
- // ASTVisitor astVisitor = new ASTVisitor();
- // astVisitor.setZoneId(zoneId);
- //
- // CharStream charStream1 = CharStreams.fromString(dateExpression);
- //
- // SqlLexer lexer1 = new SqlLexer(charStream1);
- // lexer1.removeErrorListeners();
- // lexer1.addErrorListener(SqlParseError.INSTANCE);
- //
- // CommonTokenStream tokens1 = new CommonTokenStream(lexer1);
- //
- // IoTDBSqlParser parser1 = new IoTDBSqlParser(tokens1);
- // parser1.getInterpreter().setPredictionMode(PredictionMode.SLL);
- // parser1.removeErrorListeners();
- // parser1.addErrorListener(SqlParseError.INSTANCE);
- // return astVisitor.parseDateExpression(parser1.dateExpression(), TIMESTAMP_PRECISION);
- // }
-
- public static Integer parseDateExpressionToInt(String dateExpression) {
- return DateUtils.parseDateExpressionToInt(dateExpression);
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/MemUtils.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/MemUtils.java
deleted file mode 100644
index 6850f78..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/MemUtils.java
+++ /dev/null
@@ -1,242 +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.collector.plugin.builtin.sink.utils;
-
-import org.apache.iotdb.collector.plugin.builtin.sink.constant.IoTDBConstant;
-import org.apache.iotdb.common.rpc.thrift.TSStatus;
-import org.apache.iotdb.rpc.TSStatusCode;
-
-import org.apache.tsfile.common.conf.TSFileConfig;
-import org.apache.tsfile.enums.TSDataType;
-import org.apache.tsfile.utils.Binary;
-import org.apache.tsfile.utils.RamUsageEstimator;
-import org.apache.tsfile.write.record.TSRecord;
-import org.apache.tsfile.write.record.datapoint.BooleanDataPoint;
-import org.apache.tsfile.write.record.datapoint.DataPoint;
-import org.apache.tsfile.write.record.datapoint.DoubleDataPoint;
-import org.apache.tsfile.write.record.datapoint.FloatDataPoint;
-import org.apache.tsfile.write.record.datapoint.IntDataPoint;
-import org.apache.tsfile.write.record.datapoint.LongDataPoint;
-import org.apache.tsfile.write.record.datapoint.StringDataPoint;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-// Notice : methods in this class may not be accurate.
-public class MemUtils {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(MemUtils.class);
-
- private MemUtils() {}
-
- /**
- * Function for obtaining the value size. For text values, there are two conditions: 1. During
- * insertion, their size has already been added to memory. 2. During flushing, their size needs to
- * be calculated.
- */
- public static long getRecordSize(TSDataType dataType, Object value, boolean addingTextDataSize) {
- if (dataType.isBinary()) {
- return 8L + (addingTextDataSize ? getBinarySize((Binary) value) : 0);
- }
- return 8L + dataType.getDataTypeSize();
- }
-
- /**
- * Function for obtaining the value size. For text values, their size has already been added to
- * memory before insertion
- */
- public static long getRowRecordSize(List<TSDataType> dataTypes, Object[] value) {
- int emptyRecordCount = 0;
- long memSize = 0L;
- for (int i = 0; i < value.length; i++) {
- if (value[i] == null) {
- emptyRecordCount++;
- continue;
- }
- memSize += getRecordSize(dataTypes.get(i - emptyRecordCount), value[i], false);
- }
- return memSize;
- }
-
- /**
- * Function for obtaining the value size. For text values, their size has already been added to
- * memory before insertion
- */
- public static long getAlignedRowRecordSize(
- List<TSDataType> dataTypes, Object[] value, TsTableColumnCategory[] columnCategories) {
- // time and index size
- long memSize = 8L + 4L;
- for (int i = 0; i < dataTypes.size(); i++) {
- if (value[i] == null
- || dataTypes.get(i).isBinary()
- || columnCategories != null && columnCategories[i] != TsTableColumnCategory.FIELD) {
- continue;
- }
- memSize += dataTypes.get(i).getDataTypeSize();
- }
- return memSize;
- }
-
- public static long getBinarySize(Binary value) {
- return RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + RamUsageEstimator.sizeOf(value.getValues());
- }
-
- public static long getBinaryColumnSize(Binary[] column, int start, int end, TSStatus[] results) {
- long memSize = 0;
- memSize += (long) (end - start) * RamUsageEstimator.NUM_BYTES_OBJECT_HEADER;
- for (int i = start; i < end; i++) {
- if (results == null
- || results[i] == null
- || results[i].code == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
- memSize += RamUsageEstimator.sizeOf(column[i].getValues());
- }
- }
- return memSize;
- }
-
- // /**
- // * Function for obtaining the value size. For text values, their size has already been added to
- // * memory before insertion
- // */
- // public static long getTabletSize(InsertTabletNode insertTabletNode, int start, int end) {
- // if (start >= end) {
- // return 0L;
- // }
- // long memSize = 0;
- // for (int i = 0; i < insertTabletNode.getMeasurements().length; i++) {
- // if (insertTabletNode.getMeasurements()[i] == null) {
- // continue;
- // }
- // // Time column memSize
- // memSize += (end - start) * 8L;
- // memSize += (long) (end - start) * insertTabletNode.getDataTypes()[i].getDataTypeSize();
- // }
- // return memSize;
- // }
- //
- // public static long getAlignedTabletSize(
- // InsertTabletNode insertTabletNode, int start, int end, TSStatus[] results) {
- // if (start >= end) {
- // return 0L;
- // }
- // long memSize = 0;
- // for (int i = 0; i < insertTabletNode.getMeasurements().length; i++) {
- // if (!insertTabletNode.isValidMeasurement(i)) {
- // continue;
- // }
- // if (results == null) {
- // memSize += (long) (end - start) * insertTabletNode.getDataTypes()[i].getDataTypeSize();
- // } else {
- // for (int j = start; j < end; j++) {
- // if (results[j] == null
- // || results[j].code == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
- // memSize += insertTabletNode.getDataTypes()[i].getDataTypeSize();
- // }
- // }
- // }
- // }
- // // time and index column memSize for vector
- // memSize += (end - start) * (8L + 4L);
- // return memSize;
- // }
-
- /** Calculate how much memory will be used if the given record is written to sequence file. */
- public static long getTsRecordMem(TSRecord tsRecord) {
- long memUsed = 8; // time
- memUsed += 8; // deviceId reference
- memUsed += tsRecord.deviceId.ramBytesUsed();
- for (DataPoint dataPoint : tsRecord.dataPointList) {
- memUsed += 8; // dataPoint reference
- memUsed += getDataPointMem(dataPoint);
- }
- return memUsed;
- }
-
- /** Function for getting the memory size of the given string. */
- public static long getStringMem(String str) {
- // wide char (2 bytes each) and 64B String overhead
- return str.length() * 2L + 64L;
- }
-
- /** Function for getting the memory size of the given data point. */
- public static long getDataPointMem(DataPoint dataPoint) {
- // type reference
- long memUsed = 8;
- // measurementId and its reference
- memUsed += getStringMem(dataPoint.getMeasurementId());
- memUsed += 8;
-
- if (dataPoint instanceof FloatDataPoint) {
- memUsed += 4;
- } else if (dataPoint instanceof IntDataPoint) {
- memUsed += 4;
- } else if (dataPoint instanceof BooleanDataPoint) {
- memUsed += 1;
- } else if (dataPoint instanceof DoubleDataPoint) {
- memUsed += 8;
- } else if (dataPoint instanceof LongDataPoint) {
- memUsed += 8;
- } else if (dataPoint instanceof StringDataPoint) {
- StringDataPoint stringDataPoint = (StringDataPoint) dataPoint;
- memUsed += 8 + 20; // array reference and array overhead
- memUsed += ((Binary) stringDataPoint.getValue()).getLength();
- // encoding string reference and its memory
- memUsed += 8;
- memUsed += getStringMem(TSFileConfig.STRING_ENCODING);
- } else {
- LOGGER.error("Unsupported data point type");
- }
-
- return memUsed;
- }
-
- /** Function for converting the byte count result to readable string. */
- public static String bytesCntToStr(long inputCnt) {
- long cnt = inputCnt;
- long gbs = cnt / IoTDBConstant.GB;
- cnt = cnt % IoTDBConstant.GB;
- long mbs = cnt / IoTDBConstant.MB;
- cnt = cnt % IoTDBConstant.MB;
- long kbs = cnt / IoTDBConstant.KB;
- cnt = cnt % IoTDBConstant.KB;
- return gbs + " GB " + mbs + " MB " + kbs + " KB " + cnt + " B";
- }
-
- public static long strToBytesCnt(String str) {
- if (str == null || str.isEmpty()) {
- return 0;
- }
- str = str.toLowerCase();
- if (!str.endsWith("b")) {
- str += "b";
- }
- long unit = 1;
- if (str.endsWith("kb")) {
- unit = IoTDBConstant.KB;
- } else if (str.endsWith("mb")) {
- unit = IoTDBConstant.MB;
- } else if (str.endsWith("gb")) {
- unit = IoTDBConstant.GB;
- }
- str = str.replaceAll("\\D", "");
- return Long.parseLong(str) * unit;
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/NodeUrlUtils.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/NodeUrlUtils.java
deleted file mode 100644
index 5b11103..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/NodeUrlUtils.java
+++ /dev/null
@@ -1,246 +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.collector.plugin.builtin.sink.utils;
-
-import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
-import org.apache.iotdb.common.rpc.thrift.TEndPoint;
-import org.apache.iotdb.rpc.UrlUtils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringJoiner;
-import java.util.stream.Collectors;
-
-public class NodeUrlUtils {
-
- private static final Logger logger = LoggerFactory.getLogger(NodeUrlUtils.class);
-
- public static final String WILD_CARD_ADDRESS = "0.0.0.0";
- public static final String LOOPBACK_HOST_NAME = "localhost";
-
- /**
- * Convert TEndPoint to TEndPointUrl
- *
- * @param endPoint TEndPoint
- * @return TEndPointUrl with format ip:port
- */
- public static String convertTEndPointUrl(TEndPoint endPoint) {
- StringJoiner url = new StringJoiner(":");
- url.add(endPoint.getIp());
- url.add(String.valueOf(endPoint.getPort()));
- return url.toString();
- }
-
- /**
- * Convert TEndPoints to TEndPointUrls
- *
- * @param endPoints List<TEndPoint>
- * @return TEndPointUrls with format TEndPointUrl_0,TEndPointUrl_1,...,TEndPointUrl_n
- */
- public static String convertTEndPointUrls(List<TEndPoint> endPoints) {
- StringJoiner urls = new StringJoiner(",");
- for (TEndPoint endPoint : endPoints) {
- urls.add(convertTEndPointUrl(endPoint));
- }
- return urls.toString();
- }
-
- /**
- * Parse TEndPoint from a given TEndPointUrl
- *
- * @param endPointUrl ip:port
- * @return TEndPoint
- * @throws BadNodeUrlException Throw when unable to parse
- */
- public static TEndPoint parseTEndPointUrl(String endPointUrl) throws BadNodeUrlException {
- return UrlUtils.parseTEndPointIpv4AndIpv6Url(endPointUrl);
- }
-
- /**
- * Parse TEndPoints from given TEndPointUrls
- *
- * @param endPointUrls List<TEndPointUrl>
- * @return List<TEndPoint>
- */
- public static List<TEndPoint> parseTEndPointUrls(List<String> endPointUrls) {
- if (endPointUrls == null) {
- throw new NumberFormatException("endPointUrls is null");
- }
- List<TEndPoint> result = new ArrayList<>();
- for (String url : endPointUrls) {
- result.add(UrlUtils.parseTEndPointIpv4AndIpv6Url(url));
- }
- return result;
- }
-
- /**
- * Parse TEndPoints from given TEndPointUrls
- *
- * @param endPointUrls TEndPointUrls
- * @return List<TEndPoint>
- * @throws BadNodeUrlException Throw when unable to parse
- */
- public static List<TEndPoint> parseTEndPointUrls(String endPointUrls) throws BadNodeUrlException {
- return parseTEndPointUrls(Arrays.asList(endPointUrls.split(",")));
- }
-
- /**
- * Convert TConfigNodeLocation to TConfigNodeUrl
- *
- * @param configNodeLocation TConfigNodeLocation
- * @return TConfigNodeUrl with format InternalEndPointUrl,ConsensusEndPointUrl
- */
- public static String convertTConfigNodeUrl(TConfigNodeLocation configNodeLocation) {
- StringJoiner url = new StringJoiner(",");
- url.add(String.valueOf(configNodeLocation.getConfigNodeId()));
- url.add(convertTEndPointUrl(configNodeLocation.getInternalEndPoint()));
- url.add(convertTEndPointUrl(configNodeLocation.getConsensusEndPoint()));
- return url.toString();
- }
-
- /**
- * Convert TConfigNodeLocations to TConfigNodeUrls
- *
- * @param configNodeLocations List<TConfigNodeLocation>
- * @return TConfigNodeUrls with format TConfigNodeUrl_0,TConfigNodeUrl_1,...,TConfigNodeUrl_n
- */
- public static String convertTConfigNodeUrls(List<TConfigNodeLocation> configNodeLocations) {
- StringJoiner urls = new StringJoiner(";");
- for (TConfigNodeLocation configNodeLocation : configNodeLocations) {
- urls.add(convertTConfigNodeUrl(configNodeLocation));
- }
- return urls.toString();
- }
-
- /**
- * Parse TConfigNodeLocation from given TConfigNodeUrl
- *
- * @param configNodeUrl InternalEndPointUrl,ConsensusEndPointUrl
- * @return TConfigNodeLocation
- * @throws BadNodeUrlException Throw when unable to parse
- */
- public static TConfigNodeLocation parseTConfigNodeUrl(String configNodeUrl)
- throws BadNodeUrlException {
- String[] split = configNodeUrl.split(",");
- if (split.length != 3) {
- logger.warn("Bad ConfigNode url: {}", configNodeUrl);
- throw new BadNodeUrlException(String.format("Bad node url: %s", configNodeUrl));
- }
- return new TConfigNodeLocation(
- Integer.parseInt(split[0]),
- UrlUtils.parseTEndPointIpv4AndIpv6Url(split[1]),
- UrlUtils.parseTEndPointIpv4AndIpv6Url(split[2]));
- }
-
- /**
- * Parse TConfigNodeLocations from given TConfigNodeUrls
- *
- * @param configNodeUrls List<TConfigNodeUrl>
- * @return List<TConfigNodeLocation>
- * @throws BadNodeUrlException Throw when unable to parse
- */
- public static List<TConfigNodeLocation> parseTConfigNodeUrls(List<String> configNodeUrls)
- throws BadNodeUrlException {
- List<TConfigNodeLocation> result = new ArrayList<>();
- for (String url : configNodeUrls) {
- result.add(parseTConfigNodeUrl(url));
- }
- return result;
- }
-
- /**
- * Parse TConfigNodeLocations from given TConfigNodeUrls
- *
- * @param configNodeUrls TConfigNodeUrls
- * @return List<TConfigNodeLocation>
- * @throws BadNodeUrlException Throw when unable to parse
- */
- public static List<TConfigNodeLocation> parseTConfigNodeUrls(String configNodeUrls)
- throws BadNodeUrlException {
- return parseTConfigNodeUrls(Arrays.asList(configNodeUrls.split(";")));
- }
-
- /**
- * Detect whether the given addresses or host names(may contain both) point to the node itself.
- *
- * @param addressesOrHostNames List of the addresses or host name to check
- * @return true if one of the given strings point to the node itself
- * @throws UnknownHostException Throw when unable to parse the given addresses or host names
- */
- public static boolean containsLocalAddress(List<String> addressesOrHostNames)
- throws UnknownHostException {
- if (addressesOrHostNames == null) {
- return false;
- }
-
- Set<String> selfAddresses = getAllLocalAddresses();
-
- for (String addressOrHostName : addressesOrHostNames) {
- if (addressOrHostName == null) {
- continue;
- }
- // Unify address or hostName, converting them to addresses
- Set<String> translatedAddresses =
- Arrays.stream(InetAddress.getAllByName(addressOrHostName))
- .map(InetAddress::getHostAddress)
- .collect(Collectors.toCollection(HashSet::new));
- translatedAddresses.retainAll(selfAddresses);
-
- if (!translatedAddresses.isEmpty()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Return all the internal, external, IPv4, IPv6 and loopback addresses(without hostname) of the
- * node
- *
- * @return the local addresses set
- * @throws UnknownHostException Throw when unable to self addresses or host names (Normally not
- * thrown)
- */
- public static Set<String> getAllLocalAddresses() throws UnknownHostException {
- // Check internal and external, IPv4 and IPv6 network addresses
- Set<String> selfAddresses =
- Arrays.stream(InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()))
- .map(InetAddress::getHostAddress)
- .collect(Collectors.toCollection(HashSet::new));
- // Check IPv4 and IPv6 loopback addresses 127.0.0.1 and 0.0.0.0.0.0.0.1
- selfAddresses.addAll(
- Arrays.stream(InetAddress.getAllByName(LOOPBACK_HOST_NAME))
- .map(InetAddress::getHostAddress)
- .collect(Collectors.toCollection(HashSet::new)));
- // Check general address 0.0.0.0
- selfAddresses.add(WILD_CARD_ADDRESS);
-
- return selfAddresses;
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PathDeserializeUtil.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PathDeserializeUtil.java
deleted file mode 100644
index f6c6905..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PathDeserializeUtil.java
+++ /dev/null
@@ -1,47 +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.collector.plugin.builtin.sink.utils;
-
-import org.apache.iotdb.collector.plugin.builtin.sink.path.AlignedPath;
-import org.apache.iotdb.collector.plugin.builtin.sink.path.MeasurementPath;
-import org.apache.iotdb.collector.plugin.builtin.sink.path.PartialPath;
-
-import org.apache.tsfile.read.common.Path;
-
-import java.nio.ByteBuffer;
-
-public class PathDeserializeUtil {
-
- public static Path deserialize(ByteBuffer buffer) {
- byte pathType = buffer.get();
- switch (pathType) {
- case 0:
- return MeasurementPath.deserialize(buffer);
- case 1:
- return AlignedPath.deserialize(buffer);
- case 2:
- return PartialPath.deserialize(buffer);
- case 3:
- return Path.deserialize(buffer);
- default:
- throw new IllegalArgumentException("Invalid path type: " + pathType);
- }
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PathUtils.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PathUtils.java
deleted file mode 100644
index b9513bd..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PathUtils.java
+++ /dev/null
@@ -1,225 +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.collector.plugin.builtin.sink.utils;
-
-import org.apache.iotdb.collector.plugin.builtin.sink.constant.IoTDBConstant;
-
-import org.apache.tsfile.common.constant.TsFileConstant;
-import org.apache.tsfile.exception.PathParseException;
-import org.apache.tsfile.file.metadata.IDeviceID;
-import org.apache.tsfile.read.common.parser.PathNodesGenerator;
-import org.apache.tsfile.read.common.parser.PathVisitor;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class PathUtils {
-
- /**
- * @param path the path will split. ex, root.ln.
- * @return string array. ex, [root, ln]
- * @throws IllegalPathException if path isn't correct, the exception will throw
- */
- public static String[] splitPathToDetachedNodes(String path) throws IllegalPathException {
- if ("".equals(path)) {
- return new String[] {};
- }
- try {
- return PathNodesGenerator.splitPathToNodes(path);
- } catch (PathParseException e) {
- throw new IllegalPathException(path);
- }
- }
-
- public static String[] isLegalPath(String path) throws IllegalPathException {
- try {
- return PathNodesGenerator.splitPathToNodes(path);
- } catch (PathParseException e) {
- throw new IllegalPathException(path);
- }
- }
-
- /**
- * check whether measurement is legal according to syntax convention. Measurement can only be a
- * single node name. The returned list is updated, could be different from the original list.
- */
- public static List<List<String>> checkIsLegalSingleMeasurementListsAndUpdate(
- List<List<String>> measurementLists) throws MetadataException {
- if (measurementLists == null) {
- return null;
- }
- // skip checking duplicated measurements
- Map<String, String> checkedMeasurements = new HashMap<>();
- List<List<String>> res = new ArrayList<>();
- for (List<String> measurements : measurementLists) {
- res.add(checkLegalSingleMeasurementsAndSkipDuplicate(measurements, checkedMeasurements));
- }
- return res;
- }
-
- /**
- * check whether measurement is legal according to syntax convention. Measurement can only be a
- * single node name, use set to skip checking duplicated measurements
- */
- public static List<String> checkLegalSingleMeasurementsAndSkipDuplicate(
- List<String> measurements, Map<String, String> checkedMeasurements) throws MetadataException {
- if (measurements == null) {
- return null;
- }
- List<String> res = new ArrayList<>();
- for (String measurement : measurements) {
- if (measurement == null) {
- res.add(null);
- continue;
- }
- String checked = checkedMeasurements.get(measurement);
- if (checked == null) {
- checked = checkAndReturnSingleMeasurement(measurement);
- checkedMeasurements.put(measurement, checked);
- }
- res.add(checked);
- }
- return res;
- }
-
- /**
- * check whether measurement is legal according to syntax convention. Measurement can only be a
- * single node name.
- */
- public static List<String> checkIsLegalSingleMeasurementsAndUpdate(List<String> measurements)
- throws MetadataException {
- if (measurements == null) {
- return null;
- }
- List<String> res = new ArrayList<>();
- for (String measurement : measurements) {
- if (measurement == null) {
- continue;
- }
- res.add(checkAndReturnSingleMeasurement(measurement));
- }
- return res;
- }
-
- /**
- * check whether measurement is legal according to syntax convention measurement could be like a.b
- * (more than one node name), in template?
- */
- public static List<List<String>> checkIsLegalMeasurementListsAndUpdate(
- List<List<String>> measurementLists) throws IllegalPathException {
- if (measurementLists == null) {
- return null;
- }
- List<List<String>> res = new ArrayList<>();
- for (List<String> measurementList : measurementLists) {
- res.add(checkIsLegalMeasurementsAndUpdate(measurementList));
- }
- return res;
- }
-
- /**
- * check whether measurement is legal according to syntax convention measurement could be like a.b
- * (more than one node name), in template?
- */
- public static List<String> checkIsLegalMeasurementsAndUpdate(List<String> measurements)
- throws IllegalPathException {
- if (measurements == null) {
- return null;
- }
- List<String> res = new ArrayList<>();
- for (String measurement : measurements) {
- if (measurement != null) {
- res.add(PathUtils.isLegalPath(measurement)[0]);
- }
- }
- return res;
- }
-
- /** check a measurement and update it if needed to. for example: `sd` -> sd */
- public static String checkAndReturnSingleMeasurement(String measurement)
- throws IllegalPathException {
- if (measurement == null) {
- return null;
- }
- if (measurement.startsWith(TsFileConstant.BACK_QUOTE_STRING)
- && measurement.endsWith(TsFileConstant.BACK_QUOTE_STRING)) {
- if (checkBackQuotes(measurement.substring(1, measurement.length() - 1))) {
- return removeBackQuotesIfNecessary(measurement);
- } else {
- throw new IllegalPathException(measurement);
- }
- }
- if (IoTDBConstant.reservedWords.contains(measurement.toUpperCase())
- || isRealNumber(measurement)
- || !TsFileConstant.NODE_NAME_PATTERN.matcher(measurement).matches()) {
- throw new IllegalPathException(measurement);
- }
- return measurement;
- }
-
- /** Return true if the str is a real number. Examples: 1.0; +1.0; -1.0; 0011; 011e3; +23e-3 */
- public static boolean isRealNumber(final String str) {
- return PathVisitor.isRealNumber(str);
- }
-
- public static boolean isStartWith(final IDeviceID deviceID, final String storageGroup) {
- return deviceID.segmentNum() > 0 && deviceID.matchDatabaseName(storageGroup);
- }
-
- /** Remove the back quotes of a measurement if necessary */
- public static String removeBackQuotesIfNecessary(String measurement) {
- String unWrapped = measurement.substring(1, measurement.length() - 1);
- if (PathUtils.isRealNumber(unWrapped)
- || !TsFileConstant.IDENTIFIER_PATTERN.matcher(unWrapped).matches()) {
- return measurement;
- } else {
- return unWrapped;
- }
- }
-
- private static boolean checkBackQuotes(final String src) {
- int num = src.length() - src.replace("`", "").length();
- if (num % 2 == 1) {
- return false;
- }
- return src.length() == (src.replace("``", "").length() + num);
- }
-
- // In tree model, the "root" shall not be a database name
- // Thus we imply that "root" is a db name in table model
- public static String qualifyDatabaseName(String databaseName) {
- if (databaseName != null && !databaseName.startsWith("root.")) {
- databaseName = "root." + databaseName;
- }
- return databaseName;
- }
-
- public static String unQualifyDatabaseName(String databaseName) {
- if (databaseName != null && databaseName.startsWith("root.")) {
- databaseName = databaseName.substring(5).toLowerCase();
- }
- return databaseName;
- }
-
- public static boolean isTableModelDatabase(final String databaseName) {
- return !databaseName.startsWith("root.");
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PipeMemoryWeightUtil.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PipeMemoryWeightUtil.java
deleted file mode 100644
index eb75e5e..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/PipeMemoryWeightUtil.java
+++ /dev/null
@@ -1,359 +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.collector.plugin.builtin.sink.utils;
-
-import org.apache.iotdb.collector.config.PipeOptions;
-import org.apache.iotdb.collector.plugin.builtin.sink.event.row.PipeRow;
-
-import org.apache.tsfile.enums.TSDataType;
-import org.apache.tsfile.file.metadata.AbstractAlignedChunkMetadata;
-import org.apache.tsfile.file.metadata.ChunkMetadata;
-import org.apache.tsfile.file.metadata.IChunkMetadata;
-import org.apache.tsfile.file.metadata.IDeviceID;
-import org.apache.tsfile.read.common.BatchData;
-import org.apache.tsfile.read.common.Chunk;
-import org.apache.tsfile.read.common.Field;
-import org.apache.tsfile.read.common.RowRecord;
-import org.apache.tsfile.utils.Binary;
-import org.apache.tsfile.utils.BitMap;
-import org.apache.tsfile.utils.Pair;
-import org.apache.tsfile.utils.TsPrimitiveType;
-import org.apache.tsfile.write.record.Tablet;
-import org.apache.tsfile.write.schema.IMeasurementSchema;
-
-import java.util.List;
-import java.util.Map;
-
-public class PipeMemoryWeightUtil {
-
- /** Estimates memory usage of a {@link Map}<{@link IDeviceID}, {@link Boolean}>. */
- public static long memoryOfIDeviceId2Bool(Map<IDeviceID, Boolean> map) {
- long usageInBytes = 0L;
- for (Map.Entry<IDeviceID, Boolean> entry : map.entrySet()) {
- usageInBytes = usageInBytes + entry.getKey().ramBytesUsed() + 1L;
- }
- return usageInBytes + 16L; // add the overhead of map
- }
-
- /** Estimates memory usage of a {@link Map}<{@link String}, {@link TSDataType}>. */
- public static long memoryOfStr2TSDataType(Map<String, TSDataType> map) {
- long usageInBytes = 0L;
- for (Map.Entry<String, TSDataType> entry : map.entrySet()) {
- usageInBytes = usageInBytes + MemUtils.getStringMem(entry.getKey()) + 4L;
- }
- return usageInBytes + 16L; // add the overhead of map
- }
-
- /** Estimates memory usage of a {@link Map}<{@link IDeviceID}, {@link List}<{@link String}>>. */
- public static long memoryOfIDeviceID2StrList(Map<IDeviceID, List<String>> map) {
- long usageInBytes = 0L;
- for (Map.Entry<IDeviceID, List<String>> entry : map.entrySet()) {
- usageInBytes += entry.getKey().ramBytesUsed();
- for (String str : entry.getValue()) {
- usageInBytes += MemUtils.getStringMem(str);
- }
- }
- return usageInBytes + 16L; // add the overhead of map
- }
-
- /**
- * Given a row of a tablet, calculate the row count and memory cost of the pipe tablet that will
- * be constructed according to config.
- *
- * @return left is the row count of tablet, right is the memory cost of tablet in bytes
- */
- public static Pair<Integer, Integer> calculateTabletRowCountAndMemory(RowRecord row) {
- int totalSizeInBytes = 0;
-
- // timestamp
- totalSizeInBytes += 8L;
-
- // values
- final List<Field> fields = row.getFields();
- int schemaCount = 0;
- if (fields != null) {
- schemaCount = fields.size();
- for (final Field field : fields) {
- if (field == null) {
- continue;
- }
-
- final TSDataType tsDataType = field.getDataType();
- if (tsDataType == null) {
- continue;
- }
-
- if (tsDataType.isBinary()) {
- final Binary binary = field.getBinaryV();
- totalSizeInBytes += binary == null ? 0 : binary.getLength();
- } else {
- totalSizeInBytes += tsDataType.getDataTypeSize();
- }
- }
- }
-
- return calculateTabletRowCountAndMemoryBySize(totalSizeInBytes, schemaCount);
- }
-
- /**
- * Given a BatchData, calculate the row count and memory cost of the pipe tablet that will be
- * constructed according to config.
- *
- * @return left is the row count of tablet, right is the memory cost of tablet in bytes
- */
- public static Pair<Integer, Integer> calculateTabletRowCountAndMemory(BatchData batchData) {
- int totalSizeInBytes = 0;
- int schemaCount = 0;
-
- // timestamp
- totalSizeInBytes += 8L;
-
- // values
- final TSDataType type = batchData.getDataType();
- if (type != null) {
- if (type == TSDataType.VECTOR && batchData.getVector() != null) {
- schemaCount = batchData.getVector().length;
- for (int i = 0; i < schemaCount; ++i) {
- final TsPrimitiveType primitiveType = batchData.getVector()[i];
- if (primitiveType == null || primitiveType.getDataType() == null) {
- continue;
- }
-
- if (primitiveType.getDataType().isBinary()) {
- final Binary binary = primitiveType.getBinary();
- totalSizeInBytes += binary == null ? 0 : binary.getLength();
- } else {
- totalSizeInBytes += primitiveType.getDataType().getDataTypeSize();
- }
- }
- } else {
- schemaCount = 1;
- if (type.isBinary()) {
- final Binary binary = batchData.getBinary();
- totalSizeInBytes += binary == null ? 0 : binary.getLength();
- } else {
- totalSizeInBytes += type.getDataTypeSize();
- }
- }
- }
-
- return calculateTabletRowCountAndMemoryBySize(totalSizeInBytes, schemaCount);
- }
-
- /**
- * Given a row of a tablet, calculate the row count and memory cost of the pipe tablet that will
- * be constructed according to config.
- *
- * @return left is the row count of tablet, right is the memory cost of tablet in bytes
- */
- public static Pair<Integer, Integer> calculateTabletRowCountAndMemory(PipeRow row) {
- return calculateTabletRowCountAndMemoryBySize(row.getCurrentRowSize(), row.size());
- }
-
- private static Pair<Integer, Integer> calculateTabletRowCountAndMemoryBySize(
- int rowSize, int schemaCount) {
- if (rowSize <= 0) {
- return new Pair<>(1, 0);
- }
-
- // Calculate row number according to the max size of a pipe tablet.
- // "-100" is the estimated size of other data structures in a pipe tablet.
- // "*8" converts bytes to bits, because the bitmap size is 1 bit per schema.
- int rowNumber =
- 8
- * (PipeOptions.PIPE_DATA_STRUCTURE_TABLET_SIZE_IN_BYTES.value() - 100)
- / (8 * rowSize + schemaCount);
- rowNumber = Math.max(1, rowNumber);
-
- if ( // This means the row number is larger than the max row count of a pipe tablet
- rowNumber > PipeOptions.PIPE_DATA_STRUCTURE_TABLET_ROW_SIZE.value()) {
- // Bound the row number, the memory cost is rowSize * rowNumber
- return new Pair<>(
- PipeOptions.PIPE_DATA_STRUCTURE_TABLET_ROW_SIZE.value(),
- rowSize * PipeOptions.PIPE_DATA_STRUCTURE_TABLET_ROW_SIZE.value());
- } else {
- return new Pair<>(rowNumber, PipeOptions.PIPE_DATA_STRUCTURE_TABLET_SIZE_IN_BYTES.value());
- }
- }
-
- public static long calculateTabletSizeInBytes(Tablet tablet) {
- long totalSizeInBytes = 0;
-
- if (tablet == null) {
- return totalSizeInBytes;
- }
-
- long[] timestamps = tablet.getTimestamps();
- Object[] tabletValues = tablet.getValues();
-
- // timestamps
- if (timestamps != null) {
- totalSizeInBytes += timestamps.length * 8L;
- }
-
- // values
- final List<IMeasurementSchema> timeseries = tablet.getSchemas();
- if (timeseries != null) {
- for (int column = 0; column < timeseries.size(); column++) {
- final IMeasurementSchema measurementSchema = timeseries.get(column);
- if (measurementSchema == null) {
- continue;
- }
-
- final TSDataType tsDataType = measurementSchema.getType();
- if (tsDataType == null) {
- continue;
- }
-
- if (tsDataType.isBinary()) {
- if (tabletValues == null || tabletValues.length <= column) {
- continue;
- }
- final Binary[] values = ((Binary[]) tabletValues[column]);
- if (values == null) {
- continue;
- }
- for (Binary value : values) {
- totalSizeInBytes +=
- value == null ? 0 : (value.getLength() == -1 ? 0 : value.getLength());
- }
- } else {
- totalSizeInBytes += (long) timestamps.length * tsDataType.getDataTypeSize();
- }
- }
- }
-
- // bitMaps
- BitMap[] bitMaps = tablet.getBitMaps();
- if (bitMaps != null) {
- for (int i = 0; i < bitMaps.length; i++) {
- totalSizeInBytes += bitMaps[i] == null ? 0 : bitMaps[i].getSize();
- }
- }
-
- // estimate other dataStructures size
- totalSizeInBytes += 100;
-
- return totalSizeInBytes;
- }
-
- // public static long calculateTableSchemaBytesUsed(TableSchema tableSchema) {
- // long totalSizeInBytes = 0;
- //
- // final String tableName = tableSchema.getTableName();
- // if (tableName != null) {
- // totalSizeInBytes += tableName.length();
- // }
- //
- // final List<IMeasurementSchema> measurementSchemas = tableSchema.getColumnSchemas();
- // if (measurementSchemas != null) {
- // totalSizeInBytes +=
- // NUM_BYTES_ARRAY_HEADER + (long) NUM_BYTES_OBJECT_REF * measurementSchemas.size();
- // for (IMeasurementSchema measurementSchema : measurementSchemas) {
- // InsertNodeMemoryEstimator.sizeOfMeasurementSchema((MeasurementSchema) measurementSchema);
- // }
- // }
- //
- // final List<Tablet.ColumnCategory> categories = tableSchema.getColumnTypes();
- // if (categories != null) {
- // totalSizeInBytes +=
- // alignObjectSize(
- // (long) NUM_BYTES_ARRAY_HEADER
- // + (long) NUM_BYTES_OBJECT_REF * (long) categories.size());
- // }
- //
- // return totalSizeInBytes;
- // }
-
- public static int calculateBatchDataRamBytesUsed(BatchData batchData) {
- int totalSizeInBytes = 0;
-
- // timestamp
- totalSizeInBytes += 8;
-
- // values
- final TSDataType type = batchData.getDataType();
- if (type != null) {
- if (type == TSDataType.VECTOR && batchData.getVector() != null) {
- for (int i = 0; i < batchData.getVector().length; ++i) {
- final TsPrimitiveType primitiveType = batchData.getVector()[i];
- if (primitiveType == null || primitiveType.getDataType() == null) {
- continue;
- }
- // consider variable references (plus 8) and memory alignment (round up to 8)
- totalSizeInBytes += roundUpToMultiple(primitiveType.getSize() + 8, 8);
- }
- } else {
- if (type.isBinary()) {
- final Binary binary = batchData.getBinary();
- // refer to org.apache.tsfile.utils.TsPrimitiveType.TsBinary.getSize
- totalSizeInBytes +=
- roundUpToMultiple((binary == null ? 8 : binary.getLength() + 8) + 8, 8);
- } else {
- totalSizeInBytes += roundUpToMultiple(TsPrimitiveType.getByType(type).getSize() + 8, 8);
- }
- }
- }
-
- return batchData.length() * totalSizeInBytes;
- }
-
- public static long calculateChunkRamBytesUsed(Chunk chunk) {
- return chunk != null ? chunk.getRetainedSizeInBytes() : 0L;
- }
-
- public static long calculateAlignedChunkMetaBytesUsed(
- AbstractAlignedChunkMetadata alignedChunkMetadata) {
- if (alignedChunkMetadata == null) {
- return 0L;
- }
-
- final ChunkMetadata timeChunkMetadata =
- (ChunkMetadata) alignedChunkMetadata.getTimeChunkMetadata();
- final List<IChunkMetadata> valueChunkMetadataList =
- alignedChunkMetadata.getValueChunkMetadataList();
-
- long size = timeChunkMetadata != null ? timeChunkMetadata.getRetainedSizeInBytes() : 0;
- if (valueChunkMetadataList != null && !valueChunkMetadataList.isEmpty()) {
- for (IChunkMetadata valueChunkMetadata : valueChunkMetadataList) {
- if (valueChunkMetadata != null) {
- size += ((ChunkMetadata) valueChunkMetadata).getRetainedSizeInBytes();
- }
- }
- }
-
- return size;
- }
-
- /**
- * Rounds up the given integer num to the nearest multiple of n.
- *
- * @param num The integer to be rounded up.
- * @param n The specified multiple.
- * @return The nearest multiple of n greater than or equal to num.
- */
- private static int roundUpToMultiple(int num, int n) {
- if (n == 0) {
- throw new IllegalArgumentException("The multiple n must be greater than 0");
- }
- // Calculate the rounded up value to the nearest multiple of n
- return ((num + n - 1) / n) * n;
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/RetryUtils.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/RetryUtils.java
deleted file mode 100644
index e113a4c..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/RetryUtils.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.collector.plugin.builtin.sink.utils;
-
-public class RetryUtils {
-
- public interface CallableWithException<T, E extends Exception> {
- T call() throws E;
- }
-
- public static final int MAX_RETRIES = 3;
-
- public static <T, E extends Exception> T retryOnException(
- final CallableWithException<T, E> callable) throws E {
- int attempt = 0;
- while (true) {
- try {
- return callable.call();
- } catch (Exception e) {
- attempt++;
- if (attempt >= MAX_RETRIES) {
- throw e;
- }
- }
- }
- }
-
- private RetryUtils() {
- // utility class
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TestOnly.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TestOnly.java
deleted file mode 100644
index 17d5508..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TestOnly.java
+++ /dev/null
@@ -1,34 +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.collector.plugin.builtin.sink.utils;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * TestOnly implies that the class or method should only be used in the tests, otherwise its
- * functionality is not guaranteed and may interfere with the normal code.
- */
-@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
-@Retention(RetentionPolicy.CLASS)
-public @interface TestOnly {}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TimestampPrecisionUtils.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TimestampPrecisionUtils.java
deleted file mode 100644
index 7bbc6ab..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TimestampPrecisionUtils.java
+++ /dev/null
@@ -1,98 +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.collector.plugin.builtin.sink.utils;
-
-import org.apache.iotdb.collector.config.PipeOptions;
-
-import java.util.concurrent.TimeUnit;
-
-public class TimestampPrecisionUtils {
- public static String TIMESTAMP_PRECISION = PipeOptions.TIMESTAMP_PRECISION.value();
-
- @FunctionalInterface
- private interface ConvertFunction<T1, T2, R> {
- R apply(T1 t1, T2 t2);
- }
-
- private static final ConvertFunction<Long, TimeUnit, Long> convertToCurrPrecisionFunction;
- public static final TimeUnit currPrecision;
-
- static {
- switch (TIMESTAMP_PRECISION) {
- case "ms":
- convertToCurrPrecisionFunction = TimeUnit.MILLISECONDS::convert;
- currPrecision = TimeUnit.MILLISECONDS;
- break;
- case "us":
- convertToCurrPrecisionFunction = TimeUnit.MICROSECONDS::convert;
- currPrecision = TimeUnit.MICROSECONDS;
- break;
- case "ns":
- convertToCurrPrecisionFunction = TimeUnit.NANOSECONDS::convert;
- currPrecision = TimeUnit.NANOSECONDS;
- break;
- // this case will never reach
- default:
- throw new UnsupportedOperationException(
- "not supported time_precision: " + TIMESTAMP_PRECISION);
- }
- }
-
- /** convert specific precision timestamp to current precision timestamp */
- public static long convertToCurrPrecision(long sourceTime, TimeUnit sourceUnit) {
- return convertToCurrPrecisionFunction.apply(sourceTime, sourceUnit);
- }
-
- /** check whether the input timestamp match the current system timestamp precision. */
- public static void checkTimestampPrecision(long time) {
- final boolean isTimestampPrecisionCheckEnabled =
- PipeOptions.TIMESTAMP_PRECISION_CHECK_ENABLED.value();
- if (!isTimestampPrecisionCheckEnabled) {
- return;
- }
- switch (TIMESTAMP_PRECISION) {
- case "ms":
- if (time > 10_000_000_000_000L || time < -10_000_000_000_000L) {
- throw new SemanticException(
- String.format(
- "The timestamp is unexpectedly large, you may forget to set the timestamp precision."
- + "Current system timestamp precision is %s, "
- + "please check whether the timestamp %s is correct."
- + "If you insist to insert this timestamp, please set timestamp_precision_check_enabled=false and restart the server.",
- TIMESTAMP_PRECISION, time));
- }
- break;
- case "us":
- if (time > 10_000_000_000_000_000L || time < -10_000_000_000_000L) {
- throw new SemanticException(
- String.format(
- "The timestamp is unexpectedly large, you may forget to set the timestamp precision."
- + "Current system timestamp precision is %s, "
- + "please check whether the timestamp %s is correct."
- + "If you insist to insert this timestamp, please set timestamp_precision_check_enabled=false and restart the server.",
- TIMESTAMP_PRECISION, time));
- }
- break;
- // Long.MaxValue is 19 digits, therefore no problem when the precision is ns.
- case "ns":
- default:
- break;
- }
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TsTableColumnCategory.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TsTableColumnCategory.java
deleted file mode 100644
index 512be69..0000000
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/plugin/builtin/sink/utils/TsTableColumnCategory.java
+++ /dev/null
@@ -1,108 +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.collector.plugin.builtin.sink.utils;
-
-import org.apache.tsfile.utils.ReadWriteIOUtils;
-import org.apache.tsfile.write.record.Tablet.ColumnCategory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-
-public enum TsTableColumnCategory {
- TAG((byte) 0),
- ATTRIBUTE((byte) 1),
- TIME((byte) 2),
- FIELD((byte) 3);
-
- private final byte category;
-
- TsTableColumnCategory(byte category) {
- this.category = category;
- }
-
- byte getValue() {
- return category;
- }
-
- public void serialize(OutputStream stream) throws IOException {
- ReadWriteIOUtils.write(category, stream);
- }
-
- public void serialize(ByteBuffer byteBuffer) {
- ReadWriteIOUtils.write(category, byteBuffer);
- }
-
- public static TsTableColumnCategory deserialize(InputStream stream) throws IOException {
- byte category = (byte) stream.read();
- return deserialize(category);
- }
-
- public static TsTableColumnCategory deserialize(ByteBuffer stream) {
- byte category = stream.get();
- return deserialize(category);
- }
-
- public static TsTableColumnCategory deserialize(byte category) {
- switch (category) {
- case 0:
- return TAG;
- case 1:
- return ATTRIBUTE;
- case 2:
- return TIME;
- case 3:
- return FIELD;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- public ColumnCategory toTsFileColumnType() {
- switch (this) {
- case TAG:
- return ColumnCategory.TAG;
- case ATTRIBUTE:
- return ColumnCategory.ATTRIBUTE;
- case FIELD:
- return ColumnCategory.FIELD;
- default:
- throw new IllegalArgumentException("Unsupported column type in TsFile: " + this);
- }
- }
-
- public static TsTableColumnCategory fromTsFileColumnType(ColumnCategory columnType) {
- switch (columnType) {
- case FIELD:
- return FIELD;
- case TAG:
- return TAG;
- case ATTRIBUTE:
- return ATTRIBUTE;
- default:
- throw new IllegalArgumentException("Unknown column type: " + columnType);
- }
- }
-
- public byte getCategory() {
- return category;
- }
-}
diff --git a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/runtime/plugin/constructor/SinkConstructor.java b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/runtime/plugin/constructor/SinkConstructor.java
index 7f223b0..5e24cfd 100644
--- a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/runtime/plugin/constructor/SinkConstructor.java
+++ b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/runtime/plugin/constructor/SinkConstructor.java
@@ -20,7 +20,7 @@
package org.apache.iotdb.collector.runtime.plugin.constructor;
import org.apache.iotdb.collector.plugin.builtin.BuiltinPlugin;
-import org.apache.iotdb.collector.plugin.builtin.sink.protocol.demo.DemoSink;
+import org.apache.iotdb.collector.plugin.builtin.sink.protocol.DemoSink;
import org.apache.iotdb.collector.runtime.plugin.meta.PluginMetaKeeper;
import org.apache.iotdb.pipe.api.PipeSink;
import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameters;