com.apama.memorystore
Event Storage


MemoryStore factory interface for creating Store event objects.

There are several different types of Store supported by MemoryStore: Correlator-persistent stores are only available if Correlator persistence has been enabled. Non-persistent monitors may use any type of store, but a monitor marked as 'persistent' may ONLY access Correlator-persistent stores.

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
 booleanstatic hasDistributedStore(string name)

Indicates whether configuration for the given distributed store name exists.
 booleanstatic hasStore(string name)

Indicate whether or not a Store with the specified name has been prepared already.
 com.apama.memorystore.Storestatic open(string name)

Open a named Store that has already been prepared, ready for use by this monitor instance.
 integerstatic prepare(string name, string filename)

Prepare a file-based read-write store associated with an existing MemoryStore database file on disk.
 integerstatic prepareCorrelatorPersistent(string name)

Prepare a Correlator-persistent read-write store to be opened and used by the application.
 integerstatic prepareDistributed(string name)

Prepare a distributed store (e.g. distributed cache) to be opened and used by the application.
 integerstatic prepareInMemory(string name)

Prepare an in-memory read-write store to be opened and used by the application.
 integerstatic 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.
 integerstatic prepareReadOnly(string name, string filename)

Prepare a file-based read-only store associated with an existing MemoryStore database file on disk.
 
Action detail

hasDistributedStore

            boolean static hasDistributedStore(string name)
        
Indicates whether configuration for the given distributed store name exists.

Returning false indicates that a prepareDistributed of the store name will definitely fail. True indicates it may succeed, but is not a guarantee of success. Does not actually connect to the distributed store.
Parameters:
name
Returns:
false if prepareDistributed for the given store name will definitely fail

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.

A persistent monitor can access only Correlator-persistent stores. If a persistent monitor tries to open any other type of store (e.g. in-memory, on-disk or distributed) the monitor instance will terminate with an error.
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.

prepareCorrelatorPersistent

            integer static prepareCorrelatorPersistent(string name)
        
Prepare a Correlator-persistent read-write store to be opened and used by the application.

Only supported when the Correlator was configured with persistence enabled.

All committed changes made to a Correlator-persistent store are persisted to disk automatically whenever the Correlator takes a snapshot of the Correlator persistent application state. Because the Correlator determines when to persist its state, you cannot explicitly request persistence for a Correlator-persistent store or any tables it contains.

Attempts to create a Correlator-persistent store in a Correlator that does not have persistence enabled will result in an error that will terminate the monitor instance.
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.

prepareDistributed

            integer static prepareDistributed(string name)
        
Prepare a distributed store (e.g. distributed cache) to be opened and used by the application.
Parameters:
name - A unique name identifying this Store, which also specifies the id of its configuration bean in the XML configuration file. This name should not contain spaces.
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.