public class PriorityThreadPoolHttpExecutor extends Object implements HttpExecutor, HttpTask.HttpTaskStartedListner, HttpTask.HttpTaskFinishedListener, HttpTask.HttpTaskCanceledListener, HttpTask.HttpTaskPriorityChangedListener
HttpExecutor executes the HttpTask, that contain a
HttpRequest, with an ThreadPoolExecutor and uses a
PriorityBlockingQueue as queue for tasks. That means, that tasks were
executed according the Comparable natural order (the least task is
the head of the queue). The HttpRequest.getPriority() is used for the
priority queue. If two tasks have the same priority the creation timestamp of
an HttpRequest gets considered as the next criterion for ordering.| Constructor and Description |
|---|
PriorityThreadPoolHttpExecutor() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancelAllOfOwner(Object owner)
Cancel all
HttpRequests of this owner |
void |
onHttpTaskCanceled(HttpTask<?> task)
Called when an
HttpRequest has been canceled, so the
corresponding HttpTask gets canceled too. |
void |
onHttpTaskFailed(HttpTask<?> httpTask,
Exception exception)
Called to inform, that a {@link HttpClientTasHttpClientTaskete, because
an error (exception) has been thrown
|
void |
onHttpTaskPriorityChanged(HttpTask<?> task,
int newPriority)
Called when the
HttpRequest has changed his priority, so the
HttpTask depends on the HttpRequest priority |
void |
onHttpTaskStarted(HttpTask<?> task)
This method gets called when an
HttpTask has started right
now |
void |
onHttpTaskSuccessful(HttpTask<?> httpTask,
HttpResponse response)
Called to inform, that a
HttpClientTask has finished successfully |
boolean |
submitTask(HttpTask<?> task)
Add a task to the
HttpExecutor. |
public boolean submitTask(HttpTask<?> task)
HttpExecutorHttpExecutor. The scheduler will then execute
this task. The time when the task gets executed depends on the concrete
HttpExecutor implementationsubmitTask in interface HttpExecutorpublic void onHttpTaskSuccessful(HttpTask<?> httpTask, HttpResponse response)
HttpTask.HttpTaskFinishedListenerHttpClientTask has finished successfullyonHttpTaskSuccessful in interface HttpTask.HttpTaskFinishedListenerhttpTask - The HttpClientTaHttpClientTasksponse
{@link HttpResponse}public void onHttpTaskFailed(HttpTask<?> httpTask, Exception exception)
HttpTask.HttpTaskFinishedListeneronHttpTaskFailed in interface HttpTask.HttpTaskFinishedListenerhttpTask - HttpClientTaskk HttpClientTask}exception - The Exception that has caused the failurepublic void onHttpTaskStarted(HttpTask<?> task)
HttpTask.HttpTaskStartedListnerHttpTask has started right
nowonHttpTaskStarted in interface HttpTask.HttpTaskStartedListnertask - The HttpTask that has started right nowpublic void onHttpTaskPriorityChanged(HttpTask<?> task, int newPriority)
HttpTask.HttpTaskPriorityChangedListenerHttpRequest has changed his priority, so the
HttpTask depends on the HttpRequest priorityonHttpTaskPriorityChanged in interface HttpTask.HttpTaskPriorityChangedListenertask - The HttpTasknewPriority - The new prioritypublic void onHttpTaskCanceled(HttpTask<?> task)
HttpTask.HttpTaskCanceledListenerHttpRequest has been canceled, so the
corresponding HttpTask gets canceled too.onHttpTaskCanceled in interface HttpTask.HttpTaskCanceledListenerpublic void cancelAllOfOwner(Object owner)
HttpExecutorHttpRequests of this ownercancelAllOfOwner in interface HttpExecutorCopyright © 2015 Hannes Dorfmann. All rights reserved.