From cf5e56054b04b921e9b37aeba1176c781737be3b Mon Sep 17 00:00:00 2001 From: Arndt Brenschede Date: Fri, 30 Sep 2016 19:15:18 +0200 Subject: [PATCH] recalc timeout change --- .../main/java/btools/router/RoutingEngine.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index 04755c9..51baeea 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -790,6 +790,8 @@ public class RoutingEngine extends Thread throw new IllegalArgumentException( "operation killed by thread-priority-watchdog after " + ( System.currentTimeMillis() - startTime)/1000 + " seconds" ); } + + if ( maxRunningTime > 0 ) { long timeout = ( matchPath == null && fastPartialRecalc ) ? maxRunningTime/3 : maxRunningTime; @@ -810,11 +812,21 @@ public class RoutingEngine extends Thread continue; } - if ( matchPath != null && fastPartialRecalc && firstMatchCost < 500 && path.cost > 30L*firstMatchCost - && !costCuttingTrack.isDirty ) + if ( fastPartialRecalc && matchPath != null && path.cost > 30L*firstMatchCost && !costCuttingTrack.isDirty ) { logInfo( "early exit: firstMatchCost=" + firstMatchCost + " path.cost=" + path.cost ); - throw new IllegalArgumentException( "early exit for a close recalc" ); + + // use an early exit, unless there's a realistc chance to complete within the timeout + if ( path.cost > maxTotalCost/2 && System.currentTimeMillis() - startTime < maxRunningTime/3 ) + { + logInfo( "early exit supressed, running for completion, resetting timeout" ); + startTime = System.currentTimeMillis(); + fastPartialRecalc = false; + } + else + { + throw new IllegalArgumentException( "early exit for a close recalc" ); + } } if ( nodeLimit > 0 ) // check node-limit for target island search