feat(driver): introduce sqlite-jdbc dependency and buffer config properties

Add sqlite-jdbc 3.53.2.0 to parent pom dependencyManagement; add sqlite-jdbc and HikariCP to dc3-common-driver pom; add BufferProperties nested group to DriverProperties; add BUFFER_REPUBLISH_SCHEDULE_JOB constant to ScheduleConstant
This commit is contained in:
pnoker
2026-07-26 00:13:29 +08:00
parent e3d335b56d
commit f019e2066b
4 changed files with 92 additions and 0 deletions
@@ -54,6 +54,11 @@ public class ScheduleConstant {
*/
public static final String DEVICE_HEALTH_SCHEDULE_JOB = "device-health-schedule-job";
/**
* Buffer republish schedule job
*/
public static final String BUFFER_REPUBLISH_SCHEDULE_JOB = "buffer-republish-schedule-job";
/**
* Driver health schedule cron
*/
+10
View File
@@ -77,6 +77,16 @@
<artifactId>caffeine</artifactId>
</dependency>
<!-- Embedded database for the local point-value buffer (resume on broker outage) -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<!-- DC3 API Related -->
<dependency>
<groupId>io.github.pnoker</groupId>
@@ -94,6 +94,12 @@ public class DriverProperties {
@Valid
private HealthProperties health = new HealthProperties();
/**
* Local buffer configuration for point-value resume on broker outage.
*/
@Valid
private BufferProperties buffer = new BufferProperties();
/**
* Metadata cache tuning for the driver runtime.
*/
@@ -283,4 +289,65 @@ public class DriverProperties {
}
/**
* Local point-value buffer options. Failed/NACKed point values are persisted to an
* embedded SQLite database and republished by a Quartz job once the broker recovers,
* so a RabbitMQ outage no longer loses collected readings.
*/
@Getter
@Setter
public static class BufferProperties {
/**
* Whether to persist failed/NACKed point values locally for later republish.
* On by default so drivers resume broker outages out of the box.
*/
private Boolean enabled = true;
/**
* SQLite database path, relative to the driver working directory. Mirrors the
* {@code dc3/logs} layout so each driver writes its own buffer file.
*/
@NotBlank(message = "Buffer db path can't be empty")
private String dbPath = "dc3/data/driver/buffer.db";
/**
* Upper bound on the buffer database size in megabytes. When exceeded the oldest
* records are evicted to keep the newest readings (capacity over completeness).
*/
@Min(1)
private long maxSizeMb = 256;
/**
* Number of buffered point values republished per Quartz tick.
*/
@Min(1)
private int batchSize = 200;
/**
* Quartz cron expression for the buffer republish job.
*/
@NotBlank(message = "Buffer republish cron can't be empty")
private String republishCron = "0/10 * * * * ?";
/**
* Maximum republish attempts before a buffered record is dropped as poison.
*/
@Min(1)
private int maxRetry = 50;
/**
* Initial backoff before the first republish retry, in seconds.
*/
@Min(1)
private long backoffSeconds = 10;
/**
* Upper bound the doubling backoff is capped at, in seconds.
*/
@Min(1)
private long maxBackoffSeconds = 600;
}
}
+10
View File
@@ -91,6 +91,9 @@
<!-- Data access -->
<mybatis.plus.version>3.5.16</mybatis.plus.version>
<mybatis.plus.dynamic.version>4.5.0</mybatis.plus.dynamic.version>
<!-- Embedded database for the driver local point-value buffer -->
<sqlite-jdbc.version>3.53.2.0</sqlite-jdbc.version>
<!-- Serialization and data formats -->
<tools.jackson.version>3.1.4</tools.jackson.version>
@@ -307,6 +310,13 @@
<scope>import</scope>
</dependency>
<!-- Embedded database for the driver local point-value buffer -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite-jdbc.version}</version>
</dependency>
<!-- Test toolchain -->
<dependency>
<groupId>org.assertj</groupId>