Madan Jampani | f1b8e17 | 2015-03-23 11:42:02 -0700 | [diff] [blame] | 1 | package 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 | */ |
| 10 | public 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 | /** |
Madan Jampani | 02b7fb8 | 2015-05-01 13:01:20 -0700 | [diff] [blame] | 59 | * Disables map updates. |
| 60 | * <p> |
| 61 | * Attempt to update the built map will throw {@code UnsupportedOperationException}. |
| 62 | * |
| 63 | * @return this ConsistentMapBuilder |
| 64 | */ |
| 65 | public ConsistentMapBuilder<K, V> withUpdatesDisabled(); |
| 66 | |
| 67 | /** |
Madan Jampani | f1b8e17 | 2015-03-23 11:42:02 -0700 | [diff] [blame] | 68 | * 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 | */ |
| 74 | public ConsistentMap<K, V> build(); |
| 75 | |
| 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 | */ |
| 83 | public AsyncConsistentMap<K, V> buildAsyncMap(); |
| 84 | } |