[ARVADOS] updated: f2652e70c70db7a9a068c5a9bc8c6ec6566a14c6

git at public.curoverse.com git at public.curoverse.com
Wed Nov 19 07:09:45 EST 2014


Summary of changes:
 apps/workbench/app/assets/javascripts/event_log.js | 45 ++++++++++++++++------
 services/api/lib/simulate_job_log.rb               |  6 ++-
 services/api/lib/tasks/replay_job_log.rake         |  6 +--
 3 files changed, 41 insertions(+), 16 deletions(-)

       via  f2652e70c70db7a9a068c5a9bc8c6ec6566a14c6 (commit)
       via  e5d3458808720f0b2ad25ba2b2be6a867b9d836e (commit)
      from  b40e379090ff9a01db439a7d4b3b2162d150f89a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f2652e70c70db7a9a068c5a9bc8c6ec6566a14c6
Author: Phil Hodgson <bitbucket at philhodgson.net>
Date:   Wed Nov 19 13:09:40 2014 +0100

    4233: show empty log stats graph when no data, and also show a full width x-axis (currently 10 minutes) even when only a few data points have been plotted

diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js
index 7bef6f4..2c4fe52 100644
--- a/apps/workbench/app/assets/javascripts/event_log.js
+++ b/apps/workbench/app/assets/javascripts/event_log.js
@@ -63,8 +63,6 @@ $(document).on('ajax:complete ready', function() {
   window.jobGraphMaxima = {};
  */
 function processLogLineForChart( logLine ) {
-    var recreate = false;
-    var rescale = false;
     try {
         var match = logLine.match(/(\S+) (\S+) (\S+) (\S+) stderr crunchstat: (\S+) (.*) -- interval (.*)/);
         if( match ) {
@@ -77,7 +75,7 @@ function processLogLineForChart( logLine ) {
             if( $.inArray( series, jobGraphSeries) < 0 ) {
                 jobGraphSeries.push(series);
                 jobGraphMaxima[series] = null;
-                recreate = true;
+                window.recreate = true;
             }
             var intervalData = match[7].trim().split(' ');
             var dt = parseFloat(intervalData[0]);
@@ -166,17 +164,32 @@ function processLogLineForChart( logLine ) {
                         }
                     });
                 }
+                // add a 10 minute old null data point to keep the chart honest if the oldest point is less than 9.5 minutes old
+                if( jobGraphData.length > 0
+                      && (Date.parse( jobGraphData[0]['t'] ).valueOf() + 9.5*60000 > Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf()) ) {
+                    var tenMinutesBefore = (new Date(Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf() - 600*1000)).toISOString().replace('Z','');
+                    jobGraphData.unshift( { 't': tenMinutesBefore } );
+                }
             }
+            window.redraw = true;
         }
     } catch( err ) {
         console.log( 'Ignoring error trying to process log line: ' + err);
     }
-    return recreate;
 }
 
 function createJobGraph(elementName) {
     delete jobGraph;
-    window.jobGraph = Morris.Line( {
+    var emptyGraph = false;
+    if( jobGraphData.length === 0 ) {
+        // If there is no data we still want to show an empty graph,
+        // so add an empty datum and placeholder series to fool it into displaying itself.
+        // Note that when finally a new series is added, the graph will be recreated anyway.
+        jobGraphData.push( {} );
+        jobGraphSeries.push( '' );
+        emptyGraph = true;
+    }
+    var graphteristics = {
         element: elementName,
         data: jobGraphData,
         ymax: 1.0,
@@ -184,7 +197,9 @@ function createJobGraph(elementName) {
         xkey: 't',
         ykeys: jobGraphSeries,
         labels: jobGraphSeries,
+        resize: true,
         hideHover: 'auto',
+        parseTime: true,
         hoverCallback: function(index, options, content) {
             var s = "<div class='morris-hover-row-label'>";
             s += options.data[index][options.xkey];
@@ -219,7 +234,17 @@ function createJobGraph(elementName) {
             }
             return s;
         }
-    });
+    }
+    if( emptyGraph ) {
+        graphteristics['axes'] = false;
+        graphteristics['parseTime'] = false;
+        graphteristics['hideHover'] = 'always';
+    }
+    window.jobGraph = Morris.Line( graphteristics );
+    if( emptyGraph ) {
+        jobGraphData = [];
+        jobGraphSeries = [];
+    }
 }
 
 function rescaleJobGraphSeries( series, scaleConversion ) {
@@ -239,12 +264,7 @@ function isJobSeriesRescalable( series ) {
 
 $(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
     if( eventData.properties.text ) {
-        var causeRecreate = processLogLineForChart( eventData.properties.text );
-        if( causeRecreate && !window.recreate ) {
-            window.recreate = true;
-        } else {
-            window.redraw = true;
-        }
+        processLogLineForChart( eventData.properties.text );
     }
 } );
 
@@ -254,6 +274,7 @@ $(document).on('ready', function(){
     setInterval( function() {
         if( recreate ) {
             window.recreate = false;
+            window.redraw = false;
             // series have changed, draw entirely new graph
             $('#log_graph_div').html('');
             createJobGraph('log_graph_div');

commit e5d3458808720f0b2ad25ba2b2be6a867b9d836e
Author: Phil Hodgson <bitbucket at philhodgson.net>
Date:   Wed Nov 19 10:51:21 2014 +0100

    4233: add deletion of existing log entries option to log replay helper and rake task

diff --git a/services/api/lib/simulate_job_log.rb b/services/api/lib/simulate_job_log.rb
index 1202a99..4ebca08 100644
--- a/services/api/lib/simulate_job_log.rb
+++ b/services/api/lib/simulate_job_log.rb
@@ -1,14 +1,18 @@
 module SimulateJobLog
-	def replay(filename, simulated_job_uuid = nil, multiplier = 1)
+	# Note that deleting existing log entries only works if a simulated job uuid is also specified.
+	def replay(filename, multiplier = 1, delete_log_entries = false, simulated_job_uuid = nil)
 		raise "Environment must be development or test" unless [ 'test', 'development' ].include? ENV['RAILS_ENV']
 
 	    multiplier = multiplier.to_f
 	    multiplier = 1.0 if multiplier <= 0
 
+	    delete_log_entries = (delete_log_entries.to_s.downcase == 'true')
+
 	    actual_start_time = Time.now
 	    log_start_time = nil
 
 		act_as_system_user do
+			Log.where("object_uuid = ?", simulated_job_uuid).delete_all if simulated_job_uuid && delete_log_entries
 			File.open(filename).each.with_index do |line, index|
 				cols = {}
 		        cols[:timestamp], cols[:job_uuid], cols[:pid], cols[:task], cols[:event_type], cols[:message] = line.split(' ', 6)
diff --git a/services/api/lib/tasks/replay_job_log.rake b/services/api/lib/tasks/replay_job_log.rake
index 59b75fa..cfa19cd 100644
--- a/services/api/lib/tasks/replay_job_log.rake
+++ b/services/api/lib/tasks/replay_job_log.rake
@@ -1,7 +1,7 @@
 require 'simulate_job_log'
-desc 'Simulate job logging from a file. Three arguments: log filename, simulated job uuid (optional), time multipler (optional). E.g. (note quotation marks): rake "replay_job_log[log.txt, qr1hi-8i9sb-nf3qk0xzwwz3lre, 2.0]"'
-task :replay_job_log, [:filename, :uuid, :multiplier] => :environment do |t, args|
+desc 'Simulate job logging from a file. Four arguments: log filename, time multipler (optional), delete existing log entries (optional, default is false), simulated job uuid (optional). Note that deleting existing log entries only works if a simulated job uuid is also specified. E.g. (use quotation marks if using spaces between args): rake "replay_job_log[log.txt, 2.0, true, qr1hi-8i9sb-nf3qk0xzwwz3lre]"'
+task :replay_job_log, [:filename, :multiplier, :delete_log_entries, :uuid] => :environment do |t, args|
 	include SimulateJobLog
     abort("No filename specified.") if args[:filename].blank?
-    replay( args[:filename], args[:uuid], args[:multiplier].to_f )
+    replay( args[:filename], args[:multiplier].to_f, args[:delete_log_entries], args[:uuid] )
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list