- Application is no longer blocked when programming hundreds of flows. The Barrier...
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / internal / PriorityMessage.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
10
11 import java.util.concurrent.atomic.AtomicLong;
12
13 import org.apache.commons.lang3.builder.EqualsBuilder;
14 import org.apache.commons.lang3.builder.HashCodeBuilder;
15 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
16 import org.openflow.protocol.OFMessage;
17
18 /**
19  * This class describes an OpenFlow message with priority
20  */
21 class PriorityMessage {
22     OFMessage msg;
23     int priority;
24     final static AtomicLong seq = new AtomicLong();
25     final long seqNum;
26     boolean syncReply; // set to true if we want to be blocked until the response arrives
27     
28     public PriorityMessage(OFMessage msg, int priority) {
29         this.msg = msg;
30         this.priority = priority;
31         this.seqNum = seq.getAndIncrement();
32         this.syncReply = false;
33     }
34
35     public PriorityMessage(OFMessage msg, int priority, boolean syncReply) {
36         this(msg, priority);
37         this.syncReply = syncReply;
38     }
39
40     public OFMessage getMsg() {
41         return msg;
42     }
43
44     public void setMsg(OFMessage msg) {
45         this.msg = msg;
46     }
47
48     public int getPriority() {
49         return priority;
50     }
51
52     public void setPriority(int priority) {
53         this.priority = priority;
54     }
55
56     @Override
57     public int hashCode() {
58         return HashCodeBuilder.reflectionHashCode(this);
59     }
60
61     @Override
62     public boolean equals(Object obj) {
63         return EqualsBuilder.reflectionEquals(this, obj);
64     }
65
66     @Override
67     public String toString() {
68         return "PriorityMessage[" + ReflectionToStringBuilder.toString(this)
69                 + "]";
70     }
71 }