-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[Dataflow Streaming] Add Operation::finishKey() and move processTimers into it #38430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
f91b5af
a8e4b0e
986b903
107517b
9e83f33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "comment": "Modify this file in a trivial way to cause this test suite to run!", | ||
| "modification": 1, | ||
| "modification": 2, | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "comment": "Modify this file in a trivial way to cause this test suite to run!", | ||
| "modification": 1, | ||
| "modification": 2, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ | |
| import org.apache.beam.runners.dataflow.worker.streaming.sideinput.SideInput; | ||
| import org.apache.beam.runners.dataflow.worker.streaming.sideinput.SideInputState; | ||
| import org.apache.beam.runners.dataflow.worker.streaming.sideinput.SideInputStateFetcher; | ||
| import org.apache.beam.runners.dataflow.worker.util.common.worker.WorkExecutor; | ||
| import org.apache.beam.runners.dataflow.worker.windmill.Windmill; | ||
| import org.apache.beam.runners.dataflow.worker.windmill.Windmill.GlobalDataId; | ||
| import org.apache.beam.runners.dataflow.worker.windmill.Windmill.GlobalDataRequest; | ||
|
|
@@ -157,6 +158,8 @@ public class StreamingModeExecutionContext extends DataflowExecutionContext<Step | |
| */ | ||
| private @Nullable UnboundedReader<?> activeReader; | ||
|
|
||
| private @Nullable WorkExecutor workExecutor; | ||
|
|
||
| public StreamingModeExecutionContext( | ||
| CounterFactory counterFactory, | ||
| String computationId, | ||
|
|
@@ -240,9 +243,11 @@ public void start( | |
| Work work, | ||
| WindmillStateReader stateReader, | ||
| SideInputStateFetcher sideInputStateFetcher, | ||
| Windmill.WorkItemCommitRequest.Builder outputBuilder) { | ||
| Windmill.WorkItemCommitRequest.Builder outputBuilder, | ||
| WorkExecutor workExecutor) { | ||
| this.key = key; | ||
| this.work = work; | ||
| this.workExecutor = workExecutor; | ||
|
arunpandianp marked this conversation as resolved.
|
||
| this.computationKey = WindmillComputationKey.create(computationId, work.getShardedKey()); | ||
| this.sideInputStateFetcher = sideInputStateFetcher; | ||
| StreamingGlobalConfig config = globalConfigHandle.getConfig(); | ||
|
|
@@ -270,6 +275,11 @@ public void start( | |
| } | ||
| } | ||
|
|
||
| public void finishKey() throws Exception { | ||
| checkNotNull(workExecutor, "workExecutor must be set before calling finishKey()"); | ||
| workExecutor.finishKey(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the public void finishKey() throws Exception {
if (finishKeyCalled) {
return;
}
checkNotNull(workExecutor, "workExecutor must be set before calling finishKey()");
finishKeyCalled = true;
workExecutor.finishKey();
} |
||
|
|
||
| /** | ||
| * Ensure that the processing time is greater than any fired processing time timers. Otherwise, a | ||
| * trigger could ignore the timer and orphan the window. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| */ | ||
| public abstract class WindmillReaderIteratorBase<T> | ||
| extends NativeReader.NativeReaderIterator<WindowedValue<T>> { | ||
| private final StreamingModeExecutionContext context; | ||
| private final Windmill.WorkItem work; | ||
| private int bundleIndex = 0; | ||
| private int messageIndex = -1; | ||
|
|
@@ -42,9 +43,10 @@ public abstract class WindmillReaderIteratorBase<T> | |
| private static final Logger LOG = LoggerFactory.getLogger(WindmillReaderIteratorBase.class); | ||
|
|
||
| protected WindmillReaderIteratorBase( | ||
| Windmill.WorkItem work, ValueProvider<Boolean> skipUndecodableElements) { | ||
| StreamingModeExecutionContext context, ValueProvider<Boolean> skipUndecodableElements) { | ||
| this.context = context; | ||
| this.skipUndecodableElements = skipUndecodableElements; | ||
| this.work = work; | ||
| this.work = context.getWorkItem(); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -54,9 +56,18 @@ public boolean start() throws IOException { | |
|
|
||
| @Override | ||
| public boolean advance() throws IOException { | ||
| if (context.workIsFailed()) { | ||
| throw new WorkItemCancelledException(context.getWorkItem().getShardingKey()); | ||
| } | ||
|
|
||
| while (true) { | ||
| if (bundleIndex >= work.getMessageBundlesCount()) { | ||
| current = null; | ||
| try { | ||
| context.finishKey(); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of wrapping all exceptions in } catch (IOException | RuntimeException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
} |
||
| return false; | ||
| } | ||
| Windmill.InputMessageBundle bundle = work.getMessageBundles(bundleIndex); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,6 +182,11 @@ public boolean start() throws IOException { | |
| @Override | ||
| public boolean advance() throws IOException { | ||
|
Comment on lines
183
to
184
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The anonymous iterator in @Override
public boolean advance() throws IOException {
if (context.workIsFailed()) {
throw new WorkItemCancelledException(context.getWorkItem().getShardingKey());
} |
||
| current = null; | ||
| try { | ||
| context.finishKey(); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.