public class AsyncEventHandler
extends java.lang.Object
implements com.optimizely.ab.event.EventHandler, java.lang.AutoCloseable
EventHandler implementation that queues events and has a separate pool of threads responsible
for the dispatch.| Modifier and Type | Class and Description |
|---|---|
static class |
AsyncEventHandler.Builder |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONFIG_MAX_CONNECTIONS |
static java.lang.String |
CONFIG_MAX_PER_ROUTE |
static java.lang.String |
CONFIG_NUM_WORKERS |
static java.lang.String |
CONFIG_QUEUE_CAPACITY |
static java.lang.String |
CONFIG_VALIDATE_AFTER_INACTIVITY |
static int |
DEFAULT_MAX_CONNECTIONS |
static int |
DEFAULT_MAX_PER_ROUTE |
static int |
DEFAULT_NUM_WORKERS |
static int |
DEFAULT_QUEUE_CAPACITY |
static int |
DEFAULT_VALIDATE_AFTER_INACTIVITY |
| Constructor and Description |
|---|
AsyncEventHandler(int queueCapacity,
int numWorkers)
Deprecated.
Use the builder
AsyncEventHandler.Builder |
AsyncEventHandler(int queueCapacity,
int numWorkers,
int maxConnections,
int connectionsPerRoute,
int validateAfter)
Deprecated.
Use the builder
AsyncEventHandler.Builder |
AsyncEventHandler(int queueCapacity,
int numWorkers,
int maxConnections,
int connectionsPerRoute,
int validateAfter,
long closeTimeout,
java.util.concurrent.TimeUnit closeTimeoutUnit) |
AsyncEventHandler(OptimizelyHttpClient httpClient,
java.util.concurrent.ExecutorService workerExecutor) |
| Modifier and Type | Method and Description |
|---|---|
static AsyncEventHandler.Builder |
builder() |
void |
close() |
void |
dispatchEvent(com.optimizely.ab.event.LogEvent logEvent) |
void |
shutdownAndAwaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
Attempts to gracefully terminate all event dispatch workers and close all resources.
|
public static final java.lang.String CONFIG_QUEUE_CAPACITY
public static final java.lang.String CONFIG_NUM_WORKERS
public static final java.lang.String CONFIG_MAX_CONNECTIONS
public static final java.lang.String CONFIG_MAX_PER_ROUTE
public static final java.lang.String CONFIG_VALIDATE_AFTER_INACTIVITY
public static final int DEFAULT_QUEUE_CAPACITY
public static final int DEFAULT_NUM_WORKERS
public static final int DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_MAX_PER_ROUTE
public static final int DEFAULT_VALIDATE_AFTER_INACTIVITY
@Deprecated
public AsyncEventHandler(int queueCapacity,
int numWorkers)
AsyncEventHandler.BuilderqueueCapacity - A depth of the event queuenumWorkers - The number of workers@Deprecated
public AsyncEventHandler(int queueCapacity,
int numWorkers,
int maxConnections,
int connectionsPerRoute,
int validateAfter)
AsyncEventHandler.BuilderqueueCapacity - A depth of the event queuenumWorkers - The number of workersmaxConnections - The max number of concurrent connectionsconnectionsPerRoute - The max number of concurrent connections per routevalidateAfter - An inactivity period in milliseconds after which persistent connections must be re-validated prior to being leased to the consumer.public AsyncEventHandler(int queueCapacity,
int numWorkers,
int maxConnections,
int connectionsPerRoute,
int validateAfter,
long closeTimeout,
java.util.concurrent.TimeUnit closeTimeoutUnit)
public AsyncEventHandler(OptimizelyHttpClient httpClient, java.util.concurrent.ExecutorService workerExecutor)
public void dispatchEvent(com.optimizely.ab.event.LogEvent logEvent)
dispatchEvent in interface com.optimizely.ab.event.EventHandlerpublic void shutdownAndAwaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
Note: termination of ongoing event dispatching is best-effort.
timeout - maximum time to wait for event dispatches to completeunit - the time unit of the timeout argumentpublic void close()
close in interface java.lang.AutoCloseablepublic static AsyncEventHandler.Builder builder()