view src/main/java/christie/topology/manager/CheckComingHost.java @ 83:2314c55534ef

add TreeTopology
author akahori
date Sat, 15 Sep 2018 09:24:36 +0900
parents f884c1bd0d36
children 87a203c99177
line wrap: on
line source

package christie.topology.manager;

import christie.annotation.Peek;
import christie.annotation.Take;
import christie.codegear.CodeGear;
import christie.codegear.CodeGearManager;
import christie.topology.HostMessage;

import java.util.HashMap;

public class CheckComingHost extends CodeGear {

    @Take
    HostMessage hostMessage;

    @Peek
    HashMap<String, String> absCookieTable;

    public CheckComingHost(){
    }

    @Override
    protected void run(CodeGearManager cgm) {

        // check cookie
        if (hostMessage.cookie != null) {
            if (absCookieTable.containsKey(hostMessage.cookie)) {
                hostMessage.nodeName = absCookieTable.get(hostMessage.cookie);
                System.out.println("match");
                // coming host has ever joined this App
                getLocalDGM().put("reconnectHost", hostMessage);
                cgm.setup(new SearchHostName());
            }
        }else {
            getLocalDGM().put("orderHash", "order");
            getLocalDGM().put("newHost", hostMessage);
        }
        cgm.setup(new CheckComingHost());
    }

}