view src/main/java/christie/codegear/CodeGearManager.java @ 8:efaa7ad906b3

Implement Queue in DataGearManager
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Thu, 28 Dec 2017 18:33:22 +0900
parents 21372a589bd3
children b49a926cbdd9
line wrap: on
line source

package christie.codegear;

import christie.datagear.DataGearManager;
import christie.datagear.LocalDataGearManager;
import christie.datagear.RemoteDataGearManager;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created by e125769 on 12/7/17.
 * CodeGearの実行
 */
public class CodeGearManager{
    private ConcurrentHashMap<String, DataGearManager>  dataGearManagers = new ConcurrentHashMap<String, DataGearManager>();
    private ConcurrentHashMap<String, CodeGearManager> cgms;
    private ThreadPoolExecutor threadPoolExecutor;

    public CodeGearManager(ThreadPoolExecutor exe, ConcurrentHashMap<String, CodeGearManager> cgms) {
        dataGearManagers.put("local", new LocalDataGearManager());
        this.cgms = cgms;
        threadPoolExecutor = exe;
    }

    public DataGearManager getDGM(){
        return dataGearManagers.get("local");
    }

    public DataGearManager getDGM(String dest){
        return dataGearManagers.get(dest);
    }

    public void createRemoteDataGeareManager(String dist){
        dataGearManagers.put(dist, new RemoteDataGearManager());
    }

    public void submit(CodeGear cg){
        threadPoolExecutor.execute(cg.cge);
    }

    public void setup(CodeGear cg){
        cg.setup(this);
    }

    public ConcurrentHashMap<String, CodeGearManager> getCgms() {
        return cgms;
    }

}