johnjcasey commented on code in PR #21765:
URL: https://github.com/apache/beam/pull/21765#discussion_r904027669


##########
sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/MappingUtils.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.cdap;
+
+import io.cdap.plugin.common.SourceInputFormatProvider;
+import io.cdap.plugin.hubspot.sink.batch.HubspotBatchSink;
+import io.cdap.plugin.hubspot.sink.batch.HubspotOutputFormat;
+import io.cdap.plugin.hubspot.source.batch.HubspotBatchSource;
+import io.cdap.plugin.hubspot.source.batch.HubspotInputFormat;
+import io.cdap.plugin.hubspot.source.batch.HubspotInputFormatProvider;
+import io.cdap.plugin.salesforce.plugin.source.batch.SalesforceBatchSource;
+import io.cdap.plugin.salesforce.plugin.source.batch.SalesforceInputFormat;
+import 
io.cdap.plugin.salesforce.plugin.source.batch.SalesforceInputFormatProvider;
+import io.cdap.plugin.servicenow.source.ServiceNowInputFormat;
+import io.cdap.plugin.servicenow.source.ServiceNowSource;
+import io.cdap.plugin.zendesk.source.batch.ZendeskBatchSource;
+import io.cdap.plugin.zendesk.source.batch.ZendeskInputFormat;
+import io.cdap.plugin.zendesk.source.batch.ZendeskInputFormatProvider;
+import javax.annotation.Nullable;
+
+public class MappingUtils {
+
+  public static @Nullable Plugin getPluginByClass(Class<?> pluginClass) {
+    if (pluginClass.equals(SalesforceBatchSource.class)) {

Review Comment:
   Sounds good



##########
sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/CdapIO.java:
##########
@@ -0,0 +1,235 @@
+/*
+ * 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.cdap;
+
+import static 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;
+
+import com.google.auto.value.AutoValue;
+import io.cdap.cdap.api.plugin.PluginConfig;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.io.hadoop.format.HDFSSynchronization;
+import org.apache.beam.sdk.io.hadoop.format.HadoopFormatIO;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.PBegin;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.PDone;
+import org.apache.hadoop.conf.Configuration;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * An unbounded/bounded sources and sinks from <a
+ * href="https://github.com/data-integrations";>CDAP</a> plugins.
+ */
+@SuppressWarnings({
+  "argument.type.incompatible",
+  "return.type.incompatible",
+  "dereference.of.nullable",
+  "UnnecessaryParentheses"
+})
+public class CdapIO {
+
+  public static <K, V> Read<K, V> read() {
+    return new AutoValue_CdapIO_Read.Builder<K, V>().build();
+  }
+
+  public static <K, V> Write<K, V> write() {
+    return new AutoValue_CdapIO_Write.Builder<K, V>().build();
+  }
+
+  /** A {@link PTransform} to read from CDAP source. */
+  @AutoValue
+  @AutoValue.CopyAnnotations
+  public abstract static class Read<K, V> extends PTransform<PBegin, 
PCollection<KV<K, V>>> {
+
+    abstract @Nullable PluginConfig getPluginConfig();
+
+    abstract @Nullable Plugin getCdapPlugin();
+
+    abstract @Nullable Class<K> getKeyClass();
+
+    abstract @Nullable Class<V> getValueClass();
+
+    abstract Builder<K, V> toBuilder();
+
+    @Experimental(Experimental.Kind.PORTABILITY)
+    @AutoValue.Builder
+    abstract static class Builder<K, V> {
+
+      abstract Builder<K, V> setPluginConfig(PluginConfig config);
+
+      abstract Builder<K, V> setCdapPlugin(Plugin plugin);
+
+      abstract Builder<K, V> setKeyClass(Class<K> keyClass);
+
+      abstract Builder<K, V> setValueClass(Class<V> valueClass);
+
+      abstract Read<K, V> build();
+    }
+
+    public Read<K, V> withCdapPlugin(Plugin plugin) {
+      checkArgument(plugin != null, "Cdap plugin can not be null");

Review Comment:
   This looks fine to me



##########
sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/MappingUtils.java:
##########
@@ -49,6 +52,6 @@ public class MappingUtils {
       return Plugin.create(
           pluginClass, ServiceNowInputFormat.class, 
SourceInputFormatProvider.class);
     }
-    return null;
+    throw new UnsupportedOperationException("Given plugin class is not 
supported!");

Review Comment:
   we should have it include what class it got in the exception message, to 
make debugging easier



##########
sdks/java/io/cdap/src/main/java/org/apache/beam/sdk/io/cdap/context/BatchSinkContextImpl.java:
##########
@@ -24,7 +24,10 @@
 public class BatchSinkContextImpl extends BatchContextImpl implements 
BatchSinkContext {
 
   @Override
-  public void addOutput(Output output) {}
+  public void addOutput(Output output) {

Review Comment:
   Please add the comment here



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