com.apama.memorystore
Event Storage
MemoryStore factory interface for creating Store event objects.
There are two different types of Store supported by MemoryStore: - In-memory only (nothing persisted to disk)
- MemoryStore database file (committed changes are persisted to disk when the persist() action is called)
To use the MemoryStore, create a monitor field (or variable) to hold the Storage factory event, and use one of the prepare* actions to asynchronously get a Store of the desired type ready for use, and give it a unique name. Once the store has been prepared, use the open(name) action to get a Store event that can be used to interact with the store.
e.g.
using com.apama.memorystore.Storage;
using com.apama.memorystore.Store;
using com.apama.memorystore.Finished;
monitor Test {
Storage storage;
Store store;
action onload() {
integer id := storage.prepareOrCreate("storename", "/tmp/example.dat");
Finished f;
on Finished(id=id):f
{
if not f.success { log "Store creation failed: "+f.status at ERROR; die; }
store := storage.open("storename");
...
}
}
}
- See Also:
- com.apama.memorystore.Store - The purpose of the Storage event is to prepare and open stores.
- com.apama.memorystore.Storage.prepareOrCreate() - The most commonly used action for preparing a persistent Store.
- com.apama.memorystore.Storage.open() - Once a store has been prepared it can be opened.
| Action summary |
boolean | static hasStore(string name)
Indicate whether or not a Store with the specified name has been prepared already. |
com.apama.memorystore.Store | static open(string name)
Open a named Store that has already been prepared, ready for use by this monitor instance. |
integer | static prepare(string name, string filename)
Prepare a file-based read-write store associated with an existing MemoryStore database file on disk. |
integer | static prepareInMemory(string name)
Prepare an in-memory read-write store to be opened and used by the application. |
integer | static prepareOrCreate(string name, string filename)
Prepare a file-based read-write store associated with a MemoryStore database file on disk, which will be created if it does not exist already. |
integer | static prepareReadOnly(string name, string filename)
Prepare a file-based read-only store associated with an existing MemoryStore database file on disk. |
hasStore
boolean static hasStore(string name)
Indicate whether or not a Store with the specified name has been prepared already.- Parameters:
- name - A unique name identifying this Store.
- Returns:
- True if it is safe to call open() on the specified store; false if preparation failed or is still in progress.
open
com.apama.memorystore.Store static open(string name)
Open a named Store that has already been prepared, ready for use by this monitor instance.
Every monitor instance should prepare and open the stores it needs. Multiple monitor instances can have the same table open at the same time.
It is an error to call open() before a prepare call for the table has finished without error.
Note that opening a store will not immediately bring all that store's tables into memory, this only happens when each individual table is itself prepared and opened.- Parameters:
- name - A unique name identifying this Store.
prepare
integer static prepare(string name, string filename)
Prepare a file-based read-write store associated with an existing MemoryStore database file on disk.
The specified file must exist and must have been created by the MemoryStore. If the specified file does not exist, or cannot be opened for read-write, the Finished event will indicate failure.- Parameters:
- name - A unique name identifying this Store.
- filename - The path of the database file holding the persistent store. If a relative path is specified, it is relative to the directory that contains the associated Apama Studio project (i.e. the Correlator working directory).
- Returns:
- The unique identifier for this operation, which will be included in the Finished event sent after the operation is complete and it becomes safe to call open() on this store.
- See Also:
- com.apama.memorystore.Finished - A Finished event will be sent when this asynchronous operation has completed.
prepareInMemory
integer static prepareInMemory(string name)
Prepare an in-memory read-write store to be opened and used by the application.- Parameters:
- name - A unique name identifying this Store.
- Returns:
- The unique identifier for this operation, which will be included in the Finished event sent after the operation is complete and it becomes safe to call open() on this store.
- See Also:
- com.apama.memorystore.Finished - A Finished event will be sent when this asynchronous operation has completed.
prepareOrCreate
integer static prepareOrCreate(string name, string filename)
Prepare a file-based read-write store associated with a MemoryStore database file on disk, which will be created if it does not exist already.- Parameters:
- name - A unique name identifying this Store.
- filename - The path of the database file holding the persistent store. If a relative path is specified, it is relative to the directory that contains the associated Apama Studio project (i.e. the Correlator working directory). The parent directory of the specified file must already exist.
- Returns:
- The unique identifier for this operation, which will be included in the Finished event sent after the operation is complete and it becomes safe to call open() on this store.
- See Also:
- com.apama.memorystore.Finished - A Finished event will be sent when this asynchronous operation has completed.
prepareReadOnly
integer static prepareReadOnly(string name, string filename)
Prepare a file-based read-only store associated with an existing MemoryStore database file on disk.- Parameters:
- name - A unique name identifying this Store.
- filename - The path of the database file holding the persistent store. If a relative path is specified, it is relative to the directory that contains the associated Apama Studio project (i.e. the Correlator working directory).
- Returns:
- The unique identifier for this operation, which will be included in the Finished event sent after the operation is complete and it becomes safe to call open() on this store.
- See Also:
- com.apama.memorystore.Finished - A Finished event will be sent when this asynchronous operation has completed.