alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 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 | */ |
Thomas Vachuska | 52f2cd1 | 2018-11-08 21:20:04 -0800 | [diff] [blame] | 16 | package org.onosproject.store.meter.impl; |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 17 | |
| 18 | import org.onosproject.cluster.NodeId; |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 19 | import org.onosproject.net.meter.Meter; |
| 20 | import org.onosproject.net.meter.MeterFailReason; |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 21 | |
| 22 | import java.util.Optional; |
| 23 | |
| 24 | /** |
| 25 | * A class representing the meter information stored in the meter store. |
| 26 | */ |
| 27 | public class MeterData { |
| 28 | |
| 29 | private final Meter meter; |
| 30 | private final Optional<MeterFailReason> reason; |
| 31 | private final NodeId origin; |
| 32 | |
pierventre | 1b8afbc | 2020-07-13 14:07:05 +0200 | [diff] [blame] | 33 | /** |
| 34 | * Builds up a meter data. |
| 35 | * @param meter the meter |
| 36 | * @param reason the reason of the failure |
| 37 | * @param origin the node from which the request is originated |
| 38 | * @deprecated in ONOS 2.2 |
| 39 | */ |
| 40 | @Deprecated |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 41 | public MeterData(Meter meter, MeterFailReason reason, NodeId origin) { |
| 42 | this.meter = meter; |
| 43 | this.reason = Optional.ofNullable(reason); |
| 44 | this.origin = origin; |
| 45 | } |
| 46 | |
pierventre | 1b8afbc | 2020-07-13 14:07:05 +0200 | [diff] [blame] | 47 | /** |
| 48 | * Builds up a meter data. |
| 49 | * @param meter the meter |
| 50 | * @param reason the reason of the failure |
| 51 | */ |
| 52 | public MeterData(Meter meter, MeterFailReason reason) { |
| 53 | this(meter, reason, null); |
| 54 | } |
| 55 | |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 56 | public Meter meter() { |
| 57 | return meter; |
| 58 | } |
| 59 | |
| 60 | public Optional<MeterFailReason> reason() { |
| 61 | return this.reason; |
| 62 | } |
| 63 | |
pierventre | 1b8afbc | 2020-07-13 14:07:05 +0200 | [diff] [blame] | 64 | /** |
| 65 | * Returns the origin node. |
| 66 | * @return the node id of the origin node |
| 67 | * @deprecated in ONOS 2.2 |
| 68 | */ |
| 69 | @Deprecated |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 70 | public NodeId origin() { |
| 71 | return this.origin; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | } |