public class J7FileStatsStorage extends java.lang.Object implements StatsStorage
StatsStorage
implementation, based on SQLite.
Note: Where possible, use FileStatsStorage
which should be faster (is based
on MapDB).
Obviously, the storage formats for J7FileStatsStorage and FileStatsStorage
are
incompatible.Constructor and Description |
---|
J7FileStatsStorage(java.io.File file) |
Modifier and Type | Method and Description |
---|---|
protected java.util.List<StatsStorageEvent> |
checkStorageEvents(Persistable p) |
void |
close()
Close any open resources (files, etc)
|
void |
deregisterStatsStorageListener(StatsStorageListener listener)
Remove the specified listener, if it is present.
|
java.util.List<Persistable> |
getAllStaticInfos(java.lang.String sessionID,
java.lang.String typeID)
Get all static informations for the given session and type ID
|
java.util.List<Persistable> |
getAllUpdatesAfter(java.lang.String sessionID,
java.lang.String typeID,
long timestamp)
Get all updates for the given session ID (all worker IDs), that occur after (not including) the given timestamp.
|
java.util.List<Persistable> |
getAllUpdatesAfter(java.lang.String sessionID,
java.lang.String typeID,
java.lang.String workerID,
long timestamp)
Get all updates for the given session and worker ID, that occur after (not including) the given timestamp.
|
Persistable |
getLatestUpdate(java.lang.String sessionID,
java.lang.String typeID,
java.lang.String workerID)
Get the latest update record (i.e., update record with the largest timestamp value) for the specified
session and worker IDs
|
java.util.List<Persistable> |
getLatestUpdateAllWorkers(java.lang.String sessionID,
java.lang.String typeID)
Get the latest update for all workers, for the given session ID
|
java.util.List<StatsStorageListener> |
getListeners()
Get a list (shallow copy) of all listeners currently present
|
int |
getNumUpdateRecordsFor(java.lang.String sessionID)
Return the number of update records for the given session ID (all workers)
|
int |
getNumUpdateRecordsFor(java.lang.String sessionID,
java.lang.String typeID,
java.lang.String workerID)
Return the number of update records for the given session ID and worker ID
|
Persistable |
getStaticInfo(java.lang.String sessionID,
java.lang.String typeID,
java.lang.String workerID)
Get the static info for the given session and worker IDs, or null if no such static info has been reported
|
StorageMetaData |
getStorageMetaData(java.lang.String sessionID,
java.lang.String typeID)
Get the session metadata, if any has been registered via
StatsStorageRouter.putStorageMetaData(StorageMetaData) |
Persistable |
getUpdate(java.lang.String sessionID,
java.lang.String typeId,
java.lang.String workerID,
long timestamp)
Get the specified update (or null, if none exists for the given session/worker ids and timestamp)
|
boolean |
isClosed() |
java.util.List<java.lang.String> |
listSessionIDs()
Get a list of all sessions stored by this storage backend
|
java.util.List<java.lang.String> |
listTypeIDsForSession(java.lang.String sessionID)
Get the list of type IDs for the given session ID
|
java.util.List<java.lang.String> |
listWorkerIDsForSession(java.lang.String sessionID)
For a given session ID, list all of the known worker IDs
|
java.util.List<java.lang.String> |
listWorkerIDsForSessionAndType(java.lang.String sessionID,
java.lang.String typeID)
For a given session ID and type ID, list all of the known worker IDs
|
protected void |
notifyListeners(java.util.List<StatsStorageEvent> sses) |
void |
putStaticInfo(java.util.Collection<? extends Persistable> collection)
Static info: reported once per session, upon initialization
|
void |
putStaticInfo(Persistable staticInfo)
Static info: reported once per session, upon initialization
|
void |
putStorageMetaData(java.util.Collection<? extends StorageMetaData> collection) |
void |
putStorageMetaData(StorageMetaData storageMetaData)
Method to store some additional metadata for each session.
|
void |
putUpdate(java.util.Collection<? extends Persistable> collection)
Updates: stored multiple times per session (periodically, for example)
|
void |
putUpdate(Persistable update)
Updates: stored multiple times per session (periodically, for example)
|
void |
registerStatsStorageListener(StatsStorageListener listener)
Add a new StatsStorageListener.
|
void |
removeAllListeners()
Remove all listeners from the StatsStorage instance
|
boolean |
sessionExists(java.lang.String sessionID)
Check if the specified session ID exists or not
|
java.lang.String |
toString() |
public J7FileStatsStorage(@NonNull java.io.File file)
file
- Storage location for the statsprotected java.util.List<StatsStorageEvent> checkStorageEvents(Persistable p)
public void putStorageMetaData(StorageMetaData storageMetaData)
StatsStorageRouter
putStorageMetaData
in interface StatsStorageRouter
storageMetaData
- Storage metadata to storepublic void putStorageMetaData(java.util.Collection<? extends StorageMetaData> collection)
putStorageMetaData
in interface StatsStorageRouter
public void putStaticInfo(Persistable staticInfo)
StatsStorageRouter
putStaticInfo
in interface StatsStorageRouter
staticInfo
- Static info to storepublic void putStaticInfo(java.util.Collection<? extends Persistable> collection)
StatsStorageRouter
putStaticInfo
in interface StatsStorageRouter
collection
- Static info to storepublic void putUpdate(Persistable update)
StatsStorageRouter
putUpdate
in interface StatsStorageRouter
update
- Update info to storepublic void putUpdate(java.util.Collection<? extends Persistable> collection)
StatsStorageRouter
putUpdate
in interface StatsStorageRouter
collection
- Update info to storepublic void close() throws java.io.IOException
StatsStorage
close
in interface StatsStorage
java.io.IOException
public boolean isClosed()
isClosed
in interface StatsStorage
public java.util.List<java.lang.String> listSessionIDs()
StatsStorage
listSessionIDs
in interface StatsStorage
public boolean sessionExists(java.lang.String sessionID)
StatsStorage
sessionExists
in interface StatsStorage
sessionID
- Session ID to checkpublic Persistable getStaticInfo(java.lang.String sessionID, java.lang.String typeID, java.lang.String workerID)
StatsStorage
getStaticInfo
in interface StatsStorage
sessionID
- Session IDworkerID
- worker IDpublic java.util.List<Persistable> getAllStaticInfos(java.lang.String sessionID, java.lang.String typeID)
StatsStorage
getAllStaticInfos
in interface StatsStorage
sessionID
- Session ID to get static info fortypeID
- Type ID to get static info forpublic java.util.List<java.lang.String> listTypeIDsForSession(java.lang.String sessionID)
StatsStorage
listTypeIDsForSession
in interface StatsStorage
sessionID
- Session ID to querypublic java.util.List<java.lang.String> listWorkerIDsForSession(java.lang.String sessionID)
StatsStorage
listWorkerIDsForSession
in interface StatsStorage
sessionID
- Session IDpublic java.util.List<java.lang.String> listWorkerIDsForSessionAndType(java.lang.String sessionID, java.lang.String typeID)
StatsStorage
listWorkerIDsForSessionAndType
in interface StatsStorage
sessionID
- Session IDtypeID
- Type IDpublic int getNumUpdateRecordsFor(java.lang.String sessionID)
StatsStorage
getNumUpdateRecordsFor
in interface StatsStorage
sessionID
- Session IDpublic int getNumUpdateRecordsFor(java.lang.String sessionID, java.lang.String typeID, java.lang.String workerID)
StatsStorage
getNumUpdateRecordsFor
in interface StatsStorage
sessionID
- Session IDworkerID
- Worker IDpublic Persistable getLatestUpdate(java.lang.String sessionID, java.lang.String typeID, java.lang.String workerID)
StatsStorage
getLatestUpdate
in interface StatsStorage
sessionID
- session IDworkerID
- worker IDpublic Persistable getUpdate(java.lang.String sessionID, java.lang.String typeId, java.lang.String workerID, long timestamp)
StatsStorage
getUpdate
in interface StatsStorage
sessionID
- Session IDworkerID
- Worker IDtimestamp
- Timestamppublic java.util.List<Persistable> getLatestUpdateAllWorkers(java.lang.String sessionID, java.lang.String typeID)
StatsStorage
getLatestUpdateAllWorkers
in interface StatsStorage
sessionID
- Session IDpublic java.util.List<Persistable> getAllUpdatesAfter(java.lang.String sessionID, java.lang.String typeID, java.lang.String workerID, long timestamp)
StatsStorage
getAllUpdatesAfter
in interface StatsStorage
sessionID
- Session IDworkerID
- Worker Idtimestamp
- Timestamppublic java.util.List<Persistable> getAllUpdatesAfter(java.lang.String sessionID, java.lang.String typeID, long timestamp)
StatsStorage
getAllUpdatesAfter
in interface StatsStorage
sessionID
- Session IDtimestamp
- Timestamppublic StorageMetaData getStorageMetaData(java.lang.String sessionID, java.lang.String typeID)
StatsStorage
StatsStorageRouter.putStorageMetaData(StorageMetaData)
getStorageMetaData
in interface StatsStorage
sessionID
- Session ID to get metadatpublic void registerStatsStorageListener(StatsStorageListener listener)
StatsStorage
registerStatsStorageListener
in interface StatsStorage
listener
- Listener to addpublic void deregisterStatsStorageListener(StatsStorageListener listener)
StatsStorage
deregisterStatsStorageListener
in interface StatsStorage
listener
- Listener to removepublic void removeAllListeners()
StatsStorage
removeAllListeners
in interface StatsStorage
public java.util.List<StatsStorageListener> getListeners()
StatsStorage
getListeners
in interface StatsStorage
public java.lang.String toString()
toString
in class java.lang.Object
protected void notifyListeners(java.util.List<StatsStorageEvent> sses)