Github user manuzhang commented on a diff in the pull request:

    https://github.com/apache/incubator-gearpump/pull/156#discussion_r102384171
  
    --- Diff: core/src/main/scala/org/apache/gearpump/util/RestartPolicy.scala 
---
    @@ -26,16 +26,24 @@ import akka.actor.ChildRestartStats
      * When one executor or task fails, Gearpump will try to start. However, 
if it fails after
      * multiple retries, then we abort.
      *
    - * @param maxNrOfRetries The number of times is allowed to be restarted, 
negative value means no
    - *                       limit, if the limit is exceeded the policy will 
not allow to restart
    + * @param totalNrOfRetries The total number of times is allowed to be 
restarted, negative value
    + *                         means no limit, if the limit is exceeded the 
policy will not allow
    + *                         to restart
    + * @param maxNrOfRetriesInRange The maximum retry times in the specified 
time window.
      * @param withinTimeRange Duration of the time window for maxNrOfRetries.
      *                        Duration.Inf means no window
      */
    -class RestartPolicy(maxNrOfRetries: Int, withinTimeRange: Duration) {
    +class RestartPolicy(totalNrOfRetries: Int, maxNrOfRetriesInRange: Int, 
withinTimeRange: Duration) {
    +  private var historicalRetries: Int = 0
       private val status = new ChildRestartStats(null, 0, 0L)
    -  private val retriesWindow = (Some(maxNrOfRetries), 
Some(withinTimeRange.toMillis.toInt))
    +  private val retriesWindow = (Some(maxNrOfRetriesInRange), 
Some(withinTimeRange.toMillis.toInt))
     
       def allowRestart: Boolean = {
    -    status.requestRestartPermission(retriesWindow)
    +    historicalRetries += 1
    +    if (totalNrOfRetries > 0 && historicalRetries > totalNrOfRetries) {
    --- End diff --
    
    We mixed our own policy with Akka's implementation here. Can we make 
it simpler ? Is restarting based on number of retries, i.e. `retriesWindow = 
(Some(maxNrOfRetriesInRange), None)` good enough ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to