blob: 6a02f34ba2664a334b9fcd9dc271374fe4b2c12b [file] [log] [blame]
Madan Jampanif1b8e172015-03-23 11:42:02 -07001package org.onosproject.store.service;
2
3
4/**
5 * Builder for consistent maps.
6 *
7 * @param <K> type for map key
8 * @param <V> type for map value
9 */
10public interface ConsistentMapBuilder<K, V> {
11
12 /**
13 * Sets the name of the map.
14 * <p>
15 * Each consistent map is identified by a unique map name.
16 * </p>
17 * <p>
18 * Note: This is a mandatory parameter.
19 * </p>
20 *
21 * @param name name of the consistent map
22 * @return this ConsistentMapBuilder
23 */
24 public ConsistentMapBuilder<K, V> withName(String name);
25
26 /**
27 * Sets a serializer that can be used to serialize
28 * both the keys and values inserted into the map. The serializer
29 * builder should be pre-populated with any classes that will be
30 * put into the map.
31 * <p>
32 * Note: This is a mandatory parameter.
33 * </p>
34 *
35 * @param serializer serializer
36 * @return this ConsistentMapBuilder
37 */
38 public ConsistentMapBuilder<K, V> withSerializer(Serializer serializer);
39
40 /**
41 * Disables distribution of map entries across multiple database partitions.
42 * <p>
43 * When partitioning is disabled, the returned map will have a single partition
44 * that spans the entire cluster. Furthermore, the changes made to the map are
45 * ephemeral and do not survive a full cluster restart.
46 * </p>
47 * <p>
48 * Disabling partitions is more appropriate when the returned map is used for
49 * coordination activities such as leader election and not for long term data persistence.
50 * </p>
51 * <p>
52 * Note: By default partitions are enabled and entries in the map are durable.
53 * </p>
54 * @return this ConsistentMapBuilder
55 */
56 public ConsistentMapBuilder<K, V> withPartitionsDisabled();
57
58 /**
59 * Builds an consistent map based on the configuration options
60 * supplied to this builder.
61 *
62 * @return new consistent map
63 * @throws java.lang.RuntimeException if a mandatory parameter is missing
64 */
65 public ConsistentMap<K, V> build();
66
67 /**
68 * Builds an async consistent map based on the configuration options
69 * supplied to this builder.
70 *
71 * @return new async consistent map
72 * @throws java.lang.RuntimeException if a mandatory parameter is missing
73 */
74 public AsyncConsistentMap<K, V> buildAsyncMap();
75}