LinDB on GitHub
  1. Client
  2. Java

Use Java Client write data.

Java client library docs and Maven artifact.

Installation

This clients are hosted in Maven central Repository.

If you want to use it with the Maven, you have to add only the dependency on the artifact.

Download the latest version:

Maven

<dependency>
    <groupId>io.lindb</groupId>
    <artifactId>lindb-client</artifactId>
    <version>0.0.4</version>
</dependency>

Gradle

dependencies {
    implementation "io.lindb:lindb-client:0.0.4"
}

Example

Write data use asynchronous, example as below, more examples

package io.lindb.client.example;

import io.lindb.client.Client;
import io.lindb.client.ClientFactory;
import io.lindb.client.Options;
import io.lindb.client.api.Point;
import io.lindb.client.api.Write;

public class WritePoint {
	public static void main(String[] args) throws Exception {
		Options options = Options.builder()
				.addDefaultTag("region", "shanghai")
				.useGZip(true).batchSize(5).flushInterval(1000)
				.build();
		// create LinDB Client with broker endpoint
		Client client = ClientFactory.create("http://localhost:9000", options);
		// get write for database
		Write write = client.write("_internal");

		for (int i = 0; i < 10; i++) {
			Point point = Point.builder("host.cpu").addLast("load", 1.0)
					.addTag("ip", "1.1.1." + i).build();
			boolean ok = write.put(point);
			System.out.println("write status: " + ok);
		}
		// need close write after write done
		write.close();
		System.out.println("done");
		client.close();
	}
}