Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.opencord.olt.internalapi; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableMap; |
| 19 | import com.google.common.collect.ImmutableSet; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.meter.MeterId; |
| 22 | import org.onosproject.net.meter.MeterKey; |
| 23 | import org.opencord.sadis.BandwidthProfileInformation; |
| 24 | |
| 25 | import java.util.Collection; |
| 26 | import java.util.concurrent.CompletableFuture; |
| 27 | |
| 28 | /** |
| 29 | * Olt service for meter operations. |
| 30 | */ |
| 31 | public 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 Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 42 | * 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 Hart | 4f178fa | 2020-02-03 10:46:01 -0800 | [diff] [blame] | 70 | /** |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 71 | * Removes the DeviceBandwidthProfile from the pendingMeters. |
| 72 | * |
Andrea Campanella | 600d2e2 | 2020-06-22 11:00:31 +0200 | [diff] [blame] | 73 | * @param deviceId the device |
| 74 | * @param bwpInfo the bandwidth profile info |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 75 | * |
| 76 | */ |
Andrea Campanella | 600d2e2 | 2020-06-22 11:00:31 +0200 | [diff] [blame] | 77 | void removeFromPendingMeters(DeviceId deviceId, BandwidthProfileInformation bwpInfo); |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 78 | |
| 79 | /** |
Andrea Campanella | d1e2664 | 2020-10-23 12:08:32 +0200 | [diff] [blame] | 80 | * 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 Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 84 | * |
Andrea Campanella | 600d2e2 | 2020-06-22 11:00:31 +0200 | [diff] [blame] | 85 | * @param deviceId the device |
| 86 | * @param bwpInfo the bandwidth profile info |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 87 | * |
Andrea Campanella | d1e2664 | 2020-10-23 12:08:32 +0200 | [diff] [blame] | 88 | * @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 Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 90 | */ |
Andrea Campanella | d1e2664 | 2020-10-23 12:08:32 +0200 | [diff] [blame] | 91 | boolean checkAndAddPendingMeter(DeviceId deviceId, BandwidthProfileInformation bwpInfo); |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 92 | |
| 93 | /** |
Andrea Campanella | 600d2e2 | 2020-06-22 11:00:31 +0200 | [diff] [blame] | 94 | * Clears out meters for the given device. |
Jonathan Hart | 4f178fa | 2020-02-03 10:46:01 -0800 | [diff] [blame] | 95 | * |
| 96 | * @param deviceId device ID |
| 97 | */ |
| 98 | void clearMeters(DeviceId deviceId); |
Andrea Campanella | 600d2e2 | 2020-06-22 11:00:31 +0200 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * Clears out local state for the given device. |
| 102 | * |
| 103 | * @param deviceId device ID |
| 104 | */ |
| 105 | void clearDeviceState(DeviceId deviceId); |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 106 | } |