Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
this.isAligned = isAligned;
this.sourceEvent = sourceEvent;
this.needToReport = needToReport;
inheritSourceEventReportSkippingIfNecessary();

// Allocate empty memory block, will be resized later.
this.allocatedMemoryBlock =
Expand Down Expand Up @@ -399,6 +400,18 @@
});
}
this.needToReport = true;
inheritSourceEventReportSkippingIfNecessary();
}

private void inheritSourceEventReportSkippingIfNecessary() {
if (needToReport && shouldSkipReportOnCommitBecauseOfSourceEvent()) {
skipReportOnCommit();
}
}

private boolean shouldSkipReportOnCommitBecauseOfSourceEvent() {
return sourceEvent instanceof PipeTsFileInsertionEvent

Check warning on line 413 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeRawTabletInsertionEvent.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this instanceof check and cast with 'instanceof PipeTsFileInsertionEvent pipetsfileinsertionevent'

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZ8gv7UHXgCgWw53Sruy&open=AZ8gv7UHXgCgWw53Sruy&pullRequest=18088
&& !((PipeTsFileInsertionEvent) sourceEvent).shouldReportGeneratedEventsOnCommit();
}

// This getter is reserved for user-defined plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
protected volatile ProgressIndex overridingProgressIndex;
private Set<String> tableNames;
private String tsFileDedupScopeID;
// False when generated tablet events should wait for an external progress report.
private volatile boolean shouldReportGeneratedEventsOnCommit = true;

// This is set to check the tsFile paths by privilege
private Map<IDeviceID, String[]> treeSchemaMap;
Expand Down Expand Up @@ -462,6 +464,23 @@
return resource.getMaxProgressIndex();
}

public PipeTsFileInsertionEvent skipReportOnCommitAndGeneratedEvents() {
return setShouldReportGeneratedEventsOnCommit(false);
}

public boolean shouldReportGeneratedEventsOnCommit() {
return shouldReportGeneratedEventsOnCommit;
}

private PipeTsFileInsertionEvent setShouldReportGeneratedEventsOnCommit(
final boolean shouldReportGeneratedEventsOnCommit) {
this.shouldReportGeneratedEventsOnCommit = shouldReportGeneratedEventsOnCommit;
if (!shouldReportGeneratedEventsOnCommit) {
skipReportOnCommit();
}
return this;
}

public void eliminateProgressIndex() {
if (Objects.isNull(overridingProgressIndex)
&& Objects.nonNull(resource)
Expand Down Expand Up @@ -517,7 +536,8 @@
startTime,
endTime,
isTsFileSealed)
.bindTsFileDedupScopeID(tsFileDedupScopeID);
.bindTsFileDedupScopeID(tsFileDedupScopeID)
.setShouldReportGeneratedEventsOnCommit(shouldReportGeneratedEventsOnCommit);
}

@Override
Expand All @@ -529,7 +549,7 @@
public void throwIfNoPrivilege() {
try {
if (AuthorityChecker.SUPER_USER.equals(userName)) {
return;

Check warning on line 552 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/PipeTsFileInsertionEvent.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 103 to 64, Complexity from 21 to 14, Nesting Level from 5 to 2, Number of Variables from 13 to 6.

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AZ8gv7ZSXgCgWw53Sruz&open=AZ8gv7ZSXgCgWw53Sruz&pullRequest=18088
}
if (!waitForTsFileClose()) {
LOGGER.info(DataNodePipeMessages.TEMPORARY_TSFILE_DETECTED_WILL_SKIP_ITS_TRANSFER, tsFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.EXTRACTOR_HISTORY_END_TIME_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.EXTRACTOR_HISTORY_LOOSE_RANGE_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.EXTRACTOR_HISTORY_START_TIME_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.EXTRACTOR_HISTORY_TSFILE_ORDER_BY_QUERY_PRIORITY_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.EXTRACTOR_MODE_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.EXTRACTOR_MODE_SNAPSHOT_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.EXTRACTOR_MODE_STREAMING_DEFAULT_VALUE;
Expand Down Expand Up @@ -107,6 +108,7 @@
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.SOURCE_HISTORY_END_TIME_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.SOURCE_HISTORY_LOOSE_RANGE_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.SOURCE_HISTORY_START_TIME_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.SOURCE_HISTORY_TSFILE_ORDER_BY_QUERY_PRIORITY_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.SOURCE_MODE_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.SOURCE_MODE_SNAPSHOT_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant.SOURCE_MODE_STREAMING_KEY;
Expand Down Expand Up @@ -186,6 +188,16 @@ public void validate(final PipeParameterValidator validator) throws Exception {
SOURCE_HISTORY_ENABLE_KEY, true, Boolean.TRUE.toString(), Boolean.FALSE.toString())
.validateAttributeValueRange(
SOURCE_REALTIME_ENABLE_KEY, true, Boolean.TRUE.toString(), Boolean.FALSE.toString())
.validateAttributeValueRange(
EXTRACTOR_HISTORY_TSFILE_ORDER_BY_QUERY_PRIORITY_KEY,
true,
Boolean.TRUE.toString(),
Boolean.FALSE.toString())
.validateAttributeValueRange(
SOURCE_HISTORY_TSFILE_ORDER_BY_QUERY_PRIORITY_KEY,
true,
Boolean.TRUE.toString(),
Boolean.FALSE.toString())
.validate(
args -> (boolean) args[0] || (boolean) args[1],
"Should not set both history.enable and realtime.enable to false.",
Expand Down
Loading
Loading