blob: 05ae43a3b44cd98070d2fbb728a2e475fc20e4e3 [file] [log] [blame]
Daniele Moro94660a02019-12-02 12:02:07 -08001/*
2 * Copyright 2019-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
17package org.opencord.bng;
18
19import com.google.common.base.MoreObjects;
20import com.google.common.collect.ImmutableMap;
21import org.onosproject.net.behaviour.BngProgrammable.BngCounterType;
22import org.onosproject.net.pi.runtime.PiCounterCellData;
23
24import java.util.Map;
25
26/**
27 * Subject for attachment-level statistics events.
28 */
29public final class BngStatsEventSubject {
30
31 private final BngAttachment bngAttachment;
32 private final String attachmentKey;
33 private final ImmutableMap<BngCounterType, PiCounterCellData> attachmentStats;
34
35 /**
36 * Creates a subject for attachment-level statistics event.
37 *
38 * @param attachmentKey The attachment key
39 * @param bngAttachment The attachment instance
40 * @param attachmentStats The attachments statistics
41 */
42 public BngStatsEventSubject(String attachmentKey, BngAttachment bngAttachment,
43 Map<BngCounterType, PiCounterCellData> attachmentStats) {
44 this.attachmentKey = attachmentKey;
45 this.bngAttachment = bngAttachment;
46 this.attachmentStats = ImmutableMap.copyOf(attachmentStats);
47 }
48
49 /**
50 * Returns an immutable representation of the attachment-level statistics.
51 *
52 * @return The pair attachment instance and attachment-level statistics
53 */
54 public Map<BngCounterType, PiCounterCellData> getAttachmentStats() {
55 return attachmentStats;
56 }
57
58 /**
59 * Returns the BNG attachment instance of the attachment-level statistics.
60 *
61 * @return The BNG attachment instance
62 */
63 public BngAttachment getBngAttachment() {
64 return this.bngAttachment;
65 }
66
67 public String getAttachmentKey() {
68 return this.attachmentKey;
69 }
70
71
72 @Override
73 public String toString() {
74 return MoreObjects.toStringHelper(this)
75 .add("attachmentKey", attachmentKey)
76 .add("bngAttachment", bngAttachment)
77 .add("attachmentsStats", attachmentStats)
78 .toString();
79 }
80}