blob: 3c2e516214a40cf57ba27231c055ebeefb681843 [file] [log] [blame]
Madan Jampani619453b2015-07-22 23:47:09 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Madan Jampanib5d72d52015-04-03 16:53:50 -070016package org.onosproject.store.service;
17
Madan Jampanif4d58f32015-06-05 17:38:22 -070018import java.util.concurrent.ScheduledExecutorService;
19
Madan Jampanib5d72d52015-04-03 16:53:50 -070020/**
21 * Builder for AtomicCounter.
22 */
23public interface AtomicCounterBuilder {
24
25 /**
26 * Sets the name for the atomic counter.
27 * <p>
28 * Each atomic counter is identified by a unique name.
29 * </p>
30 * <p>
31 * Note: This is a mandatory parameter.
32 * </p>
33 *
34 * @param name name of the atomic counter
35 * @return this AtomicCounterBuilder
36 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070037 AtomicCounterBuilder withName(String name);
Madan Jampanib5d72d52015-04-03 16:53:50 -070038
39 /**
40 * Creates this counter on the partition that spans the entire cluster.
41 * <p>
42 * When partitioning is disabled, the counter state will be
43 * ephemeral and does not survive a full cluster restart.
44 * </p>
45 * <p>
46 * Note: By default partitions are enabled.
47 * </p>
48 * @return this AtomicCounterBuilder
49 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070050 AtomicCounterBuilder withPartitionsDisabled();
Madan Jampanib5d72d52015-04-03 16:53:50 -070051
52 /**
Madan Jampanif4d58f32015-06-05 17:38:22 -070053 * Enables retries when counter operations fail.
54 * <p>
55 * Note: Use with caution. By default retries are disabled.
56 * </p>
57 * @return this AtomicCounterBuilder
58 */
59 AtomicCounterBuilder withRetryOnFailure();
60
61 /**
62 * Sets the executor service to use for retrying failed operations.
63 * <p>
64 * Note: Must be set when retries are enabled
65 * </p>
Brian O'Connor85cf4da2015-06-05 23:44:28 -070066 * @param executor executor service
Madan Jampanif4d58f32015-06-05 17:38:22 -070067 * @return this AtomicCounterBuilder
68 */
69 AtomicCounterBuilder withRetryExecutor(ScheduledExecutorService executor);
70
71 /**
Madan Jampanib5d72d52015-04-03 16:53:50 -070072 * Builds a AtomicCounter based on the configuration options
73 * supplied to this builder.
74 *
75 * @return new AtomicCounter
76 * @throws java.lang.RuntimeException if a mandatory parameter is missing
77 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070078 AtomicCounter build();
Madan Jampanib5d72d52015-04-03 16:53:50 -070079
80 /**
81 * Builds a AsyncAtomicCounter based on the configuration options
82 * supplied to this builder.
83 *
84 * @return new AsyncAtomicCounter
85 * @throws java.lang.RuntimeException if a mandatory parameter is missing
86 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070087 AsyncAtomicCounter buildAsyncCounter();
Madan Jampanib5d72d52015-04-03 16:53:50 -070088}