public class GenericStreamStorage extends AbstractModule<StreamStorageConfig> implements IRecordStorageModule<StreamStorageConfig>, IObsStorage, IEventListener
Generic wrapper/adapter enabling any storage implementation to store data
coming from data events (e.g. sensor data, processed data, etc.)
This class takes care of registering with the appropriate producers and
uses the storage API to store records in the underlying storage.
config, eventHandler
Constructor and Description |
---|
GenericStreamStorage() |
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
|
protected void |
configureStorageForDataSource(IDataProducerModule<?> dataSource,
IRecordStorageModule<?> storage) |
protected void |
ensureProducerInfo(String producerID) |
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
|
Iterator<String> |
getFoiIDs(IFoiFilter filter)
Gets IDs of FOIs matching the filter
|
Iterator<net.opengis.gml.v32.AbstractFeature> |
getFois(IFoiFilter filter)
Retrieves features of interest matching the given filter
|
org.vast.util.Bbox |
getFoisSpatialExtent()
Gets the bounding rectangle of all features of interest contained
in this storage
|
net.opengis.sensorml.v20.AbstractProcess |
getLatestDataSourceDescription()
Retrieves latest data source description (i.e.
|
int |
getNumFois(IFoiFilter filter)
Gets the number of features of interest matching the filter
|
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
|
protected Collection<? extends IStreamingDataInterface> |
getSelectedOutputs(IDataProducerModule<?> dataSource) |
void |
handleEvent(Event<?> e) |
boolean |
isAutoCommit()
Retrieves auto-commit state
|
protected void |
prepareToReceiveEvents(IStreamingDataInterface output) |
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 |
storeFoi(String producerID,
net.opengis.gml.v32.AbstractFeature foi)
Stores a new feature of interest 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 |
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, registerListener, saveState, unregisterListener, updateConfig
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfiguration, getLocalID, getName, init, isEnabled, loadState, registerListener, saveState, unregisterListener, updateConfig
public void start() throws SensorHubException
IModule
start
in interface IModule<StreamStorageConfig>
SensorHubException
protected void configureStorageForDataSource(IDataProducerModule<?> dataSource, IRecordStorageModule<?> storage) throws StorageException
StorageException
protected Collection<? extends IStreamingDataInterface> getSelectedOutputs(IDataProducerModule<?> dataSource)
protected void ensureProducerInfo(String producerID)
protected void prepareToReceiveEvents(IStreamingDataInterface output)
public void stop() throws SensorHubException
IModule
stop
in interface IModule<StreamStorageConfig>
SensorHubException
public void cleanup() throws SensorHubException
IModule
cleanup
in interface IModule<StreamStorageConfig>
SensorHubException
public void handleEvent(Event<?> e)
handleEvent
in interface IEventListener
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) throws IOException
IStorageModule
backup
in interface IStorageModule<StreamStorageConfig>
IOException
public void restore(InputStream is) throws IOException
IStorageModule
restore
in interface IStorageModule<StreamStorageConfig>
IOException
public void setAutoCommit(boolean autoCommit)
IStorageModule
setAutoCommit
in interface IStorageModule<StreamStorageConfig>
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<StreamStorageConfig>
public void commit()
IStorageModule
commit
in interface IStorageModule<StreamStorageConfig>
public void rollback()
IStorageModule
rollback
in interface IStorageModule<StreamStorageConfig>
public void sync(IStorageModule<?> storage) throws StorageException
IStorageModule
sync
in interface IStorageModule<StreamStorageConfig>
StorageException
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 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 int getNumFois(IFoiFilter filter)
IObsStorage
getNumFois
in interface IObsStorage
filter
- filtering criteriaspublic org.vast.util.Bbox getFoisSpatialExtent()
IObsStorage
getFoisSpatialExtent
in interface IObsStorage
public Iterator<String> getFoiIDs(IFoiFilter filter)
IObsStorage
getFoiIDs
in interface IObsStorage
filter
- filtering criteriaspublic Iterator<net.opengis.gml.v32.AbstractFeature> getFois(IFoiFilter filter)
IObsStorage
getFois
in interface IObsStorage
filter
- filtering criteriaspublic void storeFoi(String producerID, net.opengis.gml.v32.AbstractFeature foi)
IObsStorage
storeFoi
in interface IObsStorage
producerID
- ID of producer by which this FOI has been observedfoi
- feature object to storeCopyright © 2015 Sensia Software LLC. All rights reserved.