1 10 package org.jgap.distr.grid; 11 12 import org.apache.log4j.*; 13 import org.homedns.dade.jcgrid.*; 14 import org.homedns.dade.jcgrid.worker.*; 15 import org.apache.commons.cli.*; 16 import org.homedns.dade.jcgrid.cmd.MainCmd; 17 18 25 public class JGAPWorkers { 26 27 private final static String CVS_REVISION = "$Revision: 1.4 $"; 28 29 private Class m_workerClass; 30 31 private Class m_workerFeedbackClaas; 32 33 private final static String className = JGAPWorkers.class.getName(); 34 35 private static Logger log = Logger.getLogger(className); 36 37 public JGAPWorkers(String [] args) 38 throws Exception { 39 MainCmd.setUpLog4J("worker", true); 40 GridNodeWorkerConfig config = new GridNodeWorkerConfig(); 41 Options options = new Options(); 42 CommandLine cmd = MainCmd.parseCommonOptions(options, config, args); 43 if (config.getSessionName().equals("none")) { 44 config.setSessionName("MyGAWorker_session"); 45 } 46 getNeededFiles(config); 47 startWork(config); 48 } 49 50 55 public void getNeededFiles(GridNodeWorkerConfig a_config) { 56 57 59 61 63 } 65 66 public JGAPWorkers(GridNodeWorkerConfig a_config) 67 throws Exception { 68 startWork(a_config); 69 } 70 71 protected void startWork(GridNodeWorkerConfig a_config) 72 throws Exception { 73 GridWorker[] gw = new GridWorker[a_config.getWorkerCount()]; 76 for (int i = 0; i < a_config.getWorkerCount(); i++) { 77 gw[i] = new GridWorker(); 80 gw[i].setNodeConfig( (GridNodeGenericConfig) a_config.clone()); 81 ( (GridNodeGenericConfig) gw[i].getNodeConfig()). 82 setSessionName(a_config.getSessionName() + "_" + i); 83 ( (GridNodeGenericConfig) gw[i].getNodeConfig()). 84 setWorkingDir(a_config.getWorkingDir() + "_" + i); 85 Worker myWorker = new JGAPWorker(); 86 gw[i].setWorker(myWorker); 89 gw[i].start(); 95 } 96 for (int i = 0; i < a_config.getWorkerCount(); i++) { 99 gw[i].waitShutdown(); 100 } 101 } 102 103 119 public static void main(String [] args) 120 throws Exception { 121 MainCmd.setUpLog4J("worker", true); 122 GridNodeWorkerConfig config = new GridNodeWorkerConfig(); 123 Options options = new Options(); 124 CommandLine cmd = MainCmd.parseCommonOptions(options, config, args); 125 new JGAPWorkers(config); 128 } 129 } 130 | Popular Tags |