blob: d5f226f2c2d8f0579d057c79f2342d69fd8e7c61 [file] [log] [blame]
Madan Jampani762246d2015-07-21 15:40:59 -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 */
16package org.onosproject.store.service;
17
18/**
19 * Builder for constructing new AtomicValue instances.
20 *
21 * @param <V> atomic value type
22 */
23public interface AtomicValueBuilder<V> {
24 /**
25 * Sets the name for the atomic value.
26 * <p>
27 * Each atomic value is identified by a unique name.
28 * </p>
29 * <p>
30 * Note: This is a mandatory parameter.
31 * </p>
32 *
33 * @param name name of the atomic value
34 * @return this AtomicValueBuilder for method chaining
35 */
36 AtomicValueBuilder<V> withName(String name);
37
38 /**
39 * Sets a serializer that can be used to serialize the value.
40 * <p>
41 * Note: This is a mandatory parameter.
42 * </p>
43 *
44 * @param serializer serializer
45 * @return this AtomicValueBuilder for method chaining
46 */
47 AtomicValueBuilder<V> withSerializer(Serializer serializer);
48
49 /**
50 * Creates this atomic value on the partition that spans the entire cluster.
51 * <p>
52 * When partitioning is disabled, the value state will be
53 * ephemeral and does not survive a full cluster restart.
54 * </p>
55 * <p>
56 * Note: By default partitions are enabled.
57 * </p>
58 * @return this AtomicValueBuilder for method chaining
59 */
60 AtomicValueBuilder<V> withPartitionsDisabled();
61
62 /**
Flavio Castro41b1f3a2015-07-31 13:51:32 -070063 * Instantiates Metering service to gather usage and performance metrics.
64 * By default, usage data will be stored.
65 *
66 * @return this AtomicValueBuilder for method chaining
67 */
68 AtomicValueBuilder<V> withMeteringDisabled();
69
70 /**
Madan Jampanidfde6ba2016-01-13 21:36:09 -080071 * Builds a AsyncAtomicValue based on the configuration options
72 * supplied to this builder.
73 *
74 * @return new AsyncAtomicValue
75 * @throws java.lang.RuntimeException if a mandatory parameter is missing
76 */
77 AsyncAtomicValue<V> buildAsyncValue();
78
79 /**
Madan Jampani762246d2015-07-21 15:40:59 -070080 * Builds a AtomicValue based on the configuration options
81 * supplied to this builder.
82 *
83 * @return new AtomicValue
84 * @throws java.lang.RuntimeException if a mandatory parameter is missing
85 */
86 AtomicValue<V> build();
87}