import WebFlow.submitJob2.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class BatchJobStatus extends JInternalFrame implements Runnable { private String user; private String host; private String jobid; private String qstatCommand; private desktop d; private submitJob2 submit; private JTextArea statusTA; private boolean jobRunning = true; public BatchJobStatus(String jobid, String host, String user, desktop d, submitJob2 submit) { super("Job Status", true, true, true, true); this.jobid=jobid; this.user=user; this.host=host; this.d=d; this.submit=submit; qstatCommand = "/usr/craysoft/nqe/bin/qstat "+jobid; JPanel bck = new JPanel(); bck.setLayout(new BorderLayout()); getContentPane().add(bck); bck.add(new JLabel("Status of job "+jobid+" running on "+host, JLabel.CENTER), BorderLayout.NORTH); statusTA = new JTextArea(30,3); statusTA.setFont(new Font("Courier",Font.PLAIN,12)); JScrollPane scroller = new JScrollPane(statusTA,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); bck.add(scroller,BorderLayout.CENTER); this.setBounds(0,450,750,200); d.getContentPane().add(this, new Integer(0)); } public void run() { while(jobRunning) { waitFor(5000); System.out.println(qstatCommand); submit.submitRsh(host,"pse",qstatCommand); String OLine=""; statusTA.setText(OLine); int curLine=0; while(!OLine.equals("theEnd")) { OLine=submit.getOLine(curLine); System.out.println(OLine); if(OLine.equals("wait")) { waitFor(10); } else { if(OLine.equals("theEnd")) { if(curLine==0) jobRunning=false; } else statusTA.append(OLine+"\n"); submit.setLineRead(curLine); curLine++; if(curLine==20) curLine=0; } } } System.out.println("done."); dispose(); } public synchronized void waitFor(long howLong) { try { wait(howLong); } catch (Exception e) {System.out.println(e+ "while WaitFor");} } }