LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  July 2015

HPS-SVN July 2015

Subject:

r3217 - in /java/trunk/record-util/src/main/java/org/hps/record/evio/crawler: JCacheManager.java RunLogUpdater.java RunProcessor.java RunSummaryUpdater.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Wed, 1 Jul 2015 15:13:16 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (209 lines)

Author: [log in to unmask]
Date: Wed Jul  1 08:13:01 2015
New Revision: 3217

Log:
Minor changes to crawler (fix allow updates flag and other changes).

Modified:
    java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/JCacheManager.java
    java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunLogUpdater.java
    java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunProcessor.java
    java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunSummaryUpdater.java

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/JCacheManager.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/JCacheManager.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/JCacheManager.java	Wed Jul  1 08:13:01 2015
@@ -50,6 +50,11 @@
          * The current status from executing the 'jcache request' command.
          */
         private String status;
+        
+        /**
+         * The xml node with request data.
+         */
+        private Element xml;
 
         /**
          * Create a new <code>CacheStatus</code> object.
@@ -122,38 +127,58 @@
         }
 
         /**
-         * Return </code>true</code> if status is "done".
-         *
-         * @return </code>true</code> if status is "done"
+         * Return <code>true</code> if status is "done".
+         *
+         * @return <code>true</code> if status is "done"
          */
         boolean isDone() {
             return "done".equals(this.status);
         }
 
         /**
-         * Return </code>true</code> if status is "hit".
-         *
-         * @return </code>true</code> if status is "hit"
+         * Return <code>true</code> if status is "hit".
+         *
+         * @return <code>true</code> if status is "hit"
          */
         boolean isHit() {
             return "hit".equals(this.status);
         }
 
         /**
-         * Return </code>true</code> if status is "pending".
-         *
-         * @return </code>true</code> if status is "pending"
+         * Return <code>true</code> if status is "pending".
+         *
+         * @return <code>true</code> if status is "pending"
          */
         boolean isPending() {
             return "pending".equals(this.status);
         }
-
-        /**
-         * Request the file status string using the 'jcache request' command.
-         *
-         * @return the file status string
-         */
-        private String requestFileStatus() {
+        
+        /**
+         * Return <code>true</code> if status is "failed".
+         */
+        boolean isFailed() {
+            return "failed".equals(this.status);
+        }
+        
+        /**
+         * Get the error message from the XML request.
+         * 
+         * @return the error message from the XML request
+         */
+        String getErrorMessage() {
+            if (this.xml.getChild("request").getChild("file").getChild("error") != null) {
+                return this.xml.getChild("request").getChild("file").getChild("error").getText();
+            } else {
+                return "";
+            }
+        }
+      
+        /**
+         * Run the <i>jcache request</i> command for this request ID and return the XML output.
+         * 
+         * @return the XML output from the <i>jcache request</i> command
+         */
+        private Element request() {
             Process process = null;
             try {
                 process = new ProcessBuilder(JCACHE_COMMAND, "request", this.requestId.toString()).start();
@@ -169,15 +194,22 @@
             if (status != 0) {
                 throw new RuntimeException("The jcache request returned an error status: " + status);
             }
-            return this.getRequestXml(process.getInputStream()).getChild("request").getChild("file").getChildText("status");
+            return this.getRequestXml(process.getInputStream());            
         }
 
         /**
          * Update the cache status.
          */
         void update() {
-            this.status = this.requestFileStatus();
+            // Request status update and get the XML from that process.
+            this.xml = request();
+            
+            // Update the status from the XML.
+            this.status = this.xml.getChild("request").getChild("file").getChildText("status");
+            
+            // Is request done or file already in cache?
             if (this.isDone() || this.isHit()) {
+                // Flag file as cached.
                 this.cached = true;
             }
         }
@@ -345,6 +377,13 @@
                     // Log that this file is now cached. It will not be checked next time.
                     LOGGER.info(cacheStatus.getFile().getPath() + " is cached with status " + cacheStatus.getStatus(false));
                 }
+                
+                // Did the request fail?
+                if (cacheStatus.isFailed()) {
+                    // Cache failure is a fatal error.
+                    LOGGER.severe("cache request failed with error: " + cacheStatus.getErrorMessage());
+                    throw new RuntimeException("Cache request failed.");
+                }
             } else {
                 LOGGER.info(cacheStatus.getFile().getPath() + " is already cached");
             }

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunLogUpdater.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunLogUpdater.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunLogUpdater.java	Wed Jul  1 08:13:01 2015
@@ -49,11 +49,14 @@
         
         // Set the run log with the run info to update.
         this.runLog = runLog;
+        
+        // Set whether db updates are allowed (replacement of existing records).
+        this.allowUpdates = allowUpdates;
     }
             
     /**
-     * Insert the run summary information into the database, including updating the run_log_files
-     * and run_log_epics tables.
+     * Insert the run summary information into the database, including updating the <i>run_log_files</i>
+     * and <i>run_log_epics</i> tables.
      *
      * @param connection the database connection
      * @throws SQLException if there is an error querying the database
@@ -76,9 +79,11 @@
                                 
                 // Create the db updater for the RunSummary.
                 RunSummaryUpdater runUpdater = new RunSummaryUpdater(connection, runSummary);
-                
+                                                
                 // Set whether existing records can be replaced.
                 runUpdater.setAllowDeleteExisting(allowUpdates);
+                
+                LOGGER.info("allow updates: " + allowUpdates);
                 
                 // Insert the run records.
                 runUpdater.insert();

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunProcessor.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunProcessor.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunProcessor.java	Wed Jul  1 08:13:01 2015
@@ -379,7 +379,9 @@
             RunSummary runSummary = runs.getRunSummary(run);
             
             // Clear the cache manager.
-            cacheManager.clear();
+            if (config.useFileCache()) {
+                cacheManager.clear();
+            }
 
             // Create a processor to process all the EVIO events in the run.
             final RunProcessor runProcessor = RunProcessor.createRunProcessor(cacheManager, runSummary, config);

Modified: java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunSummaryUpdater.java
 =============================================================================
--- java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunSummaryUpdater.java	(original)
+++ java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/RunSummaryUpdater.java	Wed Jul  1 08:13:01 2015
@@ -145,7 +145,7 @@
         // Does the run exist in the database already?
         if (this.runExists()) {
             // Is deleting existing rows allowed?
-            if (allowDeleteExisting) {
+            if (this.allowDeleteExisting) {
                 // Delete the existing rows.
                 this.delete();
             } else {

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use