[
https://issues.apache.org/jira/browse/BEAM-4166?focusedWorklogId=94850&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-94850
]
ASF GitHub Bot logged work on BEAM-4166:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Apr/18 23:09
Start Date: 24/Apr/18 23:09
Worklog Time Spent: 10m
Work Description: jkff closed pull request #5216: [BEAM-4166] Invoke
@Setup in FnApiDoFnRunner
URL: https://github.com/apache/beam/pull/5216
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnApiDoFnRunner.java
b/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnApiDoFnRunner.java
index b899c16767a..ec1d9b081e4 100644
---
a/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnApiDoFnRunner.java
+++
b/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnApiDoFnRunner.java
@@ -384,6 +384,7 @@
this.windowingStrategy = windowingStrategy;
this.doFnSignature = DoFnSignatures.signatureForDoFn(doFn);
this.doFnInvoker = DoFnInvokers.invokerFor(doFn);
+ this.doFnInvoker.invokeSetup();
this.stateBinder = new BeamFnStateBinder();
this.startBundleContext = new StartBundleContext();
this.processBundleContext = new ProcessBundleContext();
diff --git
a/sdks/java/harness/src/test/java/org/apache/beam/fn/harness/FnApiDoFnRunnerTest.java
b/sdks/java/harness/src/test/java/org/apache/beam/fn/harness/FnApiDoFnRunnerTest.java
index 722561fc6fa..85aa564353a 100644
---
a/sdks/java/harness/src/test/java/org/apache/beam/fn/harness/FnApiDoFnRunnerTest.java
+++
b/sdks/java/harness/src/test/java/org/apache/beam/fn/harness/FnApiDoFnRunnerTest.java
@@ -18,6 +18,7 @@
package org.apache.beam.fn.harness;
+import static com.google.common.base.Preconditions.checkState;
import static
org.apache.beam.sdk.util.WindowedValue.timestampedValueInGlobalWindow;
import static org.apache.beam.sdk.util.WindowedValue.valueInGlobalWindow;
import static org.hamcrest.Matchers.contains;
@@ -97,10 +98,33 @@
private static final TupleTag<String> mainOutput = new
TupleTag<>("mainOutput");
private static final TupleTag<String> additionalOutput = new
TupleTag<>("output");
+ private enum State {
+ NOT_SET_UP,
+ OUTSIDE_BUNDLE,
+ INSIDE_BUNDLE,
+ }
+
+ private State state = State.NOT_SET_UP;
+
private BoundedWindow window;
+ @Setup
+ public void setUp() {
+ checkState(State.NOT_SET_UP.equals(state), "Unexpected state: %s",
state);
+ state = State.OUTSIDE_BUNDLE;
+ }
+
+ // No testing for TearDown - it's currently not supported by FnHarness.
+
+ @StartBundle
+ public void startBundle() {
+ checkState(State.OUTSIDE_BUNDLE.equals(state), "Unexpected state: %s",
state);
+ state = State.INSIDE_BUNDLE;
+ }
+
@ProcessElement
public void processElement(ProcessContext context, BoundedWindow window) {
+ checkState(State.INSIDE_BUNDLE.equals(state), "Unexpected state: %s",
state);
context.output("MainOutput" + context.element());
context.output(additionalOutput, "AdditionalOutput" + context.element());
this.window = window;
@@ -108,6 +132,8 @@ public void processElement(ProcessContext context,
BoundedWindow window) {
@FinishBundle
public void finishBundle(FinishBundleContext context) {
+ checkState(State.INSIDE_BUNDLE.equals(state), "Unexpected state: %s",
state);
+ state = State.OUTSIDE_BUNDLE;
if (window != null) {
context.output("FinishBundle", window.maxTimestamp(), window);
window = null;
----------------------------------------------------------------
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: 94850)
Time Spent: 50m (was: 40m)
> FnApiDoFnRunner doesn't invoke setup/teardown
> ---------------------------------------------
>
> Key: BEAM-4166
> URL: https://issues.apache.org/jira/browse/BEAM-4166
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-harness
> Reporter: Eugene Kirpichov
> Assignee: Eugene Kirpichov
> Priority: Major
> Time Spent: 50m
> Remaining Estimate: 0h
>
> And we apparently lack test coverage for that - one would think that
> ValidatesRunner tests would check lifecycle.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)