Interface BeaconCache
-
- All Known Implementing Classes:
BeaconCacheImpl
public interface BeaconCacheBeacon Cache used to cache the Beacons generated by all sessions, actions, ...
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddActionData(BeaconKey key, long timestamp, java.lang.String data)Add action data for a givenbeaconIDto this cache.voidaddEventData(BeaconKey key, long timestamp, java.lang.String data)Add event data for a givenkeyto this cache.voidaddObserver(java.util.Observer o)Add anObserverwhich gets notified after a new event data or action data got inserted.voiddeleteCacheEntry(BeaconKey key)Delete a cache entry for a givenkey.intevictRecordsByAge(BeaconKey key, long minTimestamp)Evictbeacon cache recordsby age for a given beacon.intevictRecordsByNumber(BeaconKey key, int numRecords)Evictbeacon cache recordsby number for given beacon.java.util.Set<BeaconKey>getBeaconKeys()Get a Set of currently insertedBeaconKeys.java.lang.StringgetNextBeaconChunk(BeaconKey key, java.lang.String chunkPrefix, int maxSize, char delimiter)Get the next chunk for sending to the backend.longgetNumBytesInCache()Get number of bytes currently stored in cache.booleanhasDataForSending(BeaconKey key)Test if there is more data to send.booleanisEmpty(BeaconKey key)Tests if an cached entry forkeyis empty.voidprepareDataForSending(BeaconKey key)Prepare all data, that has been recorded so far, for sending.voidremoveChunkedData(BeaconKey key)Remove all data that was previously included in chunks.voidresetChunkedData(BeaconKey key)Reset all data that was previously included in chunks.
-
-
-
Method Detail
-
addObserver
void addObserver(java.util.Observer o)
Add anObserverwhich gets notified after a new event data or action data got inserted.- Parameters:
o- Observer to add.
-
addEventData
void addEventData(BeaconKey key, long timestamp, java.lang.String data)
Add event data for a givenkeyto this cache.All registered observers are notified, after the event data has been added.
- Parameters:
key- The key of the beacon (aka Session ID and Session seq. no.) for which to add event data.timestamp- The data's timestamp.data- serialized event data to add.
-
addActionData
void addActionData(BeaconKey key, long timestamp, java.lang.String data)
Add action data for a givenbeaconIDto this cache.- Parameters:
key- The key of the beacon (aka Session ID and Session seq. no.) for which to add action data.timestamp- The data's timestamp.data- serialized action data to add.
-
deleteCacheEntry
void deleteCacheEntry(BeaconKey key)
Delete a cache entry for a givenkey.- Parameters:
key- The beacon's ID (aka Session ID and Session seq. no.) which to delete.
-
prepareDataForSending
void prepareDataForSending(BeaconKey key)
Prepare all data, that has been recorded so far, for sending.Note: This method must only be invoked from the beacon sending thread.
- Parameters:
key- The beacon's ID (aka Session ID and Session seq. no.) for which to copy the collected data.
-
hasDataForSending
boolean hasDataForSending(BeaconKey key)
Test if there is more data to send.- Parameters:
key- key The beacon's ID (aka Session ID and Session seq. no.) for which to test if there is more data to send.- Returns:
trueif there is data for sending,falseifBeaconKeydoes not exist or there is no data for sending.
-
getNextBeaconChunk
java.lang.String getNextBeaconChunk(BeaconKey key, java.lang.String chunkPrefix, int maxSize, char delimiter)
Get the next chunk for sending to the backend.Note: This method must only be invoked from the beacon sending thread.
- Parameters:
key- The key of the beacon for which to get the next chunk.chunkPrefix- Prefix to append to the beginning of the chunk.maxSize- Maximum chunk size. As soon as chunk's size is greater than or equal to maxSize result is returned.delimiter- Delimiter between consecutive chunks.- Returns:
nullif givenkeydoes not exist, an empty string, if there is no more data to send or the next chunk to send.
-
removeChunkedData
void removeChunkedData(BeaconKey key)
Remove all data that was previously included in chunks.This method must be called, when data retrieved via
getNextBeaconChunk(BeaconKey, String, int, char)was successfully sent to the backend, otherwise subsequent calls togetNextBeaconChunk(BeaconKey, String, int, char)will retrieve the same data again and again.Note: This method must only be invoked from the beacon sending thread.
- Parameters:
key- The key of the beacon for which to remove already chunked data.
-
resetChunkedData
void resetChunkedData(BeaconKey key)
Reset all data that was previously included in chunks.Note: This method must only be invoked from the beacon sending thread.
- Parameters:
key- The key of the beacon for which to remove already chunked data.
-
getBeaconKeys
java.util.Set<BeaconKey> getBeaconKeys()
Get a Set of currently insertedBeaconKeys.The return value is a snapshot of currently inserted beacon keys. All changes made after this call are not reflected in the returned Set.
- Returns:
- Snapshot of all beacon keys in the cache.
-
evictRecordsByAge
int evictRecordsByAge(BeaconKey key, long minTimestamp)
Evictbeacon cache recordsby age for a given beacon.- Parameters:
key- The key identifying a beacon.minTimestamp- The minimum timestamp allowed.- Returns:
- Returns the number of evicted cache records.
-
evictRecordsByNumber
int evictRecordsByNumber(BeaconKey key, int numRecords)
Evictbeacon cache recordsby number for given beacon.- Parameters:
key- The key identifying a beacon beacon.numRecords- The maximum number of records to evict.- Returns:
- Returns the number of evicted cache records.
-
getNumBytesInCache
long getNumBytesInCache()
Get number of bytes currently stored in cache.- Returns:
- Number of bytes currently stored in cache.
-
isEmpty
boolean isEmpty(BeaconKey key)
Tests if an cached entry forkeyis empty.- Parameters:
key- The key identifying a beacon.- Returns:
trueif the cached entry is empty,falseotherwise.
-
-