From d8e8af7f0cd775dd39f076815b09f1494a9df7fb Mon Sep 17 00:00:00 2001 From: karel rehor Date: Fri, 24 Oct 2025 10:55:12 +0200 Subject: [PATCH 1/4] docs: starting spring-example --- examples/spring/pom.xml | 130 ++++++++++++++++++ .../java/org/influxdb/v3/Application.java | 75 ++++++++++ .../org/influxdb/v3/config/AppConfig.java | 73 ++++++++++ .../org/influxdb/v3/reading/EnvReading.java | 79 +++++++++++ .../influxdb/v3/reading/RandomEnvReading.java | 14 ++ .../java/org/influxdb/v3/sensor/Sensor.java | 25 ++++ .../influxdb/v3/sensor/SensorCollection.java | 23 ++++ .../influxdb/v3/service/PersistService.java | 111 +++++++++++++++ .../influxdb/v3/service/ReadingsService.java | 110 +++++++++++++++ .../src/main/resources/application.properties | 10 ++ .../spring/src/main/resources/logback.xml | 18 +++ 11 files changed, 668 insertions(+) create mode 100644 examples/spring/pom.xml create mode 100644 examples/spring/src/main/java/org/influxdb/v3/Application.java create mode 100644 examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java create mode 100644 examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java create mode 100644 examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java create mode 100644 examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java create mode 100644 examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java create mode 100644 examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java create mode 100644 examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java create mode 100644 examples/spring/src/main/resources/application.properties create mode 100644 examples/spring/src/main/resources/logback.xml diff --git a/examples/spring/pom.xml b/examples/spring/pom.xml new file mode 100644 index 00000000..246427b3 --- /dev/null +++ b/examples/spring/pom.xml @@ -0,0 +1,130 @@ + + + 4.0.0 + + + + com.influxdb.v3.spring + spring-example + 1.0-SNAPSHOT + spring-example + + + UTF-8 + 17 + 6.2.11 + + + + + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-core + ${spring.version} + + + org.springframework + spring-aspects + ${spring.version} + + + org.springframework.retry + spring-retry + 2.0.12 + + + com.influxdb + influxdb3-java + 1.6.0-SNAPSHOT + + + + ch.qos.logback + logback-classic + 1.5.18 + + + + + + + + + + + maven-clean-plugin + 3.4.0 + + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.13.0 + + + maven-surefire-plugin + 3.3.0 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.2 + + + maven-deploy-plugin + 3.1.2 + + + + maven-site-plugin + 3.12.1 + + + maven-project-info-reports-plugin + 3.6.1 + + + + + diff --git a/examples/spring/src/main/java/org/influxdb/v3/Application.java b/examples/spring/src/main/java/org/influxdb/v3/Application.java new file mode 100644 index 00000000..0a04ffd1 --- /dev/null +++ b/examples/spring/src/main/java/org/influxdb/v3/Application.java @@ -0,0 +1,75 @@ +package org.influxdb.v3; + +import com.influxdb.v3.client.PointValues; +import org.influxdb.v3.config.AppConfig; +import org.influxdb.v3.reading.EnvReading; +import org.influxdb.v3.sensor.SensorCollection; +import org.influxdb.v3.service.PersistService; +import org.influxdb.v3.service.ReadingsService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.time.Duration; +import java.util.stream.Stream; + +@Component +public class Application { + + static Logger logger = LoggerFactory.getLogger(Application.class); + + public static void main(String[] args) throws InterruptedException, IOException { + try(var ctx = new AnnotationConfigApplicationContext(AppConfig.class)) { + ctx.registerShutdownHook(); + + SensorCollection sensors = ctx.getBean(SensorCollection.class); + PersistService persistService = ctx.getBean(PersistService.class); + persistService.persistDataRandom(sensors, 1, Duration.ofMinutes(5)); + + ReadingsService readingsService = ctx.getBean(ReadingsService.class); + logger.info("==== [ Get as Point Values ] ===="); + logPVStream(readingsService.getAllReadingsAsPV()); + logger.info("==== [ Get as Mapped EnvReadings ] ===="); + logEnvReadingStream(readingsService.getAllReadings()); + logger.info("==== [ Get as Object Array ] ===="); + logObjArrayStream(readingsService.getAllReadingsAsObj()); + + } + } + + public static void logPVStream(Stream pvs) { + StringBuilder pvResults = new StringBuilder(); + pvs.forEach(pv -> { + pvResults.append(String.format("%s, ", pv.getTimestamp())); + pvResults.append(String.format("name: %s, ", pv.getTag(("name")))); + pvResults.append(String.format("model: %s, ", pv.getTag(("model")))); + pvResults.append(String.format("id: %s, ", pv.getTag(("id")))); + pvResults.append(String.format("temp: %3.2f ", pv.getFloatField(("temp")))); + pvResults.append(String.format("press: %3.2f ", pv.getFloatField(("press")))); + pvResults.append(String.format("humid: %3.2f ", pv.getFloatField(("humid")))); + pvResults.append("\n"); + }); + logger.info("PointValueResults: \n {}\n", pvResults); + } + + public static void logObjArrayStream(Stream oas) { + StringBuilder results = new StringBuilder(); + oas.forEach(o -> { + for(int i = 0; i < o.length;i++) { + results.append(String.format("%s, ", o[i])); + } + results.append("\n"); + }); + logger.info("ObjectArrayStream results: \n {}\n", results); + } + + public static void logEnvReadingStream(Stream evs) { + StringBuilder result = new StringBuilder(); + evs.forEach(point -> { + result.append(String.format("%s\n", point.toString())); + }); + logger.info(result.toString()); + } +} \ No newline at end of file diff --git a/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java b/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java new file mode 100644 index 00000000..1dcf0f57 --- /dev/null +++ b/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java @@ -0,0 +1,73 @@ +package org.influxdb.v3.config; + +import com.influxdb.v3.client.InfluxDBClient; +import org.influxdb.v3.sensor.Sensor; +import org.influxdb.v3.sensor.SensorCollection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.retry.annotation.EnableRetry; +import org.springframework.retry.backoff.FixedBackOffPolicy; +import org.springframework.retry.policy.SimpleRetryPolicy; +import org.springframework.retry.support.RetryTemplate; + +import java.util.List; + +@Configuration +@EnableRetry +@ComponentScan(basePackages = "org.influxdb.v3") +@PropertySource("classpath:application.properties") +public class AppConfig { + + Logger logger = LoggerFactory.getLogger(AppConfig.class); + + static List sensors = List.of(new Sensor("Able", "R2D2", "123"), + new Sensor("Baker", "C3PO", "456"), + new Sensor("Charle", "Robbie", "789"), + new Sensor("Delta", "R2D2", "abc"), + new Sensor( "Easy", "C3PO", "def" + ) + ); + + @Value("${influxdb.url}") + private String influxDBUrl; + + @Value("${influxdb.token}") + private String influxDBToken; + + @Value("${influxdb.database}") + private String influxDBDatabase; + + @Bean(name={"internalSensors"}) + public SensorCollection sensorCollectionInit(){ + logger.debug("sensorCollection"); + return new SensorCollection(sensors); + } + + @Bean + @Qualifier("influxDBClient") + public InfluxDBClient influxDBClient(){ + logger.debug("influxDBClientBaseInit with " + influxDBUrl); + return InfluxDBClient.getInstance(influxDBUrl, influxDBToken.toCharArray(), influxDBDatabase); + } + + @Bean + public RetryTemplate retryTemplate(){ + RetryTemplate retryTemplate = new RetryTemplate(); + + FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy(); + fixedBackOffPolicy.setBackOffPeriod(2000l); + retryTemplate.setBackOffPolicy(fixedBackOffPolicy); + + SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(); + retryPolicy.setMaxAttempts(2); + retryTemplate.setRetryPolicy(retryPolicy); + + return retryTemplate; + } +} diff --git a/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java b/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java new file mode 100644 index 00000000..f02cbc5c --- /dev/null +++ b/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java @@ -0,0 +1,79 @@ +package org.influxdb.v3.reading; + +import com.influxdb.v3.client.Point; +import org.influxdb.v3.sensor.Sensor; + +import java.time.Instant; + +public class EnvReading { + + Sensor sensor; + double temperature; + double humidity; + double pressure; + Instant timestamp; + + public EnvReading(Sensor sensor, double temperature, double humidity, double pressure) { + this.sensor = sensor; + this.temperature = temperature; + this.humidity = humidity; + this.pressure = pressure; + } + + public EnvReading(Sensor sensor, double temperature, double humidity, double pressure, Instant timestamp) { + this.sensor = sensor; + this.temperature = temperature; + this.humidity = humidity; + this.pressure = pressure; + this.timestamp = timestamp; + } + + + public Sensor getSensor() { + return this.sensor; + } + + public void setSensor(Sensor sensor) { + this.sensor = sensor; + } + + public double getTemperature() { + return this.temperature; + } + + public void setTemperature(double temperature) { + this.temperature = temperature; + } + + public double getHumidity() { + return this.humidity; + } + + public void setHumidity(double humidity) { + this.humidity = humidity; + } + public double getPressure() { + return this.pressure; + } + public void setPressure(double pressure) { + this.pressure = pressure; + } + + public Point toPoint(String measurement, Instant timestamp) { + if (this.timestamp == null) { + this.timestamp = timestamp; + } + return new Point(measurement) + .setTags(this.sensor.toTags()) + .setFloatField("temp", this.temperature) + .setFloatField("humid", this.humidity) + .setFloatField("press", this.pressure) + .setTimestamp(timestamp); + } + + @Override + public String toString() { + return String.format("sensor[%s] temp: %f3.3, humid: %f3.3, press: %f3.3, time: %s", + sensor, temperature, humidity, pressure, timestamp); + } +} diff --git a/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java b/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java new file mode 100644 index 00000000..bacdabfe --- /dev/null +++ b/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java @@ -0,0 +1,14 @@ +package org.influxdb.v3.reading; + +import org.influxdb.v3.sensor.Sensor; + +public class RandomEnvReading { + + public static EnvReading genReading(Sensor sensor){ + return new EnvReading(sensor, + (Math.random() * 40.0) + (Math.random() * 40.0) - 20.0, + (Math.random() * 60) + (Math.random() * 40), + Math.random() * 8.0 + 26.0 + ); + } +} diff --git a/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java b/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java new file mode 100644 index 00000000..e9c5d56e --- /dev/null +++ b/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java @@ -0,0 +1,25 @@ +package org.influxdb.v3.sensor; + +import java.util.Map; + +public class Sensor { + + String name; + String model; + String id; + + public Sensor(String name, String model, String id) { + this.name = name; + this.model = model; + this.id = id; + } + + public Map toTags() { + return Map.of("name", name, "model", model, "id", id); + } + + @Override + public String toString() { + return String.format("name: %s, model: %s, id: %s", name, model, id); + } +} diff --git a/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java b/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java new file mode 100644 index 00000000..10a7d3f2 --- /dev/null +++ b/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java @@ -0,0 +1,23 @@ +package org.influxdb.v3.sensor; + +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +public class SensorCollection { + + List sensors; + + @Autowired + public SensorCollection(List sensors){ + this.sensors = sensors; + } + + public List getSensors() { + return sensors; + } + + public void setSensors(List sensors) { + this.sensors = sensors; + } +} diff --git a/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java b/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java new file mode 100644 index 00000000..9e3856f4 --- /dev/null +++ b/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java @@ -0,0 +1,111 @@ +package org.influxdb.v3.service; + +import com.influxdb.v3.client.InfluxDBApiException; +import com.influxdb.v3.client.InfluxDBClient; +import com.influxdb.v3.client.Point; +import org.apache.arrow.flight.FlightRuntimeException; +import org.influxdb.v3.reading.RandomEnvReading; +import org.influxdb.v3.sensor.Sensor; +import org.influxdb.v3.sensor.SensorCollection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.retry.annotation.Recover; +import org.springframework.retry.support.RetryTemplate; +import org.springframework.stereotype.Service; + +import java.net.ConnectException; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; + +@Service +public class PersistService { + + Logger logger = LoggerFactory.getLogger(PersistService.class); + + InfluxDBClient influxDBClientBase; + + @Value("${influxdb.measurement}") + String measurement; + + @Value("${app.debug}") + boolean debug; + + @Autowired + public PersistService(@Qualifier("influxDBClient")InfluxDBClient influxDBClient) { + this.influxDBClientBase = influxDBClient; + } + + //@Retryable(retryFor = {InfluxDBApiException.class}, + // maxAttemptsExpression = "${write.retry.maxAttempts}", + // backoff = @Backoff(delayExpression = "${write.retry.maxDelay}") + //) + // @Retryable() + public void persistDataRandom(SensorCollection sensors, int count, Duration interval) { + logger.info("persistDataRandom " + count + " sensor sets at interval: " + interval); + + RetryTemplate retryTemplate = RetryTemplate.builder() + .maxAttempts(10) + .exponentialBackoff(100, 2, 10000) + .retryOn(List.of(InfluxDBApiException.class, FlightRuntimeException.class, ConnectException.class)) + .traversingCauses() + .build(); + + retryTemplate.execute(context -> { + logger.info("DEBUG conext {}", context); + Instant current = Instant.now().minus(Duration.ofMillis(count * interval.toMillis())); + Instant end = Instant.now(); + int current_count = 0; + while (current_count < count) { + List points = new ArrayList<>(); + for (Sensor sensor : sensors.getSensors()) { + Point reading = RandomEnvReading.genReading(sensor).toPoint(measurement, current); + points.add(reading); + logger.info("reading {}", reading.toLineProtocol()); + } + influxDBClientBase.writePoints(points); + current = current.plus(interval); + current_count++; + } + return null; + }); + } + + /* TODO + Runnable randomDataGenerator(Instant start, + Instant end, + Duration pauseInterval) { + if (end.isBefore(start)) { + throw new IllegalArgumentException(String.format("end %s is before start %s", end, start)); + } + return () -> { + while(Instant.now().isBefore(start)) { + logger.info("Waiting to start randomDataGenerator at {}", start); + LockSupport.parkNanos(pauseInterval.toNanos()); + } + while(Instant.now().isBefore(end)) { + logger.info("Waiting to end randomDataGenerator at {}", end); + LockSupport.parkNanos(pauseInterval.toNanos()); + } + logger.info("RandomDataGenerator ending at {}", Instant.now()); + }; + } */ + + @Recover + public void recoverInflux(InfluxDBApiException influxDBApiException) { + logger.info("PersistService recoverInflux {}", influxDBApiException.getMessage()); + } + + @Recover + public void recoverFlight(FlightRuntimeException flightRuntimeException) { + logger.info("PersistService recoverFlight {}", flightRuntimeException.getMessage()); + } + + @Recover void recoverConnect(ConnectException connectException) { + logger.info("PersistService recoverConnect {}", connectException.getMessage()); + } +} diff --git a/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java b/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java new file mode 100644 index 00000000..d3174b6f --- /dev/null +++ b/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java @@ -0,0 +1,110 @@ +package org.influxdb.v3.service; + +import com.influxdb.v3.client.InfluxDBApiException; +import com.influxdb.v3.client.InfluxDBClient; +import com.influxdb.v3.client.PointValues; +import org.apache.arrow.flight.FlightRuntimeException; +import org.influxdb.v3.reading.EnvReading; +import org.influxdb.v3.sensor.Sensor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.retry.annotation.Recover; +import org.springframework.retry.support.RetryTemplate; +import org.springframework.stereotype.Service; + +import javax.annotation.Nonnull; +import java.net.ConnectException; +import java.time.Duration; +import java.time.Instant; +import java.util.List; +import java.util.stream.Stream; + + +@Service +public class ReadingsService { + + Logger logger = LoggerFactory.getLogger(ReadingsService.class); + + @Value("${readings.query1}") + String query1; + + InfluxDBClient influxDBClientBase; + + @Autowired + public ReadingsService(@Qualifier("influxDBClient")InfluxDBClient influxDBClient) { + logger.debug("instantiating ReadingsService"); + this.influxDBClientBase = influxDBClient; + } + + //@Retryable(retryFor = ConnectException.class, + // maxAttemptsExpression = "${query.retry.maxAttempts}", + // backoff = @Backoff(delayExpression = "${query.retry.maxDelay}")) + public Stream getAllReadings() { + RetryTemplate retryTemplate = RetryTemplate.builder() + .retryOn(List.of(InfluxDBApiException.class, + FlightRuntimeException.class, + ConnectException.class)) + .maxAttempts(10) + .exponentialBackoff(Duration.ofMillis(100), 2, Duration.ofSeconds(10)) + .build(); + + return retryTemplate.execute(context -> { + logger.info("ReadingsService getting all readings"); + logger.info("RetryContext {}", context); + return buildEnvReadings(influxDBClientBase.queryPoints(query1)); + }); + } + + public Stream getAllReadingsAsPV(){ + /* RetryTemplate retryTemplate = RetryTemplate.builder() + .retryOn(List.of(InfluxDBApiException.class, + FlightRuntimeException.class, + ConnectException.class)) + .maxAttempts(10) + .exponentialBackoff(Duration.ofMillis(100), 2, Duration.ofSeconds(10)) + .build(); */ + + //return retryTemplate.execute(context -> { + // logger.info("ReadingsService getting all readings"); + // logger.info("RetryContext {}", context); + return influxDBClientBase.queryPoints(query1); + // }); + + } + + public Stream getAllReadingsAsObj(){ + return influxDBClientBase.query(query1); + } + + @Recover + public void recoverInflux(InfluxDBApiException influxDBApiException) { + logger.info("ReadingsService recovering {}", influxDBApiException.getMessage()); + } + + @Recover + public void recoverFlight(FlightRuntimeException flightRuntimeException) { + logger.info("ReadingsService recoverFlight {}", flightRuntimeException.getMessage()); + } + + @Recover void recoverConnect(ConnectException connectException) { + logger.info("ReadingsService recoverConnect {}", connectException.getMessage()); + } + + Stream buildEnvReadings(Stream pointValuesStream) { + return pointValuesStream.map(e -> { + double temp = e.getFloatField("temp") == null ? 0 : e.getFloatField("temp"); + double humid = e.getFloatField("humid") == null ? 0 : e.getFloatField("humid"); + double press = e.getFloatField("press") == null ? 0 : e.getFloatField("press"); + Number timestamp = e.getTimestamp() == null ? 0 : e.getTimestamp(); + return new EnvReading(new Sensor(e.getTag("name"), e.getTag("model"), e.getTag("id")), + temp, humid, press, parseTimestamp(timestamp)); + }); + } + + private static Instant parseTimestamp(@Nonnull Number timestamp){ + return Instant.ofEpochMilli(timestamp.longValue() / 1_000_000); + } +} diff --git a/examples/spring/src/main/resources/application.properties b/examples/spring/src/main/resources/application.properties new file mode 100644 index 00000000..49c48194 --- /dev/null +++ b/examples/spring/src/main/resources/application.properties @@ -0,0 +1,10 @@ +influxdb.url=http://localhost:8181/ +influxdb.token=apiv3_CkSgT0o6oIUEQomAFUbqYYvA3p2bk5EzYHha4gl0d8Ya0F27y-6ql9pDo681Jjw264N0jXZhxW6FOiyKntUGcQ +influxdb.database=my-db +influxdb.measurement=betasensor +app.debug=false +readings.query1=SELECT * FROM "${influxdb.measurement}" ORDER BY time DESC +query.retry.maxAttempts=3 +query.retry.maxDelay=1000 +write.retry.maxAttempts=5 +write.retry.maxDelay=200 diff --git a/examples/spring/src/main/resources/logback.xml b/examples/spring/src/main/resources/logback.xml new file mode 100644 index 00000000..3a4c1ffd --- /dev/null +++ b/examples/spring/src/main/resources/logback.xml @@ -0,0 +1,18 @@ + + + + + + + + + %d{HH:mm:ss.SSS} %blue(%-5level) %magenta(%logger{36}) - %msg %n + + + + + + + + + From 947c18ab47c0e86f001945255b6999a1c6a33fd2 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Tue, 11 Nov 2025 15:29:43 +0100 Subject: [PATCH 2/4] chore: Spring example cleanup --- examples/spring/pom.xml | 129 +++++++----------- .../java/org/influxdb/v3/Application.java | 47 ++++--- .../org/influxdb/v3/config/AppConfig.java | 51 ++++--- .../org/influxdb/v3/reading/EnvReading.java | 50 ++----- .../influxdb/v3/reading/RandomEnvReading.java | 8 +- .../java/org/influxdb/v3/sensor/Sensor.java | 4 +- .../influxdb/v3/sensor/SensorCollection.java | 9 +- .../influxdb/v3/service/PersistService.java | 84 +++--------- .../influxdb/v3/service/ReadingsService.java | 87 ++++-------- .../src/main/resources/application.properties | 9 +- .../spring/src/main/resources/logback.xml | 2 +- 11 files changed, 186 insertions(+), 294 deletions(-) diff --git a/examples/spring/pom.xml b/examples/spring/pom.xml index 246427b3..57da0608 100644 --- a/examples/spring/pom.xml +++ b/examples/spring/pom.xml @@ -3,12 +3,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.influxdb.v3.spring spring-example 1.0-SNAPSHOT @@ -18,20 +12,9 @@ UTF-8 17 6.2.11 + org.influxdb.v3.Application - - org.springframework @@ -58,73 +41,61 @@ influxdb3-java 1.6.0-SNAPSHOT - ch.qos.logback logback-classic - 1.5.18 - - - - - - - - maven-clean-plugin - 3.4.0 - - - - maven-resources-plugin - 3.3.1 - - - maven-compiler-plugin - 3.13.0 - - - maven-surefire-plugin - 3.3.0 - - - maven-jar-plugin - 3.4.2 - - - maven-install-plugin - 3.1.2 - - - maven-deploy-plugin - 3.1.2 - - - - maven-site-plugin - 3.12.1 - - - maven-project-info-reports-plugin - 3.6.1 - - - + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + java + + + + + ${exec.main} + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + 11 + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.2.1 + + true + ../../checkstyle.xml + true + false + + src/main/java + + + + + verify + + checkstyle + + + + + diff --git a/examples/spring/src/main/java/org/influxdb/v3/Application.java b/examples/spring/src/main/java/org/influxdb/v3/Application.java index 0a04ffd1..16102052 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/Application.java +++ b/examples/spring/src/main/java/org/influxdb/v3/Application.java @@ -1,6 +1,9 @@ package org.influxdb.v3; -import com.influxdb.v3.client.PointValues; +import java.time.Duration; +import java.util.stream.Stream; +import javax.annotation.Nonnull; + import org.influxdb.v3.config.AppConfig; import org.influxdb.v3.reading.EnvReading; import org.influxdb.v3.sensor.SensorCollection; @@ -11,17 +14,17 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.stereotype.Component; -import java.io.IOException; -import java.time.Duration; -import java.util.stream.Stream; +import com.influxdb.v3.client.PointValues; @Component -public class Application { +public final class Application { + + private Application() { } static Logger logger = LoggerFactory.getLogger(Application.class); - public static void main(String[] args) throws InterruptedException, IOException { - try(var ctx = new AnnotationConfigApplicationContext(AppConfig.class)) { + public static void main(final String[] args) { + try (var ctx = new AnnotationConfigApplicationContext(AppConfig.class)) { ctx.registerShutdownHook(); SensorCollection sensors = ctx.getBean(SensorCollection.class); @@ -30,16 +33,26 @@ public static void main(String[] args) throws InterruptedException, IOException ReadingsService readingsService = ctx.getBean(ReadingsService.class); logger.info("==== [ Get as Point Values ] ===="); - logPVStream(readingsService.getAllReadingsAsPV()); + /* + Be sure to use streams in try-with-resources blocks, failure to do so + may not close the underlying Arrow FlightStream properly, and + a memory leak can result. + */ + try (Stream stream = readingsService.getAllReadingsAsPV()) { + logPVStream(stream); + } logger.info("==== [ Get as Mapped EnvReadings ] ===="); - logEnvReadingStream(readingsService.getAllReadings()); + try (Stream stream = readingsService.getAllReadings()) { + logEnvReadingStream(stream); + } logger.info("==== [ Get as Object Array ] ===="); - logObjArrayStream(readingsService.getAllReadingsAsObj()); - + try (Stream stream = readingsService.getAllReadingsAsObj()) { + logObjArrayStream(stream); + } } } - public static void logPVStream(Stream pvs) { + public static void logPVStream(final @Nonnull Stream pvs) { StringBuilder pvResults = new StringBuilder(); pvs.forEach(pv -> { pvResults.append(String.format("%s, ", pv.getTimestamp())); @@ -51,21 +64,21 @@ public static void logPVStream(Stream pvs) { pvResults.append(String.format("humid: %3.2f ", pv.getFloatField(("humid")))); pvResults.append("\n"); }); - logger.info("PointValueResults: \n {}\n", pvResults); + logger.info("PointValueResults:\n{}\n", pvResults); } - public static void logObjArrayStream(Stream oas) { + public static void logObjArrayStream(final @Nonnull Stream oas) { StringBuilder results = new StringBuilder(); oas.forEach(o -> { - for(int i = 0; i < o.length;i++) { + for (int i = 0; i < o.length; i++) { results.append(String.format("%s, ", o[i])); } results.append("\n"); }); - logger.info("ObjectArrayStream results: \n {}\n", results); + logger.info("ObjectArrayStream results:\n{}\n", results); } - public static void logEnvReadingStream(Stream evs) { + public static void logEnvReadingStream(final @Nonnull Stream evs) { StringBuilder result = new StringBuilder(); evs.forEach(point -> { result.append(String.format("%s\n", point.toString())); diff --git a/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java b/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java index 1dcf0f57..c277d045 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java +++ b/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java @@ -1,6 +1,9 @@ package org.influxdb.v3.config; -import com.influxdb.v3.client.InfluxDBClient; +import java.net.ConnectException; +import java.util.List; + +import org.apache.arrow.flight.FlightRuntimeException; import org.influxdb.v3.sensor.Sensor; import org.influxdb.v3.sensor.SensorCollection; import org.slf4j.Logger; @@ -12,11 +15,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.retry.annotation.EnableRetry; -import org.springframework.retry.backoff.FixedBackOffPolicy; -import org.springframework.retry.policy.SimpleRetryPolicy; import org.springframework.retry.support.RetryTemplate; -import java.util.List; +import com.influxdb.v3.client.InfluxDBApiException; +import com.influxdb.v3.client.InfluxDBClient; @Configuration @EnableRetry @@ -28,10 +30,9 @@ public class AppConfig { static List sensors = List.of(new Sensor("Able", "R2D2", "123"), new Sensor("Baker", "C3PO", "456"), - new Sensor("Charle", "Robbie", "789"), + new Sensor("Charlie", "Robbie", "789"), new Sensor("Delta", "R2D2", "abc"), - new Sensor( "Easy", "C3PO", "def" - ) + new Sensor("Easy", "C3PO", "def") ); @Value("${influxdb.url}") @@ -43,31 +44,37 @@ public class AppConfig { @Value("${influxdb.database}") private String influxDBDatabase; - @Bean(name={"internalSensors"}) - public SensorCollection sensorCollectionInit(){ + @Bean(name = {"internalSensors"}) + public SensorCollection sensorCollectionInit() { logger.debug("sensorCollection"); return new SensorCollection(sensors); } @Bean - @Qualifier("influxDBClient") - public InfluxDBClient influxDBClient(){ + public InfluxDBClient influxDBClient() { logger.debug("influxDBClientBaseInit with " + influxDBUrl); return InfluxDBClient.getInstance(influxDBUrl, influxDBToken.toCharArray(), influxDBDatabase); } @Bean - public RetryTemplate retryTemplate(){ - RetryTemplate retryTemplate = new RetryTemplate(); - - FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy(); - fixedBackOffPolicy.setBackOffPeriod(2000l); - retryTemplate.setBackOffPolicy(fixedBackOffPolicy); - - SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(); - retryPolicy.setMaxAttempts(2); - retryTemplate.setRetryPolicy(retryPolicy); + @Qualifier("writesTemplate") + public RetryTemplate retryTemplateWrites() { + return RetryTemplate.builder() + .maxAttempts(5) + .exponentialBackoff(100, 2, 10000) + .retryOn(List.of(InfluxDBApiException.class, ConnectException.class)) + .traversingCauses() + .build(); + } - return retryTemplate; + @Bean + @Qualifier("readsTemplate") + public RetryTemplate retryTemplateReads() { + return RetryTemplate.builder() + .maxAttempts(3) + .exponentialBackoff(100, 2, 10000) + .retryOn(List.of(InfluxDBApiException.class, FlightRuntimeException.class, ConnectException.class)) + .traversingCauses() + .build(); } } diff --git a/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java b/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java index f02cbc5c..7ac7c64e 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java +++ b/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java @@ -1,9 +1,11 @@ package org.influxdb.v3.reading; -import com.influxdb.v3.client.Point; +import java.time.Instant; +import javax.annotation.Nonnull; + import org.influxdb.v3.sensor.Sensor; -import java.time.Instant; +import com.influxdb.v3.client.Point; public class EnvReading { @@ -13,14 +15,21 @@ public class EnvReading { double pressure; Instant timestamp; - public EnvReading(Sensor sensor, double temperature, double humidity, double pressure) { + public EnvReading(final @Nonnull Sensor sensor, + final double temperature, + final double humidity, + final double pressure) { this.sensor = sensor; this.temperature = temperature; this.humidity = humidity; this.pressure = pressure; } - public EnvReading(Sensor sensor, double temperature, double humidity, double pressure, Instant timestamp) { + public EnvReading(final @Nonnull Sensor sensor, + final double temperature, + final double humidity, + final double pressure, + final @Nonnull Instant timestamp) { this.sensor = sensor; this.temperature = temperature; this.humidity = humidity; @@ -28,38 +37,7 @@ public EnvReading(Sensor sensor, double temperature, double humidity, double pre this.timestamp = timestamp; } - - public Sensor getSensor() { - return this.sensor; - } - - public void setSensor(Sensor sensor) { - this.sensor = sensor; - } - - public double getTemperature() { - return this.temperature; - } - - public void setTemperature(double temperature) { - this.temperature = temperature; - } - - public double getHumidity() { - return this.humidity; - } - - public void setHumidity(double humidity) { - this.humidity = humidity; - } - public double getPressure() { - return this.pressure; - } - public void setPressure(double pressure) { - this.pressure = pressure; - } - - public Point toPoint(String measurement, Instant timestamp) { + public Point toPoint(final String measurement, final @Nonnull Instant timestamp) { if (this.timestamp == null) { this.timestamp = timestamp; } diff --git a/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java b/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java index bacdabfe..7feb6756 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java +++ b/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java @@ -1,10 +1,14 @@ package org.influxdb.v3.reading; +import javax.annotation.Nonnull; + import org.influxdb.v3.sensor.Sensor; -public class RandomEnvReading { +public final class RandomEnvReading { + + private RandomEnvReading() { } - public static EnvReading genReading(Sensor sensor){ + public static EnvReading genReading(final @Nonnull Sensor sensor) { return new EnvReading(sensor, (Math.random() * 40.0) + (Math.random() * 40.0) - 20.0, (Math.random() * 60) + (Math.random() * 40), diff --git a/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java b/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java index e9c5d56e..673991d1 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java +++ b/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java @@ -8,7 +8,9 @@ public class Sensor { String model; String id; - public Sensor(String name, String model, String id) { + public Sensor(final String name, + final String model, + final String id) { this.name = name; this.model = model; this.id = id; diff --git a/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java b/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java index 10a7d3f2..60235c64 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java +++ b/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java @@ -1,15 +1,16 @@ package org.influxdb.v3.sensor; -import org.springframework.beans.factory.annotation.Autowired; - import java.util.List; +import javax.annotation.Nonnull; + +import org.springframework.beans.factory.annotation.Autowired; public class SensorCollection { List sensors; @Autowired - public SensorCollection(List sensors){ + public SensorCollection(final @Nonnull List sensors) { this.sensors = sensors; } @@ -17,7 +18,7 @@ public List getSensors() { return sensors; } - public void setSensors(List sensors) { + public void setSensors(final @Nonnull List sensors) { this.sensors = sensors; } } diff --git a/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java b/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java index 9e3856f4..8d84ec60 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java +++ b/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java @@ -1,9 +1,10 @@ package org.influxdb.v3.service; -import com.influxdb.v3.client.InfluxDBApiException; -import com.influxdb.v3.client.InfluxDBClient; -import com.influxdb.v3.client.Point; -import org.apache.arrow.flight.FlightRuntimeException; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; + import org.influxdb.v3.reading.RandomEnvReading; import org.influxdb.v3.sensor.Sensor; import org.influxdb.v3.sensor.SensorCollection; @@ -12,15 +13,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -import org.springframework.retry.annotation.Recover; import org.springframework.retry.support.RetryTemplate; import org.springframework.stereotype.Service; -import java.net.ConnectException; -import java.time.Duration; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; +import com.influxdb.v3.client.InfluxDBClient; +import com.influxdb.v3.client.Point; @Service public class PersistService { @@ -32,35 +29,24 @@ public class PersistService { @Value("${influxdb.measurement}") String measurement; - @Value("${app.debug}") - boolean debug; + RetryTemplate retryTemplate; @Autowired - public PersistService(@Qualifier("influxDBClient")InfluxDBClient influxDBClient) { + public PersistService(final InfluxDBClient influxDBClient, + final @Qualifier("writesTemplate")RetryTemplate retryTemplateWrites) { this.influxDBClientBase = influxDBClient; + this.retryTemplate = retryTemplateWrites; } - //@Retryable(retryFor = {InfluxDBApiException.class}, - // maxAttemptsExpression = "${write.retry.maxAttempts}", - // backoff = @Backoff(delayExpression = "${write.retry.maxDelay}") - //) - // @Retryable() - public void persistDataRandom(SensorCollection sensors, int count, Duration interval) { - logger.info("persistDataRandom " + count + " sensor sets at interval: " + interval); - - RetryTemplate retryTemplate = RetryTemplate.builder() - .maxAttempts(10) - .exponentialBackoff(100, 2, 10000) - .retryOn(List.of(InfluxDBApiException.class, FlightRuntimeException.class, ConnectException.class)) - .traversingCauses() - .build(); + public void persistDataRandom(final SensorCollection sensors, final int count, final Duration interval) { - retryTemplate.execute(context -> { - logger.info("DEBUG conext {}", context); + this.retryTemplate.execute(context -> { + logger.info("persistDataRandom " + count + " sensor sets at interval: " + interval); + logger.info("context {}", context); Instant current = Instant.now().minus(Duration.ofMillis(count * interval.toMillis())); Instant end = Instant.now(); - int current_count = 0; - while (current_count < count) { + int currentCount = 0; + while (currentCount < count) { List points = new ArrayList<>(); for (Sensor sensor : sensors.getSensors()) { Point reading = RandomEnvReading.genReading(sensor).toPoint(measurement, current); @@ -69,43 +55,9 @@ public void persistDataRandom(SensorCollection sensors, int count, Duration inte } influxDBClientBase.writePoints(points); current = current.plus(interval); - current_count++; + currentCount++; } return null; }); } - - /* TODO - Runnable randomDataGenerator(Instant start, - Instant end, - Duration pauseInterval) { - if (end.isBefore(start)) { - throw new IllegalArgumentException(String.format("end %s is before start %s", end, start)); - } - return () -> { - while(Instant.now().isBefore(start)) { - logger.info("Waiting to start randomDataGenerator at {}", start); - LockSupport.parkNanos(pauseInterval.toNanos()); - } - while(Instant.now().isBefore(end)) { - logger.info("Waiting to end randomDataGenerator at {}", end); - LockSupport.parkNanos(pauseInterval.toNanos()); - } - logger.info("RandomDataGenerator ending at {}", Instant.now()); - }; - } */ - - @Recover - public void recoverInflux(InfluxDBApiException influxDBApiException) { - logger.info("PersistService recoverInflux {}", influxDBApiException.getMessage()); - } - - @Recover - public void recoverFlight(FlightRuntimeException flightRuntimeException) { - logger.info("PersistService recoverFlight {}", flightRuntimeException.getMessage()); - } - - @Recover void recoverConnect(ConnectException connectException) { - logger.info("PersistService recoverConnect {}", connectException.getMessage()); - } } diff --git a/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java b/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java index d3174b6f..37da7460 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java +++ b/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java @@ -1,9 +1,9 @@ package org.influxdb.v3.service; -import com.influxdb.v3.client.InfluxDBApiException; -import com.influxdb.v3.client.InfluxDBClient; -import com.influxdb.v3.client.PointValues; -import org.apache.arrow.flight.FlightRuntimeException; +import java.time.Instant; +import java.util.stream.Stream; +import javax.annotation.Nonnull; + import org.influxdb.v3.reading.EnvReading; import org.influxdb.v3.sensor.Sensor; import org.slf4j.Logger; @@ -11,17 +11,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -import org.springframework.retry.annotation.Recover; import org.springframework.retry.support.RetryTemplate; import org.springframework.stereotype.Service; -import javax.annotation.Nonnull; -import java.net.ConnectException; -import java.time.Duration; -import java.time.Instant; -import java.util.List; -import java.util.stream.Stream; - +import com.influxdb.v3.client.InfluxDBClient; +import com.influxdb.v3.client.PointValues; @Service public class ReadingsService { @@ -33,67 +27,42 @@ public class ReadingsService { InfluxDBClient influxDBClientBase; + RetryTemplate retryTemplate; + @Autowired - public ReadingsService(@Qualifier("influxDBClient")InfluxDBClient influxDBClient) { + public ReadingsService(final InfluxDBClient influxDBClient, + final @Qualifier("readsTemplate") RetryTemplate retryTemplateReads) { logger.debug("instantiating ReadingsService"); this.influxDBClientBase = influxDBClient; + this.retryTemplate = retryTemplateReads; } - //@Retryable(retryFor = ConnectException.class, - // maxAttemptsExpression = "${query.retry.maxAttempts}", - // backoff = @Backoff(delayExpression = "${query.retry.maxDelay}")) public Stream getAllReadings() { - RetryTemplate retryTemplate = RetryTemplate.builder() - .retryOn(List.of(InfluxDBApiException.class, - FlightRuntimeException.class, - ConnectException.class)) - .maxAttempts(10) - .exponentialBackoff(Duration.ofMillis(100), 2, Duration.ofSeconds(10)) - .build(); - - return retryTemplate.execute(context -> { - logger.info("ReadingsService getting all readings"); + System.out.println("DEBUG query1 " + query1); + return this.retryTemplate.execute(context -> { + logger.info("getting all readings"); logger.info("RetryContext {}", context); return buildEnvReadings(influxDBClientBase.queryPoints(query1)); }); } - public Stream getAllReadingsAsPV(){ - /* RetryTemplate retryTemplate = RetryTemplate.builder() - .retryOn(List.of(InfluxDBApiException.class, - FlightRuntimeException.class, - ConnectException.class)) - .maxAttempts(10) - .exponentialBackoff(Duration.ofMillis(100), 2, Duration.ofSeconds(10)) - .build(); */ - - //return retryTemplate.execute(context -> { - // logger.info("ReadingsService getting all readings"); - // logger.info("RetryContext {}", context); - return influxDBClientBase.queryPoints(query1); - // }); - - } - - public Stream getAllReadingsAsObj(){ - return influxDBClientBase.query(query1); + public Stream getAllReadingsAsPV() { + return this.retryTemplate.execute(context -> { + logger.info("getting all readings as PointValues"); + logger.info("RetryContext {}", context); + return influxDBClientBase.queryPoints(query1); + }); } - @Recover - public void recoverInflux(InfluxDBApiException influxDBApiException) { - logger.info("ReadingsService recovering {}", influxDBApiException.getMessage()); - } - - @Recover - public void recoverFlight(FlightRuntimeException flightRuntimeException) { - logger.info("ReadingsService recoverFlight {}", flightRuntimeException.getMessage()); - } - - @Recover void recoverConnect(ConnectException connectException) { - logger.info("ReadingsService recoverConnect {}", connectException.getMessage()); + public Stream getAllReadingsAsObj() { + return this.retryTemplate.execute(context -> { + logger.info("getting all readings as Object"); + logger.info("RetryContext {}", context); + return influxDBClientBase.query(query1); + }); } - Stream buildEnvReadings(Stream pointValuesStream) { + Stream buildEnvReadings(final Stream pointValuesStream) { return pointValuesStream.map(e -> { double temp = e.getFloatField("temp") == null ? 0 : e.getFloatField("temp"); double humid = e.getFloatField("humid") == null ? 0 : e.getFloatField("humid"); @@ -104,7 +73,7 @@ Stream buildEnvReadings(Stream pointValuesStream) { }); } - private static Instant parseTimestamp(@Nonnull Number timestamp){ + private static Instant parseTimestamp(final @Nonnull Number timestamp) { return Instant.ofEpochMilli(timestamp.longValue() / 1_000_000); } } diff --git a/examples/spring/src/main/resources/application.properties b/examples/spring/src/main/resources/application.properties index 49c48194..91e09a78 100644 --- a/examples/spring/src/main/resources/application.properties +++ b/examples/spring/src/main/resources/application.properties @@ -1,10 +1,5 @@ influxdb.url=http://localhost:8181/ -influxdb.token=apiv3_CkSgT0o6oIUEQomAFUbqYYvA3p2bk5EzYHha4gl0d8Ya0F27y-6ql9pDo681Jjw264N0jXZhxW6FOiyKntUGcQ +influxdb.token=my-token influxdb.database=my-db -influxdb.measurement=betasensor -app.debug=false +influxdb.measurement=springsensor readings.query1=SELECT * FROM "${influxdb.measurement}" ORDER BY time DESC -query.retry.maxAttempts=3 -query.retry.maxDelay=1000 -write.retry.maxAttempts=5 -write.retry.maxDelay=200 diff --git a/examples/spring/src/main/resources/logback.xml b/examples/spring/src/main/resources/logback.xml index 3a4c1ffd..9f1204ad 100644 --- a/examples/spring/src/main/resources/logback.xml +++ b/examples/spring/src/main/resources/logback.xml @@ -12,7 +12,7 @@ - + From 7a4fe345958b4765d942b1ac444ed5af65ce0af0 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Tue, 11 Nov 2025 16:34:21 +0100 Subject: [PATCH 3/4] chore: add license info to example files. --- .../java/org/influxdb/v3/Application.java | 21 +++++++++++++++++++ .../org/influxdb/v3/config/AppConfig.java | 21 +++++++++++++++++++ .../org/influxdb/v3/reading/EnvReading.java | 21 +++++++++++++++++++ .../influxdb/v3/reading/RandomEnvReading.java | 21 +++++++++++++++++++ .../java/org/influxdb/v3/sensor/Sensor.java | 21 +++++++++++++++++++ .../influxdb/v3/sensor/SensorCollection.java | 21 +++++++++++++++++++ .../influxdb/v3/service/PersistService.java | 21 +++++++++++++++++++ .../influxdb/v3/service/ReadingsService.java | 21 +++++++++++++++++++ 8 files changed, 168 insertions(+) diff --git a/examples/spring/src/main/java/org/influxdb/v3/Application.java b/examples/spring/src/main/java/org/influxdb/v3/Application.java index 16102052..e16654e7 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/Application.java +++ b/examples/spring/src/main/java/org/influxdb/v3/Application.java @@ -1,3 +1,24 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.influxdb.v3; import java.time.Duration; diff --git a/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java b/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java index c277d045..b08d1073 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java +++ b/examples/spring/src/main/java/org/influxdb/v3/config/AppConfig.java @@ -1,3 +1,24 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.influxdb.v3.config; import java.net.ConnectException; diff --git a/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java b/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java index 7ac7c64e..bda41507 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java +++ b/examples/spring/src/main/java/org/influxdb/v3/reading/EnvReading.java @@ -1,3 +1,24 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.influxdb.v3.reading; import java.time.Instant; diff --git a/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java b/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java index 7feb6756..6ee9f71c 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java +++ b/examples/spring/src/main/java/org/influxdb/v3/reading/RandomEnvReading.java @@ -1,3 +1,24 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.influxdb.v3.reading; import javax.annotation.Nonnull; diff --git a/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java b/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java index 673991d1..63443cb5 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java +++ b/examples/spring/src/main/java/org/influxdb/v3/sensor/Sensor.java @@ -1,3 +1,24 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.influxdb.v3.sensor; import java.util.Map; diff --git a/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java b/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java index 60235c64..13851d6b 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java +++ b/examples/spring/src/main/java/org/influxdb/v3/sensor/SensorCollection.java @@ -1,3 +1,24 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.influxdb.v3.sensor; import java.util.List; diff --git a/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java b/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java index 8d84ec60..41474117 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java +++ b/examples/spring/src/main/java/org/influxdb/v3/service/PersistService.java @@ -1,3 +1,24 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.influxdb.v3.service; import java.time.Duration; diff --git a/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java b/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java index 37da7460..51fb362a 100644 --- a/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java +++ b/examples/spring/src/main/java/org/influxdb/v3/service/ReadingsService.java @@ -1,3 +1,24 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.influxdb.v3.service; import java.time.Instant; From ad2cc948bf9a04d73106ea82999bbf42507e11d9 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Tue, 11 Nov 2025 17:02:33 +0100 Subject: [PATCH 4/4] chore: fix license checks for non-code files in examples. --- examples/spring/pom.xml | 24 +++++++++++++++++++++++- pom.xml | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/examples/spring/pom.xml b/examples/spring/pom.xml index 57da0608..ff1134b9 100644 --- a/examples/spring/pom.xml +++ b/examples/spring/pom.xml @@ -1,4 +1,26 @@ - + 4.0.0 diff --git a/pom.xml b/pom.xml index 70be09cb..bf950bc7 100644 --- a/pom.xml +++ b/pom.xml @@ -417,7 +417,7 @@ **/target/**, **/*.jar, **/.git/**, **/.*, **/*.png, **/*.iml, **/*.bolt, .idea/**, **/*nightly*/**, **/.m2/**, LICENSE, **/*.md, **/.github/**, license_header.txt, release.properties/, **/pom.xml.releaseBackup, **/pom.xml.tag, **/semantic.yml, - .circleci/config.yml, **/*.pem + .circleci/config.yml, **/*.pem, **/resources/*.properties, **/resources/*.xml