Brian O'Connor | 5dcf578 | 2016-04-09 02:13:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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 | */ |
alshabib | 36a4d73 | 2016-06-01 16:03:59 -0700 | [diff] [blame] | 16 | package org.opencord.olt; |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 17 | |
| 18 | import org.onlab.packet.VlanId; |
| 19 | import org.onosproject.event.AbstractEvent; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | |
| 22 | import java.util.Optional; |
| 23 | |
| 24 | /** |
| 25 | * Describes an access device event. |
| 26 | */ |
| 27 | public class AccessDeviceEvent extends AbstractEvent<AccessDeviceEvent.Type, DeviceId> { |
| 28 | |
| 29 | private final Optional<VlanId> sVlan; |
| 30 | private final Optional<VlanId> cVlan; |
| 31 | |
| 32 | public enum Type { |
| 33 | /** |
| 34 | * A subscriber was registered and provisioned. |
| 35 | */ |
| 36 | SUBSCRIBER_REGISTERED, |
| 37 | |
| 38 | /** |
| 39 | * A subscriber was unregistered and deprovisioned. |
| 40 | */ |
| 41 | SUBSCRIBER_UNREGISTERED, |
| 42 | |
| 43 | /** |
| 44 | * An access device connected. |
| 45 | */ |
| 46 | DEVICE_CONNECTED, |
| 47 | |
| 48 | /** |
| 49 | * An access device disconnected. |
| 50 | */ |
| 51 | DEVICE_DISCONNECTED |
| 52 | |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * |
| 57 | * Creates an event of a given type and for the specified device, |
| 58 | * along with the cVlanId and sVlanId. The vlan fields may not be provisioned |
| 59 | * if the event is related to the access device (dis)connection. |
| 60 | * |
| 61 | * @param type the event type |
| 62 | * @param deviceId the device id |
| 63 | * @param sVlanId the service vlan |
| 64 | * @param cVlanId the customer vlan |
| 65 | */ |
| 66 | public AccessDeviceEvent(Type type, DeviceId deviceId, |
| 67 | VlanId sVlanId, |
| 68 | VlanId cVlanId) { |
| 69 | super(type, deviceId); |
| 70 | this.sVlan = Optional.ofNullable(sVlanId); |
| 71 | this.cVlan = Optional.ofNullable(cVlanId); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * |
| 76 | * Creates an event of a given type and for the specified device, and timestamp |
| 77 | * along with the cVlanId and sVlanId. The vlan fields may not be provisioned |
| 78 | * if the event is related to the access device (dis)connection. |
| 79 | * |
| 80 | * @param type the event type |
| 81 | * @param deviceId the device id |
| 82 | * @param time a timestamp |
| 83 | * @param sVlanId the service vlan |
| 84 | * @param cVlanId the customer vlan |
| 85 | */ |
| 86 | protected AccessDeviceEvent(Type type, DeviceId deviceId, long time, |
| 87 | VlanId sVlanId, |
| 88 | VlanId cVlanId) { |
| 89 | super(type, deviceId, time); |
| 90 | this.sVlan = Optional.ofNullable(sVlanId); |
| 91 | this.cVlan = Optional.ofNullable(cVlanId); |
| 92 | |
| 93 | } |
| 94 | |
| 95 | public Optional<VlanId> sVlanId() { |
| 96 | return sVlan; |
| 97 | } |
| 98 | |
| 99 | public Optional<VlanId> cVlanId() { |
| 100 | return cVlan; |
| 101 | } |
| 102 | |
| 103 | } |