Search in sources :

Example 1 with CassandraClient

use of com.datastax.oss.cdc.CassandraClient in project cdc-apache-cassandra by datastax.

the class CassandraSource method initCassandraClient.

void initCassandraClient() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, InstantiationException {
    this.cassandraClient = new CassandraClient(this.config, Version.getVersion(), sourceContext.getSourceName(), this);
    Tuple2<KeyspaceMetadata, TableMetadata> tuple = cassandraClient.getTableMetadata(this.config.getKeyspaceName(), this.config.getTableName());
    Preconditions.checkArgument(tuple._1 != null, String.format(Locale.ROOT, "Keyspace %s does not exist", this.config.getKeyspaceName()));
    Preconditions.checkArgument(tuple._2 != null, String.format(Locale.ROOT, "Table %s.%s does not exist", this.config.getKeyspaceName(), this.config.getTableName()));
    this.pkColumns = tuple._2.getPrimaryKey().stream().map(c -> c.getName().asInternal()).collect(Collectors.toList());
    this.keyConverter = createConverter(getKeyConverterClass(), tuple._1, tuple._2, tuple._2.getPrimaryKey());
    this.mutationKeyConverter = new NativeAvroConverter(tuple._1, tuple._2, tuple._2.getPrimaryKey());
    setValueConverterAndQuery(tuple._1, tuple._2);
}
Also used : TableMetadata(com.datastax.oss.driver.api.core.metadata.schema.TableMetadata) NativeAvroConverter(com.datastax.oss.pulsar.source.converters.NativeAvroConverter) CassandraClient(com.datastax.oss.cdc.CassandraClient) KeyspaceMetadata(com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)

Aggregations

CassandraClient (com.datastax.oss.cdc.CassandraClient)1 KeyspaceMetadata (com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)1 TableMetadata (com.datastax.oss.driver.api.core.metadata.schema.TableMetadata)1 NativeAvroConverter (com.datastax.oss.pulsar.source.converters.NativeAvroConverter)1