tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.cluster.messaging; |
| 2 | |
| 3 | import org.onlab.onos.cluster.NodeId; |
| 4 | import org.onlab.packet.IpPrefix; |
| 5 | |
| 6 | /** |
| 7 | * Hello message that nodes use to greet each other. |
| 8 | */ |
| 9 | public class HelloMessage extends ClusterMessage { |
| 10 | |
| 11 | private NodeId nodeId; |
| 12 | private IpPrefix ipAddress; |
| 13 | private int tcpPort; |
| 14 | |
| 15 | // For serialization |
| 16 | private HelloMessage() { |
| 17 | super(MessageSubject.HELLO); |
| 18 | nodeId = null; |
| 19 | ipAddress = null; |
| 20 | tcpPort = 0; |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Creates a new hello message for the specified end-point data. |
| 25 | * |
| 26 | * @param nodeId sending node identification |
| 27 | * @param ipAddress sending node IP address |
| 28 | * @param tcpPort sending node TCP port |
| 29 | */ |
| 30 | public HelloMessage(NodeId nodeId, IpPrefix ipAddress, int tcpPort) { |
| 31 | super(MessageSubject.HELLO); |
tom | 8158314 | 2014-09-30 01:40:29 -0700 | [diff] [blame] | 32 | this.nodeId = nodeId; |
| 33 | this.ipAddress = ipAddress; |
| 34 | this.tcpPort = tcpPort; |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Returns the sending node identifer. |
| 39 | * |
| 40 | * @return node identifier |
| 41 | */ |
| 42 | public NodeId nodeId() { |
| 43 | return nodeId; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns the sending node IP address. |
| 48 | * |
| 49 | * @return node IP address |
| 50 | */ |
| 51 | public IpPrefix ipAddress() { |
| 52 | return ipAddress; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns the sending node TCP listen port. |
| 57 | * |
| 58 | * @return TCP listen port |
| 59 | */ |
| 60 | public int tcpPort() { |
| 61 | return tcpPort; |
| 62 | } |
tom | 8158314 | 2014-09-30 01:40:29 -0700 | [diff] [blame] | 63 | |
tom | 1d416c5 | 2014-09-29 20:55:24 -0700 | [diff] [blame] | 64 | } |