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

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

                Author: ASF GitHub Bot
            Created on: 30/Nov/18 00:03
            Start Date: 30/Nov/18 00:03
    Worklog Time Spent: 10m 
      Work Description: ajamato commented on a change in pull request #6786: 
[BEAM-5850] Add QueueingBeamFnDataClient and make process, finish and start run 
on the same thread to support metrics.
URL: https://github.com/apache/beam/pull/6786#discussion_r237705743
 
 

 ##########
 File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/data/QueueingBeamFnDataClient.java
 ##########
 @@ -0,0 +1,180 @@
+/*
+ * 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.fn.harness.data;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.TimeUnit;
+import org.apache.beam.fn.harness.control.ProcessBundleHandler;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.InstructionRequest;
+import org.apache.beam.model.pipeline.v1.Endpoints;
+import org.apache.beam.model.pipeline.v1.Endpoints.ApiServiceDescriptor;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.fn.data.CloseableFnDataReceiver;
+import org.apache.beam.sdk.fn.data.FnDataReceiver;
+import org.apache.beam.sdk.fn.data.InboundDataClient;
+import org.apache.beam.sdk.fn.data.LogicalEndpoint;
+import org.apache.beam.sdk.util.WindowedValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A {@link BeamFnDataClient} that queues elements so that they can be 
consumed and processed in the
+ * thread which calls @{link #drainAndBlock}.
+ */
+public class QueueingBeamFnDataClient implements BeamFnDataClient {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(QueueingBeamFnDataClient.class);
+
+  private final BeamFnDataClient mainClient;
+  private final SynchronousQueue<ConsumerAndData> queue;
+  private final ConcurrentHashMap<InboundDataClient, Object> idcs;
+
+  public QueueingBeamFnDataClient(BeamFnDataClient mainClient) {
+    this.mainClient = mainClient;
+    this.queue = new SynchronousQueue<>();
+    this.idcs = new ConcurrentHashMap<>();
+  }
+
+  @Override
+  public <T> InboundDataClient receive(
+      ApiServiceDescriptor apiServiceDescriptor,
+      LogicalEndpoint inputLocation,
+      Coder<WindowedValue<T>> coder,
+      FnDataReceiver<WindowedValue<T>> consumer) {
+    LOG.debug(
+        "Registering consumer for instruction {} and target {}",
+        inputLocation.getInstructionId(),
+        inputLocation.getTarget());
+
+    QueueingFnDataReceiver<T> queueingConsumer = new 
QueueingFnDataReceiver<T>(consumer);
 
 Review comment:
   This is synonymous. Not renaming. Consumer and receiver are used throughout 
the whole code base. Doing an entire code base rename would be worth doing if 
we pick and enforce a single term

----------------------------------------------------------------
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: 170895)
    Time Spent: 13h 50m  (was: 13h 40m)

> Make process, finish and start run on the same thread to support metrics.
> -------------------------------------------------------------------------
>
>                 Key: BEAM-5850
>                 URL: https://issues.apache.org/jira/browse/BEAM-5850
>             Project: Beam
>          Issue Type: New Feature
>          Components: java-fn-execution
>            Reporter: Alex Amato
>            Assignee: Alex Amato
>            Priority: Major
>          Time Spent: 13h 50m
>  Remaining Estimate: 0h
>
> Update BeamFnDataReceiver to place elements into a Queue and consumer then 
> and call the element processing receiver in blockTillReadFinishes



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

Reply via email to