org.peace_tools.core.job
Class SubmitJobWizardPage

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.peace_tools.generic.GenericWizardPage
                      extended by org.peace_tools.core.job.SubmitJobWizardPage
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, javax.accessibility.Accessible, WizardPage

public class SubmitJobWizardPage
extends GenericWizardPage
implements java.lang.Runnable

This class serves as the final page in a JobWizard. This page provides the user with feedback as the job is submitted to be run on the server. The job submission process consists of the following steps:

  1. First a directory is created on the remote server for this job. The directory is created under the peace installation path on the remote server.
  2. Next, the existence of the source EST data file on the remote server is checked. If the file is not present then it is copied to the remote server. Otherwise the existing file is verified and if it matches it is used.
  3. Finally, the job runner script are copied to the install folder and the job runner script is executed to submit the job to run on the server.
Note that the process of submitting the job can take several seconds (or even a minute if EST file to copied is large). Consequently the operations are run on a separate thread to ensure that the GUI continues to provide feedback without appearing as if it is hanging (it would appear to be hanging if the operations are performed on the same thread).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.lang.String FILE_MISMATCH
          A generic informational message that is displayed to the user when EST file mismatch is detected
private static java.lang.String INFO_MSG
          A generic informational message that is displayed at the top of this wizard page to provide some contextual information to the user.
private static java.lang.String JOB_SUBMIT_ERROR
          A generic informational message that is displayed to the user when any error occurs during the job submission process.
private  javax.swing.JTextArea log
          Field to read and edit a brief description about the job.
private static long serialVersionUID
          A serialization UID to keep the compiler happy.
private  ServerSession server
          The session to the server on which the job is to be submitted.
private  javax.swing.JLabel[] stepInfo
          The step information labels to display information about the steps to be done and those that have been completed.
private static java.lang.String SUCCESS_MESSAGE
          A generic informational message that is displayed to the user after a job has successfully started up.
private  JobWizard wizard
          A reference to the wizard dialog that logically owns this page.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SubmitJobWizardPage(JobWizard wizard)
          The constructor.
 
Method Summary
private  void copyESTFile()
          Helper method to copy EST data file to shared space if needed.
private  void createEntries()
          Helper method to create entries in the work space.
private  void createJobDirectory()
          This is a helper method that is used to create a valid directory where this job's files will be copied.
protected  void createJobUpdateThread()
          Helper method to create a thread to periodically poll a job.
private  void deployRunnerScript()
          This is a helper method that is used to deploy the job runner script to the server.
private  java.lang.String getServerESTFile()
          Helper method to compute the full path to the EST data file on the server.
 void pageChanged(WizardDialog dialog, int currPage, int prevPage)
          This method is called just before this page is to be displayed.
 void run()
          Method to perform various tasks involved in successfully creating and submitting a job on a remote server.
private  void setStepStatus(int stepIndex, boolean performing)
          Helper method to update the status of a step.
private  void startSession()
          This is a helper method that is used to establish a valid session with the remote server on which the job is to be submitted.
private  void submitJob()
          Helper method to run the job runner on the server.
 
Methods inherited from class org.peace_tools.generic.GenericWizardPage
getPage, getSubTitle, getTitle, pageChanging, setTitle
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

wizard

private final JobWizard wizard
A reference to the wizard dialog that logically owns this page. This reference is used to enable and disable buttons on this wizard appropriately.


log

private javax.swing.JTextArea log
Field to read and edit a brief description about the job. This information can be anything the user desires and is meaningful only to the user.


stepInfo

private javax.swing.JLabel[] stepInfo
The step information labels to display information about the steps to be done and those that have been completed. These labels are created in the constructor and updated periodically.


INFO_MSG

private static final java.lang.String INFO_MSG
A generic informational message that is displayed at the top of this wizard page to provide some contextual information to the user.

See Also:
Constant Field Values

JOB_SUBMIT_ERROR

private static final java.lang.String JOB_SUBMIT_ERROR
A generic informational message that is displayed to the user when any error occurs during the job submission process.

See Also:
Constant Field Values

FILE_MISMATCH

private static final java.lang.String FILE_MISMATCH
A generic informational message that is displayed to the user when EST file mismatch is detected

See Also:
Constant Field Values

SUCCESS_MESSAGE

private static final java.lang.String SUCCESS_MESSAGE
A generic informational message that is displayed to the user after a job has successfully started up.

See Also:
Constant Field Values

server

private ServerSession server
The session to the server on which the job is to be submitted. The connection is used throughout the process of job submission by various methods. It is created in the startSession() method.


serialVersionUID

private static final long serialVersionUID
A serialization UID to keep the compiler happy.

See Also:
Constant Field Values
Constructor Detail

SubmitJobWizardPage

public SubmitJobWizardPage(JobWizard wizard)
The constructor. The constructor sets up the various components on this wizard page. The components include: A series of labels to show the various steps being performed and a JTextArea to display additional log information.

Parameters:
wizard - The wizard that logically owns this page.
Method Detail

pageChanged

public void pageChanged(WizardDialog dialog,
                        int currPage,
                        int prevPage)
This method is called just before this page is to be displayed. This page disables all the buttons in the wizard and jump starts the background thread that performs the various tasks.

Specified by:
pageChanged in interface WizardPage
Overrides:
pageChanged in class GenericWizardPage
Parameters:
dialog - The wizard dialog that owns this wizard page.
currPage - The current page to be displayed.
prevPage - The previous page that was displayed.

setStepStatus

private void setStepStatus(int stepIndex,
                           boolean performing)
Helper method to update the status of a step. This method is used to provide visual feedback to the user as to which step is being performed by this wizard.

Parameters:
stepIndex - The index of the step whose status is to be updated.
performing - If this flag is true, then this step is underway. If it is false, it is assumed that the step has been completed.

run

public void run()
Method to perform various tasks involved in successfully creating and submitting a job on a remote server. This method is called just after the wizard page has been displayed from a separate thread.

Specified by:
run in interface java.lang.Runnable

createJobUpdateThread

protected void createJobUpdateThread()
Helper method to create a thread to periodically poll a job. This is a helper method that is used to create a daemon thread to check status of the job. The thread is created as a daemon thread so that the system can exit out of the thread in a graceful manner.


submitJob

private void submitJob()
                throws java.lang.Exception
Helper method to run the job runner on the server. This method is invoked from the run method to actually run the job runner on the remote machine. This method execute the job runner on the remote machine with "start" as the command line parameter.

Throws:
java.lang.Exception

deployRunnerScript

private void deployRunnerScript()
                         throws java.lang.Exception
This is a helper method that is used to deploy the job runner script to the server. This method is invoked from the run() method to adapt the local runner script (which is a template) by filling in the template parameters with actual values and copying the script to the remote machine.

Throws:
java.lang.Exception - This method throws exceptions on errors.

copyESTFile

private void copyESTFile()
                  throws java.io.IOException
Helper method to copy EST data file to shared space if needed. This method checks to see if the EST data file already exists on the server. If not it copies the EST data file over.

Throws:
java.io.IOException

getServerESTFile

private java.lang.String getServerESTFile()
Helper method to compute the full path to the EST data file on the server.

Returns:
The full path (based on install path) to the EST data file on the server.

createEntries

private void createEntries()
Helper method to create entries in the work space. This method is invoked from the run() method and performs the task of creating MST, Cluster, and Job entries.


startSession

private void startSession()
                   throws java.io.IOException
This is a helper method that is used to establish a valid session with the remote server on which the job is to be submitted.

Throws:
java.io.IOException

createJobDirectory

private void createJobDirectory()
                         throws java.lang.Exception
This is a helper method that is used to create a valid directory where this job's files will be copied.

Throws:
java.lang.Exception