public class PVCacheImpl extends Object implements PVCache, DataStorageListener
PVCache first implementation. Handles the communication between a
list of sources, a storage and registered queries threw
PVCacheListener. Manages a list of requested intervals which are
intersected with new requested TimeInterval. Manages a list a
completed intervals which is the result of the concatenation of the lists of
completed intervals per sources. When data is lost from storage, the
IntervalsList generated from the TimestampsSet is subtracted
to all requested/completed intervals lists.| Constructor and Description |
|---|
PVCacheImpl(String channelName,
Collection<DataSource> dataSources,
DataStorage storage) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(PVCacheListener listener)
Add a
PVCacheListener to be notified when new samples are
available. |
void |
dataLoss(TimestampsSet lostSet)
Informs that the specified set of
Timestamp have been removed
from storage. |
void |
flush() |
String |
getChannelName() |
IntervalsList |
getCompletedIntervalsList()
Get the completed intervals list.
|
PVCacheStatistics |
getStatistics() |
DataStorage |
getStorage() |
boolean |
isProcessingSources() |
boolean |
isStatisticsEnabled() |
void |
removeListener(PVCacheListener listener)
Remove a
PVCacheListener. |
DataRequestThread |
retrieveDataAsync(TimeInterval newIntervalToRetrieve)
Asynchronously retrieves samples from sources for the requested
TimeInterval and asynchronously requests DataStorage for
immediately available samples. |
SortedSet<Data> |
retrieveDataSync(TimeInterval interval)
Synchronously requests
DataStorage for immediately available
samples. |
void |
setRetrievalGap(TimeDuration retrievalGap) |
void |
setStatisticsEnabled(boolean enabled) |
void |
startLiveDataProcessing()
Start processing live data samples.
|
void |
stopLiveDataProcessing()
Stop processing live data samples.
|
public PVCacheImpl(String channelName, Collection<DataSource> dataSources, DataStorage storage)
public void startLiveDataProcessing()
startLiveDataProcessing in interface PVCachepublic void stopLiveDataProcessing()
stopLiveDataProcessing in interface PVCachepublic void addListener(PVCacheListener listener)
PVCacheListener to be notified when new samples are
available.addListener in interface PVCachelistener - to be addedpublic void removeListener(PVCacheListener listener)
PVCacheListener.removeListener in interface PVCachelistener - to be removedpublic DataRequestThread retrieveDataAsync(TimeInterval newIntervalToRetrieve)
TimeInterval and asynchronously requests DataStorage for
immediately available samples.retrieveDataAsync in interface PVCachenewIntervalToRetrieve - TimeInterval to be retrieved.public SortedSet<Data> retrieveDataSync(TimeInterval interval)
DataStorage for immediately available
samples.retrieveDataSync in interface PVCacheinterval - TimeInterval to be retrieved.public void dataLoss(TimestampsSet lostSet)
Timestamp have been removed
from storage.dataLoss in interface DataStorageListenerlostSet - TimestampsSet of lost Timestamp.public IntervalsList getCompletedIntervalsList()
TimeInterval is completed
when all DataSource have finished responding.getCompletedIntervalsList in interface PVCacheIntervalsList the list of completed intervals.public void setStatisticsEnabled(boolean enabled)
setStatisticsEnabled in interface PVCachepublic boolean isStatisticsEnabled()
isStatisticsEnabled in interface PVCachepublic PVCacheStatistics getStatistics()
getStatistics in interface PVCachepublic boolean isProcessingSources()
isProcessingSources in interface PVCachepublic String getChannelName()
getChannelName in interface PVCachepublic void setRetrievalGap(TimeDuration retrievalGap)
public DataStorage getStorage()
Copyright © 2015. All rights reserved.