Skip to content
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

Guarantee correct ordering across partitions #18

Merged
merged 1 commit into from
Oct 31, 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Rockset Kafka Connect Changelog
## v2.0.0 2023-10-30
- New configuration option `rockset.retry.backoff.ms`
- Removed deprecated configurations `rockset.apikey`, `rockset.collection`, and `rockset.workspace`
- Bug fix for potential out-of-order message delivery

## v1.4.3 2023-09-15
- Update rockset-java client dependency

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ curl -i http://localhost:8083/connectors -H "Content-Type: application/json" -X
"tasks.max": "20",
"rockset.task.threads": "5",
"rockset.batch.size": "1000",
"rockset.retry.backoff.ms": "5000",
"topics": "<your-kafka-topics separated by commas>",
"rockset.integration.key": "<rockset-kafka-integration-key>",
"rockset.apiserver.url": "https://api.rs2.usw2.rockset.com",
"rockset.apiserver.url": "https://api.usw2a1.rockset.com",
"format": "json"
}
}'
Expand Down Expand Up @@ -122,7 +123,7 @@ See the [the Confluent documentation](https://docs.confluent.io/current/connect/
|-------- |----------------------------|-----------------------|
| `rockset.task.threads` | Number of threads that each task should spawn when writing to Rockset. | 5 |
| `rockset.batch.size` | Max number of documents to be written within a single network request | 1000 |

| `rockset.retry.backoff.ms` | Delay in ms between retries to Rockset | 5000 |
## License

Rockset Connect for Kafka is licensed under the Apache License 2.0.
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>rockset</groupId>
<artifactId>kafka-connect-rockset</artifactId>
<version>1.4.3</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<name>kafka-connect-rockset</name>
Expand Down Expand Up @@ -38,6 +38,12 @@
<artifactId>kafka-connect-avro-converter</artifactId>
<version>7.2.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
34 changes: 11 additions & 23 deletions src/main/java/rockset/RocksetConnectorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
import org.slf4j.LoggerFactory;

public class RocksetConnectorConfig extends AbstractConfig {
private static Logger log = LoggerFactory.getLogger(RocksetConnectorConfig.class);
private static final Logger log = LoggerFactory.getLogger(RocksetConnectorConfig.class);
public static final String FORMAT = "format";
public static final String ROCKSET_APISERVER_URL = "rockset.apiserver.url";
public static final String ROCKSET_APIKEY = "rockset.apikey";
public static final String ROCKSET_INTEGRATION_KEY = "rockset.integration.key";
public static final String ROCKSET_COLLECTION = "rockset.collection";
public static final String ROCKSET_WORKSPACE = "rockset.workspace";
public static final String ROCKSET_TASK_THREADS = "rockset.task.threads";
public static final String ROCKSET_BATCH_SIZE = "rockset.batch.size";
public static final String ROCKSET_RETRY_BACKOFF_MS = "rockset.retry.backoff.ms";

private RocksetConnectorConfig(ConfigDef config, Map<String, String> originals) {
super(config, originals, true);
Expand All @@ -44,7 +42,7 @@ public static ConfigDef config() {
.documentation("Rockset API Server URL")
.importance(Importance.HIGH)
.validator(RocksetConnectorConfig::validateApiServer)
.defaultValue("https://api.rs2.usw2.rockset.com")
.defaultValue("https://api.usw2a1.rockset.com")
.build())
.define(
ConfigKeyBuilder.of(ROCKSET_INTEGRATION_KEY, Type.STRING)
Expand Down Expand Up @@ -73,24 +71,10 @@ public static ConfigDef config() {
.defaultValue("json")
.build())
.define(
ConfigKeyBuilder.of(ROCKSET_APIKEY, Type.STRING)
.documentation("(Deprecated) Rockset API Key")
.importance(Importance.HIGH)
.defaultValue(null)
.build())
.define(
ConfigKeyBuilder.of(ROCKSET_COLLECTION, Type.STRING)
.documentation(
"(Deprecated) Rockset collection that incoming documents will be written to.")
.importance(Importance.HIGH)
.defaultValue(null)
.build())
.define(
ConfigKeyBuilder.of(ROCKSET_WORKSPACE, Type.STRING)
.documentation(
"(Deprecated) Rockset workspace that incoming documents will be written to.")
.importance(Importance.HIGH)
.defaultValue("commons")
ConfigKeyBuilder.of(ROCKSET_RETRY_BACKOFF_MS, Type.INT)
.documentation("How long to backoff in milliseconds between retriable errors")
.importance(Importance.MEDIUM)
.defaultValue(5000)
.build());
}

Expand Down Expand Up @@ -154,4 +138,8 @@ public int getRocksetBatchSize() {
public String getFormat() {
return this.getString(FORMAT);
}

public int getRetryBackoffMs() {
return this.getInt(ROCKSET_RETRY_BACKOFF_MS);
}
}
19 changes: 9 additions & 10 deletions src/main/java/rockset/RocksetRequestWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,16 @@ public class RocksetRequestWrapper implements RequestWrapper {
private static final String KAFKA_ENDPOINT = "/v1/receivers/kafka";
private static final ObjectMapper mapper = new ObjectMapper();

private OkHttpClient client;
private String integrationKeyEncoded;
private String apiServer;
private final OkHttpClient client;
private final String integrationKeyEncoded;
private final String apiServer;

// used for testing
public RocksetRequestWrapper(RocksetConnectorConfig config, OkHttpClient client) {
this.client = client;

parseConnectionString(config.getRocksetIntegrationKey());
this.integrationKeyEncoded = base64EncodeAsUserPassword(config.getRocksetIntegrationKey());
this.apiServer = config.getRocksetApiServerUrl();
}

private void parseConnectionString(String integrationKey) {
this.integrationKeyEncoded = base64EncodeAsUserPassword(integrationKey);
}

private static String base64EncodeAsUserPassword(String integrationKey) {
final String userPassword = integrationKey + ":"; // password is empty
return Base64.getEncoder().encodeToString(userPassword.getBytes(StandardCharsets.UTF_8));
Expand Down Expand Up @@ -93,6 +87,11 @@ private boolean isSuccessHttpCode(int code) {

private void sendDocs(String topic, List<KafkaMessage> messages) {
Preconditions.checkArgument(!messages.isEmpty());
if (Thread.interrupted()) {
// Exit early in case another thread failed and the whole batch of requests from
// RocksetSinkTask::put() are going to be cancelled
throw new ConnectException("Interrupted during call to RocksetRequestWrapper::addDocs");
}
log.debug("Sending batch of {} messages for topic: {} to Rockset", messages.size(), topic);

KafkaDocumentsRequest documentsRequest =
Expand Down
Loading
Loading