blob: b8527c73e6326f15dcce5460ef5e5878d83a132d [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;
Simon Hunt53612212016-12-04 17:19:52 -080019import org.onosproject.net.Annotations;
Thomas Vachuska48448082016-02-19 22:14:54 -080020import org.onosproject.net.DeviceId;
21import 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
Simon Hunt53612212016-12-04 17:19:52 -080071 * @param annots annotations
Thomas Vachuska48448082016-02-19 22:14:54 -080072 * @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 Hunt53612212016-12-04 17:19:52 -080077 Annotations annots, List<Set<NodeId>> masterNodeIds);
Thomas Vachuska48448082016-02-19 22:14:54 -080078
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 Hunt53612212016-12-04 17:19:52 -080085 * @param annots annotations
Thomas Vachuska48448082016-02-19 22:14:54 -080086 * @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 Hunt53612212016-12-04 17:19:52 -080091 Annotations annots, List<Set<NodeId>> masterNodeIds);
Thomas Vachuska48448082016-02-19 22:14:54 -080092
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 Vachuska48448082016-02-19 22:14:54 -0800116}