blob: 0a77e46a684cd5486f5777390b729aa8aa38087c [file] [log] [blame]
Carmelo Casconee5b28722018-06-22 17:28:28 +02001/*
Carmelo Cascone4c289b72019-01-22 15:30:45 -08002 * Copyright 2019-present Open Networking Foundation
Carmelo Casconee5b28722018-06-22 17:28:28 +02003 *
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
Carmelo Cascone4c289b72019-01-22 15:30:45 -080017package org.onosproject.p4runtime.ctl.controller;
Carmelo Casconee5b28722018-06-22 17:28:28 +020018
19import org.onosproject.net.DeviceId;
20import org.onosproject.p4runtime.api.P4RuntimeEventSubject;
21
22/**
23 * Channel event in P4Runtime.
24 */
Carmelo Cascone4c289b72019-01-22 15:30:45 -080025public final class ChannelEvent implements P4RuntimeEventSubject {
Carmelo Casconee5b28722018-06-22 17:28:28 +020026
Carmelo Cascone4c289b72019-01-22 15:30:45 -080027 public enum Type {
Carmelo Casconee5b28722018-06-22 17:28:28 +020028 OPEN,
29 CLOSED,
30 ERROR
31 }
32
33 private DeviceId deviceId;
34 private Type type;
35
36 /**
37 * Creates channel event with given status and throwable.
38 *
39 * @param deviceId the device
40 * @param type error type
41 */
Carmelo Cascone4c289b72019-01-22 15:30:45 -080042 public ChannelEvent(DeviceId deviceId, Type type) {
Carmelo Casconee5b28722018-06-22 17:28:28 +020043 this.deviceId = deviceId;
44 this.type = type;
45 }
46
47 /**
48 * Gets the type of this event.
49 *
50 * @return the error type
51 */
52 public Type type() {
53 return type;
54 }
55
56 @Override
57 public DeviceId deviceId() {
58 return deviceId;
59 }
60}