Skip to content

Storage Backends

shvquu edited this page Jun 15, 2026 · 1 revision

Storage Backends

ServerDoctor persists performance history, conflicts, security risks, recommendations and plugin inventory through a single StorageProvider abstraction with five interchangeable repositories. Five backends ship in the box.

All backends are selected via storage.type in Configuration. The storage module is framework-free: the platform adapter reads the config and hands the storage layer a plain StorageConfig, so no Bukkit/Velocity types leak into persistence.

In-Memory

  • type: memory
  • No credentials, nothing written to disk; everything is lost on restart.
  • Intended for testing or ephemeral setups, and used as the last-resort fallback.

SQLite

  • type: sqlite, sqlite.file: "serverdoctor.db"
  • Embedded, zero-setup, single file in the data folder.
  • Access is serialized through one connection (a single-writer model).
  • Best for a single node with local disk.

PostgreSQL

  • type: postgresql
  • Pooled via HikariCP; the schema is created automatically (CREATE TABLE IF NOT EXISTS).
  • Driver: org.postgresql:postgresql.
  • Tables: performance, conflicts, security_risks, recommendations, plugin_inventory.
  • Recommended for networks — multiple ServerDoctor instances can share one database.

MariaDB / MySQL

  • type: mariadb
  • Same pooled JDBC backend as PostgreSQL, only the SQL dialect differs (auto-increment key, DOUBLE, ON DUPLICATE KEY).
  • Driver: org.mariadb.jdbc:mariadb-java-client (also works against MySQL servers).
  • Indexed timestamp columns are VARCHAR(64) to satisfy MariaDB's index rules.

MongoDB

  • type: mongodb
  • Driver: org.mongodb:mongodb-driver-sync.
  • Collections: performance, conflicts, security_risks, recommendations, plugin_inventory. Each plugin-inventory snapshot is one document with an embedded plugins array. "Most recent first" ordering uses the documents' _id.
  • Accepts either discrete host/port/username/password/auth-database fields or a full connection-string (e.g. an Atlas mongodb+srv://… URI), which takes precedence.

Connection pooling

PostgreSQL and MariaDB use HikariCP (max pool size 10, min idle 2, 30s connection timeout, 30min max lifetime). Pooling also handles reconnects, so a server-side idle timeout won't break persistence.

Jar size note

All four drivers are bundled into the universal jar. The MongoDB driver plus BSON is the largest. If you only use SQL backends, you can drop the mongodb-driver-sync dependency in serverdoctor-storage/build.gradle.kts to keep the jar smaller — only type: mongodb is then unavailable.

Networks

On a multi-node network, point the proxy and every backend server at the same PostgreSQL/MariaDB/MongoDB. They all write into one store, giving you a network-wide history. SQLite and In-Memory are per-node only.

Clone this wiki locally