You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/09/13 13:45:17 UTC

[GitHub] [ignite-extensions] NSAmelchev commented on a diff in pull request #176: IGNITE-17452 Implement Kafka to thin client CDC streamer

NSAmelchev commented on code in PR #176:
URL: https://github.com/apache/ignite-extensions/pull/176#discussion_r969649812


##########
modules/cdc-ext/src/main/java/org/apache/ignite/cdc/kafka/KafkaToIgniteClientCdcStreamer.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.ignite.cdc.kafka;
+
+import java.util.Collection;
+import java.util.Properties;
+import java.util.UUID;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cdc.AbstractCdcEventsApplier;
+import org.apache.ignite.cdc.thin.CdcEventsIgniteClientApplier;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
+import org.apache.ignite.internal.client.thin.ClientBinary;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ * Implementation of {@link AbstractKafkaToIgniteCdcStreamer} that streams all data changes to a destination cluster
+ * through Ignite thin client.
+ *
+ * @see IgniteClient
+ */
+public class KafkaToIgniteClientCdcStreamer extends AbstractKafkaToIgniteCdcStreamer {
+    /** Ignite thin client configuration. */
+    private final ClientConfiguration clientCfg;
+
+    /** Ignite thin client. */
+    private IgniteClient client;
+
+    /**
+     * @param clientCfg Ignite thin client configuration.
+     * @param kafkaProps Kafka properties.
+     * @param streamerCfg Streamer configuration.
+     */
+    public KafkaToIgniteClientCdcStreamer(ClientConfiguration clientCfg, Properties kafkaProps,
+        KafkaToIgniteCdcStreamerConfiguration streamerCfg) {
+        super(kafkaProps, streamerCfg);
+
+        A.notNull(clientCfg, "Destination thin client configuration.");
+
+        this.clientCfg = clientCfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void initLogger() throws Exception {
+        log = U.initLogger(null, "kafka-ignite-streamer", UUID.randomUUID(), U.defaultWorkDirectory());
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void runx() throws Exception {
+        try (IgniteClient client = Ignition.startClient(clientCfg)) {
+            this.client = client;
+
+            runAppliers();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected AbstractCdcEventsApplier eventsApplier() {
+        GridBinaryMarshaller.popContext(binaryContext());

Review Comment:
   To deserialise `BinaryObjectImpl`. See `BinaryObjectImpl#readExternal`



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org