Mercurial > hg > Database > Christie
diff 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 |
line wrap: on
line diff
--- a/src/main/java/christie/topology/HostMessage.java Sat Sep 15 17:41:14 2018 +0900 +++ b/src/main/java/christie/topology/HostMessage.java Sat Sep 15 18:59:12 2018 +0900 @@ -3,34 +3,64 @@ import org.msgpack.annotation.Message; +import java.net.InetAddress; +import java.net.UnknownHostException; + @Message public class HostMessage { - public String hostName; - public int port; + private String hostName; + private int port; + private String nodeName; // this is nodeName which have these IP and port. + private String connectionName; + private String remoteNodeName; - public String connectionName; - public String nodeName; // this is nodeName which have these IP and port. + private String cookie; // MD5 - public String remoteNodeName; - public String cookie; // MD5 - - public boolean alive; + private boolean alive; public HostMessage() { } - public HostMessage(String name, int port) { - this.hostName = name; + + public void setLocalHostAndPort(int port){ + try { + this.hostName = InetAddress.getLocalHost().getHostAddress(); + this.port = port; + } catch (UnknownHostException e) { + e.printStackTrace(); + } + } + + public void setHostAndPort(String hostName, int port) { + this.hostName = hostName; this.port = port; } - public HostMessage(String name, int port, String connectionName) { - this.hostName = name; - this.port = port; + public void setNodeInfo(String nodeName, String connectionName, String remoteNodeName){ + this.nodeName = nodeName; this.connectionName = connectionName; + this.remoteNodeName = remoteNodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; } - public boolean isAlive() { - return alive; - } + public String getHostName() { return hostName; } + + public int getPort() { return port; } + + public String getNodeName() { return nodeName; } + + public String getConnectionName() { return connectionName; } + + public String getRemoteNodeName() { return remoteNodeName; } + + public void setAlive(boolean alive) { this.alive = alive; } + + public boolean isAlive() { return alive; } + + public void setCookie(String cookie) { this.cookie = cookie; } + + public String getCookie() { return cookie; } public String toString() { return "HostMessage : name = " + hostName + ", port = " + Integer.toString(port) + " connectionName = " +