[ 
https://issues.apache.org/jira/browse/BEAM-5262?focusedWorklogId=142926&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-142926
 ]

ASF GitHub Bot logged work on BEAM-5262:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Sep/18 00:11
            Start Date: 11/Sep/18 00:11
    Worklog Time Spent: 10m 
      Work Description: youngoli commented on a change in pull request #6301: 
[BEAM-5262] Add Reference runner support for add state stream
URL: https://github.com/apache/beam/pull/6301#discussion_r216512517
 
 

 ##########
 File path: 
runners/direct-java/src/main/java/org/apache/beam/runners/direct/portable/job/ReferenceRunnerJobService.java
 ##########
 @@ -201,6 +204,36 @@ public void getState(
     responseObserver.onCompleted();
   }
 
+  @Override
+  public void getStateStream(
+      GetJobStateRequest request, StreamObserver<GetJobStateResponse> 
responseObserver) {
+    LOG.trace("{} {}", GetJobStateRequest.class.getSimpleName(), request);
+    String invocationId = request.getJobId();
+    try {
+      Thread.sleep(WAIT_MS);
+      Enum state = jobStates.getOrDefault(request.getJobId(), 
Enum.UNRECOGNIZED);
+      
responseObserver.onNext(GetJobStateResponse.newBuilder().setState(state).build());
+      while (Enum.RUNNING.equals(state)) {
+        Thread.sleep(WAIT_MS);
+        state = jobStates.getOrDefault(request.getJobId(), Enum.UNRECOGNIZED);
+      }
+      
responseObserver.onNext(GetJobStateResponse.newBuilder().setState(state).build());
 
 Review comment:
   This seems wrong based on my understanding of onNext. I assumed (based on a 
quick reading of the documentation for StreamObservers) that onNext would have 
to be called every time the state enum changed. With the call before and after 
the while loop, it seems like it would be called twice in succession if the 
state is initially something other than Enum.RUNNING.

----------------------------------------------------------------
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: 142926)
    Time Spent: 40m  (was: 0.5h)

> JobState support for Reference Runner
> -------------------------------------
>
>                 Key: BEAM-5262
>                 URL: https://issues.apache.org/jira/browse/BEAM-5262
>             Project: Beam
>          Issue Type: Bug
>          Components: runner-direct
>            Reporter: Ankur Goenka
>            Assignee: Ankur Goenka
>            Priority: Minor
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Reference runner does not support getStateStream which is needed by portable 
> SDK



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to