Apache Flink, Cassandra keyspace cluster

The extension for flink cassandra connector that lets you specify default cassandra keyspace.

Лицензия

Лицензия

Категории

Категории

Cassandra Данные Базы данных KeY Data Formats Formal Verification
Группа

Группа

com.github.szczurmys
Идентификатор

Идентификатор

flink-cassandra-keyspace-cluster
Последняя версия

Последняя версия

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Apache Flink, Cassandra keyspace cluster
The extension for flink cassandra connector that lets you specify default cassandra keyspace.
Ссылка на сайт

Ссылка на сайт

https://github.com/szczurmys/flink-cassandra-keyspace-cluster
Система контроля версий

Система контроля версий

http://github.com/szczurmys/flink-cassandra-keyspace-cluster/tree/master

Скачать flink-cassandra-keyspace-cluster

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.szczurmys/flink-cassandra-keyspace-cluster/ -->
<dependency>
    <groupId>com.github.szczurmys</groupId>
    <artifactId>flink-cassandra-keyspace-cluster</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.szczurmys/flink-cassandra-keyspace-cluster/
implementation 'com.github.szczurmys:flink-cassandra-keyspace-cluster:1.1.0'
// https://jarcasting.com/artifacts/com.github.szczurmys/flink-cassandra-keyspace-cluster/
implementation ("com.github.szczurmys:flink-cassandra-keyspace-cluster:1.1.0")
'com.github.szczurmys:flink-cassandra-keyspace-cluster:jar:1.1.0'
<dependency org="com.github.szczurmys" name="flink-cassandra-keyspace-cluster" rev="1.1.0">
  <artifact name="flink-cassandra-keyspace-cluster" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.szczurmys', module='flink-cassandra-keyspace-cluster', version='1.1.0')
)
libraryDependencies += "com.github.szczurmys" % "flink-cassandra-keyspace-cluster" % "1.1.0"
[com.github.szczurmys/flink-cassandra-keyspace-cluster "1.1.0"]

Зависимости

provided (1)

Идентификатор библиотеки Тип Версия
org.apache.flink : flink-connector-cassandra_2.11 jar 1.5.0

test (3)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.assertj : assertj-core jar 3.10.0
org.mockito : mockito-all jar 1.10.19

Модули Проекта

Данный проект не имеет модулей.

flink-cassandra-keyspace-cluster

Apache License, Version 2.0, January 2004 Maven Central

An extension for flink cassandra connector that lets you specify default cassandra keyspace.


For flink version >= 1.6 you should not use it, because it does not work.
They added defaultKeyspace parameter for connector builder:

        CassandraSink.addSink(dataSource)
                //...
                .setDefaultKeyspace("Your default keyspace")
                //...
                .build();

The main adventages (for flink version < 1.6) of the KeyspaceClusterBuilder is that it allows you to use POJO (using mappers http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/mapping/Mapper.html) without defining constant keyspace, and you can get keyspace from properties.


Example:

public class Main {
    public void main(String[] args) {
        String keyspace = "keyspace_flink";
        if(args.length > 0) {
            keyspace = args[0];
        }

        final TypeCodec<LocalDateTime> localDateTimeCodec = null; //Own codec

        //...
        CassandraPojoSink<Pojo> sink = new CassandraPojoSink<>(
            Pojo.class, 
            new KeyspaceClusterBuilder(keyspace) {
                @Override
                protected Cluster.Builder filledBuilder(Cluster.Builder builder) {
                    return builder.addContactPoint("localhost");
                }
                @Override
                protected void configureCluster(Cluster cluster) {
                    cluster
                        .getConfiguration()
                        .getCodecRegistry()
                        .register(localDateTimeCodec);
                }
            }
        );
        //...
    }
}

@Table(name = "test")
public class Pojo implements Serializable {
    //...
}

In standard solution you have to define constant keyspace in annotation:

public class Main {
    public void main(String[] args) {
        //...

        final TypeCodec<LocalDateTime> localDateTimeCodec = null; //Own codec

        CassandraPojoSink<Pojo> sink = new CassandraPojoSink<>(
            Pojo.class, 
            new ClusterBuilder() {
                @Override
                protected Cluster buildCluster(Cluster.Builder builder) {
                    Cluster cluster = builder.addContactPoint("localhost").build();
                    cluster
                        .getConfiguration()
                        .getCodecRegistry()
                        .register(localDateTimeCodec);
                    return cluster;
                }
            }
        );
        //...
    }
}

@Table(keyspace = "keyspace_flink", name = "test")
public class Pojo implements Serializable {
    //...
}

Версии библиотеки

Версия
1.1.0
1.0.0