Skip to content

[DE-627] batch writes #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

## [Unreleased]

- batch writes (DE-627, #23)

## [1.0.0] - 2023-05-26

- initial release
Expand Down
4 changes: 2 additions & 2 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Set package version:

```shell
export PACKAGE_VERSION=1.0.0
export PACKAGE_VERSION=1.1.0
```

Create the Docker network:
Expand Down Expand Up @@ -69,7 +69,7 @@ The messages produced can be checked at [http://172.28.0.1:8080/topics/orders](h
Create db collection:

```shell
curl -u root:test http://172.28.0.1:8529/_api/collection -d '{"name": "orders"}'
curl -u root:test http://172.28.0.1:8529/_api/collection -d '{"name": "orders", "numberOfShards": 3}'
```

Explore configuration options in the console at [http://172.28.0.1:8080/connect-clusters/kafka-connect/create-connector](http://172.28.0.1:8080/connect-clusters/kafka-connect/create-connector)
Expand Down
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.arangodb</groupId>
<artifactId>kafka-connect-arangodb</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<packaging>jar</packaging>
<inceptionYear>2023</inceptionYear>

Expand Down Expand Up @@ -62,7 +62,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kafka.version>3.4.1</kafka.version>
<confluent.version>7.4.0</confluent.version>
<arangodb.version>7.1.0</arangodb.version>
<arangodb.version>7.3.0</arangodb.version>
<jackson.version>2.13.5</jackson.version>
<slf4j.version>1.7.36</slf4j.version>
</properties>
Expand All @@ -78,6 +78,16 @@
<name>Confluent</name>
<url>https://packages.confluent.io/maven/</url>
</repository>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/arangodb/kafka/ArangoSinkConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
public class ArangoSinkConnector extends SinkConnector {
private static final Logger LOG = LoggerFactory.getLogger(SinkConnector.class);
private Map<String, String> config;
private boolean acquireHostList;
private List<HostDescription> initialEndpoints;
private HostListMonitor hostListMonitor;

@Override
Expand All @@ -54,8 +56,11 @@ public void start(Map<String, String> props) {
throw new ConnectException(e);
}

hostListMonitor = new HostListMonitor(sinkConfig, context);
if (sinkConfig.isAcquireHostListEnabled()) {
acquireHostList = sinkConfig.isAcquireHostListEnabled();
initialEndpoints = sinkConfig.getEndpoints();

if (acquireHostList) {
hostListMonitor = new HostListMonitor(sinkConfig, context);
hostListMonitor.start();
}
}
Expand All @@ -67,7 +72,7 @@ public Class<? extends Task> taskClass() {

@Override
public List<Map<String, String>> taskConfigs(int maxTasks) {
List<HostDescription> endpoints = new ArrayList<>(hostListMonitor.getEndpoints());
List<HostDescription> endpoints = new ArrayList<>(acquireHostList ? hostListMonitor.getEndpoints() : initialEndpoints);
int rotationDistance = endpoints.size() / maxTasks;
if (rotationDistance == 0) {
rotationDistance = 1;
Expand All @@ -89,8 +94,10 @@ public List<Map<String, String>> taskConfigs(int maxTasks) {

@Override
public void stop() {
LOG.info("stopping ArangoSinkConnector");
hostListMonitor.stop();
if (acquireHostList) {
LOG.info("stopping ArangoSinkConnector");
hostListMonitor.stop();
}
}

@Override
Expand Down
Loading