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

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

                Author: ASF GitHub Bot
            Created on: 20/Dec/18 02:01
            Start Date: 20/Dec/18 02:01
    Worklog Time Spent: 10m 
      Work Description: ajamato commented on a change in pull request #7272: 
[BEAM-6161] Introduce PCollectionConsumerRegistry and add ElementCoun…
URL: https://github.com/apache/beam/pull/7272#discussion_r243136147
 
 

 ##########
 File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/data/PCollectionConsumerRegistry.java
 ##########
 @@ -33,32 +36,65 @@
 public class PCollectionConsumerRegistry {
 
   private ListMultimap<String, FnDataReceiver<WindowedValue<?>>> 
pCollectionIdsToConsumers;
+  private Map<String, ElementCountFnDataReceiver> 
pCollectionIdsToWrappedConsumer;
 
   public PCollectionConsumerRegistry() {
     pCollectionIdsToConsumers = ArrayListMultimap.create();
+    pCollectionIdsToWrappedConsumer = new HashMap<String, 
ElementCountFnDataReceiver>();
   }
 
-  public <T> FnDataReceiver<WindowedValue<T>> registerAndWrap(
-      String pCollectionId, FnDataReceiver<WindowedValue<T>> consumer) {
-    // TODO(ajamato): Test multiple consumers of the same pcollection before 
merging to master.
-    FnDataReceiver<WindowedValue<T>> wrappedReceiver =
-        new ElementCountFnDataReceiver<T>(consumer, pCollectionId);
-    pCollectionIdsToConsumers.put(pCollectionId, (FnDataReceiver) 
wrappedReceiver);
-    return wrappedReceiver;
+  public <T> void register(String pCollectionId, 
FnDataReceiver<WindowedValue<T>> consumer) {
+    // Just save these consumers for now, but package them up later with an
+    // ElementCountFnDataReceiver and possibly a MultiplexingFnDataReceiver
+    // if there are multiple consumers.
+    ElementCountFnDataReceiver wrappedConsumer =
+        pCollectionIdsToWrappedConsumer.getOrDefault(pCollectionId, null);
+    if (wrappedConsumer != null) {
+      throw new RuntimeException(
 
 Review comment:
   Interesting idea, but the builder would basically need to be the same as 
this. Having an exception thrown if built twice, or mroe things are added 
after, etc. Let's leave it as is for now, unless there is much more advantage

----------------------------------------------------------------
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: 177284)

> Add ElementCount MonitoringInfos for the Java SDK
> -------------------------------------------------
>
>                 Key: BEAM-6161
>                 URL: https://issues.apache.org/jira/browse/BEAM-6161
>             Project: Beam
>          Issue Type: New Feature
>          Components: java-fn-execution, sdk-java-harness
>            Reporter: Alex Amato
>            Assignee: Alex Amato
>            Priority: Major
>          Time Spent: 3h 40m
>  Remaining Estimate: 0h
>




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

Reply via email to