Mercurial > hg > Database > Christie
view src/main/java/christie/codegear/CodeGearManager.java @ 24:0930b0554299
use DataGears
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 25 Jan 2018 23:02:02 +0900 |
parents | b8dc461b29f4 |
children | be58bfe90766 |
line wrap: on
line source
package christie.codegear; import christie.daemon.ChristieDaemon; import christie.daemon.IncomingTcpConnection; 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<Integer, CodeGearManager> cgms; private ThreadPoolExecutor threadPoolExecutor; private LocalDataGearManager localDGM = new LocalDataGearManager(); private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>(); public int cgmID; public CodeGearManager(int cgmID, ThreadPoolExecutor exe, ConcurrentHashMap<Integer, CodeGearManager> cgms, int localPort) { dataGearManagers.put("local", localDGM); this.cgms = cgms; threadPoolExecutor = exe; this.cgmID = cgmID; new ChristieDaemon(localPort, this).listen(); } public LocalDataGearManager getLocalDGM(){ return localDGM; } public DataGearManager getDGM(String dgmName){ if (dataGearManagers.containsKey(dgmName)){ return dataGearManagers.get(dgmName); } else { throw new IllegalArgumentException("DGM "+ dgmName + " is not found."); } } public RemoteDataGearManager createRemoteDGM(String dgmName, String address, int port){ RemoteDataGearManager remote = new RemoteDataGearManager(dgmName, address, port, this); dataGearManagers.put(dgmName, remote); return remote; } public void submit(CodeGear cg){ threadPoolExecutor.execute(cg.getCge()); } public void setup(CodeGear cg){ cg.setup(this); } public ConcurrentHashMap<Integer, CodeGearManager> getCgms() { return cgms; } public void setAccept(String key, IncomingTcpConnection in) { acceptHash.put(key, in); } }