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

Bugfixes #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/main/java/io/connect/scylladb/ScyllaDbSessionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public TableMetadata.Table tableMetadata(String tableName) {
result = new TableMetadataImpl.TableImpl(tableMetadata.get());
this.tableMetadataCache.put(tableName, result);
} else {
log.warn("Could not find metadata for table {} in keyspace {}. Are you sure the table exists?", tableName, keyspaceMetadata.getName().asCql(false));
result = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import io.confluent.kafka.connect.utils.config.ValidEnum;
import io.confluent.kafka.connect.utils.config.ValidPort;
import io.connect.scylladb.topictotable.TopicConfigs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Configuration class for {@link ScyllaDbSinkConnector}.
Expand Down Expand Up @@ -62,6 +64,10 @@ public class ScyllaDbSinkConnectorConfig extends AbstractConfig {
private static final Pattern TOPIC_KS_TABLE_SETTING_PATTERN =
Pattern.compile("topic\\.([a-zA-Z0-9._-]+)\\.([^.]+|\"[\"]+\")\\.([^.]+|\"[\"]+\")\\.(mapping|consistencyLevel|ttlSeconds|deletesEnabled)$");

private static final String[] TOPIC_WISE_CONFIGS_VALID_SUFFIXES = {".mapping",".consistencyLevel",".ttlSeconds",".deletesEnabled"};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some comments that briefly explains what this const is


private static final Logger log = LoggerFactory.getLogger(ScyllaDbSinkConnectorConfig.class);

static final Set<String> CLIENT_COMPRESSION = ImmutableSet.of("none", "lz4", "snappy");

static final Set<String> TABLE_COMPRESSORS = ImmutableSet.of("SnappyCompressor", "LZ4Compressor", "DeflateCompressor", "none");
Expand Down Expand Up @@ -111,8 +117,9 @@ public ScyllaDbSinkConnectorConfig(Map<?, ?> originals) {
Map<String, Map<String, String>> topicWiseConfigsMap = new HashMap<>();
for (final Map.Entry<String, String> entry : ((Map<String, String>) originals).entrySet()) {
final String name2 = entry.getKey();
if (name2.startsWith("topic.")) {
if (name2.startsWith("topic.") && hasTopicWiseConfigSuffix(name2)) {
final String topicName = this.tryMatchTopicName(name2);
log.debug("Interpreting " + name2 + " as custom TopicWiseConfig for topic " + topicName);
final Map<String, String> topicMap = topicWiseConfigsMap.computeIfAbsent(topicName, t -> new HashMap());
topicMap.put(name2.split("\\.")[name2.split("\\.").length - 1], entry.getValue());
}
Expand Down Expand Up @@ -567,6 +574,13 @@ private String tryMatchTopicName(final String name) {
throw new IllegalArgumentException("The setting: " + name + " does not match topic.keyspace.table nor topic.codec regular expression pattern");
}

private boolean hasTopicWiseConfigSuffix(final String name) {
for (String suffix : TOPIC_WISE_CONFIGS_VALID_SUFFIXES) {
if (name.endsWith(suffix)) return true;
}
return false;
}

private static String[] toStringArray(Object[] arr){
return Arrays.stream(arr).map(Object::toString).toArray(String[]::new);
}
Expand Down
Loading