📄 staxmonitorprocessextension.java
字号:
getValueAt(selectedRow, 0), (Vector)fProcessHashtable.get(processID)); } } public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void handleEvent(Map map) { String block = (String)map.get("block"); String processName = (String)map.get("name"); String location = (String)map.get("location"); String machineHandleText = location + ":"; String handleNumber = (String)map.get("handle"); machineHandleText += handleNumber; String processID = location + ":" + handleNumber; String command = (String)map.get("command"); String status = (String)map.get("status"); if (status.equals("start")) { String parms = (String)map.get("parms"); Object rowData[] = new Object[6]; rowData[0] = processName; rowData[1] = " "; rowData[2] = " "; rowData[3] = block; rowData[4] = machineHandleText; rowData[5] = command; fProcessTableModel.addRow(rowData); STAXMonitorUtil.updateRowHeights(fProcessTable, 1); STAXMonitorUtil.sizeColumnsToFitText(fProcessTable); // Get process start timestamp because it's not provided in // the event property map. STAFResult queryResult = fHandle.submit2( fStaxMachine, fStaxServiceName, "QUERY JOB " + fJobNumber + " PROCESS " + location + ":" + handleNumber); if (queryResult.rc != 0) { // Ignore since process may have already completed return; } STAFMarshallingContext mc = STAFMarshallingContext.unmarshall(queryResult.result); Map processMap = (HashMap)mc.getRootObject(); String startTimestamp = (String)processMap.get("startTimestamp"); // startTimestamp format is YYYYMMDD-HH:MM:SS String startDate = startTimestamp.substring(0, 8); String startTime = startTimestamp.substring(9); synchronized(fProcessStartTimes) { fProcessStartTimes.put( processID, STAXMonitorUtil.getCalendar2(startDate, startTime)); } Vector procDataVector = new Vector(); STAXMonitorUtil.assignProcessInfo(processMap, procDataVector); synchronized(fProcessHashtable) { fProcessHashtable.put(processID, procDataVector); } } else if (status.equals("stop")) { Vector dataVector = fProcessTableModel.getDataVector(); for (int i = 0; i < dataVector.size(); i++) { Vector currentRow = (Vector)(dataVector.elementAt(i)); synchronized(fProcessHashtable) { fProcessHashtable.remove(machineHandleText); } synchronized(fProcessStartTimes) { fProcessStartTimes.remove(machineHandleText); } if (((String)currentRow.elementAt(4)). equalsIgnoreCase(machineHandleText)) { fProcessTableModel.removeRow(i); STAXMonitorUtil.updateRowHeights(fProcessTable, 1); STAXMonitorUtil.sizeColumnsToFitText(fProcessTable); break; } } } } public void term() { boolean fContinueProcessMonitor = false; STAXMonitorUtil.freeHandle(fHandle.getHandle()); } class STAFProcessMonitor extends Thread { public void run() { final int frequency = fMonitorFrame.getProcessMonitorInterval(); if (frequency <= 0) return; while (fContinueProcessMonitor) { int waitTime = frequency; Runnable runnable; final Vector dataVector = fProcessTableModel.getDataVector(); for (int i = 0; i < dataVector.size(); i++) { Vector currentRow = (Vector)(dataVector.elementAt(i)); String locationAndHandle = (String)currentRow.elementAt(4); final String location = locationAndHandle.substring( 0, locationAndHandle.lastIndexOf(":")); final String handle = locationAndHandle.substring( locationAndHandle.lastIndexOf(":") + 1); final int row = i; String message = STAXMonitorUtil. getMonitorMessage(location, handle); final String processMessage = message; runnable = new Runnable() { public void run() { try { fProcessTableModel.setValueAt(processMessage, row, 2); STAXMonitorUtil.sizeColumnsToFitText( fProcessTable); fProcessTable.repaint(); } catch(java.lang.ArrayIndexOutOfBoundsException e) { // do nothing } } }; SwingUtilities.invokeLater(runnable); } try { Thread.sleep(waitTime); } catch (InterruptedException ex) { } } } } class MonitorElapsedTime extends Thread { public void run() { final int waitTime = fMonitorFrame.getElapsedTimeInterval(); if (waitTime == 0) return; while (fContinueElapsedTime) { synchronized(fProcessTableModel) { Runnable processRunnable = new Runnable() { public void run() { Vector dataVector = fProcessTableModel.getDataVector(); for (int i = 0; i < dataVector.size(); i++) { Vector currentRow = (Vector)(dataVector.elementAt(i)); String locationAndHandle = (String)currentRow.elementAt(4); final int row = i; synchronized(fProcessStartTimes) { Calendar processStarted = (Calendar) fProcessStartTimes.get( locationAndHandle); { fProcessTableModel.setValueAt( STAXMonitorUtil.getElapsedTime( processStarted), row, 1); } } } fProcessTable.repaint(); } }; try { SwingUtilities.invokeAndWait(processRunnable); } catch (InterruptedException ex) { ex.printStackTrace(); } catch (InvocationTargetException ex) { ex.printStackTrace(); } } try { Thread.sleep(waitTime); } catch (InterruptedException ex) { } } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -