[ https://issues.apache.org/jira/browse/BEAM-4653?focusedWorklogId=124717&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-124717 ]
ASF GitHub Bot logged work on BEAM-4653: ---------------------------------------- Author: ASF GitHub Bot Created on: 19/Jul/18 00:48 Start Date: 19/Jul/18 00:48 Worklog Time Spent: 10m Work Description: bsidhom commented on a change in pull request #5898: [BEAM-4653] Add support to the Java SDK harness to execute timers. URL: https://github.com/apache/beam/pull/5898#discussion_r203566555 ########## File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnApiDoFnRunner.java ########## @@ -256,6 +287,125 @@ public void finishBundle() { } } + private class FnApiTimer implements org.apache.beam.sdk.state.Timer { + private final String timerId; + private final TimeDomain timeDomain; + private final Instant currentTimestamp; + private final Duration allowedLateness; + private final WindowedValue<?> currentElementOrTimer; + + private Duration period = Duration.ZERO; + private Duration offset = Duration.ZERO; + + FnApiTimer(String timerId, WindowedValue<KV<?, ?>> currentElementOrTimer) { + this.timerId = timerId; + this.currentElementOrTimer = currentElementOrTimer; + + TimerDeclaration timerDeclaration = context.doFnSignature.timerDeclarations().get(timerId); + this.timeDomain = + DoFnSignatures.getTimerSpecOrThrow(timerDeclaration, context.doFn).getTimeDomain(); + + switch (timeDomain) { + case EVENT_TIME: + this.currentTimestamp = currentElementOrTimer.getTimestamp(); + break; + case PROCESSING_TIME: + this.currentTimestamp = new Instant(DateTimeUtils.currentTimeMillis()); + break; + case SYNCHRONIZED_PROCESSING_TIME: + this.currentTimestamp = new Instant(DateTimeUtils.currentTimeMillis()); + break; + default: + throw new IllegalStateException(String.format("Unknown timedomain %s", timeDomain)); Review comment: IllegalArgumentException? ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 124717) Time Spent: 2h (was: 1h 50m) > Java SDK harness should support user timers > ------------------------------------------- > > Key: BEAM-4653 > URL: https://issues.apache.org/jira/browse/BEAM-4653 > Project: Beam > Issue Type: Sub-task > Components: sdk-java-harness > Reporter: Luke Cwik > Assignee: Luke Cwik > Priority: Major > Labels: portability > Time Spent: 2h > Remaining Estimate: 0h > > Wire up the onTimer method in the Java SDK harness FnApiDoFnRunner connecting > it to the RemoteGrpcPort read/write that is responsible for > producing/consumer timers. -- This message was sent by Atlassian JIRA (v7.6.3#76005)