view src/main/java/christie/topology/manager/CheckComingHost.java @ 41:cf5a75bc3e55

add
author akahori
date Tue, 31 Jul 2018 17:46:32 +0900
parents
children 6664efac18ee
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
    public void run(CodeGearManager cgm) {

        boolean match = false;
        // check cookie
        if (hostMessage.cookie != null) {
            if (absCookieTable.containsKey(hostMessage.cookie)){
                match = true;
                hostMessage.absName = absCookieTable.get(hostMessage.cookie);
                System.out.println("match");
            }
        }

        if (match){
            // coming host has ever joined this App
            getLocalDGM().put("reconnectHost", hostMessage);

            // TODO: これから実装する
            //new SearchHostName();
        } else {
            getLocalDGM().put("orderHash", "order");
            getLocalDGM().put("newHost", hostMessage);
        }

        cgm.setup(new CheckComingHost());
    }




}