[
https://issues.jboss.org/browse/ISPN-2533?page=com.atlassian.jira.plugin....
]
Vladimir Blagojevic edited comment on ISPN-2533 at 11/23/12 12:47 PM:
----------------------------------------------------------------------
Thomas,
Yeah you are right. However, since Future#get() does not throw TimeoutException we have to
throw ExecutionException in cases where user sets timeout on tasks and calls
Future#get().When throwing exception we have to take into account timeout specified with
task builder and Future#get(timeout,TimeUnit) as well. The algorithm I would suggest is
the following:
{code}
private V innerGet(long timeout, TimeUnit unit) throws ExecutionException,
TimeoutException {
...
...
long taskTimeout = getOwningTask().timeout();
long futureTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit);
long actualTimeout = 0;
if (taskTimeout > 0 || futureTimeout > 0){
if(taskTimeout > 0 && futureTimeout == 0){
actualTimeout = taskTimeout;
} else if (taskTimeout == 0 && futureTimeout > 0) {
actualTimeout = futureTimeout;
} else if (taskTimeout > 0 && futureTimeout >0) {
actualTimeout = taskTimeout < futureTimeout ? taskTimeout :
futureTimeout;
}
}
if (actualTimeout > 0) {
response = retrieveResult(f.get(actualTimeout, TimeUnit.MILLISECONDS));
} else {
response = retrieveResult(f.get());
}
...
}
{code}
was (Author: vblagojevic):
Thomas,
Yeah you are right. However, since Future#get() does not throw TimeoutException we have to
throw ExecutionException in cases where user sets timeout on tasks and calls Future#get().
Also we have to take into account timeout specified with task builder and
Future#get(timeout,TimeUnit). The algorithm I would suggest is the following:
{code}
private V innerGet(long timeout, TimeUnit unit) throws ExecutionException,
TimeoutException {
...
...
long taskTimeout = getOwningTask().timeout();
long futureTimeout = TimeUnit.MILLISECONDS.convert(timeout, unit);
long actualTimeout = 0;
if (taskTimeout > 0 || futureTimeout > 0){
if(taskTimeout > 0 && futureTimeout == 0){
actualTimeout = taskTimeout;
} else if (taskTimeout == 0 && futureTimeout > 0) {
actualTimeout = futureTimeout;
} else if (taskTimeout > 0 && futureTimeout >0) {
actualTimeout = taskTimeout < futureTimeout ? taskTimeout :
futureTimeout;
}
}
if (actualTimeout > 0) {
response = retrieveResult(f.get(actualTimeout, TimeUnit.MILLISECONDS));
} else {
response = retrieveResult(f.get());
}
...
}
{code}
Timeout on local executed DistributedTasks not work
---------------------------------------------------
Key: ISPN-2533
URL:
https://issues.jboss.org/browse/ISPN-2533
Project: Infinispan
Issue Type: Bug
Components: Distributed Execution and Map/Reduce
Affects Versions: 5.2.0.Beta4
Reporter: Thomas Fromm
Assignee: Vladimir Blagojevic
Attachments: 0001-ISPN-2533-Testcase.patch
When executing DistributedTask on local node, the configured timeout is ignored.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira