Mercurial > hg > Database > Christie
comparison src/main/java/christie/topology/HostMessage.java @ 94:87a203c99177
update HostMessage refactor
author | akahori |
---|---|
date | Sat, 15 Sep 2018 18:59:12 +0900 |
parents | 7abfe041b75c |
children | e1e919f12ed9 |
comparison
equal
deleted
inserted
replaced
93:7abfe041b75c | 94:87a203c99177 |
---|---|
1 package christie.topology; | 1 package christie.topology; |
2 | 2 |
3 | 3 |
4 import org.msgpack.annotation.Message; | 4 import org.msgpack.annotation.Message; |
5 | 5 |
6 import java.net.InetAddress; | |
7 import java.net.UnknownHostException; | |
8 | |
6 @Message | 9 @Message |
7 public class HostMessage { | 10 public class HostMessage { |
8 public String hostName; | 11 private String hostName; |
9 public int port; | 12 private int port; |
13 private String nodeName; // this is nodeName which have these IP and port. | |
14 private String connectionName; | |
15 private String remoteNodeName; | |
10 | 16 |
11 public String connectionName; | 17 private String cookie; // MD5 |
12 public String nodeName; // this is nodeName which have these IP and port. | |
13 | 18 |
14 public String remoteNodeName; | 19 private boolean alive; |
15 public String cookie; // MD5 | |
16 | |
17 public boolean alive; | |
18 | 20 |
19 public HostMessage() { } | 21 public HostMessage() { } |
20 public HostMessage(String name, int port) { | 22 |
21 this.hostName = name; | 23 public void setLocalHostAndPort(int port){ |
24 try { | |
25 this.hostName = InetAddress.getLocalHost().getHostAddress(); | |
26 this.port = port; | |
27 } catch (UnknownHostException e) { | |
28 e.printStackTrace(); | |
29 } | |
30 } | |
31 | |
32 public void setHostAndPort(String hostName, int port) { | |
33 this.hostName = hostName; | |
22 this.port = port; | 34 this.port = port; |
23 } | 35 } |
24 | 36 |
25 public HostMessage(String name, int port, String connectionName) { | 37 public void setNodeInfo(String nodeName, String connectionName, String remoteNodeName){ |
26 this.hostName = name; | 38 this.nodeName = nodeName; |
27 this.port = port; | |
28 this.connectionName = connectionName; | 39 this.connectionName = connectionName; |
40 this.remoteNodeName = remoteNodeName; | |
29 } | 41 } |
30 | 42 |
31 public boolean isAlive() { | 43 public void setNodeName(String nodeName) { |
32 return alive; | 44 this.nodeName = nodeName; |
33 } | 45 } |
46 | |
47 public String getHostName() { return hostName; } | |
48 | |
49 public int getPort() { return port; } | |
50 | |
51 public String getNodeName() { return nodeName; } | |
52 | |
53 public String getConnectionName() { return connectionName; } | |
54 | |
55 public String getRemoteNodeName() { return remoteNodeName; } | |
56 | |
57 public void setAlive(boolean alive) { this.alive = alive; } | |
58 | |
59 public boolean isAlive() { return alive; } | |
60 | |
61 public void setCookie(String cookie) { this.cookie = cookie; } | |
62 | |
63 public String getCookie() { return cookie; } | |
34 | 64 |
35 public String toString() { | 65 public String toString() { |
36 return "HostMessage : name = " + hostName + ", port = " + Integer.toString(port) + " connectionName = " + | 66 return "HostMessage : name = " + hostName + ", port = " + Integer.toString(port) + " connectionName = " + |
37 connectionName + " absName = " + nodeName + " remoteAbsName = " + remoteNodeName | 67 connectionName + " absName = " + nodeName + " remoteAbsName = " + remoteNodeName |
38 + " cokkie = " + cookie ; | 68 + " cokkie = " + cookie ; |