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> |
Brian O'Connor | 85cf4da | 2015-06-05 23:44:28 -0700 | [diff] [blame] | 51 | * @param executor executor service |
Madan Jampani | f4d58f3 | 2015-06-05 17:38:22 -0700 | [diff] [blame] | 52 | * @return this AtomicCounterBuilder |
| 53 | */ |
| 54 | AtomicCounterBuilder withRetryExecutor(ScheduledExecutorService executor); |
| 55 | |
| 56 | /** |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 57 | * Builds a AtomicCounter based on the configuration options |
| 58 | * supplied to this builder. |
| 59 | * |
| 60 | * @return new AtomicCounter |
| 61 | * @throws java.lang.RuntimeException if a mandatory parameter is missing |
| 62 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 63 | AtomicCounter build(); |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Builds a AsyncAtomicCounter based on the configuration options |
| 67 | * supplied to this builder. |
| 68 | * |
| 69 | * @return new AsyncAtomicCounter |
| 70 | * @throws java.lang.RuntimeException if a mandatory parameter is missing |
| 71 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 72 | AsyncAtomicCounter buildAsyncCounter(); |
Madan Jampani | b5d72d5 | 2015-04-03 16:53:50 -0700 | [diff] [blame] | 73 | } |