blob: 3a4054c933d0b9a99cbae980fa7983d470148b54 [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 Carrerodadb3572019-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
30 private final ConnectPoint connectPoint;
31
Marcos Aurelio Carrerodadb3572019-11-25 13:34:25 -030032 private final Map.Entry<String, AtomicLong> countersEntry;
33
34 private final String dhcpCountersTopic;
35
36 private final String subscriberId;
37
Jonathan Hartc36c9552018-07-31 15:07:53 -040038 /**
39 * Type of the event.
40 */
41 public enum Type {
42 /**
43 * DHCP lease was updated.
44 */
45 UPDATED,
46
47 /**
48 * DHCP lease was removed.
49 */
Marcos Aurelio Carrerodadb3572019-11-25 13:34:25 -030050 REMOVED,
51
52 /**
53 * DHCP stats update.
54 */
55 STATS_UPDATE
56 }
57
58 /**
59 * Creates a new event used for STATS.
60 *
61 * @param type type of the event
62 * @param allocationInfo DHCP allocation info
63 * @param connectPoint connect point the client is on
64 * @param countersEntry an entry that represents the counters (used for STATS events)
65 * @param dhcpCountersTopic Kafka topic where the dhcp counters are published
66 * @param subscriberId the subscriber identifier information
67 */
68 public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint,
69 Map.Entry<String, AtomicLong> countersEntry,
70 String dhcpCountersTopic, String subscriberId) {
71 super(type, allocationInfo);
72 this.connectPoint = connectPoint;
73 this.countersEntry = countersEntry;
74 this.dhcpCountersTopic = dhcpCountersTopic;
75 this.subscriberId = subscriberId;
Jonathan Hartc36c9552018-07-31 15:07:53 -040076 }
77
78 /**
79 * Creates a new event.
80 *
81 * @param type type of the event
82 * @param allocationInfo DHCP allocation info
83 * @param connectPoint connect point the client is on
84 */
85 public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint) {
86 super(type, allocationInfo);
87 this.connectPoint = connectPoint;
Marcos Aurelio Carrerodadb3572019-11-25 13:34:25 -030088 this.countersEntry = null;
89 this.dhcpCountersTopic = null;
90 this.subscriberId = null;
Jonathan Hartc36c9552018-07-31 15:07:53 -040091 }
92
93 /**
94 * Gets the DHCP client connect point.
95 *
96 * @return connect point
97 */
98 public ConnectPoint connectPoint() {
99 return connectPoint;
100 }
Marcos Aurelio Carrerodadb3572019-11-25 13:34:25 -0300101
102 /**
103 * Gets the counters map entry.
104 *
105 * @return counters map entry
106 */
107 public Map.Entry<String, AtomicLong> getCountersEntry() {
108 return countersEntry;
109 }
110
111 /**
112 * Gets the Kafka topic where the dhcp counters are published.
113 *
114 * @return the dhcp kafka topic
115 */
116 public String getDhcpCountersTopic() {
117 return dhcpCountersTopic;
118 }
119
120 /**
121 * Gets the subscriber identifier information.
122 *
123 * @return the Id from subscriber
124 */
125 public String getSubscriberId() {
126 return subscriberId;
127 }
Jonathan Hartc36c9552018-07-31 15:07:53 -0400128}