Package dev.frostlake.persistence
Class PersistenceManager
java.lang.Object
dev.frostlake.persistence.PersistenceManager
Manages persistence of catalog metadata and table data to disk
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyState(CatalogSnapshot snapshot, MemoryTableDataStore tableData, Catalog catalog, StorageEngine storageEngine) Apply an in-memory engine state (frombuildState(dev.frostlake.metastore.Catalog, dev.frostlake.storage.StorageEngine, dev.frostlake.persistence.MemoryTableDataStore)) into a fresh catalog + storage.buildState(Catalog catalog, StorageEngine storageEngine, MemoryTableDataStore tableData) Build the full engine state entirely in memory — the write half of an in-JVM engine clone.voidcheckpointTo(Path dir, Catalog catalog, StorageEngine storageEngine) Write a full state snapshot (catalog + table data) intodir, regardless of thepersistence.enabledflag — the durable side of a WAL checkpoint.voidclearAll()Clear all persisted datavoidInitialize persistence directory structurevoidloadCatalog(Catalog catalog, StorageEngine storageEngine) Load catalog metadata from diskvoidNote that a statement ran (or was attempted — a failed one can still leave a persistent change, e.g. an advanced sequence), so the next autosave interval must write.voidrestoreFrom(Path dir, Catalog catalog, StorageEngine storageEngine) Restore a full state snapshot previously written bycheckpointTo(java.nio.file.Path, dev.frostlake.metastore.Catalog, dev.frostlake.storage.StorageEngine)into the live catalog + storage, regardless of thepersistence.enabledflag — used during WAL recovery.voidsaveCatalog(Catalog catalog, StorageEngine storageEngine) Save catalog metadata to diskvoidstartAutoSave(Catalog catalog, StorageEngine storageEngine) Start auto-save scheduler if enabledvoidStop auto-save scheduler
-
Constructor Details
-
PersistenceManager
-
-
Method Details
-
noteStatementExecuted
public void noteStatementExecuted()Note that a statement ran (or was attempted — a failed one can still leave a persistent change, e.g. an advanced sequence), so the next autosave interval must write. -
initialize
Initialize persistence directory structure- Throws:
IOException
-
startAutoSave
Start auto-save scheduler if enabled -
stopAutoSave
public void stopAutoSave()Stop auto-save scheduler -
checkpointTo
Write a full state snapshot (catalog + table data) intodir, regardless of thepersistence.enabledflag — the durable side of a WAL checkpoint. The WAL records this snapshot's reference only after this returns, so a crash here just leaves an ignored orphan directory.- Throws:
IOException
-
buildState
public CatalogSnapshot buildState(Catalog catalog, StorageEngine storageEngine, MemoryTableDataStore tableData) throws IOException Build the full engine state entirely in memory — the write half of an in-JVM engine clone. The catalog snapshot is returned; every table's rows land intableData.- Throws:
IOException
-
applyState
public void applyState(CatalogSnapshot snapshot, MemoryTableDataStore tableData, Catalog catalog, StorageEngine storageEngine) throws IOException, ClassNotFoundException Apply an in-memory engine state (frombuildState(dev.frostlake.metastore.Catalog, dev.frostlake.storage.StorageEngine, dev.frostlake.persistence.MemoryTableDataStore)) into a fresh catalog + storage.- Throws:
IOExceptionClassNotFoundException
-
restoreFrom
public void restoreFrom(Path dir, Catalog catalog, StorageEngine storageEngine) throws IOException, ClassNotFoundException Restore a full state snapshot previously written bycheckpointTo(java.nio.file.Path, dev.frostlake.metastore.Catalog, dev.frostlake.storage.StorageEngine)into the live catalog + storage, regardless of thepersistence.enabledflag — used during WAL recovery.- Throws:
IOExceptionClassNotFoundException
-
saveCatalog
Save catalog metadata to disk- Throws:
IOException
-
loadCatalog
public void loadCatalog(Catalog catalog, StorageEngine storageEngine) throws IOException, ClassNotFoundException Load catalog metadata from disk- Throws:
IOExceptionClassNotFoundException
-
clearAll
Clear all persisted data- Throws:
IOException
-