blob: da97948ea0613bfe7924e8a7ced8fa735b647869 [file] [log] [blame]
Jian Li0967cd72015-11-25 17:38:48 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jian Li0967cd72015-11-25 17:38:48 -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.cpman;
17
Jian Li89eeccd2016-05-06 02:10:33 -070018import com.google.common.collect.ImmutableSet;
19import org.onlab.util.Tools;
Jian Li0967cd72015-11-25 17:38:48 -080020import org.onosproject.cluster.NodeId;
21import org.onosproject.net.DeviceId;
22
23import java.util.Optional;
Jian Li85060ac2016-02-04 09:58:56 -080024import java.util.Set;
Jian Li23906cc2016-03-31 11:16:44 -070025import java.util.concurrent.CompletableFuture;
Jian Li67e1e152016-04-18 17:52:58 -070026import java.util.concurrent.TimeUnit;
Jian Li85060ac2016-02-04 09:58:56 -080027
Jian Li67e1e152016-04-18 17:52:58 -070028import static org.onosproject.cpman.ControlResource.Type;
Jian Li0967cd72015-11-25 17:38:48 -080029
30/**
31 * Control Plane Statistics Service Interface.
32 */
Jian Li60804322015-12-02 14:46:31 -080033public interface ControlPlaneMonitorService {
Jian Li0967cd72015-11-25 17:38:48 -080034
Jian Li89eeccd2016-05-06 02:10:33 -070035 long TIMEOUT_MILLIS = 2000;
36
Jian Li0967cd72015-11-25 17:38:48 -080037 /**
Jian Li60804322015-12-02 14:46:31 -080038 * Adds a new control metric value with a certain update interval.
Jian Li0967cd72015-11-25 17:38:48 -080039 *
Jian Li23906cc2016-03-31 11:16:44 -070040 * @param controlMetric control plane metric (e.g., control
41 * message rate, cpu, memory, etc.)
42 * @param updateIntervalInMinutes value update interval (in minute)
43 * @param deviceId device identifier
Jian Li0967cd72015-11-25 17:38:48 -080044 */
Jian Lic5cb4a12016-02-03 23:24:42 -080045 void updateMetric(ControlMetric controlMetric, int updateIntervalInMinutes,
46 Optional<DeviceId> deviceId);
Jian Li0967cd72015-11-25 17:38:48 -080047
48 /**
Jian Lie044d1a2016-01-25 09:01:20 -080049 * Adds a new control metric value with a certain update interval.
50 *
Jian Li23906cc2016-03-31 11:16:44 -070051 * @param controlMetric control plane metric (e.g., disk and
52 * network metrics)
53 * @param updateIntervalInMinutes value update interval (in minute)
54 * @param resourceName resource name
Jian Lie044d1a2016-01-25 09:01:20 -080055 */
Jian Lic5cb4a12016-02-03 23:24:42 -080056 void updateMetric(ControlMetric controlMetric, int updateIntervalInMinutes,
57 String resourceName);
Jian Lie044d1a2016-01-25 09:01:20 -080058
59 /**
Jian Li67e1e152016-04-18 17:52:58 -070060 * Obtains snapshot of control plane load of a specific device.
Jian Li7d180c52016-02-01 21:53:08 -080061 * The metrics range from control messages and system metrics
Jian Li67e1e152016-04-18 17:52:58 -070062 * (e.g., CPU and memory info).
63 * If the device id is not specified, it returns system metrics, otherwise,
64 * it returns control message stats of the given device.
Jian Li23906cc2016-03-31 11:16:44 -070065 *
66 * @param nodeId node identifier
67 * @param type control metric type
68 * @param deviceId device identifier
Jian Li67e1e152016-04-18 17:52:58 -070069 * @return completable future object of control load snapshot
Jian Li23906cc2016-03-31 11:16:44 -070070 */
Jian Li67e1e152016-04-18 17:52:58 -070071 CompletableFuture<ControlLoadSnapshot> getLoad(NodeId nodeId,
72 ControlMetricType type,
73 Optional<DeviceId> deviceId);
Jian Li23906cc2016-03-31 11:16:44 -070074
75 /**
Jian Li67e1e152016-04-18 17:52:58 -070076 * Obtains snapshot of control plane load of a specific resource.
77 * The metrics include I/O device metrics (e.g., disk and network metrics).
Jian Li23906cc2016-03-31 11:16:44 -070078 *
79 * @param nodeId node identifier
80 * @param type control metric type
81 * @param resourceName resource name
Jian Li67e1e152016-04-18 17:52:58 -070082 * @return completable future object of control load snapshot
Jian Li23906cc2016-03-31 11:16:44 -070083 */
Jian Li67e1e152016-04-18 17:52:58 -070084 CompletableFuture<ControlLoadSnapshot> getLoad(NodeId nodeId,
85 ControlMetricType type,
86 String resourceName);
87
88 /**
89 * Obtains snapshot of control plane load of a specific device with the
90 * projected range.
91 *
92 * @param nodeId node identifier
93 * @param type control metric type
94 * @param duration projected duration
95 * @param unit projected time unit
96 * @param deviceId device identifier
97 * @return completable future object of control load snapshot
98 */
99 CompletableFuture<ControlLoadSnapshot> getLoad(NodeId nodeId,
100 ControlMetricType type,
101 int duration, TimeUnit unit,
102 Optional<DeviceId> deviceId);
103
104 /**
105 * Obtains snapshot of control plane load of a specific resource with the
106 * projected range.
107 *
108 * @param nodeId node identifier
109 * @param type control metric type
110 * @param duration projected duration
111 * @param unit projected time unit
112 * @param resourceName resource name
113 * @return completable future object of control load snapshot
114 */
115 CompletableFuture<ControlLoadSnapshot> getLoad(NodeId nodeId,
116 ControlMetricType type,
117 int duration, TimeUnit unit,
118 String resourceName);
Jian Li85060ac2016-02-04 09:58:56 -0800119
120 /**
121 * Obtains a list of names of available resources.
122 *
Jian Li89eeccd2016-05-06 02:10:33 -0700123 * @param nodeId node identifier
Jian Li72b9b122016-02-11 15:58:51 -0800124 * @param resourceType resource type
Jian Li89eeccd2016-05-06 02:10:33 -0700125 * @return completable future object of a collection of available resource names
Jian Li85060ac2016-02-04 09:58:56 -0800126 */
Jian Li89eeccd2016-05-06 02:10:33 -0700127 CompletableFuture<Set<String>> availableResources(NodeId nodeId, Type resourceType);
128
129 /**
130 * Synchronous version of availableResource.
131 * Obtains a list of names of available resources.
132 *
133 * @param nodeId node identifier
134 * @param resourceType resource type
135 * @return a collection of available resource names
136 */
137 default Set<String> availableResourcesSync(NodeId nodeId, Type resourceType) {
138 return Tools.futureGetOrElse(availableResources(nodeId, resourceType),
139 TIMEOUT_MILLIS, TimeUnit.MILLISECONDS, ImmutableSet.of());
140 }
Jian Li0967cd72015-11-25 17:38:48 -0800141}