Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.opencord.dhcpl2relay; |
| 18 | |
| 19 | import org.onosproject.event.AbstractEvent; |
| 20 | import org.onosproject.net.ConnectPoint; |
| 21 | |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 22 | import java.util.Map; |
| 23 | import java.util.concurrent.atomic.AtomicLong; |
| 24 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 25 | /** |
| 26 | * Dhcp L2 relay event. |
| 27 | */ |
| 28 | public class DhcpL2RelayEvent extends AbstractEvent<DhcpL2RelayEvent.Type, DhcpAllocationInfo> { |
| 29 | |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 30 | public static final String GLOBAL_COUNTER = "global"; |
| 31 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 32 | private final ConnectPoint connectPoint; |
| 33 | |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 34 | private final Map.Entry<String, AtomicLong> countersEntry; |
| 35 | |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 36 | private final String subscriberId; |
| 37 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 38 | /** |
| 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 Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 50 | 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) |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 65 | * @param subscriberId the subscriber identifier information |
| 66 | */ |
| 67 | public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint, |
Jonathan Hart | 77ca315 | 2020-02-21 14:31:21 -0800 | [diff] [blame] | 68 | Map.Entry<String, AtomicLong> countersEntry, String subscriberId) { |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 69 | super(type, allocationInfo); |
| 70 | this.connectPoint = connectPoint; |
| 71 | this.countersEntry = countersEntry; |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 72 | this.subscriberId = subscriberId; |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Creates a new event. |
| 77 | * |
| 78 | * @param type type of the event |
| 79 | * @param allocationInfo DHCP allocation info |
| 80 | * @param connectPoint connect point the client is on |
| 81 | */ |
| 82 | public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint) { |
| 83 | super(type, allocationInfo); |
| 84 | this.connectPoint = connectPoint; |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 85 | this.countersEntry = null; |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 86 | this.subscriberId = null; |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Gets the DHCP client connect point. |
| 91 | * |
| 92 | * @return connect point |
| 93 | */ |
| 94 | public ConnectPoint connectPoint() { |
| 95 | return connectPoint; |
| 96 | } |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * Gets the counters map entry. |
| 100 | * |
| 101 | * @return counters map entry |
| 102 | */ |
| 103 | public Map.Entry<String, AtomicLong> getCountersEntry() { |
| 104 | return countersEntry; |
| 105 | } |
| 106 | |
| 107 | /** |
Marcos Aurelio Carrero | eaf02b8 | 2019-11-25 13:34:25 -0300 | [diff] [blame] | 108 | * Gets the subscriber identifier information. |
| 109 | * |
| 110 | * @return the Id from subscriber |
| 111 | */ |
| 112 | public String getSubscriberId() { |
| 113 | return subscriberId; |
| 114 | } |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 115 | } |