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 | * Adds the DeviceBandwidthProfile to the pendingMeters. |
| 72 | * |
| 73 | * @param deviceBandwidthProfile the device to bandwidth profile mapping |
| 74 | */ |
| 75 | void addToPendingMeters(DeviceBandwidthProfile deviceBandwidthProfile); |
| 76 | |
| 77 | /** |
| 78 | * Removes the DeviceBandwidthProfile from the pendingMeters. |
| 79 | * |
| 80 | * @param deviceBandwidthProfile the device to bandwidth profile mapping |
| 81 | * |
| 82 | */ |
| 83 | void removeFromPendingMeters(DeviceBandwidthProfile deviceBandwidthProfile); |
| 84 | |
| 85 | /** |
| 86 | * Checks if DeviceBandwidthProfile is pending. |
| 87 | * |
| 88 | * @param deviceBandwidthProfile the device to bandwidth profile mapping |
| 89 | * |
| 90 | * @return true if pending. |
| 91 | */ |
| 92 | boolean isMeterPending(DeviceBandwidthProfile deviceBandwidthProfile); |
| 93 | |
| 94 | /** |
Jonathan Hart | 4f178fa | 2020-02-03 10:46:01 -0800 | [diff] [blame] | 95 | * Clears out bandwidth profile to meter mappings for the given device. |
| 96 | * |
| 97 | * @param deviceId device ID |
| 98 | */ |
| 99 | void clearMeters(DeviceId deviceId); |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 100 | } |