Hi Andrea,
The other time that affects write-frequency is in
RebindManagerImpl.periodicPersistPeriod. This is the major one as
it affects the maximum frequency that (changed) entities/locations
will be persisted.
---
For some code pointers into hooking in the blob-store
persistence...
See BrooklynMementoPersisterToMultiFile for where we control
writing to and reading from the file system.
I suspect this could be generalised so that it isn't just about
files.
It delegates to... MementoFileWriter. This is the file-specific
piece that you'd want to replace. However, it also includes
generic logic to handle concurrency: if asked to write,write,write
then it handles queuing up these writes and discarding the middle
write if the new request comes in before the middle one has
started (etc). It also handles concurrent calls to write/delete to
ensure that the last-update wins.
---
Rather than completely duplicating these classes, it's probably
worth starting with an interface such as:
public interface ObjectStore {
public interface ObjectAccessor<T> {
void writeAsync(T val);
void deleteAsync();
T read();
}
/**
* For reading/writing data to the given path.
* For example, if a file-based ObjectStore is configured
to write to file://path/to/root/
* then subPath=abc would read/write data to file://path/to/root/abc
*/
ObjectAccessor newAccessor(String subPath);
/**
* Lists the paths of objects contained at the given
path.
* For example, if a
file-based ObjectStore is configured to write to
file://path/to/root/
* then parentSubPath=entities would return the
contents of /path/to/root/entities/, such as
* [entities/e1, entities/e2, entities/e3].
* The returned
paths values are usable in calls to {@link
#newAccessor(String)}.
*/
List<String> listContents(String parentSubPath);
/**
* Makes a copy of all objects under parentSubPath.
* For example, if a
file-based ObjectStore is configured to write to
file://path/to/root/
* then parentSubPath="abc",
backupSubPath="abc.bak" would be the same as:
* `cp -R
/path/to/root/abc/*
/path/to/root/abc.bak/`
*/
void backupContents(String parentSubPath,
backupSubPath);
/**
* Closes all resources used by this ObjectStore. No
subsequent calls should be made to the ObjectStore;
* behaviour of such calls is undefined but likely to
throw exceptions.
*/
void close();
}
The BrooklynMementoPersisterToMultiFile could then be refactored
to use this, and the existing file-based code refactored to
implement that interface.
Does that make sense to you?
Thoughts?
Aled