Merge pull request #113 from imont/harvest-timeout

Introduce harvesting timeout option
This commit is contained in:
bgrozev 2017-05-08 11:22:29 -05:00 committed by GitHub
commit e099d4acbe
2 changed files with 18 additions and 1 deletions

View File

@ -232,6 +232,12 @@ public class StackProperties
public static final String USE_DYNAMIC_HOST_HARVESTER
= "org.ice4j.ice.harvest.USE_DYNAMIC_HOST_HARVESTER";
/**
* Timeout, in seconds, of how long to wait for an individual harvest before timing out
*/
public static final String HARVESTING_TIMEOUT
= "org.ice4j.ice.harvest.HARVESTING_TIMEOUT";
/**
* Returns the String value of the specified property (minus all
* encompassing whitespaces)and null in case no property value was mapped

View File

@ -21,6 +21,7 @@ import java.util.*;
import java.util.concurrent.*;
import java.util.logging.*;
import org.ice4j.*;
import org.ice4j.ice.*;
/**
@ -197,7 +198,17 @@ public class CandidateHarvesterSet
{
try
{
future.get();
future.get(StackProperties.getInt(StackProperties.HARVESTING_TIMEOUT, 15), TimeUnit.SECONDS);
break;
}
catch (TimeoutException te)
{
CandidateHarvesterSetElement harvester = task.getKey().getHarvester();
if (harvester != null)
{
harvester.setEnabled(false);
}
logger.warning("timed out while harvesting from " + harvester);
break;
}
catch (CancellationException ce)