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

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

                Author: ASF GitHub Bot
            Created on: 19/Apr/18 04:17
            Start Date: 19/Apr/18 04:17
    Worklog Time Spent: 10m 
      Work Description: bsidhom commented on a change in pull request #5150:  
[BEAM-4071] Add Portable Runner Job API shim
URL: https://github.com/apache/beam/pull/5150#discussion_r182629978
 
 

 ##########
 File path: 
runners/reference/java/src/main/java/org/apache/beam/runners/reference/JobServicePipelineResult.java
 ##########
 @@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.reference;
+
+import com.google.common.util.concurrent.Uninterruptibles;
+import com.google.protobuf.ByteString;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.apache.beam.model.jobmanagement.v1.JobApi;
+import org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobRequest;
+import org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobResponse;
+import org.apache.beam.model.jobmanagement.v1.JobApi.GetJobStateRequest;
+import org.apache.beam.model.jobmanagement.v1.JobApi.GetJobStateResponse;
+import 
org.apache.beam.model.jobmanagement.v1.JobServiceGrpc.JobServiceBlockingStub;
+import org.apache.beam.sdk.PipelineResult;
+import org.apache.beam.sdk.metrics.MetricResults;
+import org.joda.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class JobServicePipelineResult implements PipelineResult {
+
+  private static final long POLL_INTERVAL_SEC = 10;
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(JobServicePipelineResult.class);
+
+  private final ByteString jobId;
+  private final CloseableResource<JobServiceBlockingStub> jobService;
+
+  JobServicePipelineResult(ByteString jobId, 
CloseableResource<JobServiceBlockingStub> jobService) {
+    this.jobId = jobId;
+    this.jobService = jobService;
+  }
+
+  @Override
+  public State getState() {
+    JobServiceBlockingStub stub = jobService.get();
+    GetJobStateResponse response =
+        
stub.getState(GetJobStateRequest.newBuilder().setJobIdBytes(jobId).build());
+    return getJavaState(response.getState());
+  }
+
+  @Override
+  public State cancel() {
+    JobServiceBlockingStub stub = jobService.get();
+    CancelJobResponse response =
+        
stub.cancel(CancelJobRequest.newBuilder().setJobIdBytes(jobId).build());
+    return getJavaState(response.getState());
+  }
+
+  @Override
+  public State waitUntilFinish(Duration duration) {
+    if (duration.compareTo(Duration.millis(1)) < 1) {
+      // Equivalent to infinite timeout.
+      return waitUntilFinish();
+    } else {
+      CompletableFuture<State> result = 
CompletableFuture.supplyAsync(this::waitUntilFinish);
+      try {
+        return Uninterruptibles.getUninterruptibly(
 
 Review comment:
   <!--thread_id:cc_182613813_t; 
commit:a16a978c74d440d81ca78b3c44be72eae312ef74; resolved:1-->
   <!--section:context-quote-->
   > **tgroh** wrote:
   > Why is this uninterruptible?
   
   <!--section:body-->
   To ensure that we sleep fully for the amount of time requested. Given that 
we don't use interrupts anywhere in Beam code, we don't expect this to happen 
anyway. Alternatively we could just crash on interrupts (i.e., throw a 
RuntimeException wrapping the interruption).

----------------------------------------------------------------
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: 92388)
    Time Spent: 13h 20m  (was: 13h 10m)

> Portable Runner Job API shim
> ----------------------------
>
>                 Key: BEAM-4071
>                 URL: https://issues.apache.org/jira/browse/BEAM-4071
>             Project: Beam
>          Issue Type: New Feature
>          Components: runner-core
>            Reporter: Ben Sidhom
>            Assignee: Ben Sidhom
>            Priority: Minor
>          Time Spent: 13h 20m
>  Remaining Estimate: 0h
>
> There needs to be a way to execute Java-SDK pipelines against a portable job 
> server. The job server itself is expected to be started up out-of-band. The 
> "PortableRunner" should take an option indicating the Job API endpoint and 
> defer other runner configurations to the backend itself.



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

Reply via email to