-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new Compactions-Page containing the Compactions-Chart moved from …
…the Servers-Page #18
- Loading branch information
Nils Kübler
committed
Apr 10, 2013
1 parent
a0baca1
commit 71a2319
Showing
13 changed files
with
186 additions
and
71 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
app/assets/javascripts/main/compactions/show_compactions.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright 2012 Sentric. See LICENSE for details. | ||
|
||
$ -> | ||
showCompactionsView = window.showCompactionsView = new ShowCompactionsView | ||
el: $("#show-compactions-view") |
52 changes: 52 additions & 0 deletions
52
app/assets/javascripts/views/compactions/ShowCompactions.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2012 Sentric. See LICENSE for details. | ||
|
||
class @ShowCompactionsView extends Backbone.View | ||
|
||
initialize: -> | ||
@metricsCharts = [] | ||
@$(".compaction-metric-chart-view").each (idx, element) => | ||
@metricsCharts.push @createMetricView(@$(element)) | ||
|
||
@visualCountDown = new VisualCountDownView | ||
el: @$(".refresh-text") | ||
pattern: "(next refresh in %delay% seconds)" | ||
@visualCountDown.on "done", _.bind(@updateMetrics, @) | ||
|
||
if @metricsCharts.length > 0 | ||
@compactions = @metricsCharts[0].collection | ||
@compactions.on "reset", _.bind(@updateLongestCompactionDuration, @) | ||
|
||
@updateMetrics() | ||
|
||
createMetricView: ($el) -> | ||
metrics = Metrics.byNames( $el.data("metric-names") ) | ||
view = new MetricChartView | ||
el: $el | ||
collection: metrics | ||
metricFilter: (collection) -> collection.groupedByTable() | ||
doNormalize: false | ||
renderer: 'area' | ||
palette: new RickshawUtil.TablePalette() | ||
view | ||
|
||
updateMetrics: -> | ||
view.collection.fetch() for view in @metricsCharts | ||
@visualCountDown.startCountDown(125, 1, 1000) | ||
|
||
updateLongestCompactionDuration: -> | ||
max = 0 | ||
target = "[none]" | ||
date = new Date() | ||
@compactions.each (metric) -> | ||
begin = metric.begin; | ||
_(metric.getValues()).each (record) -> | ||
if(record.v > 0) | ||
begin = record.ts | ||
else if record.ts - begin > max | ||
max = record.ts - begin | ||
date = new Date(begin) | ||
target = metric.getTargetDesc() | ||
|
||
route = Routes.Regions.show | ||
name: target | ||
@$(".longest-compaction").html("<b>#{(max/1000.0).toFixed(1)}s</b> <a href='#{route}'>on Region</a>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright 2012 Sentric. See LICENSE for details. | ||
*/ | ||
|
||
package controllers | ||
|
||
import play.api.mvc._ | ||
import utils.MetricUtil | ||
|
||
object Compactions extends Controller { | ||
def index = Action { implicit request => | ||
Ok(views.html.compactions.index(MetricUtil.findLongestCompactionInLastWeek())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package utils | ||
|
||
import models.MetricDef | ||
import java.util.Date | ||
|
||
/* | ||
* Copyright 2012 Sentric. See LICENSE for details. | ||
*/ | ||
object MetricUtil { | ||
|
||
def findLongestCompactionInLastWeek(regionName:String) : (Long, Date) = { | ||
findLongestCompactionInLastWeek(MetricDef.COMPACTIONS(regionName)) | ||
} | ||
|
||
def findLongestCompactionInLastWeek(metricDef:MetricDef) : (Long, Date) = { | ||
val metric = metricDef.metric(MetricDef.now()-1000*3600*24*7, MetricDef.now()) | ||
var begin = metric.begin; | ||
var max = 0L; | ||
metric.values.foreach { record => | ||
if(record.v > 0) | ||
begin = record.ts | ||
else | ||
max = scala.math.max(max, record.ts - begin) | ||
} | ||
(max, new Date(begin)) | ||
} | ||
|
||
def findLongestCompactionInLastWeek() : (Long, Date, String) = { | ||
val metrics = MetricDef.findByName(MetricDef.COMPACTIONS) | ||
var result = (0L, new Date(), "") | ||
metrics.foreach { metricDef => | ||
val longest = findLongestCompactionInLastWeek(metricDef) | ||
if(longest._1 > result._1) { | ||
result = (longest._1, longest._2, metricDef.targetDesc) | ||
} | ||
} | ||
result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
@(longestCompaction: (Long, java.util.Date, String))(implicit request: play.api.mvc.Request[Any]) | ||
|
||
@import java.text.DateFormat | ||
|
||
@includes = { | ||
<link rel="stylesheet" media="screen" href='@routes.Assets.at("stylesheets/metric_chart_view.css")'> | ||
<script src='@routes.Assets.at("javascripts/views/common/VisualCountDown.js")' type="text/javascript"></script> | ||
<script src='@routes.Assets.at("javascripts/views/common/MetricChart.js")' type="text/javascript"></script> | ||
<script src='@routes.Assets.at("javascripts/views/compactions/ShowCompactions.js")' type="text/javascript"></script> | ||
<script src='@routes.Assets.at("javascripts/models/Metric.js")' type="text/javascript"></script> | ||
<script src='@routes.Assets.at("javascripts/models/MetricSeries.js")' type="text/javascript"></script> | ||
<script src='@routes.Assets.at("javascripts/main/compactions/show_compactions.js")' type="text/javascript"></script> | ||
} | ||
|
||
@content = { | ||
<div id="show-compactions-view"> | ||
<div class="widget"> | ||
<div class="title">Compactions <span class="refresh-text"></span></div> | ||
<div class="content"> | ||
<ul> | ||
<li>Longest Compaction during last 24 Hours: <span class="longest-compaction">-please wait-</span></li> | ||
<li>Longest Compaction during last 7 Days: <span><b>@(longestCompaction._1/1000.0)s</b> at @(DateFormat.getInstance().format(longestCompaction._2)) on <a href='@routes.Regions.show(longestCompaction._3)'>on Region</a></span></li> | ||
</ul> | ||
</div> | ||
<div> | ||
|
||
</div> | ||
</div> | ||
|
||
<div class="widget"> | ||
<div class="title">History</div> | ||
<div class="content"> | ||
@clusterMetricChart(Seq( | ||
models.MetricDef.COMPACTIONS | ||
)) | ||
</div> | ||
<div class="description"> | ||
<div class="headline"></div> | ||
<div class="body"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
|
||
@clusterMetricChart(metricNames: Seq[String]) = { | ||
<div class="metric-chart-view compaction-metric-chart-view" data-metric-names="@com.codahale.jerkson.Json.generate(metricNames)"> | ||
<div class="x-axis"></div> | ||
<div class="chart"></div> | ||
<div class="legend-container"> | ||
<div class="smoother" title="Smoothing"></div> | ||
<div class="legend"></div> | ||
</div> | ||
<div class="timeline"></div> | ||
<div class="slider"></div> | ||
</div> | ||
} | ||
|
||
@breadcrumbs = { | ||
|
||
} | ||
|
||
@main("Compactions")(content)(includes)(breadcrumbs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters