darenwkt commented on code in PR #202:
URL: 
https://github.com/apache/flink-connector-aws/pull/202#discussion_r2134500129


##########
flink-connector-aws/flink-connector-cloudwatch/src/main/java/org/apache/flink/connector/cloudwatch/sink/MetricWriteRequest.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.flink.connector.cloudwatch.sink;
+
+import org.apache.flink.annotation.PublicEvolving;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import software.amazon.awssdk.annotations.NotNull;
+import software.amazon.awssdk.services.cloudwatch.model.MetricDatum;
+import software.amazon.awssdk.services.cloudwatch.model.StatisticSet;
+
+import java.io.Serializable;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/** Pojo used as sink input, containing information for a single CloudWatch 
MetricDatum Object. */
+@PublicEvolving
+public class MetricWriteRequest implements Serializable {
+
+    public String metricName;
+    public Dimension[] dimensions;
+    public Double[] values;
+    public Double[] counts;
+    public Instant timestamp;
+    public String unit;
+    public Integer storageResolution;
+    public Double statisticMax;
+    public Double statisticMin;
+    public Double statisticSum;
+    public Double statisticCount;
+
+    public MetricWriteRequest() {}
+
+    public MetricWriteRequest(
+            @NotNull String metricName,
+            Dimension[] dimensions,
+            Double[] values,
+            Double[] counts,
+            Instant timestamp,
+            String unit,
+            Integer storageResolution,
+            Double statisticMax,
+            Double statisticMin,
+            Double statisticSum,
+            Double statisticCount) {
+        this.metricName = metricName;
+        this.dimensions = dimensions;
+        this.values = values;
+        this.counts = counts;
+        this.timestamp = timestamp;
+        this.unit = unit;
+        this.storageResolution = storageResolution;
+        this.statisticMax = statisticMax;
+        this.statisticMin = statisticMin;
+        this.statisticSum = statisticSum;
+        this.statisticCount = statisticCount;
+    }
+
+    public Dimension[] getDimensions() {
+        return dimensions;
+    }
+
+    public Double[] getValues() {
+        return values;
+    }
+
+    public String getMetricName() {
+        return metricName;
+    }
+
+    public Double[] getCounts() {
+        return counts;
+    }
+
+    public Instant getTimestamp() {
+        return timestamp;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public Integer getStorageResolution() {
+        return storageResolution;
+    }
+
+    public Double getStatisticMax() {
+        return statisticMax;
+    }
+
+    public Double getStatisticMin() {
+        return statisticMin;
+    }
+
+    public Double getStatisticSum() {
+        return statisticSum;
+    }
+
+    public Double getStatisticCount() {
+        return statisticCount;
+    }
+
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /** A single Dimension. */
+    public static class Dimension implements Serializable {
+        public String name;

Review Comment:
   Yes, updated



##########
flink-connector-aws/flink-connector-cloudwatch/src/main/java/org/apache/flink/connector/cloudwatch/sink/DefaultMetricWriteRequestElementConverter.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.flink.connector.cloudwatch.sink;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.connector.sink2.SinkWriter;
+import org.apache.flink.connector.base.sink.writer.ElementConverter;
+
+import java.util.UnknownFormatConversionException;
+
+/**
+ * An implementation of the {@link ElementConverter} that uses the AWS 
CloudWatch SDK v2. The user
+ * needs to provide the {@code InputT} in the form of {@link 
MetricWriteRequest}.
+ *
+ * <p>The InputT needs to be structured and only supports {@link 
MetricWriteRequest}
+ */
+@Internal
+public class DefaultMetricWriteRequestElementConverter<InputT>
+        extends MetricWriteRequestElementConverter<InputT> {
+
+    @Override
+    public MetricWriteRequest apply(InputT element, SinkWriter.Context 
context) {
+        if (!(element instanceof MetricWriteRequest)) {
+            throw new UnknownFormatConversionException(
+                    "DefaultMetricWriteRequestElementConverter only supports 
MetricWriteRequest element.");
+        }
+
+        return (MetricWriteRequest) element;

Review Comment:
   Yes, updated



-- 
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]

Reply via email to