public class Transmission extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Transmission.Builder
Transmission.Builder
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes Transmission by enqueuing a POISON_PILL which causes each thread to return,
then shuts down the executor and awaits this.closeTimeout seconds before timing out.
|
protected org.json.JSONObject |
createJsonError(String error,
String metadata)
Returns a JSONObject indicating that a specified error has occurred.
|
void |
enqueueRequest(Object event)
Adds a Event to this Transmission's request queue.
|
void |
enqueueResponse(org.json.JSONObject json)
Adds a JSONObject to this Transmission's response queue.
|
String |
getApiHost()
Returns the API host for this Transmission.
|
boolean |
getBlockOnResponse()
Returns true if this Transmission should block on response.
|
boolean |
getBlockOnSend()
Returns true if this Transmission should block on send.
|
int |
getCloseTimeout()
Returns number of seconds Transmission's close method will wait before timing out.
|
Executor |
getExecutor()
Returns this Transmission's thread executor.
|
int |
getMaxConcurrentBranches()
Returns the number of threads to be instantiated on construction.
|
Queue |
getRequestQueue()
Returns this Transmission's queue of requests to be sent.
|
Queue |
getResponseQueue()
Return this Transmission's queue of received responses.
|
boolean |
isShutdown()
Returns true if all threads are shutdown.
|
protected void |
send(Event event)
Send an HTTP request based on a Event, wait for a response, then enqueue the response.
|
void |
sendDroppedResponse(String metadata)
Enqueue a response indicating that a Event was dropped due to sample rate, including its metadata string.
|
void |
setApiHost(String apiHost)
Sets the api host
|
void |
setBlockOnResponse(boolean blockOnResponse)
Sets if threads should block on response
|
void |
setBlockOnSend(boolean blockOnSend)
Sets if threads should block on send
|
void |
setCloseTimeout(int closeTimeout)
Sets the thread .close timeout
|
protected void |
setRequestQueue(ArrayBlockingQueue requestQueue)
Sets the request queue (for debugging purposes)
|
protected void |
setResponseQueue(ArrayBlockingQueue responseQueue)
Sets the response queue (for debugging purposes)
|
void |
setUserAgent(String userAgent)
Sets the user agent
|
org.json.JSONObject |
toJson()
Returns a JSON representation of this Transmission.
|
String |
toString()
Returns a string representation of this Transmission.
|
public void close()
protected org.json.JSONObject createJsonError(String error, String metadata)
error - string describing specified errormetadata - metadata string used for debuggingpublic void enqueueRequest(Object event)
event - Event to be enqueuedpublic void enqueueResponse(org.json.JSONObject json)
json - JSONObject to be enqueuedpublic String getApiHost()
public boolean getBlockOnResponse()
public boolean getBlockOnSend()
public int getCloseTimeout()
public Executor getExecutor()
public Queue getRequestQueue()
public Queue getResponseQueue()
public int getMaxConcurrentBranches()
public boolean isShutdown()
protected void send(Event event)
event - HonyEvent from which the HTTP request is builtpublic void sendDroppedResponse(String metadata)
metadata - metadata string used for debuggingpublic void setApiHost(String apiHost)
apiHost - api hostprotected void setRequestQueue(ArrayBlockingQueue requestQueue)
requestQueue - request queueprotected void setResponseQueue(ArrayBlockingQueue responseQueue)
responseQueue - response queuepublic void setBlockOnResponse(boolean blockOnResponse)
blockOnResponse - block on responsepublic void setBlockOnSend(boolean blockOnSend)
blockOnSend - block on sendpublic void setCloseTimeout(int closeTimeout)
closeTimeout - .close timeoutpublic void setUserAgent(String userAgent)
userAgent - userAgentpublic org.json.JSONObject toJson()
Copyright © 2017. All rights reserved.