blob: 4b921fb8d0d0897945dbc629b86ad300664f2ed5 [file] [log] [blame]
Andrea Campanellacbbb7952019-11-25 06:38:41 +00001/*
2 * Copyright 2016-present Open Networking Foundation
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 */
16package org.opencord.olt.internalapi;
17
18import com.google.common.collect.ImmutableMap;
19import com.google.common.collect.ImmutableSet;
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.meter.MeterId;
22import org.onosproject.net.meter.MeterKey;
23import org.opencord.sadis.BandwidthProfileInformation;
24
25import java.util.Collection;
26import java.util.concurrent.CompletableFuture;
27
28/**
29 * Olt service for meter operations.
30 */
31public interface AccessDeviceMeterService {
32
33 /**
34 * Returns information about bandwidthProfile-meterKey (device / meter) mappings
35 * that have been programmed in the data-plane.
36 *
37 * @return an immutable map of bandwidthProfile-meterKey (device / meter) mappings
38 */
39 ImmutableMap<String, Collection<MeterKey>> getBpMeterMappings();
40
41 /**
Andrea Campanellacbbb7952019-11-25 06:38:41 +000042 * Returns the meter id for a given bandwidth profile.
43 *
44 * @param deviceId the access device id
45 * @param bandwidthProfile the bandwidth profile id
46 * @return the meter id
47 */
48 MeterId getMeterIdFromBpMapping(DeviceId deviceId, String bandwidthProfile);
49
50 /**
51 * Returns information about device-meter relations that have been programmed in the
52 * data-plane.
53 *
54 * @return an immutable set of device-meter mappings
55 */
56 ImmutableSet<MeterKey> getProgMeters();
57
58 /**
59 * Creates a meter and sends it to the device.
60 *
61 * @param deviceId the access device id
62 * @param bpInfo the bandwidth profile information
63 * @param meterFuture the meter future to indicate whether the meter creation is
64 * successful or not.
65 * @return meter id that is generated for the given parameters
66 */
67 MeterId createMeter(DeviceId deviceId, BandwidthProfileInformation bpInfo,
68 CompletableFuture<Object> meterFuture);
69
Jonathan Hart4f178fa2020-02-03 10:46:01 -080070 /**
Andrea Campanella3ce4d282020-06-09 13:46:58 +020071 * Adds the DeviceBandwidthProfile to the pendingMeters.
72 *
Andrea Campanella600d2e22020-06-22 11:00:31 +020073 * @param deviceId the device
74 * @param bwpInfo the bandwidth profile info
Andrea Campanella3ce4d282020-06-09 13:46:58 +020075 */
Andrea Campanella600d2e22020-06-22 11:00:31 +020076 void addToPendingMeters(DeviceId deviceId, BandwidthProfileInformation bwpInfo);
Andrea Campanella3ce4d282020-06-09 13:46:58 +020077
78 /**
79 * Removes the DeviceBandwidthProfile from the pendingMeters.
80 *
Andrea Campanella600d2e22020-06-22 11:00:31 +020081 * @param deviceId the device
82 * @param bwpInfo the bandwidth profile info
Andrea Campanella3ce4d282020-06-09 13:46:58 +020083 *
84 */
Andrea Campanella600d2e22020-06-22 11:00:31 +020085 void removeFromPendingMeters(DeviceId deviceId, BandwidthProfileInformation bwpInfo);
Andrea Campanella3ce4d282020-06-09 13:46:58 +020086
87 /**
88 * Checks if DeviceBandwidthProfile is pending.
89 *
Andrea Campanella600d2e22020-06-22 11:00:31 +020090 * @param deviceId the device
91 * @param bwpInfo the bandwidth profile info
Andrea Campanella3ce4d282020-06-09 13:46:58 +020092 *
93 * @return true if pending.
94 */
Andrea Campanella600d2e22020-06-22 11:00:31 +020095 boolean isMeterPending(DeviceId deviceId, BandwidthProfileInformation bwpInfo);
Andrea Campanella3ce4d282020-06-09 13:46:58 +020096
97 /**
Andrea Campanella600d2e22020-06-22 11:00:31 +020098 * Clears out meters for the given device.
Jonathan Hart4f178fa2020-02-03 10:46:01 -080099 *
100 * @param deviceId device ID
101 */
102 void clearMeters(DeviceId deviceId);
Andrea Campanella600d2e22020-06-22 11:00:31 +0200103
104 /**
105 * Clears out local state for the given device.
106 *
107 * @param deviceId device ID
108 */
109 void clearDeviceState(DeviceId deviceId);
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000110}