dlg99 commented on a change in pull request #9927:
URL: https://github.com/apache/pulsar/pull/9927#discussion_r617724217



##########
File path: 
pulsar-io/kafka-connect-adaptor/src/main/java/org/apache/pulsar/io/kafka/connect/PulsarKafkaConnectSinkConfig.java
##########
@@ -0,0 +1,90 @@
+/**
+ * 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.pulsar.io.kafka.connect;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Map;
+import org.apache.pulsar.io.core.annotations.FieldDoc;
+
+@Data
+@Accessors(chain = true)
+public class PulsarKafkaConnectSinkConfig implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @FieldDoc(
+            defaultValue = "1",
+            help = "Number of messages the sink processes before flush.")
+    private int batchSize = 1;
+
+    @FieldDoc(
+            defaultValue = "2147483647L",
+            help = "The batch size that Kafka producer will attempt to batch 
records together.")
+    private long lingerTimeMs = 2147483647L;
+
+    @FieldDoc(
+            defaultValue = "pulsar-io-adaptor-topic",
+            help = "The Kafka topic name that passed to kafka sink.")
+    private String topic = "pulsar-io-adaptor-topic";
+
+    @FieldDoc(
+            required = true,
+            defaultValue = "",
+            help = "A kafka-connector sink class to use.")
+    private String kafkaConnectorSinkClass;
+
+    @FieldDoc(
+            defaultValue = "",
+            help = "Config properties to pass to the kafka connector.")
+    private Map<String, String> kafkaConnectorConfigProperties;
+
+    @FieldDoc(
+            defaultValue = "kafka-adaptor-sink-offsets",
+            help = "Pulsar topic to store offsets at.")
+    private String offsetStorageTopic = "kafka-adaptor-sink-offsets";
+
+    @FieldDoc(
+            required = true,
+            defaultValue = "",
+            help = "Pulsar service URL.")
+    private String pulsarServiceUrl;

Review comment:
       > In 2.8.0 SinkContext allows you to access PulsarAdmin
   
   @eolivelli I looked at this and it is somewhat correct. Somewhat is because:
   1. PulsarAdmin is exposed only if config.isExposePulsarAdminClientEnabled() 
is set. 
   2. One has to cast received instance of SinkContext to Context, assuming 
that SinkContext implementation also implements Context, because what we have 
is:
   ```
   interface SinkContext extends ConnectorContext
   interface SourceContext extends ConnectorContext
   interface ConnectorContext (in org.apache.pulsar.io.core, doesn't extend 
anything)
   
   interface Context (in org.apache.pulsar.functions.api, doesn't extend 
anything, the one with getPulsarAdmin())
   class ContextImpl implements Context, SinkContext, SourceContext, 
AutoCloseable
   ```
   
   So any access to getPulsarAdmin() and other API from Context interface in 
sink/source would need to do instanceof check & cast to Context which enforces 
assumption that any SinkContext/SourceContext also is a Context. 
   This results in a few problems: discoverability of the API (i.e. in IDE), 
cannot change i.e. SinkContext implementation and assume it works because there 
is implicit requirement for any SinkContext impl to also implement a few other 
interfaces etc.
   Can we just make it explicit and move some or all of these methods into the 
ConnectorContext, make Context extend ConnectorContext?
   




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


Reply via email to