Mercurial > hg > Database > Christie
view src/main/java/christie/codegear/CodeGearManager.java @ 5:5be6647b87d2
StartCodeGear implements Runnable to wait InputDataGear
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 14 Dec 2017 20:46:18 +0900 |
parents | 3ea61d0bfc34 |
children | 3dcfe63d6394 |
line wrap: on
line source
package christie.codegear; import christie.datagear.DataGearManager; import christie.datagear.LocalDataGearManager; import christie.datagear.RemoteDataGearManager; import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** * Created by e125769 on 12/7/17. * CodeGearの実行 */ public class CodeGearManager{ private HashMap<String, DataGearManager> dataGearManagers = new HashMap<String, DataGearManager>(); private ThreadPoolExecutor codeGearExecutor; public CodeGearManager(ThreadPoolExecutor exe) { dataGearManagers.put("local", new LocalDataGearManager()); codeGearExecutor = exe; } public void submit(CodeGear cg){ codeGearExecutor.setThreadFactory(makeThreadFactory(Thread.MAX_PRIORITY)); codeGearExecutor.execute(cg); } private ThreadFactory makeThreadFactory(final int priority) { return new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setPriority(priority); return thread; } }; } public DataGearManager getDGM(String dest){ return dataGearManagers.get(dest); } public void createRemoteDataGeareManager(String dist){ dataGearManagers.put(dist, new RemoteDataGearManager()); } }