Introduce harvesting timeout option

This commit is contained in:
Romanas Sonkinas 2017-04-28 14:46:24 +01:00
parent b3c304146b
commit 969e363bc6
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 public static final String USE_DYNAMIC_HOST_HARVESTER
= "org.ice4j.ice.harvest.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 * Returns the String value of the specified property (minus all
* encompassing whitespaces)and null in case no property value was mapped * 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.concurrent.*;
import java.util.logging.*; import java.util.logging.*;
import org.ice4j.*;
import org.ice4j.ice.*; import org.ice4j.ice.*;
/** /**
@ -197,7 +198,17 @@ public class CandidateHarvesterSet
{ {
try 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; break;
} }
catch (CancellationException ce) catch (CancellationException ce)