view src/main/java/christie/topology/HostMessage.java @ 96:bf6ab64325f9

add Constoractor
author akahori
date Mon, 17 Sep 2018 11:20:26 +0900
parents 87a203c99177
children e1e919f12ed9
line wrap: on
line source

package christie.topology;


import org.msgpack.annotation.Message;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Message
public class HostMessage {
    private String hostName;
    private int port;
    private String nodeName; // this is nodeName which have these IP and port.
    private String connectionName;
    private String remoteNodeName;

    private String cookie; // MD5

    private boolean alive;

    public HostMessage() { }

    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 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 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 = " +
                connectionName + " absName = " + nodeName + " remoteAbsName = " + remoteNodeName
                + " cokkie = " + cookie ;
    }
}