[ARVADOS] created: 7fb83a3380e62721801a4980c48ba78208c7b2e2

git at public.curoverse.com git at public.curoverse.com
Wed May 7 02:17:18 EDT 2014


        at  7fb83a3380e62721801a4980c48ba78208c7b2e2 (commit)


commit 7fb83a3380e62721801a4980c48ba78208c7b2e2
Merge: 1d5b466 11b48e1
Author: Misha Zatsman <misha-arvados at zatsman.com>
Date:   Wed May 7 06:15:18 2014 +0000

    Merge branch 'master' of git.curoverse.com:arvados into 2638-add-cache-age-disk-usage-histogram-to-workbench


commit 1d5b46697b5d7c68b0bb159fc570ed63c1e3acc3
Author: Misha Zatsman <misha-arvados at zatsman.com>
Date:   Wed May 7 02:48:40 2014 +0000

    Avoided printing graph if no data. Added date histogram was generated.

diff --git a/apps/workbench/app/assets/stylesheets/keep_disks.css.scss b/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
index 741ac19..1fe5cd4 100644
--- a/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
+++ b/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
@@ -6,6 +6,6 @@
 div.graph {
     margin-top: 20px;
 }
-div.graph h3 {
+div.graph h3,h4 {
     text-align: center;
 }
diff --git a/apps/workbench/app/controllers/keep_disks_controller.rb b/apps/workbench/app/controllers/keep_disks_controller.rb
index c6a42b0..345d17f 100644
--- a/apps/workbench/app/controllers/keep_disks_controller.rb
+++ b/apps/workbench/app/controllers/keep_disks_controller.rb
@@ -19,6 +19,7 @@ class KeepDisksController < ApplicationController
       @cache_age_histogram = log_entry['properties'][:histogram]
       # Javascript wants dates in milliseconds.
       @histogram_date = log_entry['event_at'].to_i * 1000
+      @histogram_pretty_date = log_entry['event_at'].strftime('%b %-d, %Y')
 
       total_free_cache = @cache_age_histogram[-1][1]
       persisted_storage = 1 - total_free_cache
diff --git a/apps/workbench/app/views/keep_disks/_content_layout.html.erb b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
index 4696cab..38188a5 100644
--- a/apps/workbench/app/views/keep_disks/_content_layout.html.erb
+++ b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
@@ -1,4 +1,5 @@
-<% content_for :tab_panes do %>
+<% if @histogram_date > 0 %>
+  <% content_for :tab_panes do %>
   <%# We use protocol-relative paths here to avoid browsers refusing to load javascript over http in a page that was loaded over https. %>
   <%= javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js' %>
   <%= javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/morris.js/0.4.3/morris.min.js' %>
@@ -9,9 +10,11 @@
   </script>
   <div class='graph'>
     <h3>Cache Age vs. Disk Utilization</h3>
+    <h4>circa <%= @histogram_pretty_date %></h4>
     <div id='cache-age-vs-disk-histogram'>
     </div>
   </div>
+  <% end %>
 <% end %>
 <%= content_for :content_top %>
 <%= content_for :tab_line_buttons %>

commit 9736526e7abfd50eb8f18293f8ac312bf61937e4
Author: Misha Zatsman <misha-arvados at zatsman.com>
Date:   Wed May 7 02:33:06 2014 +0000

    Added cache age histogram!

diff --git a/apps/workbench/app/assets/javascripts/keep_disks.js.coffee b/apps/workbench/app/assets/javascripts/keep_disks.js.coffee
index 7615679..cc3aac7 100644
--- a/apps/workbench/app/assets/javascripts/keep_disks.js.coffee
+++ b/apps/workbench/app/assets/javascripts/keep_disks.js.coffee
@@ -1,3 +1,32 @@
 # Place all the behaviors and hooks related to the matching controller here.
 # All this logic will automatically be available in application.js.
 # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
+
+cache_age_in_days = (milliseconds_age) ->
+  ONE_DAY = 1000 * 60 * 60 * 24
+  milliseconds_age / ONE_DAY
+
+cache_age_hover = (milliseconds_age) ->
+  'Cache age ' + cache_age_in_days(milliseconds_age).toFixed(1) + ' days.'
+
+cache_age_axis_label = (milliseconds_age) ->
+  cache_age_in_days(milliseconds_age).toFixed(0) + ' days'
+
+float_as_percentage = (proportion) ->
+  (proportion.toFixed(4) * 100) + '%'
+
+$.renderHistogram = (histogram_data) ->
+  Morris.Area({
+    element: 'cache-age-vs-disk-histogram',
+    pointSize: 0,
+    lineWidth: 0,
+    data: histogram_data,
+    xkey: 'age',
+    ykeys: ['persisted', 'cache'],
+    labels: ['Persisted Storage Disk Utilization', 'Cached Storage Disk Utilization'],
+    ymax: 1,
+    ymin: 0,
+    xLabelFormat: cache_age_axis_label,
+    yLabelFormat: float_as_percentage,
+    dateFormat: cache_age_hover
+  })
diff --git a/apps/workbench/app/assets/stylesheets/keep_disks.css.scss b/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
index aff8b50..741ac19 100644
--- a/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
+++ b/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
@@ -3,8 +3,9 @@
 // You can use Sass (SCSS) here: http://sass-lang.com/
 
 /* Margin allows us some space between the table above. */
-div.cache-age-vs-disk-histogram {
+div.graph {
     margin-top: 20px;
 }
-
-
+div.graph h3 {
+    text-align: center;
+}
diff --git a/apps/workbench/app/controllers/keep_disks_controller.rb b/apps/workbench/app/controllers/keep_disks_controller.rb
index b7bc7c0..c6a42b0 100644
--- a/apps/workbench/app/controllers/keep_disks_controller.rb
+++ b/apps/workbench/app/controllers/keep_disks_controller.rb
@@ -4,8 +4,8 @@ class KeepDisksController < ApplicationController
     @object = KeepDisk.new defaults.merge(params[:keep_disk] || {})
     super
   end
-  def index
 
+  def index
     # Retrieve cache age histogram info
     @cache_age_histogram = []
     @histogram_date = 0
@@ -26,6 +26,8 @@ class KeepDisksController < ApplicationController
           :cache => total_free_cache - x[1],
           :persisted => persisted_storage} }
     end
+
+    # Do the regular control work needed.
     super
   end
 end
diff --git a/apps/workbench/app/views/keep_disks/_content_layout.html.erb b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
index cbad20a..4696cab 100644
--- a/apps/workbench/app/views/keep_disks/_content_layout.html.erb
+++ b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
@@ -1,8 +1,16 @@
 <% content_for :tab_panes do %>
-  <div class='cache-age-vs-disk-histogram'>
-    <%= raw @cache_age_histogram.to_json %>
-    <br>
-    <%= @histogram_date %>
+  <%# We use protocol-relative paths here to avoid browsers refusing to load javascript over http in a page that was loaded over https. %>
+  <%= javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js' %>
+  <%= javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/morris.js/0.4.3/morris.min.js' %>
+  <script type="text/javascript">
+    $(document).ready(function(){
+      $.renderHistogram(<%= raw @cache_age_histogram.to_json %>);
+    });
+  </script>
+  <div class='graph'>
+    <h3>Cache Age vs. Disk Utilization</h3>
+    <div id='cache-age-vs-disk-histogram'>
+    </div>
   </div>
 <% end %>
 <%= content_for :content_top %>

commit 638d136057f4d9ed19f132075079da396217d6fd
Author: Misha Zatsman <misha-arvados at zatsman.com>
Date:   Tue May 6 23:30:26 2014 +0000

    Added printing of histogram json.

diff --git a/apps/workbench/app/controllers/keep_disks_controller.rb b/apps/workbench/app/controllers/keep_disks_controller.rb
index 0e1a981..b7bc7c0 100644
--- a/apps/workbench/app/controllers/keep_disks_controller.rb
+++ b/apps/workbench/app/controllers/keep_disks_controller.rb
@@ -5,7 +5,27 @@ class KeepDisksController < ApplicationController
     super
   end
   def index
-    # TODO(misha):Retrieve the histogram info
+
+    # Retrieve cache age histogram info
+    @cache_age_histogram = []
+    @histogram_date = 0
+    histogram_log = Log.
+      filter([[:event_type, '=', 'block-age-free-space-histogram']]).
+      order(:created_at => :desc).
+      limit(1)
+    histogram_log.each do |log_entry|
+      # We expect this block to only execute at most once since we
+      # specified limit(1)
+      @cache_age_histogram = log_entry['properties'][:histogram]
+      # Javascript wants dates in milliseconds.
+      @histogram_date = log_entry['event_at'].to_i * 1000
+
+      total_free_cache = @cache_age_histogram[-1][1]
+      persisted_storage = 1 - total_free_cache
+      @cache_age_histogram.map! { |x| {:age => @histogram_date - x[0]*1000,
+          :cache => total_free_cache - x[1],
+          :persisted => persisted_storage} }
+    end
     super
   end
 end
diff --git a/apps/workbench/app/views/keep_disks/_content_layout.html.erb b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
index 7178b9c..cbad20a 100644
--- a/apps/workbench/app/views/keep_disks/_content_layout.html.erb
+++ b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
@@ -1,5 +1,9 @@
 <% content_for :tab_panes do %>
-<div class='cache-age-vs-disk-histogram'>Histogram will go here.</div>
+  <div class='cache-age-vs-disk-histogram'>
+    <%= raw @cache_age_histogram.to_json %>
+    <br>
+    <%= @histogram_date %>
+  </div>
 <% end %>
 <%= content_for :content_top %>
 <%= content_for :tab_line_buttons %>

commit 7e049a91425a51398f38e6b1ee839a4070483267
Author: Misha Zatsman <misha-arvados at zatsman.com>
Date:   Tue May 6 21:13:07 2014 +0000

    Added div for histogram and style for it.

diff --git a/apps/workbench/app/assets/javascripts/sizing.js b/apps/workbench/app/assets/javascripts/sizing.js
index 55d2301..640893f 100644
--- a/apps/workbench/app/assets/javascripts/sizing.js
+++ b/apps/workbench/app/assets/javascripts/sizing.js
@@ -23,7 +23,7 @@ function smart_scroll_fixup(s) {
         a = s[i];
         var h = window.innerHeight - a.getBoundingClientRect().top - 20;
         height = String(h) + "px";
-        a.style.height = height;
+        a.style['max-height'] = height;
     }
 }
 
diff --git a/apps/workbench/app/assets/stylesheets/keep_disks.css.scss b/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
index 1f7780b..aff8b50 100644
--- a/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
+++ b/apps/workbench/app/assets/stylesheets/keep_disks.css.scss
@@ -1,3 +1,10 @@
 // Place all the styles related to the KeepDisks controller here.
 // They will automatically be included in application.css.
 // You can use Sass (SCSS) here: http://sass-lang.com/
+
+/* Margin allows us some space between the table above. */
+div.cache-age-vs-disk-histogram {
+    margin-top: 20px;
+}
+
+
diff --git a/apps/workbench/app/controllers/keep_disks_controller.rb b/apps/workbench/app/controllers/keep_disks_controller.rb
index cc89228..0e1a981 100644
--- a/apps/workbench/app/controllers/keep_disks_controller.rb
+++ b/apps/workbench/app/controllers/keep_disks_controller.rb
@@ -4,4 +4,8 @@ class KeepDisksController < ApplicationController
     @object = KeepDisk.new defaults.merge(params[:keep_disk] || {})
     super
   end
+  def index
+    # TODO(misha):Retrieve the histogram info
+    super
+  end
 end
diff --git a/apps/workbench/app/views/keep_disks/_content_layout.html.erb b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
new file mode 100644
index 0000000..7178b9c
--- /dev/null
+++ b/apps/workbench/app/views/keep_disks/_content_layout.html.erb
@@ -0,0 +1,6 @@
+<% content_for :tab_panes do %>
+<div class='cache-age-vs-disk-histogram'>Histogram will go here.</div>
+<% end %>
+<%= content_for :content_top %>
+<%= content_for :tab_line_buttons %>
+<%= content_for :tab_panes %>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list