view src/main/java/christie/codegear/CodeGearManager.java @ 7:21372a589bd3

add CodeGearExecutor
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Wed, 27 Dec 2017 18:42:46 +0900
parents 3dcfe63d6394
children efaa7ad906b3
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 ThreadPoolExecutor threadPoolExecutor;

    public CodeGearManager(ThreadPoolExecutor exe) {
        dataGearManagers.put("local", new LocalDataGearManager());
        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);
    }

}