Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 1 | package org.onosproject.store.service; |
| 2 | |
Madan Jampani | f4d58f3 | 2015-06-05 17:38:22 -0700 | [diff] [blame] | 3 | import java.util.concurrent.ScheduledExecutorService; |
| 4 | |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 5 | /** |
| 6 | * Builder for AtomicCounter. |
| 7 | */ |
| 8 | public interface AtomicCounterBuilder { |
| 9 | |
| 10 | /** |
| 11 | * Sets the name for the atomic counter. |
| 12 | * <p> |
| 13 | * Each atomic counter is identified by a unique name. |
| 14 | * </p> |
| 15 | * <p> |
| 16 | * Note: This is a mandatory parameter. |
| 17 | * </p> |
| 18 | * |
| 19 | * @param name name of the atomic counter |
| 20 | * @return this AtomicCounterBuilder |
| 21 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 22 | AtomicCounterBuilder withName(String name); |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Creates this counter on the partition that spans the entire cluster. |
| 26 | * <p> |
| 27 | * When partitioning is disabled, the counter state will be |
| 28 | * ephemeral and does not survive a full cluster restart. |
| 29 | * </p> |
| 30 | * <p> |
| 31 | * Note: By default partitions are enabled. |
| 32 | * </p> |
| 33 | * @return this AtomicCounterBuilder |
| 34 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 35 | AtomicCounterBuilder withPartitionsDisabled(); |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
Madan Jampani | f4d58f3 | 2015-06-05 17:38:22 -0700 | [diff] [blame] | 38 | * Enables retries when counter operations fail. |
| 39 | * <p> |
| 40 | * Note: Use with caution. By default retries are disabled. |
| 41 | * </p> |
| 42 | * @return this AtomicCounterBuilder |
| 43 | */ |
| 44 | AtomicCounterBuilder withRetryOnFailure(); |
| 45 | |
| 46 | /** |
| 47 | * Sets the executor service to use for retrying failed operations. |
| 48 | * <p> |
| 49 | * Note: Must be set when retries are enabled |
| 50 | * </p> |
| 51 | * @return this AtomicCounterBuilder |
| 52 | */ |
| 53 | AtomicCounterBuilder withRetryExecutor(ScheduledExecutorService executor); |
| 54 | |
| 55 | /** |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 56 | * Builds a AtomicCounter based on the configuration options |
| 57 | * supplied to this builder. |
| 58 | * |
| 59 | * @return new AtomicCounter |
| 60 | * @throws java.lang.RuntimeException if a mandatory parameter is missing |
| 61 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 62 | AtomicCounter build(); |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * Builds a AsyncAtomicCounter based on the configuration options |
| 66 | * supplied to this builder. |
| 67 | * |
| 68 | * @return new AsyncAtomicCounter |
| 69 | * @throws java.lang.RuntimeException if a mandatory parameter is missing |
| 70 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 71 | AsyncAtomicCounter buildAsyncCounter(); |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 72 | } |