Skip to content

Commit e099d4a

Browse files
authored
Merge pull request #113 from imont/harvest-timeout
Introduce harvesting timeout option
2 parents dffdf0c + 969e363 commit e099d4a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/main/java/org/ice4j/StackProperties.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ public class StackProperties
232232
public static final String USE_DYNAMIC_HOST_HARVESTER
233233
= "org.ice4j.ice.harvest.USE_DYNAMIC_HOST_HARVESTER";
234234

235+
/**
236+
* Timeout, in seconds, of how long to wait for an individual harvest before timing out
237+
*/
238+
public static final String HARVESTING_TIMEOUT
239+
= "org.ice4j.ice.harvest.HARVESTING_TIMEOUT";
240+
235241
/**
236242
* Returns the String value of the specified property (minus all
237243
* encompassing whitespaces)and null in case no property value was mapped

src/main/java/org/ice4j/ice/harvest/CandidateHarvesterSet.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.concurrent.*;
2222
import java.util.logging.*;
2323

24+
import org.ice4j.*;
2425
import org.ice4j.ice.*;
2526

2627
/**
@@ -197,7 +198,17 @@ private void harvest(
197198
{
198199
try
199200
{
200-
future.get();
201+
future.get(StackProperties.getInt(StackProperties.HARVESTING_TIMEOUT, 15), TimeUnit.SECONDS);
202+
break;
203+
}
204+
catch (TimeoutException te)
205+
{
206+
CandidateHarvesterSetElement harvester = task.getKey().getHarvester();
207+
if (harvester != null)
208+
{
209+
harvester.setEnabled(false);
210+
}
211+
logger.warning("timed out while harvesting from " + harvester);
201212
break;
202213
}
203214
catch (CancellationException ce)

0 commit comments

Comments
 (0)