1. Controller switchEvents queue should be priority based. The queue holds switch...
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / internal / SwitchEvent.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
11
12 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
13 import org.openflow.protocol.OFMessage;
14
15 public class SwitchEvent {
16
17     public static enum SwitchEventType {
18         SWITCH_ADD, SWITCH_DELETE, SWITCH_ERROR, SWITCH_MESSAGE,
19     }
20
21     private SwitchEventType eventType;
22     private ISwitch sw;
23     private OFMessage msg;
24     private int priority;
25
26     public SwitchEvent(SwitchEventType type, ISwitch sw, OFMessage msg, int priority) {
27         this.eventType = type;
28         this.sw = sw;
29         this.msg = msg;
30         this.priority = priority;
31     }
32
33     public SwitchEventType getEventType() {
34         return this.eventType;
35     }
36
37     public ISwitch getSwitch() {
38         return this.sw;
39     }
40
41     public OFMessage getMsg() {
42         return this.msg;
43     }
44
45     public int getPriority() {
46         return priority;
47     }
48
49     public void setPriority(int priority) {
50         this.priority = priority;
51     }
52
53     @Override
54     public String toString() {
55         String s;
56         switch (this.eventType) {
57         case SWITCH_ADD:
58             s = "SWITCH_ADD";
59             break;
60         case SWITCH_DELETE:
61             s = "SWITCH_DELETE";
62             break;
63         case SWITCH_ERROR:
64             s = "SWITCH_ERROR";
65             break;
66         case SWITCH_MESSAGE:
67             s = "SWITCH_MESSAGE";
68             break;
69         default:
70             s = "?" + this.eventType.ordinal() + "?";
71         }
72         return "Switch Event: " + s;
73     }
74 }