[
https://issues.apache.org/jira/browse/BEAM-6161?focusedWorklogId=177091&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-177091
]
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_r243001284
##########
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. */
+ public FnDataReceiver<WindowedValue<?>> getOnlyElement(String pCollectionId)
{
Review comment:
This method is not used, please, remove. If I miss the usage, please rename
to getReceiver, or getFnDataReceiver
----------------------------------------------------------------
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: 177091)
Time Spent: 50m (was: 40m)
> 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: 50m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)