Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.store.service; |
| 17 | |
Madan Jampani | e8af1cc | 2015-06-23 14:23:31 -0700 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
| 19 | |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 20 | /** |
| 21 | * Builder for distributed set. |
| 22 | * |
| 23 | * @param <E> type set elements. |
| 24 | */ |
Madan Jampani | 50589ac | 2015-06-08 11:38:46 -0700 | [diff] [blame] | 25 | public interface DistributedSetBuilder<E> { |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Sets the name of the set. |
| 29 | * <p> |
| 30 | * Each set is identified by a unique name. |
| 31 | * </p> |
| 32 | * <p> |
| 33 | * Note: This is a mandatory parameter. |
| 34 | * </p> |
| 35 | * |
| 36 | * @param name name of the set |
Madan Jampani | 50589ac | 2015-06-08 11:38:46 -0700 | [diff] [blame] | 37 | * @return this DistributedSetBuilder |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 38 | */ |
Madan Jampani | 50589ac | 2015-06-08 11:38:46 -0700 | [diff] [blame] | 39 | DistributedSetBuilder<E> withName(String name); |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
Madan Jampani | e8af1cc | 2015-06-23 14:23:31 -0700 | [diff] [blame] | 42 | * Sets the owner applicationId for the set. |
| 43 | * <p> |
| 44 | * Note: If {@code purgeOnUninstall} option is enabled, applicationId |
| 45 | * must be specified. |
| 46 | * </p> |
| 47 | * |
| 48 | * @param id applicationId owning the set |
| 49 | * @return this DistributedSetBuilder |
| 50 | */ |
| 51 | DistributedSetBuilder<E> withApplicationId(ApplicationId id); |
| 52 | |
| 53 | /** |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 54 | * Sets a serializer that can be used to serialize |
| 55 | * the elements add to the set. The serializer |
| 56 | * builder should be pre-populated with any classes that will be |
| 57 | * put into the set. |
| 58 | * <p> |
| 59 | * Note: This is a mandatory parameter. |
| 60 | * </p> |
| 61 | * |
| 62 | * @param serializer serializer |
Madan Jampani | 50589ac | 2015-06-08 11:38:46 -0700 | [diff] [blame] | 63 | * @return this DistributedSetBuilder |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 64 | */ |
Madan Jampani | 50589ac | 2015-06-08 11:38:46 -0700 | [diff] [blame] | 65 | DistributedSetBuilder<E> withSerializer(Serializer serializer); |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
Madan Jampani | 02b7fb8 | 2015-05-01 13:01:20 -0700 | [diff] [blame] | 68 | * Disables set updates. |
| 69 | * <p> |
| 70 | * Attempt to update the built set will throw {@code UnsupportedOperationException}. |
| 71 | * |
Madan Jampani | 50589ac | 2015-06-08 11:38:46 -0700 | [diff] [blame] | 72 | * @return this DistributedSetBuilder |
Madan Jampani | 02b7fb8 | 2015-05-01 13:01:20 -0700 | [diff] [blame] | 73 | */ |
Madan Jampani | 50589ac | 2015-06-08 11:38:46 -0700 | [diff] [blame] | 74 | DistributedSetBuilder<E> withUpdatesDisabled(); |
| 75 | |
| 76 | /** |
| 77 | * Disables distribution of set entries across multiple database partitions. |
| 78 | * <p> |
| 79 | * When partitioning is disabled, the returned set will have a single partition |
| 80 | * that spans the entire cluster. Furthermore, the changes made to the set are |
| 81 | * ephemeral and do not survive a full cluster restart. |
| 82 | * </p> |
| 83 | * <p> |
| 84 | * Disabling partitions is more appropriate when the returned set is used for |
| 85 | * simple coordination activities and not for long term data persistence. |
| 86 | * </p> |
| 87 | * <p> |
| 88 | * Note: By default partitions are enabled and entries in the set are durable. |
| 89 | * </p> |
| 90 | * @return this DistributedSetBuilder |
| 91 | */ |
| 92 | DistributedSetBuilder<E> withPartitionsDisabled(); |
Madan Jampani | 02b7fb8 | 2015-05-01 13:01:20 -0700 | [diff] [blame] | 93 | |
| 94 | /** |
Madan Jampani | e8af1cc | 2015-06-23 14:23:31 -0700 | [diff] [blame] | 95 | * Purges set contents when the application owning the set is uninstalled. |
| 96 | * <p> |
| 97 | * When this option is enabled, the caller must provide a applicationId via |
| 98 | * the {@code withAppliationId} builder method. |
| 99 | * <p> |
| 100 | * By default set contents will NOT be purged when owning application is uninstalled. |
| 101 | * |
| 102 | * @return this DistributedSetBuilder |
| 103 | */ |
| 104 | DistributedSetBuilder<E> withPurgeOnUninstall(); |
| 105 | |
| 106 | /** |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 107 | * Builds an set based on the configuration options |
| 108 | * supplied to this builder. |
| 109 | * |
| 110 | * @return new set |
| 111 | * @throws java.lang.RuntimeException if a mandatory parameter is missing |
| 112 | */ |
Madan Jampani | 50589ac | 2015-06-08 11:38:46 -0700 | [diff] [blame] | 113 | DistributedSet<E> build(); |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 114 | } |