blob: 596fb6c6cfb323e0fb18da868b9eead072048a84 [file] [log] [blame]
Jonathan Hartc36c9552018-07-31 15:07:53 -04001/*
2 * Copyright 2018-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.dhcpl2relay;
18
19import org.onosproject.event.AbstractEvent;
20import org.onosproject.net.ConnectPoint;
21
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030022import java.util.Map;
23import java.util.concurrent.atomic.AtomicLong;
24
Jonathan Hartc36c9552018-07-31 15:07:53 -040025/**
26 * Dhcp L2 relay event.
27 */
28public class DhcpL2RelayEvent extends AbstractEvent<DhcpL2RelayEvent.Type, DhcpAllocationInfo> {
29
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030030 public static final String GLOBAL_COUNTER = "global";
31
Jonathan Hartc36c9552018-07-31 15:07:53 -040032 private final ConnectPoint connectPoint;
33
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030034 private final Map.Entry<String, AtomicLong> countersEntry;
35
36 private final String dhcpCountersTopic;
37
38 private final String subscriberId;
39
Jonathan Hartc36c9552018-07-31 15:07:53 -040040 /**
41 * Type of the event.
42 */
43 public enum Type {
44 /**
45 * DHCP lease was updated.
46 */
47 UPDATED,
48
49 /**
50 * DHCP lease was removed.
51 */
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030052 REMOVED,
53
54 /**
55 * DHCP stats update.
56 */
57 STATS_UPDATE
58 }
59
60 /**
61 * Creates a new event used for STATS.
62 *
63 * @param type type of the event
64 * @param allocationInfo DHCP allocation info
65 * @param connectPoint connect point the client is on
66 * @param countersEntry an entry that represents the counters (used for STATS events)
67 * @param dhcpCountersTopic Kafka topic where the dhcp counters are published
68 * @param subscriberId the subscriber identifier information
69 */
70 public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint,
71 Map.Entry<String, AtomicLong> countersEntry,
72 String dhcpCountersTopic, String subscriberId) {
73 super(type, allocationInfo);
74 this.connectPoint = connectPoint;
75 this.countersEntry = countersEntry;
76 this.dhcpCountersTopic = dhcpCountersTopic;
77 this.subscriberId = subscriberId;
Jonathan Hartc36c9552018-07-31 15:07:53 -040078 }
79
80 /**
81 * Creates a new event.
82 *
83 * @param type type of the event
84 * @param allocationInfo DHCP allocation info
85 * @param connectPoint connect point the client is on
86 */
87 public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint) {
88 super(type, allocationInfo);
89 this.connectPoint = connectPoint;
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030090 this.countersEntry = null;
91 this.dhcpCountersTopic = null;
92 this.subscriberId = null;
Jonathan Hartc36c9552018-07-31 15:07:53 -040093 }
94
95 /**
96 * Gets the DHCP client connect point.
97 *
98 * @return connect point
99 */
100 public ConnectPoint connectPoint() {
101 return connectPoint;
102 }
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -0300103
104 /**
105 * Gets the counters map entry.
106 *
107 * @return counters map entry
108 */
109 public Map.Entry<String, AtomicLong> getCountersEntry() {
110 return countersEntry;
111 }
112
113 /**
114 * Gets the Kafka topic where the dhcp counters are published.
115 *
116 * @return the dhcp kafka topic
117 */
118 public String getDhcpCountersTopic() {
119 return dhcpCountersTopic;
120 }
121
122 /**
123 * Gets the subscriber identifier information.
124 *
125 * @return the Id from subscriber
126 */
127 public String getSubscriberId() {
128 return subscriberId;
129 }
Jonathan Hartc36c9552018-07-31 15:07:53 -0400130}