Interface MongoDriver<R extends io.vena.bosk.StateTreeNode>
- All Superinterfaces:
io.vena.bosk.BoskDriver<R>
BoskDriver that maintains the bosk state in a MongoDB database.
Multiple bosks, potentially in multiple separate processes,
can be configured to use the same database, thereby creating a replica set
with all bosks sharing the same state and receiving updates from each other.
For convenience, if the database does not exist at the time of initialization,
this driver will create it and populate it with the state returned by calling
BoskDriver.initialRoot(java.lang.reflect.Type) on the downstream driver.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceMongoDriver.MongoDriverFactory<RR extends io.vena.bosk.StateTreeNode> -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Frees up resources used by this driver and leaves it unusable.static <RR extends io.vena.bosk.StateTreeNode>
MongoDriver.MongoDriverFactory<RR>factory(com.mongodb.MongoClientSettings clientSettings, MongoDriverSettings driverSettings, BsonPlugin bsonPlugin) Requires aBosk.ReadContext.voidDeserializes and re-serializes the entire bosk contents, thus updating the database to match the current serialized format.Methods inherited from interface io.vena.bosk.BoskDriver
flush, initialRoot, submitConditionalDeletion, submitConditionalReplacement, submitDeletion, submitInitialization, submitReplacement, submitReplacement
-
Method Details
-
refurbish
Deserializes and re-serializes the entire bosk contents, thus updating the database to match the current serialized format.Used to "upgrade" the database contents for schema evolution.
This method does not simply write the current in-memory bosk contents back into the database, because that would lead to race conditions with other update operations. Instead, in a causally-consistent transaction, it reads the current database state, deserializes it, re-serializes it, and writes it back. This produces predictable results even if done concurrently with other database updates.
This requires the database state to be in good condition at the outset; it can't generally be used to repair corrupted databases unless the corruption is so mild that it doesn't interfere with proper functioning beforehand. It can be expected to evolve the database from that of a supported prior format, but for unsupported formats or other corruption, YMMV.
- Throws:
IOException
-
readStatus
Requires aBosk.ReadContext.- Throws:
Exception
-
close
void close()Frees up resources used by this driver and leaves it unusable.This is done on a best-effort basis. It's more useful for tests than for production code, where there's usually no reason to close a driver.
-
factory
static <RR extends io.vena.bosk.StateTreeNode> MongoDriver.MongoDriverFactory<RR> factory(com.mongodb.MongoClientSettings clientSettings, MongoDriverSettings driverSettings, BsonPlugin bsonPlugin)
-