public class InMemoryBasicStorage extends AbstractModule<StorageConfig> implements IRecordStorageModule<StorageConfig>
In-memory basic storage implementation. This is used mainly for test purposes but could perhaps be improved to be used as a local memory cache of a remote storage.
Modifier and Type | Class and Description |
---|---|
class |
InMemoryBasicStorage.TimeSeriesImpl |
config, eventHandler
Constructor and Description |
---|
InMemoryBasicStorage() |
Modifier and Type | Method and Description |
---|---|
void |
addRecordStore(String name,
net.opengis.swe.v20.DataComponent recordStructure,
net.opengis.swe.v20.DataEncoding recommendedEncoding)
Adds a data store for a new record type in this storage
|
void |
backup(OutputStream os)
Backups storage to specified output stream
|
void |
cleanup()
Cleans up all ressources used by the module when deleted
All persistent resources created by the module should be cleaned
when this is called
|
void |
commit()
Commits all changes generated by transactional methods since the last commit event
|
net.opengis.swe.v20.DataBlock |
getDataBlock(DataKey key)
Retrieves raw data block with the specified key
|
Iterator<net.opengis.swe.v20.DataBlock> |
getDataBlockIterator(IDataFilter filter)
Gets iterator of raw data blocks matching the specified filter
|
net.opengis.sensorml.v20.AbstractProcess |
getDataSourceDescriptionAtTime(double time)
Retrieves data source description valid at specified time
|
List<net.opengis.sensorml.v20.AbstractProcess> |
getDataSourceDescriptionHistory(double startTime,
double endTime)
Retrieves history of data source description for the given time period
|
net.opengis.sensorml.v20.AbstractProcess |
getLatestDataSourceDescription()
Retrieves latest data source description (i.e.
|
int |
getNumMatchingRecords(IDataFilter filter,
long maxCount)
Computes the (potentially approximate) number of records matching the
given filter.
Since the returned value can be approximate and the number of matching records can change before or even during the actual call to IBasicStorage.getRecordIterator(IDataFilter) , the exact number of records can
only be obtained by counting the records returned by the iterator next()
function. |
int |
getNumRecords(String recordType)
Helper method to retrieve the total number of method for the specified
record type
|
Iterator<? extends IDataRecord> |
getRecordIterator(IDataFilter filter)
Gets iterator of records matching the specified filter
|
Iterator<double[]> |
getRecordsTimeClusters(String recordType)
Retrieves time boundaries of data clusters
(i.e.
|
double[] |
getRecordsTimeRange(String recordType)
Retrieves time range spanned by all records of the specified type
|
Map<String,? extends IRecordStoreInfo> |
getRecordStores()
Gets the list of available record types in this storage
|
boolean |
isAutoCommit()
Retrieves auto-commit state
|
void |
registerListener(IEventListener listener)
Registers a listener to receive events generated by this module
|
void |
removeDataSourceDescription(double time)
Removes data source description valid at specified time
|
void |
removeDataSourceDescriptionHistory(double startTime,
double endTime)
Removes data source descriptions whose validity periods lie within the given time period
|
void |
removeRecord(DataKey key)
Removes record with the specified key
|
int |
removeRecords(IDataFilter filter)
Removes all records matching the filter
|
void |
restore(InputStream is)
Restores storage from backup obtained from specified input stream
|
void |
rollback()
Cancels all changes generated by transactional methods since the last commit event
|
void |
setAutoCommit(boolean autoCommit)
Changes the storage behavior on record insertion, update or deletion
|
void |
start()
Starts the module with the current configuration.
init() should always be called before start(). |
void |
stop()
Stops the module.
All temporary resources created by the module should be cleaned when this is called (ex: memory, files, connections, etc.) stop() can be called right after init() even if start() hasn't been called. |
void |
storeDataSourceDescription(net.opengis.sensorml.v20.AbstractProcess process)
Stores a new data source description into storage.
|
void |
storeRecord(DataKey key,
net.opengis.swe.v20.DataBlock data)
Persists data block in storage
|
void |
sync(IStorageModule<?> storage)
Synchronizes storage with another storage of the same type (potentially remote)
|
void |
unregisterListener(IEventListener listener)
Unregisters a listener and thus stop receiving events generayed by this module
|
void |
updateDataSourceDescription(net.opengis.sensorml.v20.AbstractProcess process)
Update the data source description in storage.
|
void |
updateRecord(DataKey key,
net.opengis.swe.v20.DataBlock data)
Updates record with specified key with new data
|
getConfiguration, getLocalID, getName, init, isEnabled, loadState, saveState, updateConfig
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfiguration, getLocalID, getName, init, isEnabled, loadState, saveState, updateConfig
public void start() throws SensorHubException
IModule
start
in interface IModule<StorageConfig>
SensorHubException
public void stop() throws SensorHubException
IModule
stop
in interface IModule<StorageConfig>
SensorHubException
public net.opengis.sensorml.v20.AbstractProcess getLatestDataSourceDescription()
IBasicStorage
getLatestDataSourceDescription
in interface IBasicStorage
public List<net.opengis.sensorml.v20.AbstractProcess> getDataSourceDescriptionHistory(double startTime, double endTime)
IBasicStorage
getDataSourceDescriptionHistory
in interface IBasicStorage
startTime
- lower bound of the time periodendTime
- upper bound of the time periodpublic net.opengis.sensorml.v20.AbstractProcess getDataSourceDescriptionAtTime(double time)
IBasicStorage
getDataSourceDescriptionAtTime
in interface IBasicStorage
public void storeDataSourceDescription(net.opengis.sensorml.v20.AbstractProcess process)
IBasicStorage
storeDataSourceDescription
in interface IBasicStorage
process
- SensorML process description to storepublic void updateDataSourceDescription(net.opengis.sensorml.v20.AbstractProcess process)
IBasicStorage
updateDataSourceDescription
in interface IBasicStorage
process
- SensorML process description to updatepublic void removeDataSourceDescription(double time)
IBasicStorage
removeDataSourceDescription
in interface IBasicStorage
time
- any time falling within the validity period of the description version to removepublic void removeDataSourceDescriptionHistory(double startTime, double endTime)
IBasicStorage
removeDataSourceDescriptionHistory
in interface IBasicStorage
startTime
- lower bound of the time periodendTime
- upper bound of the time periodpublic Map<String,? extends IRecordStoreInfo> getRecordStores()
IBasicStorage
getRecordStores
in interface IBasicStorage
public void addRecordStore(String name, net.opengis.swe.v20.DataComponent recordStructure, net.opengis.swe.v20.DataEncoding recommendedEncoding)
IBasicStorage
addRecordStore
in interface IBasicStorage
name
- name of record type (should match output name of the data source)recordStructure
- SWE data component describing the record structurerecommendedEncoding
- recommended encoding for this record typepublic void backup(OutputStream os)
IStorageModule
backup
in interface IStorageModule<StorageConfig>
public void restore(InputStream is)
IStorageModule
restore
in interface IStorageModule<StorageConfig>
public void sync(IStorageModule<?> storage)
IStorageModule
sync
in interface IStorageModule<StorageConfig>
public void setAutoCommit(boolean autoCommit)
IStorageModule
setAutoCommit
in interface IStorageModule<StorageConfig>
autoCommit
- true to commit changes automatically when a transactional method is called,
false if the commit() method should be called manually to persist changes to storage.public boolean isAutoCommit()
IStorageModule
isAutoCommit
in interface IStorageModule<StorageConfig>
public void commit()
IStorageModule
commit
in interface IStorageModule<StorageConfig>
public void rollback()
IStorageModule
rollback
in interface IStorageModule<StorageConfig>
public void cleanup() throws StorageException
IModule
cleanup
in interface IModule<StorageConfig>
StorageException
public net.opengis.swe.v20.DataBlock getDataBlock(DataKey key)
IBasicStorage
getDataBlock
in interface IBasicStorage
key
- Record keypublic Iterator<net.opengis.swe.v20.DataBlock> getDataBlockIterator(IDataFilter filter)
IBasicStorage
getDataBlockIterator
in interface IBasicStorage
filter
- filtering parameterspublic Iterator<? extends IDataRecord> getRecordIterator(IDataFilter filter)
IBasicStorage
getRecordIterator
in interface IBasicStorage
filter
- filtering parameterspublic int getNumMatchingRecords(IDataFilter filter, long maxCount)
IBasicStorage
IBasicStorage.getRecordIterator(IDataFilter)
, the exact number of records can
only be obtained by counting the records returned by the iterator next()
function.getNumMatchingRecords
in interface IBasicStorage
filter
- filtering parametersmaxCount
- counting will stop once this threshold is reachedpublic int getNumRecords(String recordType)
IBasicStorage
getNumRecords
in interface IBasicStorage
recordType
- name of record typepublic double[] getRecordsTimeRange(String recordType)
IBasicStorage
getRecordsTimeRange
in interface IBasicStorage
recordType
- name of record typepublic Iterator<double[]> getRecordsTimeClusters(String recordType)
IBasicStorage
getRecordsTimeClusters
in interface IBasicStorage
recordType
- name of record typepublic void storeRecord(DataKey key, net.opengis.swe.v20.DataBlock data)
IBasicStorage
storeRecord
in interface IBasicStorage
key
- key object to associate to recorddata
- actual record datapublic void updateRecord(DataKey key, net.opengis.swe.v20.DataBlock data)
IBasicStorage
updateRecord
in interface IBasicStorage
key
- key of record to updatedata
- new data block to assign to the recordpublic void removeRecord(DataKey key)
IBasicStorage
removeRecord
in interface IBasicStorage
key
- record keypublic int removeRecords(IDataFilter filter)
IBasicStorage
removeRecords
in interface IBasicStorage
filter
- filtering parameterspublic void registerListener(IEventListener listener)
IModule
registerListener
in interface IEventProducer
registerListener
in interface IModule<StorageConfig>
registerListener
in class AbstractModule<StorageConfig>
public void unregisterListener(IEventListener listener)
IModule
unregisterListener
in interface IEventProducer
unregisterListener
in interface IModule<StorageConfig>
unregisterListener
in class AbstractModule<StorageConfig>
Copyright © 2015 Sensia Software LLC. All rights reserved.