xinyuiscool commented on code in PR #22576:
URL: https://github.com/apache/beam/pull/22576#discussion_r953154789
##########
runners/samza/src/main/java/org/apache/beam/runners/samza/translation/GroupByKeyTranslator.java:
##########
@@ -228,9 +225,63 @@ private static <K, InputT, OutputT>
MessageStream<OpMessage<KV<K, OutputT>>> doT
reduceFn,
windowingStrategy,
new DoFnOp.SingleOutputManagerFactory<>(),
- transformFullName,
- transformId,
- isBounded)));
+ ctx.getTransformFullName(),
+ ctx.getTransformId(),
+ isBounded),
+ ctx));
+ return outputStream;
+ }
+
+ private static <K, InputT, OutputT> MessageStream<OpMessage<KV<K, OutputT>>>
doTranslateGBK(
Review Comment:
Are we duplicating the entire doTranslateGBK(). why we are doing this?
##########
runners/samza/src/main/java/org/apache/beam/runners/samza/runtime/OpAdapter.java:
##########
@@ -51,20 +56,28 @@
private static final Logger LOG = LoggerFactory.getLogger(OpAdapter.class);
private final Op<InT, OutT, K> op;
+ private final String opName;
Review Comment:
It's not opName. it's transformFullName, right? Can we at least make the
name correcct?
##########
runners/samza/src/main/java/org/apache/beam/runners/samza/runtime/OpAdapter.java:
##########
@@ -51,20 +56,28 @@
private static final Logger LOG = LoggerFactory.getLogger(OpAdapter.class);
private final Op<InT, OutT, K> op;
+ private final String opName;
private transient List<OpMessage<OutT>> outputList;
private transient CompletionStage<Collection<OpMessage<OutT>>> outputFuture;
private transient Instant outputWatermark;
private transient OpEmitter<OutT> emitter;
private transient Config config;
private transient Context context;
+ private transient List<SamzaPipelineExceptionListener.Registrar>
exceptionListeners;
public static <InT, OutT, K> AsyncFlatMapFunction<OpMessage<InT>,
OpMessage<OutT>> adapt(
- Op<InT, OutT, K> op) {
- return new OpAdapter<>(op);
+ Op<InT, OutT, K> op, PortableTranslationContext ctx) {
Review Comment:
We don't need this variant. PortableTranslationContext inherits from
TranslationContext, so we pass in the parent is enough.
##########
runners/samza/src/main/java/org/apache/beam/runners/samza/util/SamzaPipelineExceptionListener.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.samza.util;
+
+/**
+ * An ExceptionListener following Observer pattern. Any runtime exception
caught by {@code
+ * OpAdapter} will be notified to any concrete SamzaPipelineExceptionListener
at Runtime
+ */
+public interface SamzaPipelineExceptionListener {
+
+ void onException(String opName, Exception exception);
Review Comment:
Instead of transformName, I suggest adding a new wrapper class, e.g.
ExceptionContext, which includes transform name, That way we can pass more info
down the road if needed, e.g. transform urn, payload, etc...
In design of an api, please think about future evolvement. One api for a use
case is not that great.
##########
runners/samza/src/main/java/org/apache/beam/runners/samza/runtime/OpAdapter.java:
##########
@@ -51,20 +56,28 @@
private static final Logger LOG = LoggerFactory.getLogger(OpAdapter.class);
private final Op<InT, OutT, K> op;
+ private final String opName;
private transient List<OpMessage<OutT>> outputList;
private transient CompletionStage<Collection<OpMessage<OutT>>> outputFuture;
private transient Instant outputWatermark;
private transient OpEmitter<OutT> emitter;
private transient Config config;
private transient Context context;
+ private transient List<SamzaPipelineExceptionListener.Registrar>
exceptionListeners;
public static <InT, OutT, K> AsyncFlatMapFunction<OpMessage<InT>,
OpMessage<OutT>> adapt(
- Op<InT, OutT, K> op) {
- return new OpAdapter<>(op);
+ Op<InT, OutT, K> op, PortableTranslationContext ctx) {
+ return new OpAdapter<>(op, ctx.getTransformFullName());
}
- private OpAdapter(Op<InT, OutT, K> op) {
+ public static <InT, OutT, K> AsyncFlatMapFunction<OpMessage<InT>,
OpMessage<OutT>> adapt(
+ Op<InT, OutT, K> op, TranslationContext ctx) {
+ return new OpAdapter<>(op, ctx.getTransformFullName());
+ }
+
+ private OpAdapter(Op<InT, OutT, K> op, String opName) {
Review Comment:
opName is just wrong.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]