[
https://issues.apache.org/jira/browse/BEAM-6094?focusedWorklogId=176554&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-176554
]
ASF GitHub Bot logged work on BEAM-6094:
----------------------------------------
Author: ASF GitHub Bot
Created on: 18/Dec/18 14:34
Start Date: 18/Dec/18 14:34
Worklog Time Spent: 10m
Work Description: robertwb commented on a change in pull request #7307:
[BEAM-6094] Add loopback environment for java.
URL: https://github.com/apache/beam/pull/7307#discussion_r242558347
##########
File path:
runners/reference/java/src/main/java/org/apache/beam/runners/reference/ExternalWorkerService.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 org.apache.beam.fn.harness.FnHarness;
+import
org.apache.beam.model.fnexecution.v1.BeamFnApi.NotifyRunnerAvailableRequest;
+import
org.apache.beam.model.fnexecution.v1.BeamFnApi.NotifyRunnerAvailableResponse;
+import
org.apache.beam.model.fnexecution.v1.BeamFnExternalWorkerPoolGrpc.BeamFnExternalWorkerPoolImplBase;
+import org.apache.beam.runners.fnexecution.FnService;
+import org.apache.beam.runners.fnexecution.GrpcFnServer;
+import org.apache.beam.runners.fnexecution.ServerFactory;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.vendor.grpc.v1_13_1.io.grpc.stub.StreamObserver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ExternalWorkerService extends BeamFnExternalWorkerPoolImplBase
implements FnService {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(BeamFnExternalWorkerPoolImplBase.class);
+
+ private final PipelineOptions options;
+ private final ServerFactory serverFactory = ServerFactory.createDefault();
+
+ public ExternalWorkerService(PipelineOptions options) throws Exception {
+ this.options = options;
+ }
+
+ @Override
+ public void notifyRunnerAvailable(
+ NotifyRunnerAvailableRequest request,
+ StreamObserver<NotifyRunnerAvailableResponse> responseObserver) {
+ LOG.info(
+ "Starting worker {} pointing at {}.",
+ request.getWorkerId(),
+ request.getControlEndpoint().getUrl());
+ LOG.debug("Worker request {}.", request);
+ Thread th =
+ new Thread(
+ () -> {
+ try {
+ FnHarness.main(
+ request.getWorkerId(),
+ options,
+ request.getLoggingEndpoint(),
+ request.getControlEndpoint());
+ LOG.info("Successfully started worker {}.",
request.getWorkerId());
+ } catch (Exception exn) {
+ LOG.error(String.format("Failed to start worker %s.",
request.getWorkerId()), exn);
+ }
+ });
+ th.setName("SDK-worker-" + request.getWorkerId());
+ th.setDaemon(true);
+ th.start();
Review comment:
It should be shut down via the protocol.
----------------------------------------------------------------
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: 176554)
Time Spent: 3h 40m (was: 3.5h)
> Implement External environment for Portable Beam
> ------------------------------------------------
>
> Key: BEAM-6094
> URL: https://issues.apache.org/jira/browse/BEAM-6094
> Project: Beam
> Issue Type: Improvement
> Components: beam-model
> Reporter: Robert Bradshaw
> Assignee: Robert Bradshaw
> Priority: Major
> Time Spent: 3h 40m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)