Committed by
Gerrit Code Review
[ONOS-418] GossipLinkStore: make configurable - add setter of initialDelaySec and periodSec.
Change-Id: I5286572bf74403677ad332de8d745e79aa12ddb2
Showing
1 changed file
with
32 additions
and
2 deletions
... | @@ -74,6 +74,7 @@ import com.google.common.collect.Multimaps; | ... | @@ -74,6 +74,7 @@ import com.google.common.collect.Multimaps; |
74 | import com.google.common.collect.SetMultimap; | 74 | import com.google.common.collect.SetMultimap; |
75 | import com.google.common.collect.Sets; | 75 | import com.google.common.collect.Sets; |
76 | 76 | ||
77 | +import static com.google.common.base.Preconditions.checkArgument; | ||
77 | import static com.google.common.base.Preconditions.checkNotNull; | 78 | import static com.google.common.base.Preconditions.checkNotNull; |
78 | import static com.google.common.base.Predicates.notNull; | 79 | import static com.google.common.base.Predicates.notNull; |
79 | import static com.google.common.collect.Multimaps.synchronizedSetMultimap; | 80 | import static com.google.common.collect.Multimaps.synchronizedSetMultimap; |
... | @@ -107,6 +108,15 @@ public class GossipLinkStore | ... | @@ -107,6 +108,15 @@ public class GossipLinkStore |
107 | // Timeout in milliseconds to process links on remote master node | 108 | // Timeout in milliseconds to process links on remote master node |
108 | private static final int REMOTE_MASTER_TIMEOUT = 1000; | 109 | private static final int REMOTE_MASTER_TIMEOUT = 1000; |
109 | 110 | ||
111 | + // Default delay for ScheduledExecutorService of anti-entropy(BackgroundExecutor) | ||
112 | + private static final long DEFAULT_INITIAL_DELAY = 5; | ||
113 | + | ||
114 | + // Default period for ScheduledExecutorService of anti-entropy(BackgroundExecutor) | ||
115 | + private static final long DEFAULT_PERIOD = 5; | ||
116 | + | ||
117 | + private static long initialDelaySec = DEFAULT_INITIAL_DELAY; | ||
118 | + private static long periodSec = DEFAULT_PERIOD; | ||
119 | + | ||
110 | private final Logger log = getLogger(getClass()); | 120 | private final Logger log = getLogger(getClass()); |
111 | 121 | ||
112 | // Link inventory | 122 | // Link inventory |
... | @@ -175,8 +185,6 @@ public class GossipLinkStore | ... | @@ -175,8 +185,6 @@ public class GossipLinkStore |
175 | GossipLinkStoreMessageSubjects.LINK_INJECTED, | 185 | GossipLinkStoreMessageSubjects.LINK_INJECTED, |
176 | new LinkInjectedEventListener(), executor); | 186 | new LinkInjectedEventListener(), executor); |
177 | 187 | ||
178 | - long initialDelaySec = 5; | ||
179 | - long periodSec = 5; | ||
180 | // start anti-entropy thread | 188 | // start anti-entropy thread |
181 | backgroundExecutors.scheduleAtFixedRate(new SendAdvertisementTask(), | 189 | backgroundExecutors.scheduleAtFixedRate(new SendAdvertisementTask(), |
182 | initialDelaySec, periodSec, TimeUnit.SECONDS); | 190 | initialDelaySec, periodSec, TimeUnit.SECONDS); |
... | @@ -702,6 +710,28 @@ public class GossipLinkStore | ... | @@ -702,6 +710,28 @@ public class GossipLinkStore |
702 | } | 710 | } |
703 | } | 711 | } |
704 | 712 | ||
713 | + /** | ||
714 | + * sets the time to delay first execution for anti-entropy. | ||
715 | + * (scheduleAtFixedRate of ScheduledExecutorService) | ||
716 | + * | ||
717 | + * @param delay the time to delay first execution for anti-entropy | ||
718 | + */ | ||
719 | + private void setInitialDelaySec(long delay) { | ||
720 | + checkArgument(delay >= 0, "Initial delay of scheduleAtFixedRate() must be 0 or more"); | ||
721 | + initialDelaySec = delay; | ||
722 | + } | ||
723 | + | ||
724 | + /** | ||
725 | + * sets the period between successive execution for anti-entropy. | ||
726 | + * (scheduleAtFixedRate of ScheduledExecutorService) | ||
727 | + * | ||
728 | + * @param period the period between successive execution for anti-entropy | ||
729 | + */ | ||
730 | + private void setPeriodSec(long period) { | ||
731 | + checkArgument(period > 0, "Period of scheduleAtFixedRate() must be greater than 0"); | ||
732 | + periodSec = period; | ||
733 | + } | ||
734 | + | ||
705 | private final class SendAdvertisementTask implements Runnable { | 735 | private final class SendAdvertisementTask implements Runnable { |
706 | 736 | ||
707 | @Override | 737 | @Override | ... | ... |
-
Please register or login to post a comment