1 package fr.in2p3.jsaga.adaptor.job;
2
3 import fr.in2p3.jsaga.adaptor.job.monitor.JobStatus;
4 import fr.in2p3.jsaga.adaptor.job.monitor.JobStatusNotifier;
5 import org.apache.log4j.Logger;
6 import org.globus.io.gass.server.JobOutputListener;
7
8 import java.io.*;
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public class LCGCEJobMonitorListener implements JobOutputListener {
23 private static Logger s_logger = Logger.getLogger(LCGCEJobMonitorListener.class);
24
25 private JobStatusNotifier m_notifier;
26
27 public LCGCEJobMonitorListener(JobStatusNotifier notifier) {
28 m_notifier = notifier;
29 }
30
31 public void outputChanged(String s) {
32 BufferedReader reader = new BufferedReader(new StringReader(s));
33 try {
34 String timestamps = reader.readLine();
35 String line;
36 while ( !"GRIDMONEOF".equals(line=reader.readLine()) ) {
37 String array[] = line.split(" +");
38 if (array.length == 2) {
39 String nativeJobId = array[0];
40 Integer stateCode = new Integer(array[1]);
41 String stateString = array[1];
42 JobStatus status = new GatekeeperJobStatus(nativeJobId, stateCode, stateString);
43 m_notifier.notifyChange(status);
44 } else {
45 s_logger.warn("Syntax error in grid-monitor output: "+line);
46 }
47 }
48 reader.close();
49 } catch (IOException e) {
50 s_logger.warn("Failed to read grid-monitor output");
51 }
52 }
53
54 public void outputClosed() {
55
56 }
57 }