blob: f3b6c8f5a49bcf6299c508a857b4755ff04354f2 [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>
Brian O'Connor85cf4da2015-06-05 23:44:28 -070051 * @param executor executor service
Madan Jampanif4d58f32015-06-05 17:38:22 -070052 * @return this AtomicCounterBuilder
53 */
54 AtomicCounterBuilder withRetryExecutor(ScheduledExecutorService executor);
55
56 /**
Madan Jampanib5d72d52015-04-03 16:53:50 -070057 * 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 SHIMIZU3310a342015-05-13 12:14:05 -070063 AtomicCounter build();
Madan Jampanib5d72d52015-04-03 16:53:50 -070064
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 SHIMIZU3310a342015-05-13 12:14:05 -070072 AsyncAtomicCounter buildAsyncCounter();
Madan Jampanib5d72d52015-04-03 16:53:50 -070073}