public class FileEventStore extends java.lang.Object implements KeenAttemptCountingEventStore
KeenEventStore interface using the file system
to cache events in between queueing and batch posting.| Constructor and Description |
|---|
FileEventStore(java.io.File root)
Constructs a new File-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.
|
java.lang.Object |
store(java.lang.String projectId,
java.lang.String eventCollection,
java.lang.String event)
Stores the given event.
|
public FileEventStore(java.io.File root)
throws java.io.IOException
root - The root directory in which to store queued event files.java.io.IOException - If the provided root isn't an existing directory.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)
throws java.io.IOException
getAttempts in interface KeenAttemptCountingEventStoreprojectId - the project ideventCollection - the collection namejava.io.IOException - exceptionpublic void setAttempts(java.lang.String projectId,
java.lang.String eventCollection,
java.lang.String attemptsString)
throws java.io.IOException
setAttempts in interface KeenAttemptCountingEventStoreprojectId - the project ideventCollection - the collection nameattemptsString - the String to stored for this project and collectionjava.io.IOException - exception