forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-18934][runtime] Idle stream does not advance watermark in conn…
…ected stream Watermark in the two and multi input operators is computed in operators. So far operators were unaware of the StreamStatus, therefore even if a whole input was IDLE it could still block increasing the Watermark. This commit makes operators aware of the StreamStatus. The contract of the StreamStatus is that if a stream is IDLE it should not emit records nor watermarks.
- Loading branch information
Showing
45 changed files
with
801 additions
and
83 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
...e/src/main/java/org/apache/flink/api/common/eventtime/IndexedCombinedWatermarkStatus.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,87 @@ | ||
/* | ||
* 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.flink.api.common.eventtime; | ||
|
||
import org.apache.flink.annotation.Internal; | ||
|
||
import java.util.stream.IntStream; | ||
|
||
import static org.apache.flink.util.Preconditions.checkArgument; | ||
|
||
/** | ||
* Represents combined value and status of a watermark for a set number of input partial watermarks. | ||
*/ | ||
@Internal | ||
public final class IndexedCombinedWatermarkStatus { | ||
private final CombinedWatermarkStatus combinedWatermarkStatus; | ||
private final CombinedWatermarkStatus.PartialWatermark[] partialWatermarks; | ||
|
||
private IndexedCombinedWatermarkStatus( | ||
CombinedWatermarkStatus combinedWatermarkStatus, | ||
CombinedWatermarkStatus.PartialWatermark[] partialWatermarks) { | ||
this.combinedWatermarkStatus = combinedWatermarkStatus; | ||
this.partialWatermarks = partialWatermarks; | ||
} | ||
|
||
public static IndexedCombinedWatermarkStatus forInputsCount(int inputsCount) { | ||
CombinedWatermarkStatus.PartialWatermark[] partialWatermarks = | ||
IntStream.range(0, inputsCount) | ||
.mapToObj(i -> new CombinedWatermarkStatus.PartialWatermark()) | ||
.toArray(CombinedWatermarkStatus.PartialWatermark[]::new); | ||
CombinedWatermarkStatus combinedWatermarkStatus = new CombinedWatermarkStatus(); | ||
for (CombinedWatermarkStatus.PartialWatermark partialWatermark : partialWatermarks) { | ||
combinedWatermarkStatus.add(partialWatermark); | ||
} | ||
return new IndexedCombinedWatermarkStatus(combinedWatermarkStatus, partialWatermarks); | ||
} | ||
|
||
/** | ||
* Updates the value for the given partial watermark. Can update both the global idleness as | ||
* well as the combined watermark value. | ||
* | ||
* @return true, if the combined watermark value changed. The global idleness needs to be | ||
* checked separately via {@link #isIdle()} | ||
*/ | ||
public boolean updateWatermark(int index, long timestamp) { | ||
checkArgument(index < partialWatermarks.length); | ||
partialWatermarks[index].setWatermark(timestamp); | ||
return combinedWatermarkStatus.updateCombinedWatermark(); | ||
} | ||
|
||
public long getCombinedWatermark() { | ||
return combinedWatermarkStatus.getCombinedWatermark(); | ||
} | ||
|
||
/** | ||
* Updates the idleness for the given partial watermark. Can update both the global idleness as | ||
* well as the combined watermark value. | ||
* | ||
* @return true, if the combined watermark value changed. The global idleness needs to be | ||
* checked separately via {@link #isIdle()} | ||
*/ | ||
public boolean updateStatus(int index, boolean idle) { | ||
checkArgument(index < partialWatermarks.length); | ||
partialWatermarks[index].setIdle(idle); | ||
return combinedWatermarkStatus.updateCombinedWatermark(); | ||
} | ||
|
||
public boolean isIdle() { | ||
return combinedWatermarkStatus.isIdle(); | ||
} | ||
} |
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
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
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
Oops, something went wrong.