KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > grid > evolutionDistributed > ServerAndWorker


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package examples.grid.evolutionDistributed;
11
12 import org.apache.commons.cli.*;
13 import org.homedns.dade.jcgrid.cmd.*;
14 import org.homedns.dade.jcgrid.worker.*;
15 import org.jgap.distr.grid.*;
16
17 /**
18  * Convenience call to start both the server and a worker at once. Only for
19  * demonstration purposes. Normally, you would start the server and the
20  * worker(s) separately and possibly on different hosts!<p>
21  * This class can be used to start-up any JGAP grid, because the individual
22  * data is only kept with the JGAPClient! The JGAPClient distributes any data
23  * (including classes) necessary to the workers via the server.
24  *
25  * @author Klaus Meffert
26  * @since 3.2
27  */

28 public class ServerAndWorker {
29   /** String containing the CVS revision. Read out via reflection!*/
30   private final static String JavaDoc CVS_REVISION = "$Revision: 1.1 $";
31
32   /**
33    * Convenience (demo) start of both the server and a worker.
34    *
35    * @param args might not work here in this simple example as distinct options
36    * between server and worker could lead to parsing errors.
37    *
38    * @throws Exception
39    *
40    * @author Klaus Meffert
41    * @since 3.2
42    */

43   public static void main(String JavaDoc[] args)
44       throws Exception JavaDoc {
45     // Start server.
46
// ------------
47
new JGAPServer(args);
48     // Setup worker configuration.
49
// ---------------------------
50
Options options = new Options();
51     GridNodeWorkerConfig config = new GridNodeWorkerConfig();
52     CommandLine cmd = MainCmd.parseCommonOptions(options, config, args);
53     // Start worker.
54
// -------------
55
new JGAPWorkers(config);
56   }
57 }
58
Popular Tags