This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new be643c08f50 Pipe: Removed useless PipeSetTTLPlan (#12619)
be643c08f50 is described below
commit be643c08f50cfe6e735f579995df5cc8311bbc8a
Author: Caideyipi <[email protected]>
AuthorDate: Thu May 30 16:13:50 2024 +0800
Pipe: Removed useless PipeSetTTLPlan (#12619)
---
.../consensus/request/ConfigPhysicalPlan.java | 4 -
.../request/write/pipe/payload/PipeSetTTLPlan.java | 103 ---------------------
.../pipe/event/PipeConfigRegionSnapshotEvent.java | 7 +-
.../extractor/ConfigRegionListeningFilter.java | 4 +-
.../PipeConfigPhysicalPlanPatternParseVisitor.java | 11 +--
.../receiver/protocol/IoTDBConfigNodeReceiver.java | 9 --
.../persistence/executor/ConfigPlanExecutor.java | 5 +-
.../request/ConfigPhysicalPlanSerDeTest.java | 11 ---
...eConfigPhysicalPlanPatternParseVisitorTest.java | 26 ++----
9 files changed, 16 insertions(+), 164 deletions(-)
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java
index 3c93330ae11..8ad8c9b2fd2 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java
@@ -82,7 +82,6 @@ import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeac
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan;
-import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeSetTTLPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeUnsetSchemaTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.plugin.CreatePipePluginPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.plugin.DropPipePluginPlan;
@@ -493,9 +492,6 @@ public abstract class ConfigPhysicalPlan implements
IConsensusRequest {
case PipeDeactivateTemplate:
plan = new PipeDeactivateTemplatePlan();
break;
- case PipeSetTTL:
- plan = new PipeSetTTLPlan();
- break;
case GetRegionId:
plan = new GetRegionIdPlan();
break;
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/pipe/payload/PipeSetTTLPlan.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/pipe/payload/PipeSetTTLPlan.java
deleted file mode 100644
index 67ab85d898c..00000000000
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/pipe/payload/PipeSetTTLPlan.java
+++ /dev/null
@@ -1,103 +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.confignode.consensus.request.write.pipe.payload;
-
-import org.apache.iotdb.commons.pipe.extractor.IoTDBNonDataRegionExtractor;
-import org.apache.iotdb.commons.pipe.pattern.IoTDBPipePattern;
-import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
-import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
-import org.apache.iotdb.confignode.consensus.request.write.database.SetTTLPlan;
-import
org.apache.iotdb.confignode.manager.pipe.event.PipeConfigRegionWritePlanEvent;
-import
org.apache.iotdb.confignode.manager.pipe.extractor.ConfigRegionListeningQueue;
-import
org.apache.iotdb.confignode.manager.pipe.receiver.protocol.IoTDBConfigNodeReceiver;
-
-import org.apache.tsfile.utils.ReadWriteIOUtils;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * This is a set of {@link SetTTLPlan}s generated by an {@link
IoTDBPipePattern} and a normal {@link
- * SetTTLPlan}. This is used to persist the "at most one" match between {@link
- * PipeConfigRegionWritePlanEvent} in the {@link ConfigRegionListeningQueue}
and the {@link
- * IoTDBNonDataRegionExtractor#supply()} and will be executed serially in
{@link
- * IoTDBConfigNodeReceiver}
- */
-public class PipeSetTTLPlan extends ConfigPhysicalPlan {
- private List<SetTTLPlan> planList;
-
- public PipeSetTTLPlan() {
- super(ConfigPhysicalPlanType.PipeSetTTL);
- }
-
- public PipeSetTTLPlan(final List<SetTTLPlan> planList) {
- super(ConfigPhysicalPlanType.PipeSetTTL);
- this.planList = planList;
- }
-
- public List<SetTTLPlan> getSetTTLPlans() {
- return planList;
- }
-
- @Override
- protected void serializeImpl(final DataOutputStream stream) throws
IOException {
- stream.writeShort(getType().getPlanType());
- ReadWriteIOUtils.write(planList.size(), stream);
- for (final SetTTLPlan setTTLPlan : planList) {
- final ByteBuffer buffer = setTTLPlan.serializeToByteBuffer();
- stream.write(buffer.array(), 0, buffer.limit());
- }
- }
-
- @Override
- protected void deserializeImpl(final ByteBuffer buffer) throws IOException {
- final int size = ReadWriteIOUtils.readInt(buffer);
- planList = new ArrayList<>();
- for (int i = 0; i < size; ++i) {
- planList.add((SetTTLPlan) ConfigPhysicalPlan.Factory.create(buffer));
- }
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- final PipeSetTTLPlan that = (PipeSetTTLPlan) obj;
- return Objects.equals(planList, that.planList);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(planList);
- }
-
- @Override
- public String toString() {
- return "PipeSetTTLPlan{" + "planList='" + planList + "'}";
- }
-}
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/event/PipeConfigRegionSnapshotEvent.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/event/PipeConfigRegionSnapshotEvent.java
index 3d98ad7b1c1..dcdc0f8f81d 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/event/PipeConfigRegionSnapshotEvent.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/event/PipeConfigRegionSnapshotEvent.java
@@ -80,12 +80,7 @@ public class PipeConfigRegionSnapshotEvent extends
PipeSnapshotEvent {
ConfigPhysicalPlanType.CreateSchemaTemplate.getPlanType(),
ConfigPhysicalPlanType.CommitSetSchemaTemplate.getPlanType()))));
SNAPSHOT_FILE_TYPE_2_CONFIG_PHYSICAL_PLAN_TYPE_MAP.put(
- CNSnapshotFileType.TTL,
- Collections.unmodifiableSet(
- new HashSet<>(
- Arrays.asList(
- ConfigPhysicalPlanType.SetTTL.getPlanType(),
- ConfigPhysicalPlanType.PipeSetTTL.getPlanType()))));
+ CNSnapshotFileType.TTL,
Collections.singleton(ConfigPhysicalPlanType.SetTTL.getPlanType()));
}
public PipeConfigRegionSnapshotEvent() {
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/ConfigRegionListeningFilter.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/ConfigRegionListeningFilter.java
index 0e06bdba1c2..1718fcb68cf 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/ConfigRegionListeningFilter.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/ConfigRegionListeningFilter.java
@@ -98,9 +98,7 @@ public class ConfigRegionListeningFilter {
Collections.singletonList(ConfigPhysicalPlanType.PipeDeactivateTemplate));
OPTION_PLAN_MAP.put(
- new PartialPath("schema.ttl"),
- Collections.unmodifiableList(
- Arrays.asList(ConfigPhysicalPlanType.SetTTL,
ConfigPhysicalPlanType.PipeSetTTL)));
+ new PartialPath("schema.ttl"),
Collections.singletonList(ConfigPhysicalPlanType.SetTTL));
OPTION_PLAN_MAP.put(
new PartialPath("auth.role.create"),
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanPatternParseVisitor.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanPatternParseVisitor.java
index 14559b3ac64..40d7141070d 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanPatternParseVisitor.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanPatternParseVisitor.java
@@ -31,7 +31,6 @@ import
org.apache.iotdb.confignode.consensus.request.write.database.SetTTLPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeactivateTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan;
-import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeSetTTLPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeUnsetSchemaTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.template.CommitSetSchemaTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.template.CreateSchemaTemplatePlan;
@@ -46,7 +45,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -275,13 +273,10 @@ public class PipeConfigPhysicalPlanPatternParseVisitor
pattern.matchPrefixPath(partialPath.getFullPath())
? Collections.singletonList(partialPath)
: pattern.getIntersection(partialPath);
+ // The intersectionList is either a singleton list or an empty list,
because the pipe
+ // pattern and TTL path are each either a prefix path or a full path
return !intersectionList.isEmpty()
- ? Optional.of(
- new PipeSetTTLPlan(
- intersectionList.stream()
- .map(
- path -> new SetTTLPlan(Arrays.asList(path.getNodes()),
setTTLPlan.getTTL()))
- .collect(Collectors.toList())))
+ ? Optional.of(new SetTTLPlan(intersectionList.get(0).getNodes(),
setTTLPlan.getTTL()))
: Optional.empty();
}
}
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/receiver/protocol/IoTDBConfigNodeReceiver.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/receiver/protocol/IoTDBConfigNodeReceiver.java
index ab80a73715c..7815adde258 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/receiver/protocol/IoTDBConfigNodeReceiver.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/receiver/protocol/IoTDBConfigNodeReceiver.java
@@ -41,7 +41,6 @@ import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeac
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan;
-import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeSetTTLPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeUnsetSchemaTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.template.CommitSetSchemaTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.template.ExtendSchemaTemplatePlan;
@@ -86,7 +85,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
public class IoTDBConfigNodeReceiver extends IoTDBFileReceiver {
@@ -275,13 +273,6 @@ public class IoTDBConfigNodeReceiver extends
IoTDBFileReceiver {
return ((SetTTLPlan) plan).getTTL() == TTLCache.NULL_TTL
? configManager.getTTLManager().unsetTTL((SetTTLPlan) plan, true)
: configManager.getTTLManager().setTTL((SetTTLPlan) plan, true);
- case PipeSetTTL:
- // The prior status won't be altered by the status visitor
- return PipeReceiverStatusHandler.getPriorStatus(
- ((PipeSetTTLPlan) plan)
- .getSetTTLPlans().stream()
- .map(this::executePlanAndClassifyExceptions)
- .collect(Collectors.toList()));
case DropUser:
case DropRole:
case GrantRole:
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
index 8370e68c0f7..5e5db43a5af 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
@@ -521,9 +521,8 @@ public class ConfigPlanExecutor {
// Will not be actually executed.
return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
case PipeUnsetTemplate:
- case PipeSetTTL:
- // PipeUnsetTemplate/PipeSetTTL plan will not be written here, and
exists only after pipe
- // sender collects UnsetTemplatePlan/SetTTLPlan and before receiver
calls ConfigManager.
+ // PipeUnsetTemplate plan will not be written here, and exists only
after pipe
+ // sender collects UnsetTemplatePlan and before receiver calls
ConfigManager.
throw new UnsupportedOperationException(
String.format("Plan type %s is not supported.",
physicalPlan.getType()));
case TestOnly:
diff --git
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java
index 48a5b5b29bc..cfa372be8dd 100644
---
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java
+++
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java
@@ -110,7 +110,6 @@ import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeac
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeEnrichedPlan;
-import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeSetTTLPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeUnsetSchemaTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.plugin.CreatePipePluginPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.plugin.DropPipePluginPlan;
@@ -1948,16 +1947,6 @@ public class ConfigPhysicalPlanSerDeTest {
ConfigPhysicalPlan.Factory.create(pipeDeactivateTemplatePlan.serializeToByteBuffer()));
}
- @Test
- public void pipeSetTTLPlanTest() throws IOException {
- final PipeSetTTLPlan plan =
- new PipeSetTTLPlan(
- Arrays.asList(
- new SetTTLPlan(Arrays.asList("root", "db", "**", "a", "**"),
Long.MAX_VALUE),
- new SetTTLPlan(Arrays.asList("root", "db", "a", "**"),
Long.MAX_VALUE)));
- Assert.assertEquals(plan,
ConfigPhysicalPlan.Factory.create(plan.serializeToByteBuffer()));
- }
-
@Test
public void addRegionLocationPlanTest() throws IOException {
AddRegionLocationPlan plan =
diff --git
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanPatternParseVisitorTest.java
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanPatternParseVisitorTest.java
index 69a5d32ad94..8d38006cdf9 100644
---
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanPatternParseVisitorTest.java
+++
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanPatternParseVisitorTest.java
@@ -31,7 +31,6 @@ import
org.apache.iotdb.confignode.consensus.request.write.database.SetTTLPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeactivateTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteLogicalViewPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeDeleteTimeSeriesPlan;
-import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeSetTTLPlan;
import
org.apache.iotdb.confignode.consensus.request.write.pipe.payload.PipeUnsetSchemaTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.template.CommitSetSchemaTemplatePlan;
import
org.apache.iotdb.confignode.consensus.request.write.template.CreateSchemaTemplatePlan;
@@ -52,7 +51,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.stream.Collectors;
public class PipeConfigPhysicalPlanPatternParseVisitorTest {
@@ -387,22 +385,16 @@ public class
PipeConfigPhysicalPlanPatternParseVisitorTest {
@Test
public void testSetTTL() throws IllegalPathException {
- final List<SetTTLPlan> plans =
- ((PipeSetTTLPlan)
- IoTDBConfigRegionExtractor.PATTERN_PARSE_VISITOR
- .visitTTL(
- new SetTTLPlan(Arrays.asList("root", "db", "**"),
Long.MAX_VALUE),
- prefixPathPattern)
- .orElseThrow(AssertionError::new))
- .getSetTTLPlans();
+ final SetTTLPlan plan =
+ ((SetTTLPlan)
+ IoTDBConfigRegionExtractor.PATTERN_PARSE_VISITOR
+ .visitTTL(
+ new SetTTLPlan(Arrays.asList("root", "db", "**"),
Long.MAX_VALUE),
+ prefixPathPattern)
+ .orElseThrow(AssertionError::new));
Assert.assertEquals(
- Collections.singletonList(new PartialPath("root.db.device.**")),
- plans.stream()
- .map(setTTLPlan -> new PartialPath(setTTLPlan.getPathPattern()))
- .collect(Collectors.toList()));
- Assert.assertEquals(
- Collections.singletonList(Long.MAX_VALUE),
- plans.stream().map(SetTTLPlan::getTTL).collect(Collectors.toList()));
+ new PartialPath("root.db.device.**"), new
PartialPath(plan.getPathPattern()));
+ Assert.assertEquals(Long.MAX_VALUE, plan.getTTL());
}
}