blob: cf99b5ed16eb39f1bd38f8a3a2a895ba62208e1c [file] [log] [blame]
alshabib1d2bc402015-07-31 17:04:11 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabib1d2bc402015-07-31 17:04:11 -07003 *
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 */
alshabib10c810b2015-08-18 16:59:04 -070016package org.onosproject.net.meter;
alshabib1d2bc402015-07-31 17:04:11 -070017
18import org.onosproject.event.ListenerService;
alshabib70aaa1b2015-09-25 14:30:59 -070019import org.onosproject.net.DeviceId;
alshabib1d2bc402015-07-31 17:04:11 -070020
alshabib58fe6dc2015-08-19 17:16:13 -070021import java.util.Collection;
22
alshabib1d2bc402015-07-31 17:04:11 -070023/**
24 * Service for add/updating and removing meters. Meters are
25 * are assigned to flow to rate limit them and provide a certain
26 * quality of service.
27 */
28public interface MeterService
29 extends ListenerService<MeterEvent, MeterListener> {
30
31 /**
32 * Adds a meter to the system and performs it installation.
33 *
alshabibe1248b62015-08-20 17:21:55 -070034 * @param meter a meter
35 * @return a meter (with a meter id)
alshabib1d2bc402015-07-31 17:04:11 -070036 */
alshabibe1248b62015-08-20 17:21:55 -070037 Meter submit(MeterRequest meter);
alshabib1d2bc402015-07-31 17:04:11 -070038
39 /**
40 * Remove a meter from the system and the dataplane.
41 *
42 * @param meter a meter to remove
alshabibe1248b62015-08-20 17:21:55 -070043 * @param meterId the meter id of the meter to remove.
alshabib1d2bc402015-07-31 17:04:11 -070044 */
alshabibe1248b62015-08-20 17:21:55 -070045 void withdraw(MeterRequest meter, MeterId meterId);
alshabib1d2bc402015-07-31 17:04:11 -070046
47 /**
48 * Fetch the meter by the meter id.
49 *
alshabib70aaa1b2015-09-25 14:30:59 -070050 * @param deviceId a device id
alshabib1d2bc402015-07-31 17:04:11 -070051 * @param id a meter id
52 * @return a meter
53 */
alshabib70aaa1b2015-09-25 14:30:59 -070054 Meter getMeter(DeviceId deviceId, MeterId id);
alshabib1d2bc402015-07-31 17:04:11 -070055
56 /**
alshabib58fe6dc2015-08-19 17:16:13 -070057 * Fetches all the meters.
58 *
59 * @return a collection of meters
60 */
61 Collection<Meter> getAllMeters();
62
Jian Li1932b932016-01-03 00:35:40 -080063 /**
64 * Fetches the meters by the device id.
65 *
66 * @param deviceId a device id
67 * @return a collection of meters
68 */
69 Collection<Meter> getMeters(DeviceId deviceId);
Pier Luigibdcd9672017-10-13 13:54:48 +020070
71 /**
72 * Allocates a new meter id in the system.
73 *
74 * @param deviceId the device id
75 * @return the allocated meter id, null if there is an internal error
76 * or there are no meter ids available
Wailok Shumf013a782021-07-26 16:51:01 +080077 * @deprecated in onos-2.5
Pier Luigibdcd9672017-10-13 13:54:48 +020078 */
Wailok Shumf013a782021-07-26 16:51:01 +080079 @Deprecated
Pier Luigibdcd9672017-10-13 13:54:48 +020080 MeterId allocateMeterId(DeviceId deviceId);
81
82 /**
83 * Frees the given meter id.
84 *
85 * @param deviceId the device id
86 * @param meterId the id to be freed
Wailok Shumf013a782021-07-26 16:51:01 +080087 * @deprecated in onos-2.5
Pier Luigibdcd9672017-10-13 13:54:48 +020088 */
Wailok Shumf013a782021-07-26 16:51:01 +080089 @Deprecated
Pier Luigibdcd9672017-10-13 13:54:48 +020090 void freeMeterId(DeviceId deviceId, MeterId meterId);
Andrea Campanella23250502020-05-13 15:36:57 +020091
92 /**
93 * Purges all the meters on the specified device.
94 * @param deviceId device identifier
95 */
96 default void purgeMeters(DeviceId deviceId){
97 //Default implementation does nothing
98 }
99
alshabib1d2bc402015-07-31 17:04:11 -0700100}