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