blob: 1f5400aa1bffbd712ee37b20632a753c7d58a64c [file] [log] [blame]
Madan Jampanib5d72d52015-04-03 16:53:50 -07001package org.onosproject.store.service;
2
Madan Jampanif4d58f32015-06-05 17:38:22 -07003import java.util.concurrent.ScheduledExecutorService;
4
Madan Jampanib5d72d52015-04-03 16:53:50 -07005/**
6 * Builder for AtomicCounter.
7 */
8public 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 SHIMIZU3310a342015-05-13 12:14:05 -070022 AtomicCounterBuilder withName(String name);
Madan Jampanib5d72d52015-04-03 16:53:50 -070023
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 SHIMIZU3310a342015-05-13 12:14:05 -070035 AtomicCounterBuilder withPartitionsDisabled();
Madan Jampanib5d72d52015-04-03 16:53:50 -070036
37 /**
Madan Jampanif4d58f32015-06-05 17:38:22 -070038 * 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 Jampanib5d72d52015-04-03 16:53:50 -070056 * 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 SHIMIZU3310a342015-05-13 12:14:05 -070062 AtomicCounter build();
Madan Jampanib5d72d52015-04-03 16:53:50 -070063
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 SHIMIZU3310a342015-05-13 12:14:05 -070071 AsyncAtomicCounter buildAsyncCounter();
Madan Jampanib5d72d52015-04-03 16:53:50 -070072}