public class RamEventStore extends java.lang.Object implements KeenAttemptCountingEventStore
KeenEventStore which simply keeps a copy of each event in memory until
it is explicitly removed.
NOTE: This implementation synchronizes all operations in order to ensure thread safety, but as
a result it may perform poorly under high load. For applications that require high throughput,
a custom KeenEventStore implementation is recommended.
| Constructor and Description |
|---|
RamEventStore()
Constructs a new RAM-based event store.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
get(java.lang.Object handle)
Gets the event corresponding to the given handle.
|
java.lang.String |
getAttempts(java.lang.String projectId,
java.lang.String eventCollection)
Gets the stored attempts String for a given project and collection.
|
java.util.Map<java.lang.String,java.util.List<java.lang.Object>> |
getHandles(java.lang.String projectId)
Retrieves a map from collection names to lists of handles currently stored under each
collection.
|
void |
remove(java.lang.Object handle)
Removes the specified event from the store.
|
void |
setAttempts(java.lang.String projectId,
java.lang.String eventCollection,
java.lang.String attemptsString)
Set and stores the attempts String for a given project and collection.
|
void |
setMaxEventsPerCollection(int maxEventsPerCollection)
Sets the number of events that can be stored for a single collection before aging them out.
|
java.lang.Object |
store(java.lang.String projectId,
java.lang.String eventCollection,
java.lang.String event)
Stores the given event.
|
public java.lang.Object store(java.lang.String projectId,
java.lang.String eventCollection,
java.lang.String event)
throws java.io.IOException
store in interface KeenEventStoreprojectId - The ID of the project in which the event should be stored.eventCollection - The name of the collection in which the event should be stored.event - The serialized JSON for the event to store.java.io.IOException - If there is an error storing the event.public java.lang.String get(java.lang.Object handle)
throws java.io.IOException
get in interface KeenEventStorehandle - A handle returned from a previous call to KeenEventStore.store(String, String,
String)
or KeenEventStore.getHandles(String).java.io.IOException - If there is an error retrieving the event.public void remove(java.lang.Object handle)
throws java.io.IOException
remove in interface KeenEventStorehandle - A handle returned from a previous call to KeenEventStore.store(String, String,
String)
or KeenEventStore.getHandles(String).java.io.IOException - If there is an error removing the event.public java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getHandles(java.lang.String projectId)
throws java.io.IOException
KeenClient to retrieve the
events to send in a batch to the Keen server, as well as to remove all successfully posted
events after processing the response.getHandles in interface KeenEventStoreprojectId - The ID of the project for which to retrieve event handles.java.io.IOException - If there is an error retrieving the handles.public java.lang.String getAttempts(java.lang.String projectId,
java.lang.String eventCollection)
getAttempts in interface KeenAttemptCountingEventStoreprojectId - the project ideventCollection - the collection namepublic void setAttempts(java.lang.String projectId,
java.lang.String eventCollection,
java.lang.String attemptsString)
setAttempts in interface KeenAttemptCountingEventStoreprojectId - the project ideventCollection - the collection nameattemptsString - the String to stored for this project and collectionpublic void setMaxEventsPerCollection(int maxEventsPerCollection)
maxEventsPerCollection - The maximum number of events per collection.