public class SocketBasedHTTPWorker extends java.lang.Object implements Worker
SocketBasedHTTPWorker
is a java nio based implementation of Worker
for URL execution.
The class rely on the single Selector
to read from multiple channels to execute parallel URL
tasks asynchronously at high speed.
This Worker
uses the InetSocketAddressCache
to speed up the connection phase. The read
process only reads the data required instead of the full response there by saving considerable execution
time.
The list of URL tasks are executed in batches and the metrics are aggregated batch wise and for the full
task list. The result is stored in ExecutionDataStore
for audit purpose.
The class also has retry mechanism to execute failed URL tasks again with higher timeout values.InetSocketAddressCache
,
ExecutionDataStore
Constructor and Description |
---|
SocketBasedHTTPWorker(InetSocketAddressCache inetCache,
ExecutionDataStore store,
SystemConfig systemConfig)
Initialized the
SocketBasedHTTPWorker with the required parameters. |
SocketBasedHTTPWorker(InetSocketAddressCache inetCache,
ExecutionDataStore store,
SystemConfig systemConfig,
RequestConfig requestConfig)
Initialized the
SocketBasedHTTPWorker with the required parameters. |
Modifier and Type | Method and Description |
---|---|
LightningCoreConstants.WorkerState |
execute(java.lang.String sessionId)
Execute the list of tasks for the request.
|
int |
getConnectAccuracyPercent()
Get the minimum threshold for successful connect to total request percent.
|
LightningCoreConstants.WorkerState |
getCurrentState()
Get the state of the
Worker . |
int |
getReadAccuracyPercent()
Get the minimum threshold for successful read to connect percentage
|
int |
getSlowUrlsConnectTimeoutMillis()
Get the connection timeout for failed URL tasks.
|
int |
getSlowUrlsReadWriteTimeoutMillis()
Get the read/write timeout for failed URL tasks.
|
RequestConfig |
getTaskConfig()
Get the configuration for the current tasks.
|
void |
setConnectAccuracyPercent(int connectAccuracyPercent)
Set the minimum threshold for successful connect to total request percent.
|
void |
setReadAccuracyPercent(int readAccuracyPercent)
Set the minimum threshold for successful read to connect percentage
|
void |
setRequestConfig(RequestConfig taskConfig)
Set the configuration for the current tasks.
|
void |
setSlowUrlsConnectTimeoutMillis(int slowUrlsConnectTimeoutMillis)
Set the connection timeout for failed URL tasks.
|
void |
setSlowUrlsReadWriteTimeoutMillis(int slowUrlsReadWriteTimeoutMillis)
Set the read/write timeout for failed URL tasks.
|
void |
startWorker()
Deprecated.
|
public SocketBasedHTTPWorker(InetSocketAddressCache inetCache, ExecutionDataStore store, SystemConfig systemConfig)
SocketBasedHTTPWorker
with the required parameters.inetCache
- the InetSocketAddressCache
to speed the connection phasestore
- to store the results of the executionsystemConfig
- configuration related to cache, retention policy, audit etcpublic SocketBasedHTTPWorker(InetSocketAddressCache inetCache, ExecutionDataStore store, SystemConfig systemConfig, RequestConfig requestConfig)
SocketBasedHTTPWorker
with the required parameters.inetCache
- the InetSocketAddressCache
to speed the connection phasestore
- to store the results of the executionsystemConfig
- configuration related to cache, retention policy, audit etcrequestConfig
- configuration for URL task like timeout, proxy host etcpublic int getSlowUrlsConnectTimeoutMillis()
public void setSlowUrlsConnectTimeoutMillis(int slowUrlsConnectTimeoutMillis)
slowUrlsConnectTimeoutMillis
- the connection timeout for failed URL taskspublic int getSlowUrlsReadWriteTimeoutMillis()
public void setSlowUrlsReadWriteTimeoutMillis(int slowUrlsReadWriteTimeoutMillis)
slowUrlsReadWriteTimeoutMillis
- the read/write timeout for failed URL taskspublic int getReadAccuracyPercent()
public void setReadAccuracyPercent(int readAccuracyPercent)
readAccuracyPercent
- successful read to connect percentage minimum thresholdpublic int getConnectAccuracyPercent()
public void setConnectAccuracyPercent(int connectAccuracyPercent)
connectAccuracyPercent
- the minimum threshold for successful connect to total request percent@Deprecated @PostConstruct public void startWorker()
public LightningCoreConstants.WorkerState execute(java.lang.String sessionId)
public LightningCoreConstants.WorkerState getCurrentState()
Worker
.Worker
public RequestConfig getTaskConfig()
public void setRequestConfig(RequestConfig taskConfig)
taskConfig
- the task configuration