[
https://issues.apache.org/jira/browse/BEAM-8374?focusedWorklogId=381275&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-381275
]
ASF GitHub Bot logged work on BEAM-8374:
----------------------------------------
Author: ASF GitHub Bot
Created on: 04/Feb/20 00:22
Start Date: 04/Feb/20 00:22
Worklog Time Spent: 10m
Work Description: lukecwik commented on pull request #9758: [BEAM-8374]
Enable returning missing PublishResult fields in SnsIO.Write
URL: https://github.com/apache/beam/pull/9758#discussion_r374414686
##########
File path:
sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/sns/PublishResultCoders.java
##########
@@ -0,0 +1,155 @@
+/*
+ * 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.sdk.io.aws.sns;
+
+import com.amazonaws.ResponseMetadata;
+import com.amazonaws.http.SdkHttpMetadata;
+import com.amazonaws.services.sns.model.PublishResult;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.List;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.CoderException;
+import org.apache.beam.sdk.coders.StringUtf8Coder;
+import org.apache.beam.sdk.io.aws.coders.AwsCoders;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+
+public final class PublishResultCoders {
+
+ private PublishResultCoders() {}
+
+ public static Coder<PublishResult> defaultPublishResult() {
+ return DefaultPublishResultCoder.of();
+ }
+
+ public static Coder<PublishResult> fullPublishResult() {
+ return FullPublishResultCoder.of();
+ }
+
+ public static Coder<PublishResult> minimalPublishResult() {
+ return MinimalPublishResultCoder.of();
+ }
+
+ private static class DefaultPublishResultCoder extends Coder<PublishResult>
+ implements Serializable {
+
+ private static final DefaultPublishResultCoder INSTANCE = new
DefaultPublishResultCoder();
+
+ private DefaultPublishResultCoder() {}
+
+ static DefaultPublishResultCoder of() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void encode(PublishResult value, OutputStream outStream)
+ throws CoderException, IOException {
+ StringUtf8Coder.of().encode(value.getMessageId(), outStream);
+ }
+
+ @Override
+ public PublishResult decode(InputStream inStream) throws CoderException,
IOException {
+ final String messageId = StringUtf8Coder.of().decode(inStream);
+ return new PublishResult().withMessageId(messageId);
+ }
+
+ @Override
+ public List<? extends Coder<?>> getCoderArguments() {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public void verifyDeterministic() throws NonDeterministicException {
+ StringUtf8Coder.of().verifyDeterministic();
+ }
+ }
+
+ private abstract static class AbstractPublishResultCoder extends
Coder<PublishResult>
+ implements Serializable {
+
+ private static final Coder<ResponseMetadata> RESPONSE_METADATA_CODER =
+ AwsCoders.responseMetadata();
+
+ protected abstract Coder<SdkHttpMetadata> getHttpMetadataCoder();
Review comment:
nit: stylewise I think its simpler to understand if the abstract class has a
constructor that takes the sdkhttpmetadata coder and you pass in the coder
instance in the concrete subclass implementations instead of asking authors to
override `getHttpMetadataCoder`
----------------------------------------------------------------
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: 381275)
Time Spent: 5h 10m (was: 5h)
> PublishResult returned by SnsIO is missing sdkResponseMetadata and
> sdkHttpMetadata
> ----------------------------------------------------------------------------------
>
> Key: BEAM-8374
> URL: https://issues.apache.org/jira/browse/BEAM-8374
> Project: Beam
> Issue Type: Bug
> Components: io-java-aws
> Affects Versions: 2.13.0, 2.14.0, 2.15.0
> Reporter: Jonothan Farr
> Assignee: Jonothan Farr
> Priority: Minor
> Time Spent: 5h 10m
> Remaining Estimate: 0h
>
> Currently the PublishResultCoder in SnsIO only serializes the messageId field
> so the PublishResult returned by Beam returns null for
> getSdkResponseMetadata() and getSdkHttpMetadata(). This makes it impossible
> to check the HTTP status for errors, which is necessary since this is not
> handled in SnsIO.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)