KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > grid > fitnessDistributed > MyWorkerFeedback


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.fitnessDistributed;
11
12 import org.homedns.dade.jcgrid.*;
13 import org.homedns.dade.jcgrid.worker.*;
14 import org.jgap.distr.grid.*;
15
16 /**
17  * Listener called on worker events.
18  *
19  * @author Klaus Meffert
20  * @since 3.01
21  */

22 public class MyWorkerFeedback
23     implements GridWorkerFeedback {
24   /** String containing the CVS revision. Read out via reflection!*/
25   private final static String JavaDoc CVS_REVISION = "$Revision: 1.3 $";
26
27   private String JavaDoc m_sessionName;
28
29   /**
30    * Called when listener is started.
31    */

32   public void start() {
33   }
34
35   public void beginWorkingFor(String JavaDoc a_sessionName, WorkRequest req) {
36     m_sessionName = a_sessionName;
37     System.out.println("Begin work for request " + req.getRID()
38                        + ", session " + m_sessionName);
39   }
40
41   public void endWorkingFor(WorkResult res) {
42     System.out.println("Result computed (req " + res.getRID() + ", session "
43                        + m_sessionName + "): "
44                        + ( (JGAPResult) res).getPopulation().getChromosome(0));
45   }
46
47   /**
48    * Called when listener is stopped.
49    */

50   public void stop() {
51     System.out.println("MyWorkerFeedback: listener stopped (session "
52                        + m_sessionName + ")");
53   }
54 }
55
Popular Tags