blob: 50d829c736e9b29aaa63337e8a107fdc9edbc620 [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 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070024 ConsistentMapBuilder<K, V> withName(String name);
Madan Jampanif1b8e172015-03-23 11:42:02 -070025
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 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070038 ConsistentMapBuilder<K, V> withSerializer(Serializer serializer);
Madan Jampanif1b8e172015-03-23 11:42:02 -070039
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 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070056 ConsistentMapBuilder<K, V> withPartitionsDisabled();
Madan Jampanif1b8e172015-03-23 11:42:02 -070057
58 /**
Madan Jampani02b7fb82015-05-01 13:01:20 -070059 * Disables map updates.
60 * <p>
61 * Attempt to update the built map will throw {@code UnsupportedOperationException}.
62 *
63 * @return this ConsistentMapBuilder
64 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070065 ConsistentMapBuilder<K, V> withUpdatesDisabled();
Madan Jampani02b7fb82015-05-01 13:01:20 -070066
67 /**
Madan Jampanif1b8e172015-03-23 11:42:02 -070068 * Builds an consistent map based on the configuration options
69 * supplied to this builder.
70 *
71 * @return new consistent map
72 * @throws java.lang.RuntimeException if a mandatory parameter is missing
73 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070074 ConsistentMap<K, V> build();
Madan Jampanif1b8e172015-03-23 11:42:02 -070075
76 /**
77 * Builds an async consistent map based on the configuration options
78 * supplied to this builder.
79 *
80 * @return new async consistent map
81 * @throws java.lang.RuntimeException if a mandatory parameter is missing
82 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070083 AsyncConsistentMap<K, V> buildAsyncMap();
84}