blob: a21a1f9684c43fa2d96b90e8902336d44d851502 [file] [log] [blame]
Thomas Vachuska48448082016-02-19 22:14:54 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Thomas Vachuska48448082016-02-19 22:14:54 -08003 *
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 */
16package org.onosproject.net.region;
17
18import org.onosproject.cluster.NodeId;
19import org.onosproject.net.DeviceId;
Steven Burrows19e6e4f2016-10-05 13:27:07 -050020import org.onosproject.net.HostId;
Thomas Vachuska48448082016-02-19 22:14:54 -080021import org.onosproject.store.Store;
22
23import java.util.Collection;
24import java.util.List;
25import java.util.Set;
26
27/**
28 * Manages inventory of regions of devices; not intended for direct use.
29 */
30public 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
71 * @param masterNodeIds list of master nodes; null implies empty list
72 * @return new region descriptor
73 * @throws IllegalArgumentException if item already exists
74 */
75 Region createRegion(RegionId regionId, String name, Region.Type type,
76 List<Set<NodeId>> masterNodeIds);
77
78 /**
79 * Updates the specified new region using the supplied data.
80 *
81 * @param regionId region identifier
82 * @param name friendly name
83 * @param type region type
84 * @param masterNodeIds list of master nodes; null implies empty list
85 * @return new region descriptor
86 * @throws IllegalArgumentException if item already exists
87 */
88 Region updateRegion(RegionId regionId, String name, Region.Type type,
89 List<Set<NodeId>> masterNodeIds);
90
91 /**
92 * Removes the specified region using the new set of data.
93 *
94 * @param regionId region identifier
95 */
96 void removeRegion(RegionId regionId);
97
98 /**
99 * Adds the specified collection of devices to the region.
100 *
101 * @param regionId region identifier
102 * @param deviceIds list of device identifiers
103 */
104 void addDevices(RegionId regionId, Collection<DeviceId> deviceIds);
105
106 /**
107 * Removes the specified collection of devices from the region.
108 *
109 * @param regionId region identifier
110 * @param deviceIds list of device identifiers
111 */
112 void removeDevices(RegionId regionId, Collection<DeviceId> deviceIds);
113
Steven Burrows19e6e4f2016-10-05 13:27:07 -0500114 /**
115 * Returns the set of hosts that belong to the specified region.
116 *
117 * @param regionId region identifier
118 * @return set of identifiers for hosts in the given region
119 */
120 Set<HostId> getRegionHosts(RegionId regionId);
121
Thomas Vachuska48448082016-02-19 22:14:54 -0800122}