forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add sink connector v2 implementation --------- Co-authored-by: annie-mac <xinlian@microsoft.com>
- Loading branch information
Showing
59 changed files
with
3,435 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...mos-kafka-connect/src/main/java/com/azure/cosmos/kafka/connect/CosmosDBSinkConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.cosmos.kafka.connect; | ||
|
||
import com.azure.cosmos.kafka.connect.implementation.KafkaCosmosConstants; | ||
import com.azure.cosmos.kafka.connect.implementation.sink.CosmosSinkConfig; | ||
import com.azure.cosmos.kafka.connect.implementation.sink.CosmosSinkTask; | ||
import org.apache.kafka.common.config.ConfigDef; | ||
import org.apache.kafka.connect.connector.Task; | ||
import org.apache.kafka.connect.sink.SinkConnector; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* A Sink connector that publishes topic messages to CosmosDB. | ||
*/ | ||
public class CosmosDBSinkConnector extends SinkConnector { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(CosmosDBSinkConnector.class); | ||
|
||
private CosmosSinkConfig sinkConfig; | ||
|
||
@Override | ||
public void start(Map<String, String> props) { | ||
LOGGER.info("Starting the kafka cosmos sink connector"); | ||
this.sinkConfig = new CosmosSinkConfig(props); | ||
} | ||
|
||
@Override | ||
public Class<? extends Task> taskClass() { | ||
return CosmosSinkTask.class; | ||
} | ||
|
||
@Override | ||
public List<Map<String, String>> taskConfigs(int maxTasks) { | ||
LOGGER.info("Setting task configurations with maxTasks {}", maxTasks); | ||
List<Map<String, String>> configs = new ArrayList<>(); | ||
for (int i = 0; i < maxTasks; i++) { | ||
configs.add(this.sinkConfig.originalsStrings()); | ||
} | ||
|
||
return configs; | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
LOGGER.debug("Kafka Cosmos sink connector {} is stopped."); | ||
} | ||
|
||
@Override | ||
public ConfigDef config() { | ||
return CosmosSinkConfig.getConfigDef(); | ||
} | ||
|
||
@Override | ||
public String version() { | ||
return KafkaCosmosConstants.CURRENT_VERSION; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.