|
21 | 21 |
|
22 | 22 | import org.apache.iotdb.commons.consensus.DataRegionId; |
23 | 23 | import org.apache.iotdb.commons.pipe.agent.task.PipeTaskAgent; |
| 24 | +import org.apache.iotdb.commons.pipe.agent.task.meta.PipeStaticMeta; |
| 25 | +import org.apache.iotdb.commons.pipe.config.constant.PipeSourceConstant; |
24 | 26 | import org.apache.iotdb.commons.pipe.datastructure.pattern.IoTDBPipePatternOperations; |
25 | 27 | import org.apache.iotdb.commons.pipe.datastructure.pattern.PipePattern; |
26 | 28 | import org.apache.iotdb.commons.pipe.source.IoTDBSource; |
|
45 | 47 | import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent; |
46 | 48 | import org.apache.iotdb.pipe.api.event.dml.insertion.TsFileInsertionEvent; |
47 | 49 | import org.apache.iotdb.pipe.api.exception.PipeException; |
| 50 | +import org.apache.iotdb.pipe.api.exception.PipeParameterNotValidException; |
48 | 51 |
|
49 | 52 | import org.apache.tsfile.utils.Pair; |
50 | 53 | import org.slf4j.Logger; |
@@ -100,6 +103,21 @@ public class IoTDBDataRegionSource extends IoTDBSource { |
100 | 103 | public void validate(final PipeParameterValidator validator) throws Exception { |
101 | 104 | super.validate(validator); |
102 | 105 |
|
| 106 | + final boolean forwardingPipeRequests = |
| 107 | + validator |
| 108 | + .getParameters() |
| 109 | + .getBooleanOrDefault( |
| 110 | + Arrays.asList( |
| 111 | + PipeSourceConstant.EXTRACTOR_FORWARDING_PIPE_REQUESTS_KEY, |
| 112 | + PipeSourceConstant.SOURCE_FORWARDING_PIPE_REQUESTS_KEY), |
| 113 | + PipeSourceConstant.EXTRACTOR_FORWARDING_PIPE_REQUESTS_DEFAULT_VALUE); |
| 114 | + if (!forwardingPipeRequests) { |
| 115 | + throw new PipeParameterNotValidException( |
| 116 | + String.format( |
| 117 | + "The parameter %s cannot be set to false.", |
| 118 | + PipeSourceConstant.SOURCE_FORWARDING_PIPE_REQUESTS_KEY)); |
| 119 | + } |
| 120 | + |
103 | 121 | final Pair<Boolean, Boolean> insertionDeletionListeningOptionPair = |
104 | 122 | DataRegionListeningFilter.parseInsertionDeletionListeningOptionPair( |
105 | 123 | validator.getParameters()); |
@@ -163,26 +181,6 @@ public void validate(final PipeParameterValidator validator) throws Exception { |
163 | 181 | Arrays.asList(EXTRACTOR_REALTIME_ENABLE_KEY, SOURCE_REALTIME_ENABLE_KEY), |
164 | 182 | EXTRACTOR_REALTIME_ENABLE_DEFAULT_VALUE)); |
165 | 183 |
|
166 | | - // Validate source.realtime.mode |
167 | | - if (validator |
168 | | - .getParameters() |
169 | | - .getBooleanOrDefault( |
170 | | - Arrays.asList(EXTRACTOR_REALTIME_ENABLE_KEY, SOURCE_REALTIME_ENABLE_KEY), |
171 | | - EXTRACTOR_REALTIME_ENABLE_DEFAULT_VALUE) |
172 | | - || validator.getParameters().hasAnyAttributes(SOURCE_START_TIME_KEY, SOURCE_END_TIME_KEY)) { |
173 | | - validator.validateAttributeValueRange( |
174 | | - validator.getParameters().hasAttribute(EXTRACTOR_REALTIME_MODE_KEY) |
175 | | - ? EXTRACTOR_REALTIME_MODE_KEY |
176 | | - : SOURCE_REALTIME_MODE_KEY, |
177 | | - true, |
178 | | - EXTRACTOR_REALTIME_MODE_FILE_VALUE, |
179 | | - EXTRACTOR_REALTIME_MODE_HYBRID_VALUE, |
180 | | - EXTRACTOR_REALTIME_MODE_LOG_VALUE, |
181 | | - EXTRACTOR_REALTIME_MODE_FORCED_LOG_VALUE, |
182 | | - EXTRACTOR_REALTIME_MODE_STREAM_MODE_VALUE, |
183 | | - EXTRACTOR_REALTIME_MODE_BATCH_MODE_VALUE); |
184 | | - } |
185 | | - |
186 | 184 | // Validate source.start-time and source.end-time |
187 | 185 | if (validator |
188 | 186 | .getParameters() |
@@ -260,6 +258,13 @@ private void constructRealtimeExtractor(final PipeParameters parameters) { |
260 | 258 | return; |
261 | 259 | } |
262 | 260 |
|
| 261 | + if (!(pipeName != null |
| 262 | + && (pipeName.startsWith(PipeStaticMeta.SUBSCRIPTION_PIPE_PREFIX) |
| 263 | + || pipeName.startsWith(PipeStaticMeta.CONSENSUS_PIPE_PREFIX)))) { |
| 264 | + realtimeExtractor = new PipeRealtimeDataRegionTsFileSource(); |
| 265 | + return; |
| 266 | + } |
| 267 | + |
263 | 268 | // Use hybrid mode by default |
264 | 269 | if (!parameters.hasAnyAttributes(EXTRACTOR_REALTIME_MODE_KEY, SOURCE_REALTIME_MODE_KEY)) { |
265 | 270 | realtimeExtractor = new PipeRealtimeDataRegionHybridSource(); |
|
0 commit comments