##### Coverage Report - com.ctrip.apollo.core.schedule.ExponentialSchedulePolicy

Classes in this File | Line Coverage | Branch Coverage | Complexity
ExponentialSchedulePolicy |
0% | 0/12
0% | 0/2
| 1.3333333333333333;1.333

1 |  |
     package com.ctrip.apollo.core.schedule;
2 |  |
3 |  |
     /**
4 |  |
      * @author Jason Song(song_s@ctrip.com)
5 |  |
      */
6 |  |
     public class ExponentialSchedulePolicy implements SchedulePolicy {
7 |  |
       private final long delayTimeLowerBound;
8 |  |
       private final long delayTimeUpperBound;
9 |  |
       private long lastDelayTime;
10 |  |
11 | 0 |
       public ExponentialSchedulePolicy(long delayTimeLowerBound, long delayTimeUpperBound) {
12 | 0 |
         this.delayTimeLowerBound = delayTimeLowerBound;
13 | 0 |
         this.delayTimeUpperBound = delayTimeUpperBound;
14 | 0 |
       }
15 |  |
16 |  |
       @Override
17 |  |
       public long fail() {
18 | 0 |
         long delayTime = lastDelayTime;
19 |  |
20 | 0 |
         if (delayTime == 0) {
21 | 0 |
           delayTime = delayTimeLowerBound;
22 |  |
         } else {
23 | 0 |
           delayTime = Math.min(lastDelayTime << 1, delayTimeUpperBound);
24 |  |
         }
25 |  |
26 | 0 |
         lastDelayTime = delayTime;
27 |  |
28 | 0 |
         return delayTime;
29 |  |
       }
30 |  |
31 |  |
       @Override
32 |  |
       public void success() {
33 | 0 |
         lastDelayTime = 0;
34 | 0 |
       }
35 |  |
     }