1 /*****************************************************************************/ 2 /* Software Testing Automation Framework (STAF) */ 3 /* (C) Copyright IBM Corp. 2002, 2004 */ 4 /* */ 5 /* This software is licensed under the Eclipse Public License (EPL) V1.0. */ 6 /*****************************************************************************/ 7 8 package com.ibm.staf.service.stax; 9 10 import java.awt.*; 11 import java.awt.event.*; 12 import java.util.*; 13 import java.util.List; 14 import java.io.*; 15 import java.lang.Math.*; 16 import javax.swing.*; 17 import javax.swing.border.*; 18 import javax.swing.event.*; 19 import javax.swing.tree.*; 20 import javax.swing.table.*; 21 import java.lang.reflect.*; 22 import com.ibm.staf.*; 23 import com.ibm.staf.service.*; 24 import java.text.SimpleDateFormat; 25 import java.util.jar.*; 26 27 public class STAXMonitorFrame extends JFrame implements ActionListener, 28 Runnable, 29 KeyListener, 30 MouseListener, 31 TreeSelectionListener, 32 ChangeListener 33 { 34 public static final int EXTENSION_ACTIVE = 1; 35 public static final int EXTENSION_STATUS = 2; 36 public static final int EXTENSION_INFO = 3; 37 public static final int EXTENSION_ACTIVE_JOB_ELEMENTS = 4; 38 public static final int EXTENSION_ACTIVE_JOB_ELEMENTS_AND_ACTIVE = 5; 39 public static final int EXTENSION_ACTIVE_JOB_ELEMENTS_AND_STATUS = 6; 40 public static final int EXTENSION_ACTIVE_JOB_ELEMENTS_AND_INFO = 7; 41 42 public static final int AUTOMONITOR_ALWAYS = 1; 43 public static final int AUTOMONITOR_RECOMMENDED = 2; 44 public static final int AUTOMONITOR_NEVER = 3; 45 46 public static final int DISABLED = 0; 47 public static final int ENABLED = 1; 48 public static final int DEFAULT = 2; 49 50 // STAX Service Error Codes 51 static final int BlockNotHeld = 4002; 52 static final int BlockAlreadyHeld = 4003; 53 54 String fStaxMachine; 55 String fStaxServiceName; 56 String fStaxMachineNickname; 57 String fStaxConfigMachine; 58 String fStaxInstanceUUID; 59 String fEventMachine; 60 String fEventServiceName; 61 String fJobNumber; 62 String fXmlFileName; 63 String fXmlFileMachine; 64 String fFunction; 65 String fArgs; 66 String fJobName; 67 Vector<String> fScripts; 68 Vector<String> fScriptFilesVector; 69 String fScriptFilesMachineName; 70 Vector<String> fBreakpointTriggerVector; 71 static String kMonitorFrameTitle = "STAX Job Monitor"; 72 JLabel fCurrentSelection; 73 STAXMonitorTreeNode fCurrentSelectedNode; 74 JTable fDetailsTable; 75 STAXMonitorTableModel fDetailsTableModel; 76 STAXMonitorTableSorter fDetailsModelSorter; 77 JTree fMonitorTree; 78 DefaultTreeModel fMonitorTreeModel; 79 STAFHandle fHandle; 80 private Thread fQueueThread; 81 JTable fMessageTable; 82 JScrollPane fMessageScrollPane; 83 STAXMonitorTableModel fMessageTableModel; 84 STAXMonitorTableSorter fMessageModelSorter; 85 Hashtable<String, STAXMonitorTreeNode> fMonitorTreeBlocks = 86 new Hashtable<String, STAXMonitorTreeNode>(); // key is block name 87 Hashtable<STAXMonitorTreeNode, String> fMonitorTreeBlockNodes = 88 new Hashtable<STAXMonitorTreeNode, String>(); // value is block node 89 Hashtable<String, STAXMonitorTreeNode> fCmdIDHashtable = 90 new Hashtable<String, STAXMonitorTreeNode>(); 91 Hashtable<String, STAXMonitorTreeNode> fSubjobIDHashtable = 92 new Hashtable<String, STAXMonitorTreeNode>(); 93 Hashtable<String, STAXMonitorTreeNode> fProcIDHashtable = 94 new Hashtable<String, STAXMonitorTreeNode>(); 95 Hashtable<String, STAXMonitorTreeNode> fPluginNodeHashtable = 96 new Hashtable<String, STAXMonitorTreeNode>(); 97 Hashtable<STAXMonitorTreeNode, String> fPluginNodeToIDHashtable = 98 new Hashtable<STAXMonitorTreeNode, String>(); 99 Hashtable<STAXMonitorTreeNode, String> fPluginNodeToNodeTextHashtable = 100 new Hashtable<STAXMonitorTreeNode, String>(); 101 Hashtable<STAXMonitorTreeNode, String> fMonitorTreeProcessNodes = 102 new Hashtable<STAXMonitorTreeNode, String>(); 103 Hashtable<STAXMonitorTreeNode, String> fMonitorTreeCommandNodes = 104 new Hashtable<STAXMonitorTreeNode, String>(); 105 Hashtable<STAXMonitorTreeNode, String> fMonitorTreeSubjobNodes = 106 new Hashtable<STAXMonitorTreeNode, String>(); 107 Hashtable<STAXMonitorTreeNode, Calendar> fMonitorTreeProcessStartTimes = 108 new Hashtable<STAXMonitorTreeNode, Calendar>(); 109 Hashtable<STAXMonitorTreeNode, Calendar> fMonitorTreeCommandStartTimes = 110 new Hashtable<STAXMonitorTreeNode, Calendar>(); 111 Hashtable<STAXMonitorTreeNode, Calendar> fMonitorTreeSubjobStartTimes = 112 new Hashtable<STAXMonitorTreeNode, Calendar>(); 113 boolean fMonitorStopped = false; 114 JPanel fSelectionDetailsPanel; 115 Hashtable<String, Vector<Vector<String>>> fDataHashtable = 116 new Hashtable<String, Vector<Vector<String>>>(); 117 Vector<String> fDataColumns; 118 Vector<String> fMessageColumns; 119 STAFProcessMonitor fProcessMonitor; 120 MonitorElapsedTime fElapsedTime; 121 boolean fContinueProcessMonitor = true; 122 boolean fContinueElapsedTime = true; 123 JPopupMenu fBlockPopupMenu = new JPopupMenu(); 124 JMenuItem fBlockHoldMenuItem = new JMenuItem("Hold"); 125 JMenuItem fBlockReleaseMenuItem = new JMenuItem("Release"); 126 JMenuItem fBlockTerminateMenuItem = new JMenuItem("Terminate"); 127 128 JPopupMenu fProcessPopupMenu = new JPopupMenu(); 129 JMenuItem fProcessStopMenuItem = new JMenuItem("Stop"); 130 131 JPopupMenu fSubjobPopupMenu = new JPopupMenu(); 132 JMenuItem fSubjobStartMonitoringMenuItem = new 133 JMenuItem("Start Monitoring"); 134 JMenuItem fSubjobDisplayJobLogMenuItem = new 135 JMenuItem("Display Job Log"); 136 JMenuItem fSubjobDisplayJobUserLogMenuItem = new 137 JMenuItem("Display Job User Log"); 138 JMenuItem fSubjobTerminateMenuItem = new JMenuItem("Terminate Job"); 139 STAXMonitor fParentMonitor; 140 TreePath previousTreePath; 141 JMenu fFileMenu; 142 JMenu fDisplayMenu; 143 JMenu fViewMenu; 144 JMenuItem fFileResubmit; 145 JMenuItem fFileExitAndResubmit; 146 JMenuItem fFileExit; 147 JMenuItem fDisplayJobLog = new JMenuItem("Display Job Log"); 148 JMenuItem fDisplayJobUserLog = new JMenuItem("Display Job User Log"); 149 boolean fShowNoSTAXMonitorInformation = false; 150 int fClearLogs = STAXMonitorFrame.DEFAULT; 151 int fLogTCElapsedTime = STAXMonitorFrame.DEFAULT; 152 int fLogTCNumStarts = STAXMonitorFrame.DEFAULT; 153 int fLogTCStartStop = STAXMonitorFrame.DEFAULT; 154 int fAutoMonitorSubjobs = STAXMonitorFrame.AUTOMONITOR_NEVER; 155 String fPythonOutput = STAXMonitor.DEFAULT_STRING; 156 String fPythonLogLevel = STAXMonitor.DEFAULT_STRING; 157 String fInvalidLogLevelAction = STAXMonitor.DEFAULT_STRING; 158 String fLimitMessages = ""; 159 Hashtable<STAXMonitorExtension, Vector<String>> fRegisteredPlugins = 160 new Hashtable<STAXMonitorExtension, Vector<String>>(); 161 JCheckBoxMenuItem fProcessMenu; 162 JCheckBoxMenuItem fSTAFCmdMenu; 163 JCheckBoxMenuItem fSubjobMenu; 164 JCheckBoxMenuItem fDebugMenu; 165 JCheckBoxMenuItem fTestcaseInfoMenu; 166 JCheckBoxMenuItem fTestcaseStatusMenu; 167 JCheckBoxMenuItem fActiveJobElementsMenu; 168 JCheckBoxMenuItem fCurrentSelectionMenu; 169 JCheckBoxMenuItem fMessagesMenu; 170 Hashtable<Object, STAXMonitorExtension> fViewablePlugins = 171 new Hashtable<Object, STAXMonitorExtension>(); 172 Hashtable<String, JComponent> fViewableComponents = 173 new Hashtable<String, JComponent>(); 174 JTabbedPane fActiveElementsPane = new JTabbedPane(); 175 JTabbedPane fStatusPane = new JTabbedPane(); 176 JTabbedPane fInfoPane = new JTabbedPane(); 177 Vector fPluginJarsVector; 178 Vector<String> fExternalPluginNotificationTypes = new Vector<String>(); 179 Hashtable<STAXMonitorTreeNode, Vector> fPluginNodeDetailsHashtable = 180 new Hashtable<STAXMonitorTreeNode, Vector>(); 181 STAXMonitorProcessExtension processTablePlugin; 182 STAXMonitorExtension stafcmdTablePlugin; 183 STAXMonitorExtension subjobTablePlugin; 184 STAXMonitorExtension testcaseTablePlugin; 185 STAXMonitorExtension testcaseInfoTablePlugin; 186 STAXMonitorExtension breakpointPlugin; 187 String fMessageFontName = "Dialog"; 188 String fLogViewerFontName = "Dialog"; 189 String fSaveAsDirectory = null; 190 boolean fBreakpointFirstFunction = false; 191 boolean fBreakpointSubjobFirstFunction = false; 192 STAXMonitorFrame()193 public STAXMonitorFrame() 194 { 195 } 196 STAXMonitorFrame(STAXMonitor parentMonitor, String staxMach, String staxService, String staxMachNickname, String jobNum, String eventMach, String eventService, boolean showNoMonitorInfo, String limitMessages, Vector pluginJarsVector, int autoMonitorSubjobs)197 public STAXMonitorFrame(STAXMonitor parentMonitor, String staxMach, 198 String staxService, String staxMachNickname, 199 String jobNum, 200 String eventMach, String eventService, 201 boolean showNoMonitorInfo, String limitMessages, 202 Vector pluginJarsVector, 203 int autoMonitorSubjobs) throws STAFException 204 { 205 this(false, parentMonitor, staxMach, staxService, staxMachNickname, 206 jobNum, eventMach, eventService, "", "", "", "", "", null, 207 showNoMonitorInfo, limitMessages, pluginJarsVector, null, "", 208 STAXMonitorFrame.DEFAULT, STAXMonitorFrame.DEFAULT, 209 STAXMonitorFrame.DEFAULT, STAXMonitorFrame.DEFAULT, 210 autoMonitorSubjobs, 211 STAXMonitor.DEFAULT_STRING, STAXMonitor.DEFAULT_STRING, 212 STAXMonitor.DEFAULT_STRING, 213 new Vector<String>(), false, false); 214 } 215 STAXMonitorFrame(STAXMonitor parentMonitor, String staxMachine, String staxServiceName, String staxMachineNickname, String jobNumber, String eventMachine, String eventServiceName, String xmlFileName, String xmlFileMachine, String function, String args, String jobName, Vector<String> scripts, boolean showNoMonitorInfo, String limitMessages, Vector pluginJarsVector, Vector<String> scriptFilesVector, String scriptFilesMachineName, int clearLogs, int logTCElapsedTime, int logTCNumStarts, int logTCStartStop, int autoMonitorSubjobs)216 public STAXMonitorFrame(STAXMonitor parentMonitor, String staxMachine, 217 String staxServiceName, 218 String staxMachineNickname, String jobNumber, 219 String eventMachine, String eventServiceName, 220 String xmlFileName, String xmlFileMachine, 221 String function, String args, String jobName, 222 Vector<String> scripts, boolean showNoMonitorInfo, 223 String limitMessages, Vector pluginJarsVector, 224 Vector<String> scriptFilesVector, 225 String scriptFilesMachineName, 226 int clearLogs, int logTCElapsedTime, 227 int logTCNumStarts, int logTCStartStop, 228 int autoMonitorSubjobs) throws STAFException 229 { 230 this(true, parentMonitor, staxMachine, staxServiceName, 231 staxMachineNickname, jobNumber, 232 eventMachine, eventServiceName, xmlFileName, xmlFileMachine, 233 function, args, jobName, scripts, showNoMonitorInfo, 234 limitMessages, pluginJarsVector, scriptFilesVector, 235 scriptFilesMachineName, clearLogs, logTCElapsedTime, 236 logTCNumStarts, logTCStartStop, autoMonitorSubjobs, 237 STAXMonitor.DEFAULT_STRING, STAXMonitor.DEFAULT_STRING, 238 STAXMonitor.DEFAULT_STRING, 239 new Vector<String>(), false, false); 240 } 241 STAXMonitorFrame(STAXMonitor parentMonitor, String staxMachine, String staxServiceName, String staxMachineNickname, String jobNumber, String eventMachine, String eventServiceName, String xmlFileName, String xmlFileMachine, String function, String args, String jobName, Vector<String> scripts, boolean showNoMonitorInfo, String limitMessages, Vector pluginJarsVector, Vector<String> scriptFilesVector, String scriptFilesMachineName, int clearLogs, int logTCElapsedTime, int logTCNumStarts, int logTCStartStop, int autoMonitorSubjobs, String pythonOutput, String pythonLogLevel, String invalidLogLevelAction, Vector<String> breakpointTriggerVector, boolean breakpointFirstFunction, boolean breakpointSubjobFirstFunction)242 public STAXMonitorFrame(STAXMonitor parentMonitor, String staxMachine, 243 String staxServiceName, 244 String staxMachineNickname, String jobNumber, 245 String eventMachine, String eventServiceName, 246 String xmlFileName, String xmlFileMachine, 247 String function, String args, String jobName, 248 Vector<String> scripts, boolean showNoMonitorInfo, 249 String limitMessages, 250 Vector pluginJarsVector, 251 Vector<String> scriptFilesVector, 252 String scriptFilesMachineName, 253 int clearLogs, int logTCElapsedTime, 254 int logTCNumStarts, int logTCStartStop, 255 int autoMonitorSubjobs, String pythonOutput, 256 String pythonLogLevel, String invalidLogLevelAction, 257 Vector<String> breakpointTriggerVector, 258 boolean breakpointFirstFunction, 259 boolean breakpointSubjobFirstFunction) 260 throws STAFException 261 { 262 this(true, parentMonitor, staxMachine, staxServiceName, 263 staxMachineNickname, jobNumber, 264 eventMachine, eventServiceName, xmlFileName, xmlFileMachine, 265 function, args, jobName, scripts, showNoMonitorInfo, 266 limitMessages, pluginJarsVector, scriptFilesVector, 267 scriptFilesMachineName, clearLogs, logTCElapsedTime, 268 logTCNumStarts, logTCStartStop, autoMonitorSubjobs, 269 pythonOutput, pythonLogLevel, invalidLogLevelAction, 270 breakpointTriggerVector, breakpointFirstFunction, 271 breakpointSubjobFirstFunction); 272 } 273 STAXMonitorFrame(boolean newJob, STAXMonitor parentMonitor, String staxMachine, String staxServiceName, String staxMachineNickname, String jobNumber, String eventMachine, String eventServiceName, String xmlFileName, String xmlFileMachine, String function, String args, String jobName, Vector<String> scripts, boolean showNoMonitorInfo, String limitMessages, Vector pluginJarsVector, Vector<String> scriptFilesVector, String scriptFilesMachineName, int clearLogs, int autoMonitorSubjobs)274 public STAXMonitorFrame(boolean newJob, 275 STAXMonitor parentMonitor, String staxMachine, 276 String staxServiceName, 277 String staxMachineNickname, String jobNumber, 278 String eventMachine, String eventServiceName, 279 String xmlFileName, String xmlFileMachine, 280 String function, String args, String jobName, 281 Vector<String> scripts, 282 boolean showNoMonitorInfo, 283 String limitMessages, 284 Vector pluginJarsVector, 285 Vector<String> scriptFilesVector, 286 String scriptFilesMachineName, 287 int clearLogs, 288 int autoMonitorSubjobs) throws STAFException 289 { 290 this(newJob, parentMonitor, staxMachine, staxServiceName, 291 staxMachineNickname, jobNumber, 292 eventMachine, eventServiceName, xmlFileName, xmlFileMachine, 293 function, args, jobName, scripts, showNoMonitorInfo, 294 limitMessages, pluginJarsVector, scriptFilesVector, 295 scriptFilesMachineName, clearLogs, STAXMonitorFrame.DEFAULT, 296 STAXMonitorFrame.DEFAULT, STAXMonitorFrame.DEFAULT, 297 autoMonitorSubjobs, 298 STAXMonitor.DEFAULT_STRING, STAXMonitor.DEFAULT_STRING, 299 STAXMonitor.DEFAULT_STRING, 300 new Vector<String>(), false, false); 301 } 302 STAXMonitorFrame(boolean newJob, STAXMonitor parentMonitor, String staxMachine, String staxServiceName, String staxMachineNickname, String jobNumber, String eventMachine, String eventServiceName, String xmlFileName, String xmlFileMachine, String function, String args, String jobName, Vector<String> scripts, boolean showNoMonitorInfo, String limitMessages, Vector pluginJarsVector, Vector<String> scriptFilesVector, String scriptFilesMachineName, int clearLogs, int logTCElapsedTime, int logTCNumStarts, int logTCStartStop, int autoMonitorSubjobs)303 public STAXMonitorFrame(boolean newJob, 304 STAXMonitor parentMonitor, String staxMachine, 305 String staxServiceName, 306 String staxMachineNickname, 307 String jobNumber, 308 String eventMachine, String eventServiceName, 309 String xmlFileName, String xmlFileMachine, 310 String function, String args, String jobName, 311 Vector<String> scripts, 312 boolean showNoMonitorInfo, 313 String limitMessages, 314 Vector pluginJarsVector, 315 Vector<String> scriptFilesVector, 316 String scriptFilesMachineName, 317 int clearLogs, int logTCElapsedTime, 318 int logTCNumStarts, int logTCStartStop, 319 int autoMonitorSubjobs) throws STAFException 320 { 321 this(newJob, parentMonitor, staxMachine, staxServiceName, 322 staxMachineNickname, jobNumber, 323 eventMachine, eventServiceName, xmlFileName, xmlFileMachine, 324 function, args, jobName, scripts, showNoMonitorInfo, 325 limitMessages, pluginJarsVector, scriptFilesVector, 326 scriptFilesMachineName, clearLogs, STAXMonitorFrame.DEFAULT, 327 STAXMonitorFrame.DEFAULT, STAXMonitorFrame.DEFAULT, 328 autoMonitorSubjobs, 329 STAXMonitor.DEFAULT_STRING, STAXMonitor.DEFAULT_STRING, 330 STAXMonitor.DEFAULT_STRING, 331 new Vector<String>(), false, false); 332 } 333 STAXMonitorFrame(boolean newJob, STAXMonitor parentMonitor, String staxMachine, String staxServiceName, String staxMachineNickname, String jobNumber, String eventMachine, String eventServiceName, String xmlFileName, String xmlFileMachine, String function, String args, String jobName, Vector<String> scripts, boolean fShowNoSTAXMonitorInformation, String limitMessages, Vector pluginJarsVector, Vector<String> scriptFilesVector, String scriptFilesMachineName, int clearLogs, int logTCElapsedTime, int logTCNumStarts, int logTCStartStop, int autoMonitorSubjobs, String pythonOutput, String pythonLogLevel, String invalidLogLevelAction, Vector<String> breakpointTriggerVector, boolean breakpointFirstFunction, boolean breakpointSubjobFirstFunction)334 public STAXMonitorFrame(boolean newJob, 335 STAXMonitor parentMonitor, String staxMachine, 336 String staxServiceName, 337 String staxMachineNickname, 338 String jobNumber, 339 String eventMachine, String eventServiceName, 340 String xmlFileName, String xmlFileMachine, 341 String function, String args, String jobName, 342 Vector<String> scripts, 343 boolean fShowNoSTAXMonitorInformation, 344 String limitMessages, 345 Vector pluginJarsVector, 346 Vector<String> scriptFilesVector, 347 String scriptFilesMachineName, 348 int clearLogs, int logTCElapsedTime, 349 int logTCNumStarts, int logTCStartStop, 350 int autoMonitorSubjobs, 351 String pythonOutput, String pythonLogLevel, 352 String invalidLogLevelAction, 353 Vector<String> breakpointTriggerVector, 354 boolean breakpointFirstFunction, 355 boolean breakpointSubjobFirstFunction) 356 throws STAFException 357 { 358 fPluginJarsVector = pluginJarsVector; 359 fParentMonitor = parentMonitor; 360 fStaxMachine = staxMachine; 361 fStaxServiceName = staxServiceName; 362 fStaxMachineNickname = staxMachineNickname; 363 fStaxConfigMachine = parentMonitor.getStaxConfigMachine(); 364 fStaxInstanceUUID = parentMonitor.getStaxInstanceUUID(); 365 fJobNumber = jobNumber; 366 fEventMachine = eventMachine; 367 fLimitMessages = limitMessages; 368 fBreakpointTriggerVector = breakpointTriggerVector; 369 fBreakpointFirstFunction = breakpointFirstFunction; 370 fBreakpointSubjobFirstFunction = breakpointSubjobFirstFunction; 371 372 if (fEventMachine.equals("")) 373 { 374 fEventMachine = "local"; 375 } 376 377 fEventServiceName = eventServiceName; 378 fXmlFileName = xmlFileName; 379 fXmlFileMachine = xmlFileMachine; 380 fFunction = function; 381 fArgs = args; 382 fJobName = jobName; 383 fScripts = scripts; 384 fScriptFilesVector = scriptFilesVector; 385 fScriptFilesMachineName = scriptFilesMachineName; 386 fClearLogs = clearLogs; 387 fLogTCElapsedTime = logTCElapsedTime; 388 fLogTCNumStarts = logTCNumStarts; 389 fLogTCStartStop = logTCStartStop; 390 fAutoMonitorSubjobs = autoMonitorSubjobs; 391 fPythonOutput = pythonOutput; 392 fPythonLogLevel = pythonLogLevel; 393 fInvalidLogLevelAction = invalidLogLevelAction; 394 395 fMessageFontName = parentMonitor.getMessageFontName(); 396 fLogViewerFontName = parentMonitor.getLogViewerFontName(); 397 fSaveAsDirectory = parentMonitor.getSaveAsDirectory(); 398 399 if (newJob) 400 { 401 StringBuffer request = new StringBuffer("EXECUTE HOLD FILE "); 402 request.append(STAFUtil.wrapData(fXmlFileName)); 403 404 if (!fXmlFileMachine.equals("")) 405 { 406 request.append(" MACHINE ").append( 407 STAFUtil.wrapData(fXmlFileMachine)); 408 } 409 410 if (!fFunction.equals("")) 411 { 412 request.append(" FUNCTION ").append( 413 STAFUtil.wrapData(fFunction)); 414 } 415 416 if (fArgs != null && !fArgs.equals("")) 417 { 418 request.append(" ARGS ").append(STAFUtil.wrapData(fArgs)); 419 } 420 421 if (fJobName != null && !fJobName.equals("")) 422 { 423 request.append(" JOBNAME ").append( 424 STAFUtil.wrapData(fJobName)); 425 } 426 427 if (fScripts != null) 428 { 429 if (!fScripts.isEmpty()) 430 { 431 for (int i=0; i < fScripts.size(); i++) 432 { 433 request.append(" SCRIPT ").append( 434 STAFUtil.wrapData(fScripts.elementAt(i))); 435 } 436 } 437 } 438 439 if (fScriptFilesVector != null) 440 { 441 if (!fScriptFilesVector.isEmpty()) 442 { 443 if (fScriptFilesMachineName != null && 444 !fScriptFilesMachineName.equals("")) 445 { 446 request.append(" SCRIPTFILEMACHINE ").append( 447 STAFUtil.wrapData(fScriptFilesMachineName)); 448 } 449 450 for (int i=0; i < fScriptFilesVector.size(); i++) 451 { 452 request.append(" SCRIPTFILE ").append( 453 STAFUtil.wrapData( 454 fScriptFilesVector.elementAt(i))); 455 } 456 } 457 } 458 459 if (fClearLogs == STAXMonitorFrame.ENABLED) 460 request.append(" CLEARLOGS Enabled"); 461 else if (fClearLogs == STAXMonitorFrame.DISABLED) 462 request.append(" CLEARLOGS Disabled"); 463 464 if (fLogTCElapsedTime == STAXMonitorFrame.ENABLED) 465 request.append(" LOGTCELAPSEDTIME Enabled"); 466 else if (fLogTCElapsedTime == STAXMonitorFrame.DISABLED) 467 request.append(" LOGTCELAPSEDTIME Disabled"); 468 469 if (fLogTCNumStarts == STAXMonitorFrame.ENABLED) 470 request.append(" LOGTCNUMSTARTS Enabled"); 471 else if (fLogTCNumStarts == STAXMonitorFrame.DISABLED) 472 request.append(" LOGTCNUMSTARTS Disabled"); 473 474 if (fLogTCStartStop == STAXMonitorFrame.ENABLED) 475 request.append(" LOGTCSTARTSTOP Enabled"); 476 else if (fLogTCStartStop == STAXMonitorFrame.DISABLED) 477 request.append(" LOGTCSTARTSTOP Disabled"); 478 479 if (!fPythonOutput.equals(STAXMonitor.DEFAULT_STRING)) 480 request.append(" PYTHONOUTPUT " + fPythonOutput); 481 482 if (!fPythonLogLevel.equals(STAXMonitor.DEFAULT_STRING)) 483 request.append(" PYTHONLOGLEVEL " + fPythonLogLevel); 484 485 if (!fInvalidLogLevelAction.equals(STAXMonitor.DEFAULT_STRING)) 486 request.append(" INVALIDLOGLEVELACTION " + fInvalidLogLevelAction); 487 488 if (fBreakpointTriggerVector != null) 489 { 490 if (!fBreakpointTriggerVector.isEmpty()) 491 { 492 for (int i=0; i < fBreakpointTriggerVector.size(); i++) 493 { 494 request.append( 495 fBreakpointTriggerVector.elementAt(i) + " "); 496 } 497 } 498 } 499 500 if (fBreakpointFirstFunction) 501 { 502 request.append(" BREAKPOINTFIRSTFUNCTION"); 503 } 504 505 if (fBreakpointSubjobFirstFunction) 506 { 507 request.append(" BREAKPOINTSUBJOBFIRSTFUNCTION"); 508 } 509 510 // Submit the STAX EXECUTE request and display a "Please Wait" 511 // dialog while the request is preparing to run the job 512 513 STAXMonitorExecuteResult executeResult = 514 parentMonitor.submitExecuteRequest(request.toString()); 515 516 if (executeResult.getRC() != STAFResult.Ok) 517 { 518 throw new STAFException( 519 executeResult.getRC(), 520 executeResult.getResult().toString()); 521 } 522 523 // Assign the job number that was generated for this job 524 525 fJobNumber = executeResult.getResult().toString(); 526 } 527 528 try 529 { 530 fHandle = STAXMonitorUtil.getNewSTAFHandle( 531 fStaxServiceName + "/JobMonitor/" + fStaxMachine + "/" + 532 fJobNumber); 533 } 534 catch (STAFException e) 535 { 536 throw e; 537 } 538 539 boolean jobAlreadyHeld = false; 540 541 if (!newJob) 542 { 543 String request = "HOLD JOB " + fJobNumber; 544 STAFResult holdResult = fHandle.submit2( 545 fStaxMachine, fStaxServiceName, request); 546 547 if (holdResult.rc != 0) 548 { 549 if (holdResult.rc == BlockAlreadyHeld) 550 { 551 jobAlreadyHeld = true; 552 } 553 else 554 { 555 throw new STAFException( 556 holdResult.rc, 557 "Error holding Job ID " + fJobNumber + "\n" + 558 holdResult.result); 559 } 560 } 561 } 562 563 setTitle(kMonitorFrameTitle); 564 addWindowListener(new WindowAdapter() 565 { 566 public void windowClosing(WindowEvent e) 567 { 568 if (!fMonitorStopped) 569 { 570 stopMonitor(); 571 } 572 closeMonitor(); 573 } 574 }); 575 576 fActiveElementsPane.addChangeListener(this); 577 fStatusPane.addChangeListener(this); 578 fInfoPane.addChangeListener(this); 579 580 JMenuBar mainMenuBar = new JMenuBar(); 581 setJMenuBar(mainMenuBar); 582 fFileMenu = new JMenu("File"); 583 mainMenuBar.add(fFileMenu); 584 fDisplayMenu = new JMenu("Display"); 585 mainMenuBar.add(fDisplayMenu); 586 fViewMenu = new JMenu("View"); 587 mainMenuBar.add(fViewMenu); 588 fFileResubmit = new JMenuItem("Resubmit Job"); 589 fFileResubmit.addActionListener(this); 590 fFileExitAndResubmit = new JMenuItem("Exit and Resubmit Job"); 591 fFileExitAndResubmit.addActionListener(this); 592 fFileExit = new JMenuItem("Exit"); 593 fFileExit.addActionListener(this); 594 fFileMenu.add(fFileResubmit); 595 fFileMenu.add(fFileExitAndResubmit); 596 fFileMenu.insertSeparator(2); 597 fFileMenu.add(fFileExit); 598 fDisplayMenu.add(fDisplayJobLog); 599 fDisplayMenu.add(fDisplayJobUserLog); 600 fDisplayJobLog.addActionListener(this); 601 fDisplayJobUserLog.addActionListener(this); 602 603 fDataColumns = new Vector<String>(); 604 fDataColumns.addElement(" Name "); 605 fDataColumns.addElement(" Value "); 606 607 fMessageColumns = new Vector<String>(); 608 fMessageColumns.addElement(" Timestamp "); 609 fMessageColumns.addElement(" Message "); 610 611 getContentPane().setLayout(new BorderLayout()); 612 getContentPane().setBackground(Color.white); 613 614 fSelectionDetailsPanel = new JPanel(); 615 fSelectionDetailsPanel.setLayout(new BorderLayout()); 616 617 JPanel selectionButtonPanel = new JPanel(); 618 selectionButtonPanel.setLayout(new 619 FlowLayout(FlowLayout.LEFT, 0, 0)); 620 621 JPanel detailsTablePanel = new JPanel(); 622 detailsTablePanel.setLayout(new BorderLayout()); 623 624 fDetailsTableModel = new STAXMonitorTableModel(fDataColumns, 0); 625 fDetailsModelSorter = new STAXMonitorTableSorter(fDetailsTableModel); 626 fDetailsTable = new JTable(fDetailsModelSorter); 627 fDetailsModelSorter.addMouseListenerToHeaderInTable(fDetailsTable, 1); 628 fDetailsTable.setVisible(false); 629 fDetailsTable.getTableHeader().setVisible(false); 630 631 updateDetailsTableRenderers(); 632 633 JPanel messagesPanel = new JPanel(); 634 messagesPanel.setLayout(new BorderLayout()); 635 636 fMessageTableModel = new STAXMonitorTableModel(fMessageColumns, 0); 637 fMessageModelSorter = 638 new STAXMonitorTableSorter(fMessageTableModel, 0, fMessageFontName); 639 fMessageTable = new JTable(fMessageModelSorter); 640 fMessageModelSorter.addMouseListenerToHeaderInTable(fMessageTable, 1); 641 642 fMessageTable.getColumnModel().getColumn(0).setCellRenderer( 643 new STAXMonitorTableCellRenderer( 644 Color.black, false, 645 new Font(fMessageFontName, Font.PLAIN, 12))); 646 647 fMessageTable.getColumnModel().getColumn(0). 648 setHeaderRenderer(new STAXMonitorTableCellRenderer( 649 Color.black, true, 650 new Font(fMessageFontName, Font.BOLD, 12))); 651 652 fMessageTable.getColumnModel().getColumn(1).setCellRenderer( 653 new STAXMonitorTableCellRenderer( 654 Color.black, false, 655 new Font(fMessageFontName, Font.PLAIN, 12))); 656 657 fMessageTable.getColumnModel().getColumn(1). 658 setHeaderRenderer(new STAXMonitorTableCellRenderer( 659 Color.black, true, 660 new Font(fMessageFontName, Font.BOLD, 12))); 661 662 fMessageTable.setFont(new Font(fMessageFontName, Font.PLAIN, 12)); 663 664 fMessageScrollPane = new JScrollPane(fMessageTable); 665 666 fMessageScrollPane.setVerticalScrollBarPolicy( 667 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 668 fMessageScrollPane.setHorizontalScrollBarPolicy( 669 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 670 671 fMessageTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 672 STAXMonitorUtil.sizeColumnsToFitText(fMessageTable); 673 674 fInfoPane.add("Messages", fMessageScrollPane); 675 fViewableComponents.put("Messages", fMessageScrollPane); 676 677 JScrollPane detailsScrollPane = new JScrollPane(fDetailsTable); 678 679 detailsScrollPane.setVerticalScrollBarPolicy( 680 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 681 detailsScrollPane.setHorizontalScrollBarPolicy( 682 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 683 684 fDetailsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 685 686 STAXMonitorUtil.sizeColumnsToFitText(fDetailsTable); 687 688 fCurrentSelection = new JLabel(""); 689 fCurrentSelection.setFont(new Font("Dialog", Font.BOLD, 14)); 690 fCurrentSelection.setForeground(new Color(23, 0, 122)); 691 692 fSelectionDetailsPanel.add(BorderLayout.NORTH, fCurrentSelection); 693 694 JPanel selectionDetailsPanel1 = new JPanel(); 695 selectionDetailsPanel1.setLayout(new BorderLayout()); 696 fSelectionDetailsPanel.add(BorderLayout.CENTER, detailsScrollPane); 697 698 int index = fInfoPane.getTabCount(); 699 700 fInfoPane.setBackgroundAt(index - 1, Color.white); 701 fInfoPane.setForegroundAt(index - 1, Color.darkGray); 702 703 fMonitorTree = new JTree(); 704 fMonitorTree.setCellRenderer(new 705 STAXMonitorTreeCellRenderer(fShowNoSTAXMonitorInformation)); 706 fMonitorTree.putClientProperty("JTree.lineStyle", "Angled"); 707 fMonitorTree.setShowsRootHandles(true); 708 fMonitorTree.addTreeSelectionListener(this); 709 fMonitorTreeModel = (DefaultTreeModel) fMonitorTree.getModel(); 710 fMonitorTreeModel.setRoot(new STAXMonitorTreeNode()); 711 fMonitorTree.addMouseListener(this); 712 713 JPanel treeAndSelectionPanel = new JPanel(); 714 treeAndSelectionPanel.setLayout(new BorderLayout()); 715 716 fActiveJobElementsMenu = new JCheckBoxMenuItem( 717 "Active Job Elements", true); 718 fActiveJobElementsMenu.addActionListener(this); 719 fViewMenu.add(fActiveJobElementsMenu); 720 721 JScrollPane scrollPane = new JScrollPane(fMonitorTree); 722 fActiveElementsPane.add("Active Job Elements", scrollPane); 723 724 fActiveElementsPane.setForegroundAt(0, Color.black); 725 726 fViewableComponents.put("Active Job Elements", scrollPane); 727 728 JSplitPane horizPane = new JSplitPane( 729 JSplitPane.HORIZONTAL_SPLIT, fActiveElementsPane, fStatusPane); 730 horizPane.setOneTouchExpandable(true); 731 732 JSplitPane vertPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, 733 horizPane, fInfoPane); 734 vertPane.setOneTouchExpandable(true); 735 736 JPanel monitorPanel = new JPanel(); 737 monitorPanel.setLayout(new BorderLayout()); 738 monitorPanel.add(vertPane); 739 740 fSelectionDetailsPanel.setVisible(true); 741 742 // Handle extensions 743 try 744 { 745 processTablePlugin = new STAXMonitorProcessExtension(); 746 JComponent processTable = 747 processTablePlugin.init(this, newJob, fStaxMachine, 748 fStaxServiceName, fJobNumber); 749 processTable.setVisible(true); 750 751 Vector<String> notificationTypes = new Vector<String>(); 752 753 StringTokenizer types = new StringTokenizer( 754 processTablePlugin.getNotificationEventTypes(), " "); 755 756 while (types.hasMoreElements()) 757 { 758 String type = types.nextToken().toLowerCase(); 759 notificationTypes.add(type); 760 } 761 762 fRegisteredPlugins.put(processTablePlugin, notificationTypes); 763 764 fProcessMenu = new JCheckBoxMenuItem( 765 processTablePlugin.getTitle(), true); 766 fProcessMenu.addActionListener(this); 767 fViewMenu.add(fProcessMenu); 768 769 fViewablePlugins.put(fProcessMenu, processTablePlugin); 770 771 JScrollPane procScrollPane = 772 new JScrollPane(processTablePlugin.getComponent()); 773 procScrollPane.setVerticalScrollBarPolicy( 774 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 775 procScrollPane.setHorizontalScrollBarPolicy( 776 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 777 778 fActiveElementsPane.addTab(processTablePlugin.getTitle(), 779 procScrollPane); 780 781 fViewableComponents.put(processTablePlugin.getTitle(), 782 procScrollPane); 783 784 int i = fActiveElementsPane.getTabCount(); 785 fActiveElementsPane.setBackgroundAt(i - 1, Color.white); 786 fActiveElementsPane.setForegroundAt(i - 1, Color.darkGray); 787 } 788 catch (STAFException ex) 789 { 790 System.out.println("STAFException thrown during " + 791 "STAXMonitorProcessExtension initialization. RC: " + 792 ex.rc + "\n" + ex.getMessage()); 793 } 794 795 try 796 { 797 stafcmdTablePlugin = new STAXMonitorSTAFCmdExtension(); 798 JComponent stafcmdTable = 799 stafcmdTablePlugin.init(this, newJob, fStaxMachine, 800 fStaxServiceName, fJobNumber); 801 stafcmdTable.setVisible(true); 802 803 Vector<String> notificationTypes = new Vector<String>(); 804 805 StringTokenizer types = new StringTokenizer( 806 stafcmdTablePlugin.getNotificationEventTypes(), " "); 807 808 while (types.hasMoreElements()) 809 { 810 String type = types.nextToken().toLowerCase(); 811 notificationTypes.add(type); 812 } 813 814 fRegisteredPlugins.put(stafcmdTablePlugin, notificationTypes); 815 816 fSTAFCmdMenu = new JCheckBoxMenuItem( 817 stafcmdTablePlugin.getTitle(), true); 818 fSTAFCmdMenu.addActionListener(this); 819 fViewMenu.add(fSTAFCmdMenu); 820 821 JScrollPane stafcmdScrollPane = 822 new JScrollPane(stafcmdTablePlugin.getComponent()); 823 stafcmdScrollPane.setVerticalScrollBarPolicy( 824 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 825 stafcmdScrollPane.setHorizontalScrollBarPolicy( 826 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 827 828 fActiveElementsPane.addTab(stafcmdTablePlugin.getTitle(), 829 stafcmdScrollPane); 830 831 fViewableComponents.put(stafcmdTablePlugin.getTitle(), 832 stafcmdScrollPane); 833 834 fViewablePlugins.put(fSTAFCmdMenu, stafcmdTablePlugin); 835 836 int i = fActiveElementsPane.getTabCount(); 837 fActiveElementsPane.setBackgroundAt(i - 1, Color.white); 838 fActiveElementsPane.setForegroundAt(i - 1, Color.darkGray); 839 } 840 catch (STAFException ex) 841 { 842 System.out.println("STAFException thrown during " + 843 "STAXMonitorSTAFCmdExtension initialization. RC: " + 844 ex.rc + "\n" + ex.getMessage()); 845 } 846 847 try 848 { 849 subjobTablePlugin = new STAXMonitorSubjobExtension(); 850 JComponent subjobTable = 851 subjobTablePlugin.init(this, newJob, fStaxMachine, 852 fStaxServiceName, fJobNumber); 853 subjobTable.setVisible(true); 854 855 Vector<String> notificationTypes = new Vector<String>(); 856 857 StringTokenizer types = new StringTokenizer( 858 subjobTablePlugin.getNotificationEventTypes(), " "); 859 860 while (types.hasMoreElements()) 861 { 862 String type = types.nextToken().toLowerCase(); 863 notificationTypes.add(type); 864 } 865 866 fRegisteredPlugins.put(subjobTablePlugin, notificationTypes); 867 868 fSubjobMenu = new JCheckBoxMenuItem( 869 subjobTablePlugin.getTitle(), true); 870 fSubjobMenu.addActionListener(this); 871 fViewMenu.add(fSubjobMenu); 872 873 JScrollPane subjobScrollPane = 874 new JScrollPane(subjobTablePlugin.getComponent()); 875 subjobScrollPane.setVerticalScrollBarPolicy( 876 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 877 subjobScrollPane.setHorizontalScrollBarPolicy( 878 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 879 880 fActiveElementsPane.addTab(subjobTablePlugin.getTitle(), 881 subjobScrollPane); 882 883 fViewableComponents.put(subjobTablePlugin.getTitle(), 884 subjobScrollPane); 885 886 fViewablePlugins.put(fSubjobMenu, subjobTablePlugin); 887 888 int i = fActiveElementsPane.getTabCount(); 889 fActiveElementsPane.setBackgroundAt(i - 1, Color.white); 890 fActiveElementsPane.setForegroundAt(i - 1, Color.darkGray); 891 } 892 catch (STAFException ex) 893 { 894 System.out.println("STAFException thrown during " + 895 "STAXMonitorSubjobExtension initialization. RC: " + 896 ex.rc + "\n" + ex.getMessage()); 897 } 898 899 // Debug 900 try 901 { 902 breakpointPlugin = new STAXMonitorDebugExtension(); 903 JComponent breakpointPanel = 904 breakpointPlugin.init(this, newJob, fStaxMachine, 905 fStaxServiceName, fJobNumber); 906 breakpointPanel.setVisible(true); 907 908 Vector<String> notificationTypes = new Vector<String>(); 909 910 StringTokenizer types = new StringTokenizer( 911 breakpointPlugin.getNotificationEventTypes(), " "); 912 913 while (types.hasMoreElements()) 914 { 915 String type = types.nextToken().toLowerCase(); 916 notificationTypes.add(type); 917 } 918 919 fRegisteredPlugins.put(breakpointPlugin, notificationTypes); 920 921 fActiveElementsPane.addTab(breakpointPlugin.getTitle(), 922 breakpointPlugin.getComponent()); 923 924 int i = fActiveElementsPane.getTabCount(); 925 fActiveElementsPane.setBackgroundAt(i - 1, Color.white); 926 fActiveElementsPane.setForegroundAt(i - 1, Color.darkGray); 927 928 fDebugMenu = new JCheckBoxMenuItem( 929 breakpointPlugin.getTitle(), true); 930 fDebugMenu.addActionListener(this); 931 fViewMenu.add(fDebugMenu); 932 933 fViewableComponents.put(breakpointPlugin.getTitle(), 934 breakpointPlugin.getComponent()); 935 936 fViewablePlugins.put(fDebugMenu, breakpointPlugin); 937 } 938 catch (STAFException ex) 939 { 940 System.out.println("STAFException thrown during " + 941 "STAXMonitorDebugExtension initialization. RC: " + 942 ex.rc + "\n" + ex.getMessage()); 943 } 944 945 fViewMenu.addSeparator(); 946 947 // Testcase Status 948 try 949 { 950 testcaseTablePlugin = new STAXMonitorTestcaseExtension(); 951 JComponent testcaseTable = 952 testcaseTablePlugin.init(this, newJob, fStaxMachine, 953 fStaxServiceName, fJobNumber); 954 testcaseTable.setVisible(true); 955 956 Vector<String> notificationTypes = new Vector<String>(); 957 958 StringTokenizer types = new StringTokenizer( 959 testcaseTablePlugin.getNotificationEventTypes(), " "); 960 961 while (types.hasMoreElements()) 962 { 963 String type = types.nextToken().toLowerCase(); 964 notificationTypes.add(type); 965 } 966 967 fRegisteredPlugins.put(testcaseTablePlugin, notificationTypes); 968 969 fTestcaseStatusMenu = new JCheckBoxMenuItem( 970 testcaseTablePlugin.getTitle(), true); 971 fTestcaseStatusMenu.addActionListener(this); 972 973 JScrollPane tcScrollPane = 974 new JScrollPane(testcaseTablePlugin.getComponent()); 975 tcScrollPane.setVerticalScrollBarPolicy( 976 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 977 tcScrollPane.setHorizontalScrollBarPolicy( 978 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 979 980 fViewMenu.add(fTestcaseStatusMenu); 981 982 fViewablePlugins.put(fTestcaseStatusMenu, testcaseTablePlugin); 983 984 fStatusPane.addTab(testcaseTablePlugin.getTitle(), 985 tcScrollPane); 986 987 fViewableComponents.put(testcaseTablePlugin.getTitle(), 988 tcScrollPane); 989 990 int i = fStatusPane.getTabCount(); 991 fStatusPane.setBackgroundAt(i - 1, Color.white); 992 fInfoPane.setForegroundAt(i - 1, Color.darkGray); 993 } 994 catch (STAFException ex) 995 { 996 System.out.println("STAFException thrown during " + 997 "STAXMonitorTestcaseExtension initialization. RC: " + 998 ex.rc + "\n" + ex.getMessage()); 999 } 1000 1001 // Testcase Info 1002 try 1003 { 1004 testcaseInfoTablePlugin = new STAXMonitorTestcaseExtension(); 1005 JComponent testcaseTable = 1006 testcaseInfoTablePlugin.init(this, newJob, fStaxMachine, 1007 fStaxServiceName, fJobNumber); 1008 testcaseTable.setVisible(true); 1009 1010 Vector<String> notificationTypes = new Vector<String>(); 1011 1012 StringTokenizer types = new StringTokenizer( 1013 testcaseInfoTablePlugin. getNotificationEventTypes(), " "); 1014 1015 while (types.hasMoreElements()) 1016 { 1017 String type = types.nextToken().toLowerCase(); 1018 notificationTypes.add(type); 1019 } 1020 1021 fRegisteredPlugins.put(testcaseInfoTablePlugin, notificationTypes); 1022 1023 fTestcaseInfoMenu = new JCheckBoxMenuItem( 1024 testcaseInfoTablePlugin.getTitle() + " ", false); 1025 fTestcaseInfoMenu.addActionListener(this); 1026 1027 JScrollPane tcScrollPane = 1028 new JScrollPane(testcaseInfoTablePlugin.getComponent()); 1029 tcScrollPane.setVerticalScrollBarPolicy( 1030 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 1031 tcScrollPane.setHorizontalScrollBarPolicy( 1032 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 1033 1034 fViewablePlugins.put(fTestcaseInfoMenu, testcaseInfoTablePlugin); 1035 } 1036 catch (STAFException ex) 1037 { 1038 System.out.println("STAFException thrown during " + 1039 "STAXMonitorTestcaseExtension initialization. RC: " + 1040 ex.rc + "\n" + ex.getMessage()); 1041 } 1042 1043 fViewMenu.addSeparator(); 1044 1045 fMessagesMenu = 1046 new JCheckBoxMenuItem("Messages", true); 1047 fMessagesMenu.addActionListener(this); 1048 1049 fViewMenu.add(fMessagesMenu); 1050 1051 fCurrentSelectionMenu = 1052 new JCheckBoxMenuItem("Current Selection", true); 1053 fCurrentSelectionMenu.addActionListener(this); 1054 1055 fViewMenu.add(fCurrentSelectionMenu); 1056 1057 // XXX fix this later....need to use the type to determine where 1058 // the plugin should be placed in the menu 1059 1060 if (fTestcaseInfoMenu != null) 1061 { 1062 fViewMenu.add(fTestcaseInfoMenu); 1063 } 1064 1065 fBlockPopupMenu.add(fBlockHoldMenuItem); 1066 fBlockHoldMenuItem.addActionListener(this); 1067 fBlockPopupMenu.add(fBlockReleaseMenuItem); 1068 fBlockReleaseMenuItem.addActionListener(this); 1069 fBlockPopupMenu.add(fBlockTerminateMenuItem); 1070 fBlockTerminateMenuItem.addActionListener(this); 1071 1072 fProcessPopupMenu.add(fProcessStopMenuItem); 1073 fProcessStopMenuItem.addActionListener(this); 1074 1075 fSubjobPopupMenu.add(fSubjobStartMonitoringMenuItem); 1076 fSubjobStartMonitoringMenuItem.addActionListener(this); 1077 fSubjobPopupMenu.addSeparator(); 1078 fSubjobPopupMenu.add(fSubjobDisplayJobLogMenuItem); 1079 fSubjobDisplayJobLogMenuItem.addActionListener(this); 1080 fSubjobPopupMenu.add(fSubjobDisplayJobUserLogMenuItem); 1081 fSubjobDisplayJobUserLogMenuItem.addActionListener(this); 1082 fSubjobPopupMenu.addSeparator(); 1083 fSubjobPopupMenu.add(fSubjobTerminateMenuItem); 1084 fSubjobTerminateMenuItem.addActionListener(this); 1085 1086 fProcessMonitor = new STAFProcessMonitor(); 1087 fProcessMonitor.start(); 1088 1089 fElapsedTime = new MonitorElapsedTime(); 1090 fElapsedTime.start(); 1091 1092 if (!newJob) 1093 { 1094 // Determine which blocks in the job are currently held 1095 1096 String request = "LIST JOB " + fJobNumber + " BLOCKS"; 1097 STAFResult listResult = fHandle.submit2( 1098 fStaxMachine, fStaxServiceName, request); 1099 1100 if (listResult.rc != 0) 1101 { 1102 throw new STAFException( 1103 listResult.rc, 1104 "Error listing Job Blocks\n"+ listResult.result); 1105 } 1106 1107 java.util.List blockList = (java.util.List)listResult.resultObj; 1108 Iterator iter = blockList.iterator(); 1109 1110 Vector<STAXMonitorTreeNode> heldBlocks = 1111 new Vector<STAXMonitorTreeNode>(); 1112 1113 while (iter.hasNext()) 1114 { 1115 Map blockInfoMap = (Map)iter.next(); 1116 String block = (String)blockInfoMap.get("blockName"); 1117 String status = (String)blockInfoMap.get("state"); 1118 1119 heldBlocks.addAll(handleBlock(block, status)); 1120 } 1121 1122 for (int i = 0; i < heldBlocks.size(); i++) 1123 { 1124 heldBlocks.elementAt(i).setBlockStatus( 1125 STAXMonitorTreeNode.blockHeld); 1126 } 1127 1128 // Determine the processes that are currently running in the job 1129 1130 request = "LIST JOB " + fJobNumber + " PROCESSES"; 1131 listResult = fHandle.submit2( 1132 fStaxMachine, fStaxServiceName, request); 1133 1134 if (listResult.rc != 0) 1135 { 1136 throw new STAFException( 1137 listResult.rc, 1138 "Error listing Job PROCESSES\n" + listResult.result); 1139 } 1140 1141 java.util.List processList = (java.util.List)listResult.resultObj; 1142 iter = processList.iterator(); 1143 1144 while (iter.hasNext()) 1145 { 1146 Map processMap = (Map)iter.next(); 1147 String location = (String)processMap.get("location"); 1148 String handleNumber = (String)processMap.get("handle"); 1149 1150 request = "QUERY JOB " + fJobNumber + " PROCESS " + 1151 location + ":" + handleNumber; 1152 1153 STAFResult queryResult = fHandle.submit2( 1154 fStaxMachine, fStaxServiceName, request); 1155 1156 if (queryResult.rc != 0) 1157 { 1158 // Ignore since the process may have already completed 1159 continue; 1160 } 1161 1162 processMap = (HashMap)queryResult.resultObj; 1163 1164 String block = (String)processMap.get("blockName"); 1165 String processName = (String)processMap.get("processName"); 1166 1167 handleProcess(processMap, block, processName, location, 1168 handleNumber, false); 1169 } 1170 1171 // Determine the stafcmds that are currently running in the job 1172 1173 request = "LIST JOB " + fJobNumber + " STAFCMDS"; 1174 listResult = fHandle.submit2( 1175 fStaxMachine, fStaxServiceName, request); 1176 1177 if (listResult.rc != 0) 1178 { 1179 throw new STAFException( 1180 listResult.rc, 1181 "Error listing Job STAFCMDS\n" + listResult.result); 1182 } 1183 1184 if (listResult.rc != 0) 1185 { 1186 throw new STAFException( 1187 listResult.rc, 1188 "Error listing Job STAFCMDS\n" + listResult.result); 1189 } 1190 1191 java.util.List stafcmdList = (java.util.List)listResult.resultObj; 1192 iter = stafcmdList.iterator(); 1193 1194 while (iter.hasNext()) 1195 { 1196 Map stafcmdMap = (Map)iter.next(); 1197 String commandName = (String)stafcmdMap.get("stafcmdName"); 1198 String location = (String)stafcmdMap.get("location"); 1199 String requestNumber = (String)stafcmdMap.get("requestNum"); 1200 String service = (String)stafcmdMap.get("service"); 1201 String cmdRequest = (String)stafcmdMap.get("request"); 1202 1203 request = "QUERY JOB " + fJobNumber + " STAFCMD " + 1204 requestNumber; 1205 1206 STAFResult queryResult = fHandle.submit2( 1207 fStaxMachine, fStaxServiceName, request); 1208 1209 if (queryResult.rc != 0) 1210 { 1211 // Ignore since the stafcmd may have already completed 1212 continue; 1213 } 1214 1215 stafcmdMap = (HashMap)queryResult.resultObj; 1216 1217 String block = (String)stafcmdMap.get("blockName"); 1218 1219 handleCommand(commandName, block, location, requestNumber, 1220 service, cmdRequest); 1221 } 1222 1223 request = "LIST JOB " + fJobNumber + " SUBJOBS"; 1224 1225 listResult = fHandle.submit2( 1226 fStaxMachine, fStaxServiceName, request); 1227 1228 if (listResult.rc != 0) 1229 { 1230 throw new STAFException( 1231 listResult.rc, 1232 "Error listing Job SUBJOBS\n" + listResult.result); 1233 } 1234 1235 java.util.List subjobList = (java.util.List)listResult.resultObj; 1236 iter = subjobList.iterator(); 1237 1238 while (iter.hasNext()) 1239 { 1240 Map subjobMap = (Map)iter.next(); 1241 String jobID = (String)subjobMap.get("jobID"); 1242 jobName = (String)subjobMap.get("jobName"); 1243 String jobBlock = (String)subjobMap.get("blockName"); 1244 1245 request = "QUERY JOB " + jobID; 1246 STAFResult queryResult = fHandle.submit2( 1247 fStaxMachine, fStaxServiceName, request); 1248 1249 if (queryResult.rc != 0) 1250 continue; 1251 1252 Map jobMap = (HashMap)queryResult.resultObj; 1253 1254 String jobFile = (String)jobMap.get("xmlFileName"); 1255 String jobFileMachine = (String)jobMap.get("fileMachine"); 1256 String subjobFunction = (String)jobMap.get("function"); 1257 String functionArgs = (String)jobMap.get("arguments"); 1258 String scriptFileMachine = (String)jobMap.get("scriptMachine"); 1259 1260 // Convert the list of scripts to a vector of scripts 1261 1262 java.util.List scriptList = 1263 (java.util.List)jobMap.get("scriptList"); 1264 scripts = new Vector<String>(); 1265 1266 Iterator scriptsIter = scriptList.iterator(); 1267 1268 while (scriptsIter.hasNext()) 1269 { 1270 scripts.add((String)scriptsIter.next()); 1271 } 1272 1273 // Convert the list of scriptfiles to a vector of scriptfiles 1274 1275 java.util.List scriptFileList = 1276 (java.util.List)jobMap.get("scriptFileList"); 1277 scriptFilesVector = new Vector<String>(); 1278 1279 Iterator scriptFilesIter = scriptFileList.iterator(); 1280 1281 while (scriptFilesIter.hasNext()) 1282 { 1283 scriptFilesVector.add((String)scriptFilesIter.next()); 1284 } 1285 1286 // startTimestamp format is YYYYMMDD-HH:MM:SS 1287 String startTimestamp = (String)jobMap.get("startTimestamp"); 1288 String startDate = startTimestamp.substring(0, 8); 1289 String startTime = startTimestamp.substring(9); 1290 1291 String clearLogsString = (String)jobMap.get("clearLogs"); 1292 String logTCElapsedTimeString = 1293 (String)jobMap.get("logTCElapsedTime"); 1294 String logTCNumStartsString = 1295 (String)jobMap.get("logTCNumStarts"); 1296 String logTCStartStopString = 1297 (String)jobMap.get("logTCStartStop"); 1298 1299 String pythonOutputString = (String)jobMap.get("pythonOutput"); 1300 String pythonLogLevelString = (String)jobMap.get( 1301 "pythonLogLevel"); 1302 String invalidLogLevelActionString = (String)jobMap.get( 1303 "invalidLogLevelAction"); 1304 1305 String subjobText = "Job " + jobID + " - " + jobName; 1306 1307 STAXMonitorTreeNode newNode = new STAXMonitorTreeNode( 1308 subjobText, STAXMonitorTreeNode.subjobNodeType); 1309 1310 STAXMonitorTreeNode parentNode = fMonitorTreeBlocks.get( 1311 jobBlock); 1312 1313 // parentNode can be null if the block has ended 1314 if (parentNode != null) 1315 { 1316 fMonitorTreeModel.insertNodeInto(newNode, parentNode, 1317 parentNode.getChildCount()); 1318 TreeNode[] parentNodes = 1319 fMonitorTreeModel.getPathToRoot(parentNode); 1320 1321 fMonitorTree.expandPath(new TreePath(parentNodes)); 1322 1323 fSubjobIDHashtable.put(jobID, newNode); 1324 fMonitorTreeSubjobNodes.put(newNode, jobID); 1325 1326 fMonitorTreeSubjobStartTimes.put( 1327 newNode, 1328 STAXMonitorUtil.getCalendar2(startDate, startTime)); 1329 } 1330 1331 Vector<Vector<String>> subjobDataVector = 1332 new Vector<Vector<String>>(); 1333 1334 addRow(subjobDataVector, "Job ID", jobID); 1335 addRow(subjobDataVector, "Job Name", jobName); 1336 addRow(subjobDataVector, "Clear Logs", clearLogsString); 1337 addRow(subjobDataVector, "Log TC Elapsed Time", 1338 logTCElapsedTimeString); 1339 addRow(subjobDataVector, "Log TC Num Starts", 1340 logTCNumStartsString); 1341 addRow(subjobDataVector, "Log TC Start/Stop", 1342 logTCStartStopString); 1343 addRow(subjobDataVector, "Python Output", 1344 pythonOutputString); 1345 addRow(subjobDataVector, "Python Log Level", 1346 pythonLogLevelString); 1347 addRow(subjobDataVector, "Invalid Log Level Action", 1348 invalidLogLevelActionString); 1349 addRow(subjobDataVector, "Job File", jobFile); 1350 1351 if (!jobFileMachine.equals("")) 1352 { 1353 addRow(subjobDataVector, 1354 "Job File Machine", jobFileMachine); 1355 } 1356 1357 addRow(subjobDataVector, "Function", subjobFunction); 1358 addRow(subjobDataVector, "Function Args", functionArgs); 1359 1360 for (int i = 0; i < scriptFilesVector.size(); ++i) 1361 { 1362 if (i == 0) 1363 { 1364 addRow(subjobDataVector, "Script Files Machine", 1365 scriptFileMachine); 1366 } 1367 1368 addRow(subjobDataVector, "Script File #" + (i + 1), 1369 scriptFilesVector.elementAt(i)); 1370 } 1371 1372 for (int i = 0; i < scripts.size(); ++i) 1373 { 1374 addRow(subjobDataVector, "Script #" + (i + 1), 1375 scripts.elementAt(i)); 1376 } 1377 1378 addRow(subjobDataVector, "Start Date", startDate); 1379 addRow(subjobDataVector, "Start Time", startTime); 1380 addRow(subjobDataVector, "Block", jobBlock); 1381 1382 synchronized(fDataHashtable) 1383 { 1384 fDataHashtable.put(subjobText, subjobDataVector); 1385 } 1386 } 1387 } 1388 1389 try 1390 { 1391 Thread.sleep(500); 1392 } 1393 catch (InterruptedException ex) 1394 { 1395 } 1396 1397 fInfoPane.add("Current Selection", fSelectionDetailsPanel); 1398 fViewableComponents.put("Current Selection", fSelectionDetailsPanel); 1399 1400 index = fInfoPane.getTabCount(); 1401 1402 fInfoPane.setBackgroundAt(index - 1, Color.white); 1403 fInfoPane.setForegroundAt(index - 1, Color.darkGray); 1404 1405 // Get monitor extension (plugin) classes 1406 Vector<Class> pluginClasses = parentMonitor.getPluginClasses(); 1407 1408 // Handle external extensions (plugins) 1409 for (int p = 0; p < pluginClasses.size(); p++) 1410 { 1411 try 1412 { 1413 Class pluginClass = pluginClasses.elementAt(p); 1414 Object pluginObj = null; 1415 1416 // Try using a constructor that accepts a STAX object 1417 1418 Class [] parameterTypes = new Class[1]; 1419 parameterTypes[0] = this.getClass(); 1420 1421 try 1422 { 1423 Constructor construct = 1424 pluginClass.getConstructor(parameterTypes); 1425 Object [] initArgs = new Object[1]; 1426 initArgs[0] = this; 1427 pluginObj = construct.newInstance(initArgs); 1428 } 1429 catch (NoSuchMethodException e) 1430 { 1431 // Extension does not have a constructor that accepts 1432 // a STAX object, so use constructor without parameters 1433 pluginObj = pluginClass.newInstance(); 1434 } 1435 1436 STAXMonitorExtension plugin = (STAXMonitorExtension)pluginObj; 1437 1438 JComponent pluginComponent = 1439 plugin.init(this, newJob, fStaxMachine, 1440 fStaxServiceName, fJobNumber); 1441 1442 JScrollPane pluginScrollPane = null; 1443 1444 pluginComponent.setVisible(true); 1445 1446 Vector<String> notificationTypes = new Vector<String>(); 1447 1448 StringTokenizer types = new StringTokenizer( 1449 plugin.getNotificationEventTypes(), " "); 1450 1451 while (types.hasMoreElements()) 1452 { 1453 String type = types.nextToken().toLowerCase(); 1454 notificationTypes.add(type); 1455 fExternalPluginNotificationTypes.add(type); 1456 } 1457 1458 fRegisteredPlugins.put(plugin, notificationTypes); 1459 1460 pluginScrollPane = 1461 new JScrollPane(plugin.getComponent()); 1462 pluginScrollPane.setVerticalScrollBarPolicy( 1463 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 1464 pluginScrollPane.setHorizontalScrollBarPolicy( 1465 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 1466 1467 fViewableComponents.put(plugin.getTitle(), pluginScrollPane); 1468 1469 pluginComponent.setVisible(true); 1470 1471 int pluginType = plugin.getExtensionType(); 1472 1473 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 1474 { 1475 fActiveElementsPane.addTab(plugin.getTitle(), 1476 pluginScrollPane); 1477 1478 int i = fActiveElementsPane.getTabCount(); 1479 fActiveElementsPane.setBackgroundAt(i - 1, Color.white); 1480 fActiveElementsPane.setForegroundAt(i - 1, Color.darkGray); 1481 } 1482 else if (pluginType == STAXMonitorFrame.EXTENSION_STATUS) 1483 { 1484 fStatusPane.addTab(plugin.getTitle(), pluginScrollPane); 1485 1486 int i = fStatusPane.getTabCount(); 1487 fStatusPane.setBackgroundAt(i - 1, Color.white); 1488 fStatusPane.setForegroundAt(i - 1, Color.darkGray); 1489 } 1490 else if (pluginType == STAXMonitorFrame.EXTENSION_INFO) 1491 { 1492 fInfoPane.addTab(plugin.getTitle(), pluginScrollPane); 1493 1494 int i = fInfoPane.getTabCount(); 1495 fInfoPane.setBackgroundAt(i - 1, Color.white); 1496 fInfoPane.setForegroundAt(i - 1, Color.darkGray); 1497 } 1498 } 1499 catch (InvocationTargetException e) 1500 { 1501 System.out.println("InvocationTargetException thrown during " + 1502 "STAXMonitor plugin initialization\n" + 1503 e.getMessage()); 1504 1505 e.printStackTrace(); 1506 } 1507 catch (InstantiationException e) 1508 { 1509 System.out.println("InstantiationException thrown during " + 1510 "STAXMonitor plugin initialization\n" + 1511 e.getMessage()); 1512 1513 e.printStackTrace(); 1514 } 1515 catch (IllegalAccessException e) 1516 { 1517 System.out.println("IllegalAccessException thrown during " + 1518 "STAXMonitor plugin initialization\n" + 1519 e.getMessage()); 1520 1521 e.printStackTrace(); 1522 } 1523 catch (STAFException ex) 1524 { 1525 System.out.println("STAFException thrown during " + 1526 "STAXMonitor plugin initialization. RC: " + 1527 ex.rc); 1528 } 1529 } 1530 1531 getContentPane().add(BorderLayout.CENTER, monitorPanel); 1532 1533 pack(); 1534 setSize(new Dimension(950, 600)); 1535 setLocation(50, 30); 1536 setVisible(true); 1537 1538 // the calls to invalidate and validate are needed so that 1539 // the dividers will be located correctly on Linux systems 1540 horizPane.setDividerLocation(.55); 1541 invalidate(); 1542 validate(); 1543 vertPane.setDividerLocation(.68); 1544 invalidate(); 1545 validate(); 1546 1547 startMonitor(); 1548 1549 if (!jobAlreadyHeld) 1550 { 1551 STAFResult releaseResult = fHandle.submit2( 1552 fStaxMachine, fStaxServiceName, "RELEASE JOB " + fJobNumber); 1553 1554 if ((releaseResult.rc == STAFResult.DoesNotExist) || 1555 (releaseResult.rc == BlockNotHeld)) 1556 { 1557 // need to wait for slower machines 1558 for (int i = 0; i < 15; i++) 1559 { 1560 try 1561 { 1562 Thread.sleep(2000); 1563 1564 releaseResult = fHandle.submit2( 1565 fStaxMachine, fStaxServiceName, 1566 "RELEASE JOB " + fJobNumber); 1567 1568 if ((releaseResult.rc != STAFResult.DoesNotExist) && 1569 (releaseResult.rc != BlockNotHeld)) 1570 { 1571 break; 1572 } 1573 } 1574 catch (InterruptedException ex) 1575 { 1576 } 1577 } 1578 } 1579 1580 if (releaseResult.rc != 0) 1581 { 1582 JOptionPane.showMessageDialog( 1583 this, 1584 "An error was encountered while attempting to release " + 1585 "the job, RC: " + releaseResult.rc + 1586 ", Result: " + releaseResult.result, 1587 "Error releasing job", JOptionPane.ERROR_MESSAGE); 1588 } 1589 } 1590 1591 String theJobName = fJobName; 1592 1593 if (fJobName == null) theJobName = ""; 1594 1595 setTitle(kMonitorFrameTitle + " Machine:" + 1596 fStaxMachine + " JobID:" + fJobNumber + " " + 1597 theJobName + " <Running>"); 1598 1599 fQueueThread = new Thread(this); 1600 fQueueThread.start(); // this calls the run() method 1601 } 1602 getParentMonitor()1603 public STAXMonitor getParentMonitor() 1604 { 1605 return fParentMonitor; 1606 } 1607 actionPerformed(ActionEvent e)1608 public void actionPerformed(ActionEvent e) 1609 { 1610 String action = ""; 1611 if (e.getSource() == fBlockHoldMenuItem) 1612 { 1613 action = "hold"; 1614 } 1615 else if (e.getSource() == fBlockReleaseMenuItem) 1616 { 1617 action = "release"; 1618 } 1619 else if (e.getSource() == fBlockTerminateMenuItem) 1620 { 1621 action = "terminate"; 1622 } 1623 else if (e.getSource() == fProcessStopMenuItem) 1624 { 1625 // Get the process ID for the current selected node 1626 1627 String processID = null; 1628 1629 if (fMonitorTreeProcessNodes.containsKey(fCurrentSelectedNode)) 1630 processID = fMonitorTreeProcessNodes.get(fCurrentSelectedNode); 1631 1632 if (processID == null) 1633 { 1634 // The process is no longer running 1635 return; 1636 } 1637 1638 // The processID has format processName;location;handle, but 1639 // note that processName could could a ";", 1640 // Need to object the location and handle from processID. 1641 1642 String[] temp; 1643 temp = processID.split(";"); 1644 1645 if (temp.length < 2) 1646 { 1647 // Should never happen 1648 STAXMonitorUtil.showErrorDialog( 1649 this, 1650 "An error was encountered while attempting to stop the " + 1651 "process because could not extract the process location " + 1652 "and handle from: " + processID); 1653 return; 1654 } 1655 1656 String handle = temp[temp.length - 1]; 1657 String location = temp[temp.length - 2]; 1658 1659 String request = "STOP JOB " + fJobNumber + " PROCESS " + 1660 STAFUtil.wrapData(location + ":" + handle); 1661 1662 STAFResult result = fHandle.submit2( 1663 fStaxMachine, fStaxServiceName, request); 1664 1665 if (result.rc != 0) 1666 { 1667 STAXMonitorUtil.showErrorDialog( 1668 this, 1669 "An error was encountered while attempting to stop the " + 1670 "process,\n\nSTAF " + fStaxMachine + " " + 1671 fStaxServiceName + " " + request + 1672 "\n\nRC: " + result.rc + ", Result: " + result.result); 1673 } 1674 1675 return; 1676 } 1677 else if (e.getSource() == fSubjobStartMonitoringMenuItem) 1678 { 1679 String subjobID = fMonitorTreeSubjobNodes.get( 1680 fCurrentSelectedNode); 1681 fParentMonitor.monitorExistingJob(subjobID, -1); 1682 1683 return; 1684 } 1685 else if (e.getSource() == fSubjobDisplayJobLogMenuItem) 1686 { 1687 String subjobID = fMonitorTreeSubjobNodes.get( 1688 fCurrentSelectedNode); 1689 1690 String[] showLogParms = new String[10]; 1691 showLogParms[0] = "-machine"; 1692 showLogParms[1] = fStaxMachine; 1693 showLogParms[2] = "-machineNickname"; 1694 showLogParms[3] = fStaxMachineNickname; 1695 showLogParms[4] = "-name"; 1696 showLogParms[5] = fStaxServiceName.toUpperCase() + 1697 "_Job_" + subjobID; 1698 showLogParms[6] = "-fontName"; 1699 showLogParms[7] = fLogViewerFontName; 1700 showLogParms[8] = "-saveAsDirectory"; 1701 showLogParms[9] = fSaveAsDirectory; 1702 1703 // Pass the STAX/JobMonitor/Controller handle to the log viewer 1704 // (since it won't be deleted if the Job Monitor window is closed) 1705 1706 STAXMonitorLogViewer logViewer = new STAXMonitorLogViewer( 1707 this, fParentMonitor.fHandle, showLogParms); 1708 1709 return; 1710 } 1711 else if (e.getSource() == fSubjobDisplayJobUserLogMenuItem) 1712 { 1713 String subjobID = fMonitorTreeSubjobNodes.get( 1714 fCurrentSelectedNode); 1715 1716 String[] showLogParms = new String[10]; 1717 showLogParms[0] = "-machine"; 1718 showLogParms[1] = fStaxMachine; 1719 showLogParms[2] = "-machineNickname"; 1720 showLogParms[3] = fStaxMachineNickname; 1721 showLogParms[4] = "-name"; 1722 showLogParms[5] = fStaxServiceName.toUpperCase() + 1723 "_Job_" + subjobID + "_User"; 1724 showLogParms[6] = "-fontName"; 1725 showLogParms[7] = fLogViewerFontName; 1726 showLogParms[8] = "-saveAsDirectory"; 1727 showLogParms[9] = fSaveAsDirectory; 1728 1729 // Pass the STAX/JobMonitor/Controller handle to the log viewer 1730 // (since it won't be deleted if the Job Monitor window is closed) 1731 1732 STAXMonitorLogViewer logViewer = new STAXMonitorLogViewer( 1733 this, fParentMonitor.fHandle, showLogParms); 1734 1735 return; 1736 } 1737 else if (e.getSource() == fSubjobTerminateMenuItem) 1738 { 1739 String subjobID = fMonitorTreeSubjobNodes.get( 1740 fCurrentSelectedNode); 1741 1742 int confirmation = JOptionPane.showConfirmDialog(this, 1743 "Are you certain that you want\n" + 1744 "to terminate Job # " + subjobID + " ?", 1745 "Confirm Job Termination", 1746 JOptionPane.YES_NO_OPTION, 1747 JOptionPane.QUESTION_MESSAGE); 1748 1749 if (!(confirmation == JOptionPane.YES_OPTION)) 1750 { 1751 return; 1752 } 1753 1754 String request = "TERMINATE JOB " + subjobID; 1755 1756 STAFResult result = fHandle.submit2( 1757 fStaxMachine, fStaxServiceName, request); 1758 1759 if (result.rc != 0) 1760 { 1761 STAXMonitorUtil.showErrorDialog( 1762 fParentMonitor, 1763 "An error was encountered while attempting to " + 1764 "terminate jobID " + subjobID + ", RC: " + result.rc + 1765 ", Result: " + result.result); 1766 } 1767 1768 return; 1769 } 1770 else if (e.getSource() == fDisplayJobLog) 1771 { 1772 fBlockPopupMenu.setVisible(false); 1773 1774 String[] showLogParms = new String[10]; 1775 showLogParms[0] = "-machine"; 1776 showLogParms[1] = fStaxMachine; 1777 showLogParms[2] = "-machineNickname"; 1778 showLogParms[3] = fStaxMachineNickname; 1779 showLogParms[4] = "-name"; 1780 showLogParms[5] = fStaxServiceName.toUpperCase() + 1781 "_Job_" + fJobNumber; 1782 showLogParms[6] = "-fontName"; 1783 showLogParms[7] = fLogViewerFontName; 1784 showLogParms[8] = "-saveAsDirectory"; 1785 showLogParms[9] = fSaveAsDirectory; 1786 1787 // Pass the STAX/JobMonitor/Controller handle to the log viewer 1788 // (since it won't be deleted if the Job Monitor window is closed) 1789 1790 STAXMonitorLogViewer logViewer = new STAXMonitorLogViewer( 1791 this, fParentMonitor.fHandle, showLogParms); 1792 1793 fBlockPopupMenu.setVisible(false); 1794 1795 return; 1796 } 1797 else if (e.getSource() == fDisplayJobUserLog) 1798 { 1799 fBlockPopupMenu.setVisible(false); 1800 1801 String[] showLogParms = new String[10]; 1802 showLogParms[0] = "-machine"; 1803 showLogParms[1] = fStaxMachine; 1804 showLogParms[2] = "-machineNickname"; 1805 showLogParms[3] = fStaxMachineNickname; 1806 showLogParms[4] = "-name"; 1807 showLogParms[5] = fStaxServiceName.toUpperCase() + 1808 "_Job_" + fJobNumber + "_User"; 1809 showLogParms[6] = "-fontName"; 1810 showLogParms[7] = fLogViewerFontName; 1811 showLogParms[8] = "-saveAsDirectory"; 1812 showLogParms[9] = fSaveAsDirectory; 1813 1814 // Pass the STAX/JobMonitor/Controller handle to the log viewer 1815 // (since it won't be deleted if the Job Monitor window is closed) 1816 1817 STAXMonitorLogViewer logViewer = new STAXMonitorLogViewer( 1818 this, fParentMonitor.fHandle, showLogParms); 1819 1820 fBlockPopupMenu.setVisible(false); 1821 1822 return; 1823 } 1824 else if (e.getSource() == fFileExit) 1825 { 1826 if (!fMonitorStopped) 1827 { 1828 stopMonitor(); 1829 } 1830 1831 closeMonitor(); 1832 return; 1833 } 1834 else if ((e.getSource() == fFileResubmit) || 1835 (e.getSource() == fFileExitAndResubmit)) 1836 { 1837 try 1838 { 1839 fParentMonitor.addMonitoredJob(new STAXMonitorFrame( 1840 true, fParentMonitor, fStaxMachine, fStaxServiceName, 1841 fStaxMachineNickname, fJobNumber, fEventMachine, 1842 fEventServiceName, fXmlFileName, fXmlFileMachine, 1843 fFunction, fArgs, fJobName, fScripts, 1844 fShowNoSTAXMonitorInformation, fLimitMessages, 1845 fPluginJarsVector, fScriptFilesVector, 1846 fScriptFilesMachineName, fClearLogs, 1847 fLogTCElapsedTime, fLogTCNumStarts, fLogTCStartStop, 1848 fAutoMonitorSubjobs, fPythonOutput, fPythonLogLevel, 1849 fInvalidLogLevelAction, fBreakpointTriggerVector, 1850 fBreakpointFirstFunction, fBreakpointSubjobFirstFunction)); 1851 } 1852 catch (STAFException ex) 1853 { 1854 STAXMonitorUtil.showErrorDialog( 1855 this, ex.getMessage(), 1856 new Font("Courier", Font.PLAIN, 12)); 1857 1858 return; 1859 } 1860 1861 if (e.getSource() == fFileExitAndResubmit) 1862 { 1863 if (!fMonitorStopped) 1864 { 1865 stopMonitor(); 1866 } 1867 1868 closeMonitor(); 1869 } 1870 1871 return; 1872 } 1873 else if (e.getSource() == fProcessMenu) 1874 { 1875 STAXMonitorExtension plugin = fViewablePlugins.get(e.getSource()); 1876 1877 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 1878 { 1879 JScrollPane scrollPane = new JScrollPane(plugin.getComponent()); 1880 scrollPane.setVerticalScrollBarPolicy( 1881 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 1882 scrollPane.setHorizontalScrollBarPolicy( 1883 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 1884 1885 int pluginType = plugin.getExtensionType(); 1886 1887 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 1888 { 1889 fActiveElementsPane.addTab(plugin.getTitle(), scrollPane); 1890 1891 int index = fActiveElementsPane.getTabCount(); 1892 fActiveElementsPane.setBackgroundAt( 1893 index - 1, Color.white); 1894 fActiveElementsPane.setForegroundAt( 1895 index - 1, Color.darkGray); 1896 } 1897 1898 fViewableComponents.put(plugin.getTitle(), scrollPane); 1899 } 1900 else 1901 { 1902 int pluginType = plugin.getExtensionType(); 1903 1904 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 1905 { 1906 fActiveElementsPane.remove( 1907 fViewableComponents.get(plugin.getTitle())); 1908 } 1909 1910 fViewableComponents.remove(plugin.getTitle()); 1911 } 1912 1913 return; 1914 } 1915 else if (e.getSource() == fSTAFCmdMenu) 1916 { 1917 STAXMonitorExtension plugin = fViewablePlugins.get(e.getSource()); 1918 1919 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 1920 { 1921 JScrollPane scrollPane = new JScrollPane(plugin.getComponent()); 1922 scrollPane.setVerticalScrollBarPolicy( 1923 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 1924 scrollPane.setHorizontalScrollBarPolicy( 1925 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 1926 1927 int pluginType = plugin.getExtensionType(); 1928 1929 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 1930 { 1931 fActiveElementsPane.addTab(plugin.getTitle(), scrollPane); 1932 1933 int index = fActiveElementsPane.getTabCount(); 1934 fActiveElementsPane.setBackgroundAt( 1935 index - 1, Color.white); 1936 fActiveElementsPane.setForegroundAt( 1937 index - 1, Color.darkGray); 1938 } 1939 1940 fViewableComponents.put(plugin.getTitle(), scrollPane); 1941 } 1942 else 1943 { 1944 int pluginType = plugin.getExtensionType(); 1945 1946 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 1947 { 1948 fActiveElementsPane.remove( 1949 fViewableComponents.get(plugin.getTitle())); 1950 } 1951 1952 fViewableComponents.remove(plugin.getTitle()); 1953 } 1954 1955 return; 1956 } 1957 else if (e.getSource() == fSubjobMenu) 1958 { 1959 STAXMonitorExtension plugin = fViewablePlugins.get(e.getSource()); 1960 1961 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 1962 { 1963 JScrollPane scrollPane = new JScrollPane(plugin.getComponent()); 1964 scrollPane.setVerticalScrollBarPolicy( 1965 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 1966 scrollPane.setHorizontalScrollBarPolicy( 1967 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 1968 1969 int pluginType = plugin.getExtensionType(); 1970 1971 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 1972 { 1973 fActiveElementsPane.addTab(plugin.getTitle(), scrollPane); 1974 1975 int index = fActiveElementsPane.getTabCount(); 1976 fActiveElementsPane.setBackgroundAt( 1977 index - 1, Color.white); 1978 fActiveElementsPane.setForegroundAt( 1979 index - 1, Color.darkGray); 1980 } 1981 1982 fViewableComponents.put(plugin.getTitle(), scrollPane); 1983 } 1984 else 1985 { 1986 int pluginType = plugin.getExtensionType(); 1987 1988 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 1989 { 1990 fActiveElementsPane.remove( 1991 fViewableComponents.get(plugin.getTitle())); 1992 } 1993 1994 fViewableComponents.remove(plugin.getTitle()); 1995 } 1996 1997 return; 1998 } 1999 else if (e.getSource() == fDebugMenu) 2000 { 2001 STAXMonitorExtension plugin = fViewablePlugins.get(e.getSource()); 2002 2003 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 2004 { 2005 JScrollPane scrollPane = new JScrollPane(plugin.getComponent()); 2006 scrollPane.setVerticalScrollBarPolicy( 2007 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 2008 scrollPane.setHorizontalScrollBarPolicy( 2009 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 2010 2011 int pluginType = plugin.getExtensionType(); 2012 2013 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 2014 { 2015 fActiveElementsPane.addTab( 2016 plugin.getTitle(), plugin.getComponent()); 2017 2018 int index = fActiveElementsPane.getTabCount(); 2019 fActiveElementsPane.setBackgroundAt( 2020 index - 1, Color.white); 2021 fActiveElementsPane.setForegroundAt( 2022 index - 1, Color.darkGray); 2023 } 2024 2025 fViewableComponents.put(plugin.getTitle(), 2026 plugin.getComponent()); 2027 } 2028 else 2029 { 2030 int pluginType = plugin.getExtensionType(); 2031 2032 if (pluginType == STAXMonitorFrame.EXTENSION_ACTIVE) 2033 { 2034 fActiveElementsPane.remove( 2035 fViewableComponents.get(plugin.getTitle())); 2036 } 2037 2038 fViewableComponents.remove(plugin.getTitle()); 2039 } 2040 2041 return; 2042 } 2043 else if (e.getSource() == fActiveJobElementsMenu) 2044 { 2045 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 2046 { 2047 JScrollPane scrollPane = new JScrollPane(fMonitorTree); 2048 scrollPane.setVerticalScrollBarPolicy( 2049 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 2050 scrollPane.setHorizontalScrollBarPolicy( 2051 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 2052 2053 fActiveElementsPane.add("Active Job Elements", scrollPane); 2054 fViewableComponents.put("Active Job Elements", scrollPane); 2055 } 2056 else 2057 { 2058 fActiveElementsPane.remove( 2059 fViewableComponents.get("Active Job Elements")); 2060 fViewableComponents.remove("Active Job Elements"); 2061 } 2062 2063 return; 2064 } 2065 else if (e.getSource() == fTestcaseInfoMenu) 2066 { 2067 STAXMonitorExtension plugin = fViewablePlugins.get(e.getSource()); 2068 2069 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 2070 { 2071 JScrollPane scrollPane = new JScrollPane(plugin.getComponent()); 2072 scrollPane.setVerticalScrollBarPolicy( 2073 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 2074 scrollPane.setHorizontalScrollBarPolicy( 2075 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 2076 2077 int pluginType = plugin.getExtensionType(); 2078 2079 if (pluginType == STAXMonitorFrame.EXTENSION_INFO) 2080 { 2081 fInfoPane.addTab(plugin.getTitle() + " ", scrollPane); 2082 2083 int index = fInfoPane.getTabCount(); 2084 fInfoPane.setBackgroundAt(index - 1, Color.white); 2085 fInfoPane.setForegroundAt(index - 1, Color.darkGray); 2086 } 2087 2088 fViewableComponents.put(plugin.getTitle() + " ", scrollPane); 2089 } 2090 else 2091 { 2092 int pluginType = plugin.getExtensionType(); 2093 2094 if (pluginType == STAXMonitorFrame.EXTENSION_INFO) 2095 { 2096 fInfoPane.remove( 2097 fViewableComponents.get(plugin.getTitle() + " ")); 2098 } 2099 2100 fViewableComponents.remove(plugin.getTitle() + " "); 2101 } 2102 2103 return; 2104 } 2105 else if (e.getSource() == fTestcaseStatusMenu) 2106 { 2107 STAXMonitorExtension plugin = fViewablePlugins.get(e.getSource()); 2108 2109 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 2110 { 2111 JScrollPane scrollPane = new JScrollPane(plugin.getComponent()); 2112 scrollPane.setVerticalScrollBarPolicy( 2113 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 2114 scrollPane.setHorizontalScrollBarPolicy( 2115 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 2116 2117 int pluginType = plugin.getExtensionType(); 2118 2119 if (pluginType == STAXMonitorFrame.EXTENSION_INFO) 2120 { 2121 fStatusPane.addTab(plugin.getTitle(), scrollPane); 2122 2123 int index = fStatusPane.getTabCount(); 2124 fStatusPane.setBackgroundAt(index - 1, Color.white); 2125 fStatusPane.setForegroundAt(index - 1, Color.darkGray); 2126 } 2127 2128 fViewableComponents.put(plugin.getTitle(), scrollPane); 2129 2130 } 2131 else 2132 { 2133 int pluginType = plugin.getExtensionType(); 2134 2135 if (pluginType == STAXMonitorFrame.EXTENSION_INFO) 2136 { 2137 fStatusPane.remove( 2138 fViewableComponents.get(plugin.getTitle())); 2139 } 2140 2141 fViewableComponents.remove(plugin.getTitle()); 2142 } 2143 2144 return; 2145 } 2146 else if (e.getSource() == fCurrentSelectionMenu) 2147 { 2148 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 2149 { 2150 JScrollPane scrollPane = 2151 new JScrollPane(fSelectionDetailsPanel); 2152 scrollPane.setVerticalScrollBarPolicy( 2153 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 2154 scrollPane.setHorizontalScrollBarPolicy( 2155 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 2156 fInfoPane.add("Current Selection", scrollPane); 2157 fViewableComponents.put("Current Selection", scrollPane); 2158 2159 int index = fInfoPane.getTabCount(); 2160 fInfoPane.setBackgroundAt(index - 1, 2161 Color.white); 2162 fInfoPane.setForegroundAt(index - 1, 2163 Color.darkGray); 2164 } 2165 else 2166 { 2167 fInfoPane.remove(fViewableComponents.get("Current Selection")); 2168 fViewableComponents.remove("Current Selection"); 2169 } 2170 2171 return; 2172 } 2173 else if (e.getSource() == fMessagesMenu) 2174 { 2175 if (((JCheckBoxMenuItem)e.getSource()).isSelected()) 2176 { 2177 JScrollPane scrollPane = 2178 new JScrollPane(fMessageTable); 2179 scrollPane.setVerticalScrollBarPolicy( 2180 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 2181 scrollPane.setHorizontalScrollBarPolicy( 2182 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 2183 2184 fInfoPane.add("Messages", scrollPane); 2185 fViewableComponents.put("Messages", scrollPane); 2186 } 2187 else 2188 { 2189 fInfoPane.remove(fViewableComponents.get("Messages")); 2190 fViewableComponents.remove("Messages"); 2191 } 2192 2193 return; 2194 } 2195 else 2196 { 2197 return; 2198 } 2199 2200 String blockNode = fMonitorTreeBlockNodes.get(fCurrentSelectedNode); 2201 2202 String request = action + " JOB " + fJobNumber + " BLOCK " + 2203 STAFUtil.wrapData(blockNode); 2204 2205 STAFResult result = fHandle.submit2( 2206 fStaxMachine, fStaxServiceName, request); 2207 2208 if (result.rc != 0) 2209 { 2210 STAXMonitorUtil.showErrorDialog( 2211 this, 2212 "An error was encountered while attempting to " + action + 2213 ", RC: " + result.rc + ", Result: " + result.result); 2214 } 2215 } 2216 stateChanged(ChangeEvent e)2217 public void stateChanged(ChangeEvent e) 2218 { 2219 JTabbedPane pane = (JTabbedPane)e.getSource(); 2220 2221 for (int i = 0; i < pane.getTabCount(); i++) 2222 { 2223 pane.setBackgroundAt(i, Color.white); 2224 pane.setForegroundAt(i, Color.darkGray); 2225 } 2226 2227 int selected = ((JTabbedPane)e.getSource()).getSelectedIndex(); 2228 2229 if (selected != -1) 2230 { 2231 pane.setForegroundAt(selected, Color.black); 2232 } 2233 } 2234 handleJobEvent(Map propertyMap)2235 void handleJobEvent(Map propertyMap) 2236 { 2237 String block = (String)propertyMap.get("block"); 2238 2239 String status = (String)propertyMap.get("status"); 2240 2241 if ((!status.equals("end")) && (!status.equals("stop"))) 2242 { 2243 handleBlock(block, "Running"); 2244 } 2245 2246 String type = (String)propertyMap.get("type"); 2247 2248 // At this point, all of the blocks have been added 2249 2250 if (type.equals("block")) 2251 { 2252 if (status.equals("end")) 2253 { 2254 // Remove a block when get a "end" status message as this 2255 // indicates the block has ended (normally or terminated). 2256 // Note that a block type message with a "terminate" status 2257 // indicates that a request was made to terminate a block, 2258 // but the block may not have ended yet so it should 2259 // continue to be displayed by the STAX Monitor until an 2260 // "end" status message for the block is received. 2261 2262 synchronized(fMonitorTreeModel) 2263 { 2264 synchronized(fMonitorTreeBlocks) 2265 { 2266 fMonitorTreeModel.removeNodeFromParent( 2267 fMonitorTreeBlocks.get(block)); 2268 fMonitorTreeBlockNodes.remove( 2269 fMonitorTreeBlocks.get(block)); 2270 fMonitorTreeBlocks.remove(block); 2271 } 2272 2273 fCurrentSelection.setText(""); 2274 } 2275 } 2276 else if (status.equals("hold")) 2277 { 2278 fMonitorTreeBlocks.get(block).setBlockStatus( 2279 STAXMonitorTreeNode.blockHeld); 2280 2281 fMonitorTree.updateUI(); 2282 } 2283 else if (status.equals("release")) 2284 { 2285 fMonitorTreeBlocks.get(block).setBlockStatus( 2286 STAXMonitorTreeNode.blockRunning); 2287 2288 fMonitorTree.updateUI(); 2289 } 2290 } 2291 else if (type.equals("command")) 2292 { 2293 String commandName = (String)propertyMap.get("name"); 2294 String location = (String)propertyMap.get("location"); 2295 String requestNumber = (String)propertyMap.get("requestNumber"); 2296 2297 if (status.equals("start")) 2298 { 2299 String service = (String)propertyMap.get("service"); 2300 String request = (String)propertyMap.get("request"); 2301 2302 handleCommand(commandName, block, location, requestNumber, 2303 service, request); 2304 2305 } 2306 else if (status.equals("stop")) 2307 { 2308 String commandID = commandName + ";" + location + ";" 2309 + requestNumber; 2310 2311 if (fCmdIDHashtable.containsKey(commandID)) 2312 { 2313 fMonitorTreeModel.removeNodeFromParent( 2314 fCmdIDHashtable.get(commandID)); 2315 fMonitorTreeCommandNodes.remove( 2316 fCmdIDHashtable.get(commandID)); 2317 fMonitorTreeCommandStartTimes.remove( 2318 fCmdIDHashtable.get(commandID)); 2319 fCmdIDHashtable.remove(commandID); 2320 fDataHashtable.remove(commandID); 2321 } 2322 } 2323 } 2324 else if (type.equals("process")) 2325 { 2326 String processName = (String)propertyMap.get("name"); 2327 String location = (String)propertyMap.get("location"); 2328 String handleNumber = (String)propertyMap.get("handle"); 2329 2330 if (status.equals("start")) 2331 { 2332 handleProcess(propertyMap, block, processName, location, 2333 handleNumber, true); 2334 } 2335 else if (status.equals("stop")) 2336 { 2337 String processID = processName + ";" + location + ";" + 2338 handleNumber; 2339 2340 if (fProcIDHashtable.containsKey(processID)) 2341 { 2342 synchronized(fMonitorTreeModel) 2343 { 2344 STAXMonitorTreeNode processNode = 2345 fProcIDHashtable.get(processID); 2346 2347 if (processNode == null) 2348 { 2349 System.out.println("processNode " + 2350 processID + " is null"); 2351 System.out.println(fMonitorTreeModel); 2352 System.exit(99); 2353 } 2354 2355 try 2356 { 2357 fMonitorTreeModel.removeNodeFromParent(processNode); 2358 } 2359 catch(NullPointerException e) 2360 { 2361 e.printStackTrace(); 2362 } 2363 2364 fMonitorTreeProcessNodes.remove( 2365 fProcIDHashtable.get(processID)); 2366 fMonitorTreeProcessStartTimes.remove( 2367 fProcIDHashtable.get(processID)); 2368 fProcIDHashtable.remove(processID); 2369 fDataHashtable.remove(processID); 2370 } 2371 } 2372 else 2373 { 2374 // XXX got a stop before the start? 2375 } 2376 } 2377 else 2378 { 2379 // unknown status property 2380 } 2381 } 2382 else if (type.equals("subjob")) 2383 { 2384 String jobID = (String)propertyMap.get("jobID"); 2385 2386 if (status.equals("start")) 2387 { 2388 handleSubjob(jobID, block, propertyMap); 2389 2390 } else if (status.equals("stop")) 2391 { 2392 if (fSubjobIDHashtable.containsKey(jobID)) 2393 { 2394 fMonitorTreeModel.removeNodeFromParent( 2395 fSubjobIDHashtable.get(jobID)); 2396 fMonitorTreeSubjobNodes.remove( 2397 fSubjobIDHashtable.get(jobID)); 2398 fMonitorTreeSubjobStartTimes.remove( 2399 fSubjobIDHashtable.get(jobID)); 2400 fCmdIDHashtable.remove(jobID); 2401 fDataHashtable.remove(jobID); 2402 } 2403 } 2404 } 2405 else if (type.equals("job")) 2406 { 2407 if (status.equals("end")) 2408 { 2409 fMonitorTreeModel.setRoot(new STAXMonitorTreeNode(null)); 2410 2411 String jobName = fJobName; 2412 2413 if (fJobName == null) jobName = ""; 2414 2415 setTitle(kMonitorFrameTitle + " Machine:" + 2416 fStaxMachine + " JobID:" + fJobNumber + " " + 2417 jobName + " <Completed>"); 2418 2419 fMonitorTree.setVisible(false); 2420 stopMonitor(); 2421 } 2422 } 2423 } 2424 handleCommand(String commandName, String block, String location, String requestNumber, String service, String request)2425 void handleCommand(String commandName, String block, String location, 2426 String requestNumber, String service, String request) 2427 { 2428 final String commandID = 2429 commandName + ";" + location + ";" + requestNumber; 2430 2431 STAXMonitorTreeNode newNode = 2432 new STAXMonitorTreeNode(commandName, 2433 STAXMonitorTreeNode.commandNodeType); 2434 2435 STAXMonitorTreeNode parentNode = fMonitorTreeBlocks.get(block); 2436 2437 if (parentNode == null) 2438 { 2439 // The parentNode can be null if the block has ended 2440 2441 // Asynchronously remove the command from the Active Job Elements 2442 // tree 2443 2444 Runnable runnable = new Runnable() 2445 { 2446 public void run() 2447 { 2448 if (fCmdIDHashtable.containsKey(commandID)) 2449 { 2450 fMonitorTreeModel.removeNodeFromParent( 2451 fCmdIDHashtable.get(commandID)); 2452 fMonitorTreeCommandNodes.remove( 2453 fCmdIDHashtable.get(commandID)); 2454 fMonitorTreeCommandStartTimes.remove( 2455 fCmdIDHashtable.get(commandID)); 2456 fCmdIDHashtable.remove(commandID); 2457 fDataHashtable.remove(commandID); 2458 } 2459 } 2460 }; 2461 2462 SwingUtilities.invokeLater(runnable); 2463 2464 return; 2465 } 2466 2467 fMonitorTreeModel.insertNodeInto(newNode, parentNode, 2468 parentNode.getChildCount()); 2469 TreeNode[] parentNodes = 2470 fMonitorTreeModel.getPathToRoot(parentNode); 2471 fMonitorTree.expandPath(new TreePath(parentNodes)); 2472 fCmdIDHashtable.put(commandID, newNode); 2473 fMonitorTreeCommandNodes.put(newNode, commandID); 2474 2475 Vector<Vector<String>> cmdDataVector = new Vector<Vector<String>>(); 2476 2477 addRow(cmdDataVector, "Location", location); 2478 addRow(cmdDataVector, "Request Number", requestNumber); 2479 addRow(cmdDataVector, "Service", service); 2480 addRow(cmdDataVector, "Request", request); 2481 2482 STAFResult queryResult = fHandle.submit2( 2483 fStaxMachine, fStaxServiceName, 2484 "QUERY JOB " + fJobNumber + " STAFCMD " + requestNumber); 2485 2486 if (queryResult.rc != 0) 2487 { 2488 // Stafcmd has already completed, so asynchronously remove 2489 // it from the Active Job Elements tree 2490 2491 Runnable runnable = new Runnable() 2492 { 2493 public void run() 2494 { 2495 if (fCmdIDHashtable.containsKey(commandID)) 2496 { 2497 fMonitorTreeModel.removeNodeFromParent( 2498 fCmdIDHashtable.get(commandID)); 2499 fMonitorTreeCommandNodes.remove( 2500 fCmdIDHashtable.get(commandID)); 2501 fMonitorTreeCommandStartTimes.remove( 2502 fCmdIDHashtable.get(commandID)); 2503 fCmdIDHashtable.remove(commandID); 2504 fDataHashtable.remove(commandID); 2505 } 2506 } 2507 }; 2508 SwingUtilities.invokeLater(runnable); 2509 2510 return; 2511 } 2512 2513 Map stafcmdMap = (HashMap)queryResult.resultObj; 2514 2515 String startTimestamp = (String)stafcmdMap.get("startTimestamp"); 2516 String startDate = startTimestamp.substring(0, 8); 2517 String startTime = startTimestamp.substring(9); 2518 2519 fMonitorTreeCommandStartTimes.put( 2520 newNode, STAXMonitorUtil.getCalendar2(startDate, startTime)); 2521 2522 addRow(cmdDataVector, "Started", startDate + "-" + startTime); 2523 2524 fDataHashtable.put(commandID, cmdDataVector); 2525 } 2526 handleSubjob(String jobID, String block, Map propertyMap)2527 void handleSubjob(String jobID, String block, Map propertyMap) 2528 { 2529 String jobName = (String)propertyMap.get("jobName"); 2530 String function = (String)propertyMap.get("function"); 2531 String jobFile = (String)propertyMap.get("jobfile"); 2532 String jobFileMachine = (String)propertyMap.get("jobfilemachine"); 2533 String functionArgs = (String)propertyMap.get("functionargs"); 2534 String clearLogs = (String)propertyMap.get("clearlogs"); 2535 String autoMonitor = (String)propertyMap.get("monitor"); 2536 String logTCElapsedTime = (String)propertyMap.get("logtcelapsedtime"); 2537 String logTCNumStarts = (String)propertyMap.get("logtcnumstarts"); 2538 String logTCStartStop = (String)propertyMap.get("logtcstartstop"); 2539 String pythonOutput = (String)propertyMap.get("pythonoutput"); 2540 String pythonLogLevel = (String)propertyMap.get("pythonloglevel"); 2541 String invalidLogLevelAction = (String)propertyMap.get( 2542 "invalidLogLevelAction"); 2543 String scriptFilesMachine = (String)propertyMap.get( 2544 "scriptfilesmachine"); 2545 2546 // holdJob will be null if the sub-job was not specified to be held 2547 // Otherwise, holdJob contains the hold timeout in milliseconds, with 2548 // a hold timeout of 0 indicating to job the job indefinitely 2549 String holdJob = (String)propertyMap.get("hold"); 2550 2551 String startDate = (String)propertyMap.get("startdate"); 2552 String startTime = (String)propertyMap.get("starttime"); 2553 2554 String subjobText = "Job " + jobID; 2555 2556 if (!(jobName.equals(""))) 2557 { 2558 subjobText += " - " + jobName; 2559 } 2560 2561 STAXMonitorTreeNode newNode = 2562 new STAXMonitorTreeNode(subjobText, 2563 STAXMonitorTreeNode.subjobNodeType); 2564 2565 STAXMonitorTreeNode parentNode = fMonitorTreeBlocks.get(block); 2566 2567 fMonitorTreeModel.insertNodeInto(newNode, parentNode, 2568 parentNode.getChildCount()); 2569 TreeNode[] parentNodes = 2570 fMonitorTreeModel.getPathToRoot(parentNode); 2571 2572 fMonitorTree.expandPath(new TreePath(parentNodes)); 2573 2574 fSubjobIDHashtable.put(jobID, newNode); 2575 fMonitorTreeSubjobNodes.put(newNode, jobID); 2576 2577 fMonitorTreeSubjobStartTimes.put( 2578 newNode, STAXMonitorUtil.getCalendar2(startDate, startTime)); 2579 2580 Vector<Vector<String>> subjobDataVector = new Vector<Vector<String>>(); 2581 2582 addRow(subjobDataVector, "Job ID", jobID); 2583 addRow(subjobDataVector, "Job Name", jobName); 2584 addRow(subjobDataVector, "Clear Logs", clearLogs); 2585 addRow(subjobDataVector, "Log TC Elapsed Time", logTCElapsedTime); 2586 addRow(subjobDataVector, "Log TC Num Starts", logTCNumStarts); 2587 addRow(subjobDataVector, "Log TC Start/Stop", logTCStartStop); 2588 addRow(subjobDataVector, "Python Output", pythonOutput); 2589 addRow(subjobDataVector, "Python Log Level", pythonLogLevel); 2590 addRow(subjobDataVector, "Invalid Log Level Action", 2591 invalidLogLevelAction); 2592 addRow(subjobDataVector, "Job File", jobFile); 2593 2594 if (!jobFileMachine.equals("")) 2595 { 2596 addRow(subjobDataVector, "Job File Machine", jobFileMachine); 2597 } 2598 2599 addRow(subjobDataVector, "Function", function); 2600 addRow(subjobDataVector, "Function Args", functionArgs); 2601 2602 if (propertyMap.get("scriptFileList") instanceof java.util.List) 2603 { 2604 java.util.List scriptFileList = (java.util.List)propertyMap.get( 2605 "scriptFileList"); 2606 2607 for (int i = 0; i < scriptFileList.size(); i++) 2608 { 2609 if (i == 0 && !scriptFilesMachine.equals("")) 2610 { 2611 addRow(subjobDataVector, "Script Files Machine", 2612 scriptFilesMachine); 2613 } 2614 2615 addRow(subjobDataVector, "Script File #" + (i + 1), 2616 (String)scriptFileList.get(i)); 2617 } 2618 } 2619 2620 if (propertyMap.get("scriptList") instanceof java.util.List) 2621 { 2622 java.util.List scriptList = (java.util.List)propertyMap.get( 2623 "scriptList"); 2624 2625 for (int i = 0; i < scriptList.size(); i++) 2626 { 2627 addRow(subjobDataVector, "Script #" + (i + 1), 2628 (String)scriptList.get(i)); 2629 } 2630 } 2631 2632 addRow(subjobDataVector, "Started", startDate + "-" + startTime); 2633 addRow(subjobDataVector, "Block", block); 2634 2635 fDataHashtable.put(subjobText, subjobDataVector); 2636 2637 if ((fAutoMonitorSubjobs == STAXMonitorFrame.AUTOMONITOR_ALWAYS) || 2638 (fAutoMonitorSubjobs == STAXMonitorFrame.AUTOMONITOR_RECOMMENDED 2639 && autoMonitor.equals("true"))) 2640 { 2641 fParentMonitor.monitorExistingJob(jobID, -1); 2642 2643 // After starting to monitor the sub-job, if a <job-hold> element 2644 // was specified with an "if" element that evaluated to a true 2645 // value (as indicated by holdJob != null), release the sub-job. 2646 // This ensures that the sub-job is monitored from the beginning 2647 // (e.g. will show all messages sent to the STAX Monitor). 2648 2649 if (holdJob != null) 2650 { 2651 STAFResult result = fHandle.submit2( 2652 fStaxMachine, fStaxServiceName, "RELEASE JOB " + jobID); 2653 2654 if (result.rc != STAFResult.Ok && result.rc != BlockNotHeld && 2655 result.rc != STAFResult.DoesNotExist) 2656 { 2657 STAXMonitorUtil.showErrorDialog( 2658 this, 2659 "An error was encountered while attempting to " + 2660 "release a subjob with JobID=" + jobID + 2661 ", RC: " + result.rc + ", Result: " + result.result); 2662 } 2663 } 2664 } 2665 2666 requestFocus(); 2667 } 2668 handleProcess(Map processMap, String block, String processName, String location, String handleNumber, boolean event)2669 void handleProcess(Map processMap, String block, String processName, 2670 String location, String handleNumber, boolean event) 2671 { 2672 final String processID = 2673 processName + ";" + location + ";" + handleNumber; 2674 2675 STAXMonitorTreeNode newNode = new STAXMonitorTreeNode(processName, 2676 STAXMonitorTreeNode.processNodeType); 2677 2678 synchronized(fMonitorTreeBlocks) 2679 { 2680 STAXMonitorTreeNode parentNode = fMonitorTreeBlocks.get(block); 2681 2682 synchronized(fMonitorTreeModel) 2683 { 2684 fMonitorTreeModel.insertNodeInto(newNode, parentNode, 2685 parentNode.getChildCount()); 2686 TreeNode[] parentNodes = 2687 fMonitorTreeModel.getPathToRoot(parentNode); 2688 2689 fMonitorTree.expandPath(new TreePath(parentNodes)); 2690 } 2691 } 2692 2693 fProcIDHashtable.put(processID, newNode); 2694 fMonitorTreeProcessNodes.put(newNode, processID); 2695 2696 if (event) 2697 { 2698 // Submit a STAX QUERY JOB <JobID> PROCESS <location:handle> 2699 // request to get the start timestamp for the process. 2700 // The start timestamp was not available when the process 2701 // start event was generated. 2702 2703 STAFResult queryResult = fHandle.submit2( 2704 fStaxMachine, fStaxServiceName, 2705 "QUERY JOB " + fJobNumber + " PROCESS " + 2706 location + ":" + handleNumber); 2707 2708 if (queryResult.rc != 0) 2709 { 2710 // Process has already completed, so asynchronously remove 2711 // it from the Active Job Elements tree 2712 2713 Runnable runnable = new Runnable() 2714 { 2715 public void run() 2716 { 2717 if (fProcIDHashtable.containsKey(processID)) 2718 { 2719 fMonitorTreeModel.removeNodeFromParent( 2720 fProcIDHashtable.get(processID)); 2721 fMonitorTreeCommandNodes.remove( 2722 fProcIDHashtable.get(processID)); 2723 fMonitorTreeCommandStartTimes.remove( 2724 fProcIDHashtable.get(processID)); 2725 fProcIDHashtable.remove(processID); 2726 fDataHashtable.remove(processID); 2727 } 2728 } 2729 }; 2730 SwingUtilities.invokeLater(runnable); 2731 2732 return; 2733 } 2734 2735 // Replace the process map with the query process map since 2736 // it contains all of the information about the process 2737 processMap = (HashMap)queryResult.resultObj; 2738 } 2739 2740 String startTimestamp = (String)processMap.get("startTimestamp"); 2741 2742 // startTimestamp format is YYYYMMDD-HH:MM:SS 2743 String startDate = startTimestamp.substring(0, 8); 2744 String startTime = startTimestamp.substring(9); 2745 2746 fMonitorTreeProcessStartTimes.put( 2747 newNode, STAXMonitorUtil.getCalendar2(startDate, startTime)); 2748 2749 Vector<Vector<String>> procDataVector = new Vector<Vector<String>>(); 2750 STAXMonitorUtil.assignProcessInfo(processMap, procDataVector); 2751 2752 fDataHashtable.put(processID, procDataVector); 2753 } 2754 handleBlock(String block, String status)2755 Vector<STAXMonitorTreeNode> handleBlock(String block, String status) 2756 { 2757 Vector<STAXMonitorTreeNode> heldBlocks = 2758 new Vector<STAXMonitorTreeNode>(); 2759 2760 if (block.indexOf(".") == -1) 2761 { 2762 // will occur only for main block 2763 if (!fMonitorTreeBlocks.containsKey(block)) 2764 { 2765 // starting main 2766 STAXMonitorTreeNode newNode = new STAXMonitorTreeNode( 2767 block, STAXMonitorTreeNode.blockNodeType); 2768 2769 if (status.startsWith("Held")) 2770 { 2771 heldBlocks.add(newNode); 2772 } 2773 2774 fMonitorTreeBlocks.put(block, newNode); 2775 fMonitorTreeBlockNodes.put(newNode, block); 2776 2777 fMonitorTreeModel.setRoot(newNode); 2778 } 2779 } 2780 else 2781 { 2782 String firstBlock = block.substring(0, block.indexOf(".")); 2783 2784 if (!fMonitorTreeBlocks.containsKey(firstBlock)) 2785 { 2786 // this can occur if we are starting to monitor 2787 // after the jobs has already started. need to 2788 // seed the hashmap with the first block (main) 2789 2790 STAXMonitorTreeNode newNode = new 2791 STAXMonitorTreeNode(firstBlock, 2792 STAXMonitorTreeNode.blockNodeType); 2793 2794 fMonitorTreeBlocks.put(firstBlock, newNode); 2795 fMonitorTreeBlockNodes.put(newNode, firstBlock); 2796 2797 fMonitorTreeModel.insertNodeInto(newNode, 2798 (STAXMonitorTreeNode)fMonitorTreeModel.getRoot(), 0); 2799 2800 fMonitorTree.expandPath(new TreePath( 2801 (STAXMonitorTreeNode)fMonitorTreeModel.getRoot())); 2802 } 2803 2804 String blockSection; 2805 int lastIndex = 0; 2806 lastIndex = block.indexOf("."); 2807 boolean lastBlock = false; 2808 2809 // we've already processed the first segment, main 2810 do 2811 { 2812 int nextIndex = block.indexOf(".", lastIndex + 1); 2813 2814 if (nextIndex == -1) 2815 { 2816 // this means we've reach the final block segment 2817 blockSection = block; 2818 lastBlock = true; 2819 } 2820 else 2821 { 2822 blockSection = block.substring(0, nextIndex); 2823 } 2824 2825 if (!fMonitorTreeBlocks.containsKey(blockSection)) 2826 { 2827 String lastBlockSection = blockSection.substring( 2828 blockSection.lastIndexOf(".")+1); 2829 2830 STAXMonitorTreeNode newNode = new STAXMonitorTreeNode( 2831 lastBlockSection, STAXMonitorTreeNode.blockNodeType); 2832 2833 if (lastBlock && status.startsWith("Held")) 2834 { 2835 heldBlocks.add(newNode); 2836 } 2837 2838 STAXMonitorTreeNode parentNode = fMonitorTreeBlocks.get( 2839 blockSection.substring( 2840 0, blockSection.lastIndexOf("."))); 2841 2842 fMonitorTreeModel.insertNodeInto( 2843 newNode, parentNode, parentNode.getChildCount()); 2844 fMonitorTreeBlocks.put(blockSection, newNode); 2845 fMonitorTreeBlockNodes.put(newNode, blockSection); 2846 2847 TreeNode[] parentNodes = fMonitorTreeModel.getPathToRoot( 2848 parentNode); 2849 2850 fMonitorTree.expandPath(new TreePath(parentNodes)); 2851 } 2852 lastIndex = nextIndex; 2853 } 2854 while (!blockSection.equals(block)); 2855 } 2856 2857 return heldBlocks; 2858 } 2859 2860 handleJobMessage(Map propertyMap)2861 void handleJobMessage(Map propertyMap) 2862 { 2863 String message = (String)propertyMap.get("messagetext"); 2864 2865 int timestampIndex = message.indexOf(" "); 2866 2867 Object rowData[] = new Object[2]; 2868 rowData[0] = message.substring(0, timestampIndex); 2869 2870 if (fMessageTableModel.getRowCount() == 2871 (new Integer(fLimitMessages)).intValue()) 2872 { 2873 fMessageTableModel.removeRow(0); 2874 } 2875 2876 if (fMessageTableModel.getRowCount() == 0) 2877 { 2878 int firstMsgLen = (message.substring(timestampIndex + 1)).length(); 2879 2880 StringBuffer padding = new StringBuffer(); 2881 2882 for (int i = 0; i < 200 - firstMsgLen; i++) 2883 { 2884 padding.append(" "); 2885 } 2886 2887 rowData[1] = message.substring(timestampIndex + 1) + 2888 padding.toString(); 2889 } 2890 else 2891 { 2892 rowData[1] = message.substring(timestampIndex + 1); 2893 } 2894 2895 fMessageTableModel.addRow(rowData); 2896 2897 STAXMonitorUtil.updateRowHeights(fMessageTable, 1, fMessageFontName); 2898 STAXMonitorUtil.sizeColumnsToFitText(fMessageTable); 2899 2900 Rectangle rect = fMessageTable.getVisibleRect(); 2901 Point point = rect.getLocation(); 2902 point.setLocation(rect.getX() + rect.getWidth(), 2903 rect.getY() + rect.getHeight()); 2904 int lastRow = fMessageTable.rowAtPoint(point); 2905 2906 if (lastRow > (fMessageTableModel.getRowCount() - 5)) 2907 { 2908 fMessageTable.scrollRectToVisible(new 2909 Rectangle(0,fMessageTable.getPreferredSize().height,0,0)); 2910 2911 fMessageTable.scrollRectToVisible(new 2912 Rectangle(0,fMessageTable.getPreferredSize().height,0,0)); 2913 } 2914 } 2915 addActiveJobElementsNode(String type, String id, String block, ImageIcon image, JComponent component, Vector detailsData)2916 public void addActiveJobElementsNode(String type, String id, String block, 2917 ImageIcon image, JComponent component, Vector detailsData) 2918 { 2919 // pass the ID as the NodeText 2920 addActiveJobElementsNode(type, id, block, id, image, component, 2921 detailsData); 2922 } 2923 addActiveJobElementsNode(String type, String id, String block, String nodeText, ImageIcon image, JComponent component, Vector detailsData)2924 public void addActiveJobElementsNode(String type, String id, String block, 2925 String nodeText, ImageIcon image, JComponent component, 2926 Vector detailsData) 2927 { 2928 STAXMonitorTreeNode newNode = 2929 new STAXMonitorTreeNode(nodeText, type, image, component); 2930 2931 STAXMonitorTreeNode parentNode = fMonitorTreeBlocks.get(block); 2932 fMonitorTreeModel.insertNodeInto( 2933 newNode, parentNode, parentNode.getChildCount()); 2934 TreeNode[] parentNodes = fMonitorTreeModel.getPathToRoot(parentNode); 2935 2936 fMonitorTree.expandPath(new TreePath(parentNodes)); 2937 2938 fPluginNodeHashtable.put(id, newNode); 2939 fPluginNodeToIDHashtable.put(newNode, id); 2940 fPluginNodeToNodeTextHashtable.put(newNode, nodeText); 2941 fPluginNodeDetailsHashtable.put(newNode, detailsData); 2942 } 2943 removeActiveJobElementsNode(String id, String block)2944 public void removeActiveJobElementsNode(String id, String block) 2945 { 2946 STAXMonitorTreeNode nodeToRemove = fPluginNodeHashtable.get(id); 2947 2948 fMonitorTreeModel.removeNodeFromParent(nodeToRemove); 2949 fPluginNodeHashtable.remove(id); 2950 fPluginNodeToIDHashtable.remove(nodeToRemove); 2951 fPluginNodeToNodeTextHashtable.remove(nodeToRemove); 2952 fPluginNodeDetailsHashtable.remove(nodeToRemove); 2953 } 2954 setActiveJobElementsNodeText(String id, String text)2955 public void setActiveJobElementsNodeText(String id, String text) 2956 { 2957 STAXMonitorTreeNode node = fPluginNodeHashtable.get(id); 2958 node.setPluginText(text); 2959 2960 fMonitorTree.updateUI(); 2961 2962 if (fCurrentSelectedNode != null) 2963 { 2964 synchronized(fMonitorTree) 2965 { 2966 fMonitorTree.setSelectionPath( 2967 new TreePath(fCurrentSelectedNode.getPath())); 2968 } 2969 } 2970 } 2971 keyPressed(KeyEvent e)2972 public void keyPressed(KeyEvent e) 2973 { 2974 } 2975 keyReleased(KeyEvent e)2976 public void keyReleased(KeyEvent e) {} keyTyped(KeyEvent e)2977 public void keyTyped(KeyEvent e) {} 2978 mouseClicked(MouseEvent e)2979 public void mouseClicked(MouseEvent e) {} mouseEntered(MouseEvent e)2980 public void mouseEntered(MouseEvent e) {} mouseExited(MouseEvent e)2981 public void mouseExited(MouseEvent e) {} 2982 mousePressed(MouseEvent e)2983 public void mousePressed(MouseEvent e) 2984 { 2985 displayPopup(e); 2986 } 2987 mouseReleased(MouseEvent e)2988 public void mouseReleased(MouseEvent e) 2989 { 2990 displayPopup(e); 2991 } 2992 displayPopup(MouseEvent e)2993 public void displayPopup(MouseEvent e) 2994 { 2995 if (e.isPopupTrigger()) 2996 { 2997 TreePath treePath = 2998 fMonitorTree.getPathForLocation(e.getX(), e.getY()); 2999 3000 if(treePath != null) 3001 { 3002 STAXMonitorTreeNode treeNode = 3003 (STAXMonitorTreeNode)treePath.getLastPathComponent(); 3004 3005 if (treeNode.fNodeType == STAXMonitorTreeNode.blockNodeType) 3006 { 3007 if (treeNode.fBlockStatus == 3008 STAXMonitorTreeNode.blockRunning) 3009 { 3010 fBlockHoldMenuItem.setEnabled(true); 3011 fBlockReleaseMenuItem.setEnabled(false); 3012 fBlockTerminateMenuItem.setEnabled(true); 3013 } 3014 else if (treeNode.fBlockStatus == 3015 STAXMonitorTreeNode.blockHeld) 3016 { 3017 fBlockHoldMenuItem.setEnabled(false); 3018 fBlockReleaseMenuItem.setEnabled(true); 3019 fBlockTerminateMenuItem.setEnabled(true); 3020 } 3021 else if (treeNode.fBlockStatus == 3022 STAXMonitorTreeNode.blockParentHeld) 3023 { 3024 fBlockHoldMenuItem.setEnabled(false); 3025 fBlockReleaseMenuItem.setEnabled(false); 3026 fBlockTerminateMenuItem.setEnabled(true); 3027 } 3028 3029 fMonitorTree.setSelectionPath(treePath); 3030 fBlockPopupMenu.show( 3031 e.getComponent(), e.getX(), e.getY()); 3032 } 3033 else if (treeNode.fNodeType == 3034 STAXMonitorTreeNode.subjobNodeType) 3035 { 3036 fMonitorTree.setSelectionPath(treePath); 3037 fSubjobPopupMenu.show( 3038 e.getComponent(), e.getX(), e.getY()); 3039 } 3040 else if (treeNode.fNodeType == 3041 STAXMonitorTreeNode.processNodeType) 3042 { 3043 fProcessStopMenuItem.setEnabled(true); 3044 3045 fMonitorTree.setSelectionPath(treePath); 3046 fProcessPopupMenu.show( 3047 e.getComponent(), e.getX(), e.getY()); 3048 } 3049 } 3050 } 3051 } 3052 valueChanged(TreeSelectionEvent e)3053 public void valueChanged(TreeSelectionEvent e) 3054 { 3055 TreePath selectedPath = e.getPath(); 3056 3057 if ((e.getNewLeadSelectionPath() != null) && 3058 (e.getNewLeadSelectionPath().getPath() != null) && 3059 (e.getNewLeadSelectionPath().getPath()[0] != null)) 3060 { 3061 String pathRoot = 3062 e.getNewLeadSelectionPath().getPath()[0].toString(); 3063 3064 if ((e.getNewLeadSelectionPath().getPath().length == 1) && 3065 (pathRoot != null)) 3066 { 3067 3068 if (!(pathRoot.equals("main"))) 3069 3070 { 3071 // selection has been removed 3072 fCurrentSelection.setText(""); 3073 // next line is required due to Sun BugIDs 4398286, 4402032 3074 fDetailsTable.setRowHeight(30); 3075 fDetailsTableModel = 3076 new STAXMonitorTableModel(fDataColumns, 0); 3077 fDetailsModelSorter.setModel(fDetailsTableModel); 3078 3079 updateDetailsTableRenderers(); 3080 STAXMonitorUtil.sizeColumnsToFitText(fDetailsTable); 3081 fDetailsTable.setVisible(false); 3082 fDetailsTable.getTableHeader().setVisible(false); 3083 3084 fBlockPopupMenu.setVisible(false); 3085 } 3086 } 3087 } 3088 3089 if (fCurrentSelectedNode == 3090 (STAXMonitorTreeNode)selectedPath.getLastPathComponent()) 3091 { 3092 return; 3093 } 3094 3095 fCurrentSelectedNode = 3096 (STAXMonitorTreeNode)selectedPath.getLastPathComponent(); 3097 String id = fCurrentSelectedNode.toString(); 3098 3099 if (fCurrentSelectedNode == null) 3100 { 3101 return; 3102 } 3103 3104 if (e.isAddedPath()) 3105 { 3106 fCurrentSelection.setText(id); 3107 fDetailsTable.setVisible(true); 3108 fDetailsTable.getTableHeader().setVisible(true); 3109 3110 if (fMonitorTreeProcessNodes.containsKey(fCurrentSelectedNode)) 3111 { 3112 id = fMonitorTreeProcessNodes.get(fCurrentSelectedNode); 3113 } 3114 3115 if (fMonitorTreeCommandNodes.containsKey(fCurrentSelectedNode)) 3116 { 3117 id = fMonitorTreeCommandNodes.get(fCurrentSelectedNode); 3118 } 3119 3120 if (id == null) 3121 { 3122 return; 3123 } 3124 3125 if (fDataHashtable.containsKey(id)) 3126 { 3127 int idIndex = id.indexOf(";"); 3128 3129 if (idIndex != -1) 3130 { 3131 updateCurrentSelection(id.substring(0, idIndex), 3132 (Vector)fDataHashtable.get(id)); 3133 } 3134 else 3135 { 3136 updateCurrentSelection(id, fDataHashtable.get(id)); 3137 } 3138 } 3139 else if (fPluginNodeDetailsHashtable.containsKey( 3140 fCurrentSelectedNode)) 3141 { 3142 String pluginNodeText = fPluginNodeToNodeTextHashtable.get( 3143 fCurrentSelectedNode); 3144 updateCurrentSelection( 3145 pluginNodeText, 3146 fPluginNodeDetailsHashtable.get(fCurrentSelectedNode)); 3147 } 3148 else 3149 { 3150 // next line is required due to Sun BugIDs 4398286, 4402032 3151 fDetailsTable.setRowHeight(30); 3152 fDetailsTableModel = new STAXMonitorTableModel( 3153 fDataColumns, 0); 3154 fDetailsModelSorter.setModel(fDetailsTableModel); 3155 3156 updateDetailsTableRenderers(); 3157 STAXMonitorUtil.sizeColumnsToFitText(fDetailsTable); 3158 fDetailsTable.setVisible(false); 3159 fDetailsTable.getTableHeader().setVisible(false); 3160 } 3161 3162 previousTreePath = selectedPath; 3163 } 3164 } 3165 updateCurrentSelection(String title, Vector tableData)3166 public void updateCurrentSelection(String title, Vector tableData) 3167 { 3168 if (fViewableComponents.get("Current Selection") == null) 3169 { 3170 return; 3171 } 3172 3173 if (fInfoPane.getTabCount() > 0) 3174 { 3175 fInfoPane.setSelectedIndex(fInfoPane. 3176 indexOfTab("Current Selection")); 3177 } 3178 3179 fCurrentSelection.setText(title); 3180 3181 // next line is required due to Sun BugIDs 4398286, 4402032 3182 fDetailsTable.setRowHeight(30); 3183 fDetailsTableModel = new STAXMonitorTableModel( 3184 tableData, fDataColumns); 3185 fDetailsModelSorter.setModel(fDetailsTableModel); 3186 updateDetailsTableRenderers(); 3187 STAXMonitorUtil.updateRowHeights(fDetailsTable, 1); 3188 STAXMonitorUtil.sizeColumnsToFitText(fDetailsTable); 3189 fDetailsTable.setVisible(true); 3190 fDetailsTable.getTableHeader().setVisible(true); 3191 } 3192 updateDetailsTableRenderers()3193 public void updateDetailsTableRenderers() 3194 { 3195 fDetailsTable.getColumnModel().getColumn(0).setCellRenderer( 3196 new STAXMonitorTableCellRenderer(Color.black)); 3197 3198 fDetailsTable.getColumnModel().getColumn(0). 3199 setHeaderRenderer(new STAXMonitorTableCellRenderer(Color.black, 3200 true, new Font("Dialog", Font.BOLD, 12))); 3201 3202 fDetailsTable.getColumnModel().getColumn(1).setCellRenderer( 3203 new STAXMonitorTableCellRenderer(Color.black)); 3204 3205 fDetailsTable.getColumnModel().getColumn(1). 3206 setHeaderRenderer(new STAXMonitorTableCellRenderer(Color.black, 3207 true, new Font("Dialog", Font.BOLD, 12))); 3208 } 3209 getJobNumber()3210 public String getJobNumber() 3211 { 3212 return fJobNumber; 3213 } 3214 getSTAXMachineNickname()3215 public String getSTAXMachineNickname() 3216 { 3217 return fStaxMachineNickname; 3218 } 3219 addRow(Vector<Vector<String>> vector, String name, String value)3220 public void addRow(Vector<Vector<String>> vector, 3221 String name, String value) 3222 { 3223 Vector<String> newRow = new Vector<String>(2); 3224 newRow.add(name); 3225 newRow.add(value); 3226 vector.add(newRow); 3227 } 3228 addRecentLog(String queryRequest, String tooltip)3229 public void addRecentLog(String queryRequest, String tooltip) 3230 { 3231 fParentMonitor.addRecentLog(queryRequest, tooltip); 3232 } 3233 run()3234 public void run() 3235 { 3236 STAFResult getResult; 3237 boolean continueRunning = true; 3238 3239 while (continueRunning) 3240 { 3241 // Use the ALL option to improve performance by getting multiple 3242 // messages, if available, off the queue at once 3243 3244 getResult = fHandle.submit2("local", "QUEUE", "GET ALL WAIT"); 3245 3246 if (getResult.rc != STAFResult.Ok) 3247 { 3248 // It is possible to receive a HandleDoesNotExist if 3249 // the MonitorFrame is being closed 3250 3251 continueRunning = false; 3252 break; // Can't process any more messages 3253 } 3254 3255 java.util.List queueList = (java.util.List)getResult.resultObj; 3256 3257 // Iterate through the messages got off our handle's queue 3258 3259 Iterator queueIter = queueList.iterator(); 3260 3261 while (queueIter.hasNext()) 3262 { 3263 Map queueMap = (Map)queueIter.next(); 3264 String queueType = (String)queueMap.get("type"); 3265 3266 if (queueType == null) 3267 continue; // Ignore message 3268 3269 if (queueType.equalsIgnoreCase("STAF/STAXMonitor/End")) 3270 { 3271 continueRunning = false; 3272 break; // Don't process any more messages on the queue 3273 } 3274 else if (!queueType.equalsIgnoreCase("STAF/Service/Event")) 3275 { 3276 continue; // Ignore messages that don't have this type 3277 } 3278 3279 // Process only STAF/Service/Event messages whose event type 3280 // matches the STAX service name and machine for which the 3281 // STAX Monitor is configured 3282 3283 Map messageMap = (Map)queueMap.get("message"); 3284 String type = (String)messageMap.get("type"); 3285 3286 if (!type.equalsIgnoreCase(fStaxServiceName + "/" + 3287 fStaxConfigMachine + "/" + fJobNumber)) 3288 { 3289 continue; // Ignore messages that don't have this type 3290 } 3291 3292 // Process STAF/Service/Event messages with matching event type 3293 3294 String eventID = (String)messageMap.get("eventID"); 3295 3296 STAFResult ackResult = fHandle.submit2( 3297 STAFHandle.ReqFireAndForget, fEventMachine, 3298 fEventServiceName, "ACKNOWLEDGE EVENTID " + eventID); 3299 3300 String subtype = (String)messageMap.get("subtype"); 3301 3302 final Map propertyMap = (Map)messageMap.get("propertyMap"); 3303 3304 if (subtype.equals("Message")) 3305 { 3306 Runnable runnable = new Runnable() 3307 { 3308 public void run() 3309 { 3310 handleJobMessage(propertyMap); 3311 } 3312 }; 3313 3314 try 3315 { 3316 SwingUtilities.invokeAndWait(runnable); 3317 } 3318 catch (InterruptedException e) 3319 { 3320 } 3321 catch (InvocationTargetException e) 3322 { 3323 } 3324 } 3325 else if (subtype.equals("Job") || 3326 subtype.equals("Block") || 3327 subtype.equals("Process") || 3328 subtype.equals("STAFCommand") || 3329 subtype.equals("SubJob") || 3330 subtype.equals("breakpoint")) 3331 { 3332 Runnable runnable = new Runnable() 3333 { 3334 public void run() 3335 { 3336 handleJobEvent(propertyMap); 3337 } 3338 }; 3339 3340 try 3341 { 3342 SwingUtilities.invokeAndWait(runnable); 3343 } 3344 catch (InterruptedException e) 3345 { 3346 } 3347 catch (InvocationTargetException e) 3348 { 3349 } 3350 } 3351 3352 // Process the extensions 3353 3354 Enumeration<STAXMonitorExtension> plugins = 3355 fRegisteredPlugins.keys(); 3356 3357 while (plugins.hasMoreElements()) 3358 { 3359 final STAXMonitorExtension plugin = plugins.nextElement(); 3360 3361 Vector<String> pluginRegisteredTypes = 3362 fRegisteredPlugins.get(plugin); 3363 3364 if (pluginRegisteredTypes.contains(subtype.toLowerCase())) 3365 { 3366 Runnable runnable = new Runnable() 3367 { 3368 public void run() 3369 { 3370 plugin.handleEvent(propertyMap); 3371 } 3372 }; 3373 3374 try 3375 { 3376 SwingUtilities.invokeAndWait(runnable); 3377 } 3378 catch (InterruptedException e) 3379 { 3380 } 3381 catch (InvocationTargetException e) 3382 { 3383 e.printStackTrace(); 3384 } 3385 } 3386 } // end while iterating through plugins 3387 } // end while iterating through the queue list 3388 } // end while continueRunning 3389 } 3390 startMonitor()3391 void startMonitor() 3392 { 3393 if (fStaxMachine.equals("") || fJobNumber.equals("")) 3394 { 3395 JOptionPane.showMessageDialog( 3396 this, "You must specify both a STAX Machine" + 3397 " and a Job Number", 3398 "Error starting Job Monitor", JOptionPane.ERROR_MESSAGE); 3399 } 3400 else 3401 { 3402 StringBuffer externalSubTypes = new StringBuffer(); 3403 3404 for (int i = 0; i < fExternalPluginNotificationTypes.size(); i++) 3405 { 3406 externalSubTypes.append("SUBTYPE ").append( 3407 fExternalPluginNotificationTypes.elementAt(i)).append(" "); 3408 } 3409 3410 String request = "REGISTER TYPE " + STAFUtil.wrapData( 3411 fStaxServiceName.toUpperCase() + "/" + fStaxConfigMachine + 3412 "/" + fJobNumber) + 3413 " SUBTYPE Job SUBTYPE Block SUBTYPE Process" + 3414 " SUBTYPE STAFCommand SUBTYPE Message" + 3415 " SUBTYPE Testcase SUBTYPE TestCaseStatus" + 3416 " SUBTYPE subjob SUBTYPE breakpoint" + 3417 " SUBTYPE breakpointtrigger SUBTYPE thread " + 3418 externalSubTypes.toString() + 3419 " MAXATTEMPTS 1 ACKNOWLEDGETIMEOUT 1000 BYHANDLE"; 3420 3421 STAFResult registerResult = fHandle.submit2( 3422 fEventMachine, fEventServiceName, request); 3423 3424 if (registerResult.rc != 0) 3425 { 3426 STAXMonitorUtil.showErrorDialog( 3427 this, "Could not register for Job events\n\n" + 3428 "STAF " + fEventMachine + " " + fEventServiceName + 3429 " " + request + "\n\nRC: " + registerResult.rc + 3430 ", Result: " + registerResult.result, 3431 "Error Registering for Job Events"); 3432 } 3433 else 3434 { 3435 String jobName = fJobName; 3436 3437 if (fJobName == null) jobName = ""; 3438 3439 setTitle(kMonitorFrameTitle + " Machine:" + 3440 fStaxMachine + " JobID:" + fJobNumber + " " + 3441 jobName); 3442 } 3443 } 3444 } 3445 stopMonitor()3446 void stopMonitor() 3447 { 3448 fMonitorStopped = true; 3449 3450 StringBuffer externalSubTypes = new StringBuffer(); 3451 3452 for (int i = 0; i < fExternalPluginNotificationTypes.size(); i++) 3453 { 3454 externalSubTypes.append("SUBTYPE ").append( 3455 fExternalPluginNotificationTypes.elementAt(i)).append(" "); 3456 } 3457 3458 String request = "UNREGISTER TYPE " + STAFUtil.wrapData( 3459 fStaxServiceName.toUpperCase() + "/" + fStaxConfigMachine + 3460 "/" + fJobNumber) + 3461 " SUBTYPE Job SUBTYPE Block SUBTYPE Process" + 3462 " SUBTYPE STAFCommand SUBTYPE Testcase" + 3463 " SUBTYPE TestcaseStatus SUBTYPE Message SUBTYPE subjob" + 3464 " SUBTYPE breakpoint SUBTYPE breakpointtrigger" + 3465 " SUBTYPE thread " + externalSubTypes.toString(); 3466 3467 STAFResult unRegisterResult = fHandle.submit2( 3468 fEventMachine, fEventServiceName, request); 3469 3470 if (unRegisterResult.rc != 0 && 3471 unRegisterResult.rc != STAFResult.HandleDoesNotExist) 3472 { 3473 STAXMonitorUtil.showErrorDialog( 3474 this, "Could not unregister for Job events\n\n" + 3475 "STAF " + fEventMachine + " " + fEventServiceName + 3476 " " + request + "\n\nRC: " + unRegisterResult.rc + 3477 ", Result: " + unRegisterResult.result, 3478 "Error Unregistering for Job Events"); 3479 } 3480 3481 fHandle.submit2( 3482 "local", "QUEUE", "QUEUE TYPE STAF/STAXMonitor/End MESSAGE " + 3483 STAFUtil.wrapData("")); 3484 } 3485 closeMonitor()3486 void closeMonitor() 3487 { 3488 if (fParentMonitor != null) 3489 { 3490 fParentMonitor.monitorExiting(fJobNumber); 3491 } 3492 fContinueProcessMonitor = false; 3493 fContinueElapsedTime = false; 3494 3495 STAXMonitorUtil.freeHandle(fHandle.getHandle()); 3496 3497 Enumeration<STAXMonitorExtension> plugins = fRegisteredPlugins.keys(); 3498 3499 while (plugins.hasMoreElements()) 3500 { 3501 plugins.nextElement().term(); 3502 } 3503 3504 this.dispose(); 3505 } 3506 getProcessMonitorInterval()3507 public int getProcessMonitorInterval() 3508 { 3509 return fParentMonitor.getProcessMonitorInterval(); 3510 } 3511 getElapsedTimeInterval()3512 public int getElapsedTimeInterval() 3513 { 3514 return fParentMonitor.getElapsedTimeInterval(); 3515 } 3516 3517 class STAFProcessMonitor extends Thread 3518 { run()3519 public void run() 3520 { 3521 final int frequency = getProcessMonitorInterval(); 3522 3523 if (frequency == 0) 3524 return; 3525 3526 while (fContinueProcessMonitor) 3527 { 3528 int waitTime = frequency; 3529 3530 final Enumeration<STAXMonitorTreeNode> processNodeKeys = 3531 fMonitorTreeProcessNodes.keys(); 3532 3533 int numProcesses = fMonitorTreeProcessNodes.size(); 3534 3535 while (fContinueProcessMonitor && 3536 processNodeKeys.hasMoreElements()) 3537 { 3538 STAXMonitorTreeNode processNode = null; 3539 String processID = null; 3540 3541 if (processNodeKeys.hasMoreElements()) 3542 { 3543 processNode = processNodeKeys.nextElement(); 3544 } 3545 3546 if (processNode != null) 3547 { 3548 processID = fMonitorTreeProcessNodes.get(processNode); 3549 } 3550 3551 if (processID != null) 3552 { 3553 int handleIndex = processID.lastIndexOf(";"); 3554 String handle = processID.substring(handleIndex + 1); 3555 processID = processID.substring(0, handleIndex); 3556 3557 int locationIndex = processID.lastIndexOf(";"); 3558 String location = processID.substring( 3559 locationIndex + 1); 3560 3561 String processName = processID.substring( 3562 0, locationIndex); 3563 3564 String message = STAXMonitorUtil. 3565 getMonitorMessage(location, handle); 3566 3567 final String processMessage = message; 3568 final STAXMonitorTreeNode processNode1 = processNode; 3569 3570 Runnable runnable = new Runnable() 3571 { 3572 public void run() 3573 { 3574 processNode1.setProcessMonitorText(processMessage); 3575 fMonitorTreeModel.nodeChanged(processNode1); 3576 3577 if (fCurrentSelectedNode != null) 3578 { 3579 synchronized(fMonitorTree) 3580 { 3581 fMonitorTree.setSelectionPath( 3582 new TreePath(fCurrentSelectedNode. 3583 getPath())); 3584 } 3585 } 3586 } 3587 }; 3588 SwingUtilities.invokeLater(runnable); 3589 } 3590 } 3591 3592 waitTime = frequency; 3593 try 3594 { 3595 Thread.sleep(waitTime); 3596 } 3597 catch (InterruptedException ex) 3598 { 3599 } 3600 } 3601 } 3602 } 3603 3604 class MonitorElapsedTime extends Thread 3605 { run()3606 public void run() 3607 { 3608 final int waitTime = getElapsedTimeInterval(); 3609 3610 if (waitTime == 0) 3611 return; 3612 3613 while (fContinueElapsedTime) 3614 { 3615 // handle Processes 3616 final Enumeration<STAXMonitorTreeNode> processElapsedTimeKeys = 3617 fMonitorTreeProcessStartTimes.keys(); 3618 3619 Runnable processRunnable = new Runnable() 3620 { 3621 public void run() 3622 { 3623 while (fContinueElapsedTime && 3624 processElapsedTimeKeys.hasMoreElements()) 3625 { 3626 STAXMonitorTreeNode processNode = 3627 processElapsedTimeKeys.nextElement(); 3628 3629 Calendar processStarted = 3630 fMonitorTreeProcessStartTimes.get(processNode); 3631 3632 processNode.setElapsedTime( 3633 STAXMonitorUtil.getElapsedTime(processStarted)); 3634 3635 fMonitorTreeModel.nodeChanged(processNode); 3636 } 3637 3638 if (fCurrentSelectedNode != null) 3639 { 3640 synchronized(fMonitorTree) 3641 { 3642 fMonitorTree.setSelectionPath(new 3643 TreePath(fCurrentSelectedNode. 3644 getPath())); 3645 } 3646 } 3647 } 3648 }; 3649 3650 try 3651 { 3652 SwingUtilities.invokeAndWait(processRunnable); 3653 } 3654 catch (InterruptedException ex) 3655 { 3656 ex.printStackTrace(); 3657 } 3658 catch (InvocationTargetException ex) 3659 { 3660 ex.printStackTrace(); 3661 } 3662 3663 // handle Commands 3664 final Enumeration<STAXMonitorTreeNode> commandElapsedTimeKeys = 3665 fMonitorTreeCommandStartTimes.keys(); 3666 3667 Runnable commandRunnable = new Runnable() 3668 { 3669 public void run() 3670 { 3671 while (fContinueElapsedTime && 3672 commandElapsedTimeKeys.hasMoreElements()) 3673 { 3674 STAXMonitorTreeNode commandNode = 3675 commandElapsedTimeKeys.nextElement(); 3676 Calendar commandStarted = 3677 fMonitorTreeCommandStartTimes.get(commandNode); 3678 3679 commandNode.setElapsedTime( 3680 STAXMonitorUtil.getElapsedTime(commandStarted)); 3681 3682 fMonitorTreeModel.nodeChanged(commandNode); 3683 } 3684 3685 if (fCurrentSelectedNode != null) 3686 { 3687 synchronized(fMonitorTree) 3688 { 3689 fMonitorTree.setSelectionPath( 3690 new TreePath( 3691 fCurrentSelectedNode.getPath())); 3692 } 3693 } 3694 } 3695 }; 3696 3697 try 3698 { 3699 SwingUtilities.invokeAndWait(commandRunnable); 3700 } 3701 catch (InterruptedException ex) 3702 { 3703 ex.printStackTrace(); 3704 } 3705 catch (InvocationTargetException ex) 3706 { 3707 ex.printStackTrace(); 3708 } 3709 3710 // handle Subjobs 3711 final Enumeration<STAXMonitorTreeNode> subjobElapsedTimeKeys = 3712 fMonitorTreeSubjobStartTimes.keys(); 3713 3714 Runnable subjobRunnable = new Runnable() 3715 { 3716 public void run() 3717 { 3718 while (fContinueElapsedTime && 3719 subjobElapsedTimeKeys.hasMoreElements()) 3720 { 3721 STAXMonitorTreeNode subjobNode = 3722 subjobElapsedTimeKeys.nextElement(); 3723 Calendar subjobStarted = 3724 fMonitorTreeSubjobStartTimes.get(subjobNode); 3725 3726 subjobNode.setElapsedTime( 3727 STAXMonitorUtil.getElapsedTime(subjobStarted)); 3728 3729 fMonitorTreeModel.nodeChanged(subjobNode); 3730 } 3731 3732 if (fCurrentSelectedNode != null) 3733 { 3734 synchronized(fMonitorTree) 3735 { 3736 fMonitorTree.setSelectionPath( 3737 new TreePath( 3738 fCurrentSelectedNode.getPath())); 3739 } 3740 } 3741 } 3742 }; 3743 3744 try 3745 { 3746 SwingUtilities.invokeAndWait(subjobRunnable); 3747 } 3748 catch (InterruptedException ex) 3749 { 3750 ex.printStackTrace(); 3751 } 3752 catch (InvocationTargetException ex) 3753 { 3754 ex.printStackTrace(); 3755 } 3756 3757 try 3758 { 3759 Thread.sleep(waitTime); 3760 } 3761 catch (InterruptedException ex) 3762 { 3763 } 3764 } 3765 } 3766 } 3767 }