KickJava   Java API By Example, From Geeks To Geeks.

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


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.jgap.*;
13 import org.jgap.distr.grid.*;
14 import org.apache.log4j.*;
15
16 /**
17  * Listener for feedback sent to the client. This is a simple sample
18  * implementation.
19  *
20  * @author Klaus Meffert
21  * @since 3.1
22  */

23 public class MyClientFeedback
24     implements IClientFeedback {
25   /** String containing the CVS revision. Read out via reflection!*/
26   private final static String JavaDoc CVS_REVISION = "$Revision: 1.4 $";
27
28   private final static String JavaDoc className = MyClientFeedback.class.getName();
29
30   private static Logger log = Logger.getLogger(className);
31
32   public MyClientFeedback() {
33   }
34
35   public void error(String JavaDoc msg, Exception JavaDoc ex) {
36     log.error("Error catched on client side: " + msg, ex);
37   }
38
39   public void sendingFragmentRequest(JGAPRequest req) {
40     log.warn("Sending work request " + req.getRID());
41   }
42
43   public void receivedFragmentResult(JGAPRequest req, JGAPResult res,
44                                      int idx) {
45     log.warn("Receiving work (index " + idx + "). First solution: " +
46              res.getPopulation().getChromosome(0));
47   }
48
49   public void beginWork() {
50     log.warn("Client starts sending work requests");
51   }
52
53   public void endWork() {
54     log.warn("Your request was processed completely");
55   }
56
57   public void info(String JavaDoc a_msg) {
58     log.warn(a_msg);
59   }
60
61   public void setProgressMaximum(int max) {
62   }
63
64   public void setProgressMinimum(int min) {
65   }
66
67   public void setProgressValue(int val) {
68   }
69
70   public void setRenderingTime(MyRequest req, long dt) {
71   }
72
73   public void completeFrame(int idx) {
74     log.warn("Client notified that unit " + idx + " is finished.");
75   }
76 }
77
Popular Tags