Commit in hps-java/src/main/java/org/lcsim/hps/monitoring on MAIN
DefaultEtEventProcessor.java+39-371.7 -> 1.8
JobPanel.java+4-41.12 -> 1.13
MonitoringApplication.java+16-131.42 -> 1.43
+59-54
3 modified files
fix log level handling so it works on the fly; make event processing flags volatile because it is apparently needed to work correctly

hps-java/src/main/java/org/lcsim/hps/monitoring
DefaultEtEventProcessor.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- DefaultEtEventProcessor.java	10 May 2012 21:14:53 -0000	1.7
+++ DefaultEtEventProcessor.java	10 May 2012 22:19:29 -0000	1.8
@@ -27,7 +27,7 @@
  * having a direct reference to the actual application.
  * 
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: DefaultEtEventProcessor.java,v 1.7 2012/05/10 21:14:53 jeremy Exp $
+ * @version $Id: DefaultEtEventProcessor.java,v 1.8 2012/05/10 22:19:29 jeremy Exp $
  */
 public class DefaultEtEventProcessor implements EtEventProcessor
 {
@@ -39,16 +39,16 @@
     EtConnection et;
     List<EtEventListener> listeners = new ArrayList<EtEventListener>();
     int status;    
-    boolean stopProcessing;
-    boolean stopOnError;
-    boolean nextEvents;
-    boolean pauseMode = false;
-    boolean done = false;
-    boolean blocked = false; 
+    volatile boolean stopProcessing;
+    volatile boolean nextEvents;
+    volatile boolean stopOnError;
+    volatile boolean pauseMode = false;
+    volatile boolean done = false;
+    volatile boolean blocked = false; 
     static Logger logger;
 
     /**
-     * 
+     * Create an instance of the default EtEvent processor.
      * @param et The ET connection.
      * @param eventBuilder The builder for converting from EVIO to LCIO.
      * @param jobManager The LCSim job manager.
@@ -71,7 +71,7 @@
         this.maxEvents = maxEvents;
         this.stopOnError = stopOnError;
 
-        // Setup the logger if needed.
+        // Setup the logger if needed.  This will only happen once.
         if (logger == null) {
             logger = Logger.getLogger(this.getClass().getSimpleName());
             logger.setUseParentHandlers(false);
@@ -84,7 +84,7 @@
     }
     
     /**
-     * Enable pause mode to hold after getEvents() call.
+     * Enable pause mode to pause between single events.
      * @param p True to pause after each set of events; false to do real-time processing.
      */
     void setPauseMode(boolean p) {
@@ -162,10 +162,12 @@
         return status;
     }
 
-    // Get EtEvents and process them.
-    // If in wait mode, continue after waitTime in microseconds if there are no events.
-    // If in async mode, expects non-empty event list immediately or an error occurs.
-    // If in sleep mode, the call to getEvents() will block, including requests to wake-up, until events arrive.
+    /**
+     * Get EtEvents and process them.
+     * If in wait mode, continue after waitTime in microseconds if there are no events.
+     * If in async mode, expects non-empty event list immediately or an error occurs.
+     * If in sleep mode, the call to getEvents() will block, including requests to wake-up, until events arrive.
+     */
     public void processEtEvents() throws EtTimeoutException, MaxEventsException, Exception {
 
         // Get events from the ET system.  This can potentially block forever until it receives events.
@@ -176,7 +178,23 @@
         // Loop over retrieved EtEvents.
         for (EtEvent mev : mevs) {
             
-            // Got a request to stop processing.  Break out of loop.
+            // If running in pause mode, then hold here until the "Next Event" button is pressed.
+            if (pauseMode && this.status == ConnectionStatus.CONNECTED) {
+                logger.log(Level.FINEST, "Pausing until next events requested.");
+                while (true) {
+                    if (nextEvents) {
+                        logger.log(Level.FINEST, "User requested next set of events.");
+                        nextEvents = false;
+                        break;
+                    }
+                    else if (stopProcessing) {
+                        logger.log(Level.FINEST, "Stop was requested in inner event processing loop.");
+                        break;
+                    }
+                }
+            }
+            
+            // Got an external request to stop processing.  Break out of loop.
             if (stopProcessing)
                 break;
             
@@ -184,7 +202,7 @@
             try {
                 processEtEvent(mev);
             }
-            // Catch all processing errors including ET -> EVIO, EVIO -> LCIO, and LCSim Driver execution.
+            // Catch event processing errors, including ET -> EVIO, EVIO -> LCIO, and LCSim Driver execution.
             catch (EventProcessingException e) {               
                 e.getCause().printStackTrace(); // This message shows up in detailed job log.
                 logger.log(Level.WARNING, "Error processing event <" + this.eventsProcessed + ">.");
@@ -195,23 +213,6 @@
                     break;
                 }
             }
-            finally {
-                // If running in pause mode then hold here until user hits "Next Event" button.
-                if (pauseMode && this.status == ConnectionStatus.CONNECTED) {
-                    logger.log(Level.FINEST, "Pausing until next events requested.");
-                    while (true) {
-                        if (nextEvents) {
-                            logger.log(Level.FINEST, "User requested next set of events.");
-                            nextEvents = false;
-                            break;
-                        }
-                        else if (stopProcessing) {
-                            logger.log(Level.FINEST, "Stop was requested in inner event processing loop.");
-                            break;
-                        }
-                    }
-                }
-            }
         }
     }
 
@@ -222,7 +223,7 @@
             throw new MaxEventsException();
         }
 
-        // Notify registered listeners of start of single event processing.
+        // Notify listeners of start of event.
         startOfEvent();
 
         // Increment number of events processed.
@@ -294,17 +295,18 @@
         // Clear any leftover stop request before starting, just in case.
         stopProcessing = false;
         
+        // A new job is starting so this flag gets reset.        
         done = false;
         
         // Notify listeners of job start.
         begin();
         
-        // Loop until fatal Exception or stop is requested.
+        // Loop until fatal error or stop flag is changed to true.
         while (true) { 
 
             // Got a request to stop processing.
             if (stopProcessing) {
-                logger.log(Level.FINEST, "Outer process() loop got stop request.");
+                logger.log(Level.FINEST, "Outer event processing loop got stop request.");
                 this.status = ConnectionStatus.DISCONNECT_REQUESTED;
                 break;
             }
@@ -318,7 +320,7 @@
                 logger.log(Level.WARNING, "ET connection timed out.");
                 this.status = ConnectionStatus.TIMED_OUT; 
             }
-            // Processing reached the maximum number of events.
+            // Event processing reached the maximum number of events.
             catch (MaxEventsException e) {
                 logger.log(Level.INFO, "Reached max events <" + this.maxEvents + ">.");
                 this.status = ConnectionStatus.DISCONNECTING; 

hps-java/src/main/java/org/lcsim/hps/monitoring
JobPanel.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- JobPanel.java	10 May 2012 21:14:53 -0000	1.12
+++ JobPanel.java	10 May 2012 22:19:29 -0000	1.13
@@ -51,7 +51,7 @@
 
     JobPanel() {
 
-        super(new Insets(4, 0, 0, 4), true);
+        super(new Insets(4, 2, 2, 4), true);
         setLayout(new GridBagLayout());
 
         pauseModeCheckBox = addCheckBox("Pause mode", false, true);
@@ -64,7 +64,7 @@
         steeringResourcesComboBox = addComboBox("Steering File Resource", SteeringFileUtil.getAvailableSteeringFileResources());
         detectorNameField = addField("Detector Name", 20);
         eventBuilderField = addField("Event Builder Class", 30);
-        eventBuilderField.setActionCommand(MonitoringCommands.eventBuilderCmd);
+        //eventBuilderField.setActionCommand(MonitoringCommands.eventBuilderCmd);
         logCheckBox = addCheckBox("Log to File", false, false);
         logFileField = addField("Log File", "", "Full path to log file.", 30, false);
         aidaSaveCheckBox = addCheckBox("Save AIDA at End of Job", false, false);
@@ -88,8 +88,8 @@
     }   
     
     void addActionListener(ActionListener listener) {
-        steeringFileField.addActionListener(listener);
-        eventBuilderField.addActionListener(listener);
+        //steeringFileField.addActionListener(listener);
+        //eventBuilderField.addActionListener(listener);
         logLevelComboBox.addActionListener(listener);
     }
         

hps-java/src/main/java/org/lcsim/hps/monitoring
MonitoringApplication.java 1.42 -> 1.43
diff -u -r1.42 -r1.43
--- MonitoringApplication.java	10 May 2012 21:14:53 -0000	1.42
+++ MonitoringApplication.java	10 May 2012 22:19:29 -0000	1.43
@@ -63,7 +63,7 @@
  * ring. This class is accessible to users by calling its main() method.
  * 
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: MonitoringApplication.java,v 1.42 2012/05/10 21:14:53 jeremy Exp $
+ * @version $Id: MonitoringApplication.java,v 1.43 2012/05/10 22:19:29 jeremy Exp $
  */
 public class MonitoringApplication {
 
@@ -148,6 +148,9 @@
      */
     private MonitoringApplication() {
 
+        // Create and configure the logger.
+        setupLogger();
+        
         // Create the ActionEventListener for event dispatching.
         actionListener = new MonitoringApplicationActionListener();
 
@@ -160,9 +163,6 @@
         // Create the log table GUI component.
         createLogTable();
 
-        // Create and configure the logger.
-        setupLogger();
-
         // Log that the application started successfully.
         logger.log(Level.INFO, "Application initialized successfully.");
     }
@@ -200,6 +200,7 @@
         connectionPanel = new ConnectionPanel();
         eventPanel = new EventPanel();
         jobPanel = new JobPanel();
+        jobPanel.addActionListener(actionListener);
 
         // Tab panels.
         c = new GridBagConstraints();
@@ -404,10 +405,10 @@
          * Puts log messages into the application's log table GUI component.
          */
         public void publish(LogRecord record) {
-            Object[] row = new Object[] { record.getLoggerName(), // source
+            Object[] row = new Object[] {record.getLoggerName(), // source
                     record.getMessage(), // message
                     dateFormat.format(new Date(record.getMillis())), // date
-                    record.getLevel() }; // level
+                    record.getLevel()}; // level
             logTableModel.insertRow(logTable.getRowCount(), row);
         }
 
@@ -423,7 +424,7 @@
      * logger.
      */
     private void createLogTable() {
-        final String[] logTableColumns = { "Source", "Message", "Date", "Level" };
+        final String[] logTableColumns = {"Source", "Message", "Date", "Level"};
         String data[][] = new String[0][0];
         logTableModel = new DefaultTableModel(data, logTableColumns);
         logTable = new JTable(logTableModel);
@@ -537,7 +538,9 @@
         public void actionPerformed(ActionEvent e) {
             String cmd = e.getActionCommand();
             if (cmd != MonitoringCommands.updateTimeCmd) {
-                logger.log(Level.FINEST, "Action performed <" + cmd + ">.");
+                if (logger != null) {
+                    logger.log(Level.FINEST, "Action performed <" + cmd + ">.");
+                }
             }
             if (connectCmd.equals(cmd)) {
                 startSessionThread();
@@ -677,6 +680,7 @@
         if (eventProcessor != null) {
             eventProcessor.setLogLevel(newLevel);
         }
+        logger.log(Level.INFO, "Log Level was changed to <" + jobPanel.getLogLevel().toString() + ">.");
     }
 
     /**
@@ -976,7 +980,7 @@
             }
         }
     }
-    
+
     private void redirectStdOutAndErrToFile(File file) throws FileNotFoundException {
         PrintStream ps = new PrintStream(new FileOutputStream(file.getPath()));
         System.setOut(ps);
@@ -1110,7 +1114,7 @@
      */
     private void exit() {
         if (connection != null) {
-            this.cleanupConnection();
+            cleanupConnection();
         }
         System.exit(0);
     }
@@ -1201,6 +1205,8 @@
             // Connect to the ET system.
             connect();
 
+            // TODO: Add EtEventCounter thread here for counting all ET events.
+
             // Create the event processing thread.
             createEventProcessingThread();
 
@@ -1364,9 +1370,6 @@
         // Stop event processing if currently connected.
         if (eventProcessor != null) {
             logger.log(Level.FINE, "Stopping the event processor.");
-            // This sets a flag to tell the event processor to exit from the process loop.
-            // It will not work if it is blocked but in that case the processor will exit
-            // when the ET connection goes down.
             eventProcessor.stop();
         }
 
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1