Read-Only Storage Manager
It is possible to have a Storage Manager which operates in a read-only mode. Since there is a limitation in EclipseStore that you can have only one manager that is connected to one data storage, you can bypass this restriction with this read-only mode. But there are limitations, such as:
In read-only mode, you cannot write to a data storage. This means calls to
.store()and other methods resulting in a write will throw an exception.
In read-only mode, the housekeeping processes do not run since that would corrupt the data storage because two managers operate on the same 'files'.
In read-only mode, your data root is filled on startup of the manager as usual, and lazy references operate as normal. However, there is no notification mechanism that the underlying data storage has changed, and the Storage Manager only remembers the structure of the data storage as it was when it started.
The last bullet point is important. It indicates that when another Storage Manager writes some new data, this new data never gets picked up by this read-only manager. When the other Storage Manager housekeeping process removes a file or reorganizes a file as cleanup, an exception will be thrown as the structure is changed but still expected by the read-only manager.
So, the read-only manager can only be used to read some data but should be closed 'soon' after starting, and a new manager should be created if you need to read data later on.
The following snippet shows how to make a read-only Storage Manager. It actually wraps the
StorageWriteController configured by the Foundation and can either block or pass through the normal behaviour.
EmbeddedStorageFoundation<?> foundation = ...
final StorageWriteControllerReadOnlyMode storageWriteController =
.setReadOnly() method, you can switch the read-only mode of the Storage Manager after it has started. But be careful with the method because you can’t have more than one manager that writes to the same data storage, as that would corrupt the storage.