-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pipe: Add completion signal to historical events & allow all data reg…
…ions' completion signal to drop the pipe (#12490) Co-authored-by: Steve Yurong Su <rong@apache.org>
- Loading branch information
1 parent
9a29af7
commit 40934dd
Showing
16 changed files
with
593 additions
and
116 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
integration-test/src/test/java/org/apache/iotdb/pipe/it/autocreate/IoTDBPipeAutoDropIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* 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.pipe.it.autocreate; | ||
|
||
import org.apache.iotdb.common.rpc.thrift.TSStatus; | ||
import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient; | ||
import org.apache.iotdb.confignode.rpc.thrift.TCreatePipeReq; | ||
import org.apache.iotdb.db.it.utils.TestUtils; | ||
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper; | ||
import org.apache.iotdb.rpc.TSStatusCode; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class IoTDBPipeAutoDropIT extends AbstractPipeDualAutoIT { | ||
@Test | ||
public void testAutoDropInHistoricalTransfer() throws Exception { | ||
final DataNodeWrapper receiverDataNode = receiverEnv.getDataNodeWrapper(0); | ||
|
||
final String receiverIp = receiverDataNode.getIp(); | ||
final int receiverPort = receiverDataNode.getPort(); | ||
|
||
try (final SyncConfigNodeIServiceClient client = | ||
(SyncConfigNodeIServiceClient) senderEnv.getLeaderConfigNodeConnection()) { | ||
|
||
if (!TestUtils.tryExecuteNonQueryWithRetry( | ||
senderEnv, "insert into root.db.d1(time, s1) values (1, 1)")) { | ||
return; | ||
} | ||
|
||
final Map<String, String> extractorAttributes = new HashMap<>(); | ||
final Map<String, String> processorAttributes = new HashMap<>(); | ||
final Map<String, String> connectorAttributes = new HashMap<>(); | ||
|
||
extractorAttributes.put("extractor.history.terminate-pipe-on-all-consumed", "true"); | ||
|
||
connectorAttributes.put("connector", "iotdb-thrift-connector"); | ||
connectorAttributes.put("connector.batch.enable", "false"); | ||
connectorAttributes.put("connector.ip", receiverIp); | ||
connectorAttributes.put("connector.port", Integer.toString(receiverPort)); | ||
|
||
final TSStatus status = | ||
client.createPipe( | ||
new TCreatePipeReq("p1", connectorAttributes) | ||
.setExtractorAttributes(extractorAttributes) | ||
.setProcessorAttributes(processorAttributes)); | ||
|
||
Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode()); | ||
Assert.assertEquals( | ||
TSStatusCode.SUCCESS_STATUS.getStatusCode(), client.startPipe("p1").getCode()); | ||
|
||
TestUtils.assertDataEventuallyOnEnv( | ||
senderEnv, | ||
"show pipes", | ||
"ID,CreationTime,State,PipeSource,PipeProcessor,PipeSink,ExceptionMessage,", | ||
Collections.emptySet()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...org/apache/iotdb/confignode/manager/pipe/coordinator/runtime/heartbeat/PipeHeartbeat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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.manager.pipe.coordinator.runtime.heartbeat; | ||
|
||
import org.apache.iotdb.commons.pipe.task.meta.PipeMeta; | ||
import org.apache.iotdb.commons.pipe.task.meta.PipeStaticMeta; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class PipeHeartbeat { | ||
|
||
private final Map<PipeStaticMeta, PipeMeta> pipeMetaMap = new HashMap<>(); | ||
private final Map<PipeStaticMeta, Boolean> isCompletedMap = new HashMap<>(); | ||
|
||
public PipeHeartbeat( | ||
@NotNull final List<ByteBuffer> pipeMetaByteBufferListFromAgent, | ||
/* @Nullable */ final List<Boolean> pipeCompletedListFromAgent) { | ||
for (int i = 0; i < pipeMetaByteBufferListFromAgent.size(); ++i) { | ||
final PipeMeta pipeMeta = PipeMeta.deserialize(pipeMetaByteBufferListFromAgent.get(i)); | ||
pipeMetaMap.put(pipeMeta.getStaticMeta(), pipeMeta); | ||
isCompletedMap.put( | ||
pipeMeta.getStaticMeta(), | ||
Objects.nonNull(pipeCompletedListFromAgent) && pipeCompletedListFromAgent.get(i)); | ||
} | ||
} | ||
|
||
public PipeMeta getPipeMeta(PipeStaticMeta pipeStaticMeta) { | ||
return pipeMetaMap.get(pipeStaticMeta); | ||
} | ||
|
||
public Boolean isCompleted(PipeStaticMeta pipeStaticMeta) { | ||
return isCompletedMap.get(pipeStaticMeta); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return pipeMetaMap.isEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.