Thomas Vachuska | 4844808 | 2016-02-19 22:14:54 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Thomas Vachuska | 4844808 | 2016-02-19 22:14:54 -0800 | [diff] [blame] | 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.net.region; |
| 17 | |
| 18 | import org.onosproject.cluster.NodeId; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.store.Store; |
| 21 | |
| 22 | import java.util.Collection; |
| 23 | import java.util.List; |
| 24 | import java.util.Set; |
| 25 | |
| 26 | /** |
| 27 | * Manages inventory of regions of devices; not intended for direct use. |
| 28 | */ |
| 29 | public interface RegionStore extends Store<RegionEvent, RegionStoreDelegate> { |
| 30 | |
| 31 | /** |
| 32 | * Returns set of all regions. |
| 33 | * |
| 34 | * @return set of regions |
| 35 | */ |
| 36 | Set<Region> getRegions(); |
| 37 | |
| 38 | /** |
| 39 | * Returns the region with the specified identifier. |
| 40 | * |
| 41 | * @param regionId region identifier |
| 42 | * @return region |
| 43 | * @throws org.onlab.util.ItemNotFoundException if region with given |
| 44 | * id does not exist |
| 45 | */ |
| 46 | Region getRegion(RegionId regionId); |
| 47 | |
| 48 | /** |
| 49 | * Returns the region to which the specified device belongs. |
| 50 | * |
| 51 | * @param deviceId device identifier |
| 52 | * @return region or null if device does not belong to any region |
| 53 | */ |
| 54 | Region getRegionForDevice(DeviceId deviceId); |
| 55 | |
| 56 | /** |
| 57 | * Returns the set of devices that belong to the specified region. |
| 58 | * |
| 59 | * @param regionId region identifier |
| 60 | * @return set of identifiers for devices in the given region |
| 61 | */ |
| 62 | Set<DeviceId> getRegionDevices(RegionId regionId); |
| 63 | |
| 64 | /** |
| 65 | * Creates a new region using the supplied data. |
| 66 | * |
| 67 | * @param regionId region identifier |
| 68 | * @param name friendly name |
| 69 | * @param type region type |
| 70 | * @param masterNodeIds list of master nodes; null implies empty list |
| 71 | * @return new region descriptor |
| 72 | * @throws IllegalArgumentException if item already exists |
| 73 | */ |
| 74 | Region createRegion(RegionId regionId, String name, Region.Type type, |
| 75 | List<Set<NodeId>> masterNodeIds); |
| 76 | |
| 77 | /** |
| 78 | * Updates the specified new region using the supplied data. |
| 79 | * |
| 80 | * @param regionId region identifier |
| 81 | * @param name friendly name |
| 82 | * @param type region type |
| 83 | * @param masterNodeIds list of master nodes; null implies empty list |
| 84 | * @return new region descriptor |
| 85 | * @throws IllegalArgumentException if item already exists |
| 86 | */ |
| 87 | Region updateRegion(RegionId regionId, String name, Region.Type type, |
| 88 | List<Set<NodeId>> masterNodeIds); |
| 89 | |
| 90 | /** |
| 91 | * Removes the specified region using the new set of data. |
| 92 | * |
| 93 | * @param regionId region identifier |
| 94 | */ |
| 95 | void removeRegion(RegionId regionId); |
| 96 | |
| 97 | /** |
| 98 | * Adds the specified collection of devices to the region. |
| 99 | * |
| 100 | * @param regionId region identifier |
| 101 | * @param deviceIds list of device identifiers |
| 102 | */ |
| 103 | void addDevices(RegionId regionId, Collection<DeviceId> deviceIds); |
| 104 | |
| 105 | /** |
| 106 | * Removes the specified collection of devices from the region. |
| 107 | * |
| 108 | * @param regionId region identifier |
| 109 | * @param deviceIds list of device identifiers |
| 110 | */ |
| 111 | void removeDevices(RegionId regionId, Collection<DeviceId> deviceIds); |
| 112 | |
| 113 | } |