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

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

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

 ##########
 File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/data/PCollectionConsumerRegistry.java
 ##########
 @@ -0,0 +1,64 @@
+/*
+ * 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 com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.ListMultimap;
+import java.util.List;
+import java.util.Set;
+import org.apache.beam.sdk.fn.data.FnDataReceiver;
+import org.apache.beam.sdk.util.WindowedValue;
+
+/**
+ * The {@code PCollectionConsumerRegistry} is used to maintain a collection of 
consuming
+ * FnDataReceiver for each pCollectionId. Registering with this class allows 
inserting an element
+ * count counter for every pCollection.
+ */
+public class PCollectionConsumerRegistry {
+
+  private ListMultimap<String, FnDataReceiver<WindowedValue<?>>> 
pCollectionIdsToConsumers;
+
+  public PCollectionConsumerRegistry() {
+    pCollectionIdsToConsumers = ArrayListMultimap.create();
+  }
+
+  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;
+  }
+
+  /** @return the list of pcollection ids. */
+  public Set<String> keySet() {
+    return pCollectionIdsToConsumers.keySet();
+  }
+
+  /** @return The Get the only FnDataReceiver for the pcollection. */
 
 Review comment:
   document IllegalArgumentException when multiple elements are returned for 
pCollectionId

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

> 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: 1h 20m
>  Remaining Estimate: 0h
>




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

Reply via email to