blob: ca04ed450b418cc770dc3921f1c7ccebb71f049c [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 * Removes the DeviceBandwidthProfile from 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 *
76 */
Andrea Campanella600d2e22020-06-22 11:00:31 +020077 void removeFromPendingMeters(DeviceId deviceId, BandwidthProfileInformation bwpInfo);
Andrea Campanella3ce4d282020-06-09 13:46:58 +020078
79 /**
Andrea Campanellad1e26642020-10-23 12:08:32 +020080 * Checks if DeviceBandwidthProfile is pending installation.
81 * If so immediately returns false meaning that no further action is needed,
82 * if not it adds the bandwidth profile do the pending list and returns true,
83 * meaning that further action to install the meter is required.
Andrea Campanella3ce4d282020-06-09 13:46:58 +020084 *
Andrea Campanella600d2e22020-06-22 11:00:31 +020085 * @param deviceId the device
86 * @param bwpInfo the bandwidth profile info
Andrea Campanella3ce4d282020-06-09 13:46:58 +020087 *
Andrea Campanellad1e26642020-10-23 12:08:32 +020088 * @return true if it was added to pending and a create meter action is needed,
89 * false if it is already pending and no further action is needed.
Andrea Campanella3ce4d282020-06-09 13:46:58 +020090 */
Andrea Campanellad1e26642020-10-23 12:08:32 +020091 boolean checkAndAddPendingMeter(DeviceId deviceId, BandwidthProfileInformation bwpInfo);
Andrea Campanella3ce4d282020-06-09 13:46:58 +020092
93 /**
Andrea Campanella600d2e22020-06-22 11:00:31 +020094 * Clears out meters for the given device.
Jonathan Hart4f178fa2020-02-03 10:46:01 -080095 *
96 * @param deviceId device ID
97 */
98 void clearMeters(DeviceId deviceId);
Andrea Campanella600d2e22020-06-22 11:00:31 +020099
100 /**
101 * Clears out local state for the given device.
102 *
103 * @param deviceId device ID
104 */
105 void clearDeviceState(DeviceId deviceId);
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000106}