Flink Connector
This connector provides a sink that can send data to CnosDB.
Dependency requirements
Requires CnosDB 2.1.0 or later. Requires Java 1.8 or later.
First add the dependency to your project:
<dependency>
<groupId>com.cnosdb</groupId>
<artifactId>flink-connector-cnosdb</artifactId>
<version>1.0</version>
</dependency>
Code description
Create CnosDB configuration
CnosDBConfig cnosDBConfig = CnosDBConfig.builder()
.url("http://localhost:8902")
.database("db_flink_test")
.username("root")
.password("")
.build();
Create CnosDBSink and add it to the Sink of Stream.
dataStream.addSink(new CnosDBSink(cnosDBConfig);
CnosDBSink accepts CnosDBPoint, which is actually the code implementation of LineProtocol.
new CnosDBPoint(measurement, timestamp, tags, fields);
Sample code
Sample code is here