blob: f392122984b705f215e552310208a1050659f886 [file] [log] [blame]
alshabibeadfc8e2015-08-18 15:40:46 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabibeadfc8e2015-08-18 15:40:46 -07003 *
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 Vachuska52f2cd12018-11-08 21:20:04 -080016package org.onosproject.store.meter.impl;
alshabibeadfc8e2015-08-18 15:40:46 -070017
18import org.onosproject.cluster.NodeId;
alshabib10c810b2015-08-18 16:59:04 -070019import org.onosproject.net.meter.Meter;
20import org.onosproject.net.meter.MeterFailReason;
alshabibeadfc8e2015-08-18 15:40:46 -070021
22import java.util.Optional;
23
24/**
25 * A class representing the meter information stored in the meter store.
26 */
27public class MeterData {
28
29 private final Meter meter;
30 private final Optional<MeterFailReason> reason;
31 private final NodeId origin;
32
pierventre1b8afbc2020-07-13 14:07:05 +020033 /**
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
alshabibeadfc8e2015-08-18 15:40:46 -070041 public MeterData(Meter meter, MeterFailReason reason, NodeId origin) {
42 this.meter = meter;
43 this.reason = Optional.ofNullable(reason);
44 this.origin = origin;
45 }
46
pierventre1b8afbc2020-07-13 14:07:05 +020047 /**
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
alshabibeadfc8e2015-08-18 15:40:46 -070056 public Meter meter() {
57 return meter;
58 }
59
60 public Optional<MeterFailReason> reason() {
61 return this.reason;
62 }
63
pierventre1b8afbc2020-07-13 14:07:05 +020064 /**
65 * Returns the origin node.
66 * @return the node id of the origin node
67 * @deprecated in ONOS 2.2
68 */
69 @Deprecated
alshabibeadfc8e2015-08-18 15:40:46 -070070 public NodeId origin() {
71 return this.origin;
72 }
73
74
75}