[
https://issues.apache.org/jira/browse/BEAM-6233?focusedWorklogId=194186&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-194186
]
ASF GitHub Bot logged work on BEAM-6233:
----------------------------------------
Author: ASF GitHub Bot
Created on: 04/Feb/19 19:03
Start Date: 04/Feb/19 19:03
Worklog Time Spent: 10m
Work Description: rohdesamuel commented on pull request #7330:
[BEAM-6233]: Add initial user timer support in Dataflow for batch pipelines
URL: https://github.com/apache/beam/pull/7330#discussion_r253601114
##########
File path:
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/fn/control/ProcessRemoteBundleOperation.java
##########
@@ -48,25 +62,119 @@
new OutputReceiverFactory() {
@Override
public FnDataReceiver<?> create(String pCollectionId) {
- return receivedElement -> {
- LOG.debug("Consume element {}", receivedElement);
- outputReceiverMap.get(pCollectionId).process((WindowedValue<?>)
receivedElement);
- };
+ return receivedElement -> receive(pCollectionId, receivedElement);
}
};
private final StateRequestHandler stateRequestHandler;
private final BundleProgressHandler progressHandler;
private RemoteBundle remoteBundle;
+ private final DataflowExecutionContext<?> executionContext;
+ private ExecutableStage executableStage;
+
+ private final Map<String, ProcessBundleDescriptors.TimerSpec>
timerOutputIdToSpecMap;
+ private final Map<String, Coder<BoundedWindow>> timerWindowCodersMap;
+ private final Map<String, ProcessBundleDescriptors.TimerSpec>
timerIdToTimerSpecMap;
+ private final Map<String, Object> timerIdToKey;
+ private final Map<String, Object> timerIdToPayload;
public ProcessRemoteBundleOperation(
- OperationContext context,
+ ExecutableStage executableStage,
+ DataflowExecutionContext<?> executionContext,
+ DataflowOperationContext operationContext,
StageBundleFactory stageBundleFactory,
Map<String, OutputReceiver> outputReceiverMap) {
- super(EMPTY_RECEIVER_ARRAY, context);
+ super(EMPTY_RECEIVER_ARRAY, operationContext);
+
this.stageBundleFactory = stageBundleFactory;
- this.outputReceiverMap = outputReceiverMap;
this.stateRequestHandler = StateRequestHandler.unsupported();
this.progressHandler = BundleProgressHandler.ignored();
+ this.executionContext = executionContext;
+ this.executableStage = executableStage;
+ this.outputReceiverMap = outputReceiverMap;
+
+ this.timerOutputIdToSpecMap = new HashMap<>();
+ this.timerIdToKey = new HashMap<>();
+ this.timerIdToPayload = new HashMap<>();
+ this.timerIdToTimerSpecMap = new HashMap<>();
+
+ ProcessBundleDescriptors.ExecutableProcessBundleDescriptor
executableProcessBundleDescriptor =
+ stageBundleFactory.getProcessBundleDescriptor();
+
+ BeamFnApi.ProcessBundleDescriptor processBundleDescriptor =
+ executableProcessBundleDescriptor.getProcessBundleDescriptor();
+
+ // Create and cache lookups so that we don't have to dive into the
ProcessBundleDescriptor
+ // later.
+ fillTimerSpecMaps(
+ executableProcessBundleDescriptor, this.timerIdToTimerSpecMap,
this.timerOutputIdToSpecMap);
+ this.timerWindowCodersMap =
+ fillTimerWindowCodersMap(
+ processBundleDescriptor, this.timerIdToTimerSpecMap,
this.executableStage);
+ }
+
+ // Fills the given maps from timer the TimerSpec definitions in the process
bundle descriptor.
+ private void fillTimerSpecMaps(
+ ProcessBundleDescriptors.ExecutableProcessBundleDescriptor
processBundleDescriptor,
+ Map<String, ProcessBundleDescriptors.TimerSpec> timerIdToTimerSpecMap,
+ Map<String, ProcessBundleDescriptors.TimerSpec> timerOutputIdToSpecMap) {
+ processBundleDescriptor
+ .getTimerSpecs()
+ .values()
+ .forEach(
+ transformTimerMap -> {
+ for (ProcessBundleDescriptors.TimerSpec timerSpec :
transformTimerMap.values()) {
+ timerIdToTimerSpecMap.put(timerSpec.timerId(), timerSpec);
+ timerOutputIdToSpecMap.put(timerSpec.outputCollectionId(),
timerSpec);
+ }
+ });
+ }
+
+ // Retrieves all window coders for all TimerSpecs.
+ private Map<String, Coder<BoundedWindow>> fillTimerWindowCodersMap(
+ BeamFnApi.ProcessBundleDescriptor processBundleDescriptor,
+ Map<String, ProcessBundleDescriptors.TimerSpec> timerIdToTimerSpecMap,
+ ExecutableStage executableStage) {
+ Map<String, Coder<BoundedWindow>> timerWindowCodersMap = new HashMap<>();
+ for (RunnerApi.PTransform pTransform :
processBundleDescriptor.getTransformsMap().values()) {
+ for (String timerId : timerIdToTimerSpecMap.keySet()) {
+ if (!pTransform.getInputsMap().containsKey(timerId)) {
+ continue;
+ }
+
+ RunnerApi.Coder windowingCoder =
+ getTimerWindowingCoder(pTransform, timerId,
processBundleDescriptor);
+ RehydratedComponents components =
+
RehydratedComponents.forComponents(executableStage.getComponents());
+ try {
+ timerWindowCodersMap.put(
+ timerId,
+ (Coder<BoundedWindow>)
CoderTranslation.fromProto(windowingCoder, components));
+ } catch (IOException e) {
+ LOG.error(
Review comment:
Now throws RuntimeException
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 194186)
Time Spent: 5.5h (was: 5h 20m)
> Make bundle execution with ExecutableStage support timer/states
> ---------------------------------------------------------------
>
> Key: BEAM-6233
> URL: https://issues.apache.org/jira/browse/BEAM-6233
> Project: Beam
> Issue Type: Task
> Components: runner-dataflow
> Reporter: Boyuan Zhang
> Assignee: Sam Rohde
> Priority: Major
> Time Spent: 5.5h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)