[
https://issues.apache.org/jira/browse/BEAM-6944?focusedWorklogId=220734&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-220734
]
ASF GitHub Bot logged work on BEAM-6944:
----------------------------------------
Author: ASF GitHub Bot
Created on: 29/Mar/19 21:02
Start Date: 29/Mar/19 21:02
Worklog Time Spent: 10m
Work Description: ajamato commented on pull request #8171: [BEAM-6944]
Add MeanByteCountMonitoringInfoToCounterUpdateTransformer
URL: https://github.com/apache/beam/pull/8171#discussion_r270567077
##########
File path:
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/fn/control/MeanByteCountMonitoringInfoToCounterUpdateTransformer.java
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.dataflow.worker.fn.control;
+
+import static
org.apache.beam.runners.dataflow.worker.counters.DataflowCounterUpdateExtractor.longToSplitInt;
+
+import com.google.api.services.dataflow.model.CounterUpdate;
+import com.google.api.services.dataflow.model.IntegerMean;
+import com.google.api.services.dataflow.model.NameAndKind;
+import java.util.Map;
+import java.util.Optional;
+import javax.annotation.Nullable;
+import org.apache.beam.model.pipeline.v1.MetricsApi.IntDistributionData;
+import org.apache.beam.model.pipeline.v1.MetricsApi.MonitoringInfo;
+import org.apache.beam.runners.core.metrics.SpecMonitoringInfoValidator;
+import org.apache.beam.runners.dataflow.worker.counters.NameContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** MonitoringInfo to CounterUpdate transformer capable to transform
MeanByteCount counter. */
+public class MeanByteCountMonitoringInfoToCounterUpdateTransformer
+ implements MonitoringInfoToCounterUpdateTransformer {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(BeamFnMapTaskExecutor.class);
+
+ private final SpecMonitoringInfoValidator specValidator;
+ private final Map<String, NameContext> pcollectionIdToNameContext;
+
+ // todo(migryz): utilize value from metrics.proto once it gets in.
+ private static final String SUPPORTED_URN =
"beam:metric:sampled_byte_size:v1";
+
+ /**
+ * @param specValidator SpecMonitoringInfoValidator to utilize for default
validation.
+ * @param pcollectionIdToNameContext This mapping is utilized to generate
DFE CounterUpdate name.
+ */
+ public MeanByteCountMonitoringInfoToCounterUpdateTransformer(
+ SpecMonitoringInfoValidator specValidator,
+ Map<String, NameContext> pcollectionIdToNameContext) {
+ this.specValidator = specValidator;
+ this.pcollectionIdToNameContext = pcollectionIdToNameContext;
+ }
+
+ /**
+ * Validates provided monitoring info against specs and common safety checks.
+ *
+ * @param monitoringInfo to validate.
+ * @return Optional.empty() all validation checks are passed. Optional with
error text otherwise.
+ * @throws RuntimeException if received unexpected urn.
+ */
+ protected Optional<String> validate(MonitoringInfo monitoringInfo) {
+ Optional<String> validatorResult = specValidator.validate(monitoringInfo);
+ if (validatorResult.isPresent()) {
+ return validatorResult;
+ }
+
+ String urn = monitoringInfo.getUrn();
+ if (!urn.equals(SUPPORTED_URN)) {
+ throw new RuntimeException(String.format("Received unexpected counter
urn: %s", urn));
+ }
+
+ // todo(migryz): extract and utilize pcollection label from
beam_fn_api.proto
Review comment:
capitalize TODO
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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: 220734)
Time Spent: 0.5h (was: 20m)
> Add support for MeanByteCount metric for Python Streaming to Java DF Runner
> ---------------------------------------------------------------------------
>
> Key: BEAM-6944
> URL: https://issues.apache.org/jira/browse/BEAM-6944
> Project: Beam
> Issue Type: Bug
> Components: runner-dataflow, sdk-py-harness
> Reporter: Mikhail Gryzykhin
> Assignee: Mikhail Gryzykhin
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)