Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Merge pull request #85 from mozilla/socket-timeout
Browse files Browse the repository at this point in the history
Socket timeout
  • Loading branch information
jeads committed Feb 13, 2013
2 parents 524d6fc + 37925a5 commit 4b283e1
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 21 deletions.
21 changes: 17 additions & 4 deletions datazilla/model/base.py
Expand Up @@ -12,6 +12,7 @@
import time
import json
import urllib
import socket
import zlib
import MySQLdb

Expand Down Expand Up @@ -382,6 +383,13 @@ def store_pushlogs(
"""

###
#This sets the socket timeout globally for all socket operations.
#Its default setting is None. In production, the /json-pushes
#web service call will occasionally hang on a TCP CLOSE_WAIT state.
###
socket.setdefaulttimeout(120)

# fetch the list of known branches.
branch_list = self.get_branch_list(branch)

Expand All @@ -396,7 +404,6 @@ def store_pushlogs(
"maxhours": hours,
}


for br in branch_list:
self.println(u"Branch: pushlogs for {0}".format(
unicode(br["name"])).encode("UTF-8"),
Expand All @@ -411,12 +418,18 @@ def store_pushlogs(
)
self.println("URL: {0}".format(url), 1)
# fetch the JSON content from the constructed URL.
res = urllib.urlopen(url)
json_data = res.read()

json_data = ''

try:
pushlog_dict = json.loads(json_data)
res = urllib.urlopen(url)
json_data = res.read()

except socket.timeout:
continue

try:
pushlog_dict = json.loads(json_data)
self._insert_branch_pushlogs(br["id"], pushlog_dict)
self.branch_count += 1

Expand Down
7 changes: 7 additions & 0 deletions datazilla/webapp/static/js/b2g_apps/GraphControlsComponent.js
Expand Up @@ -184,6 +184,8 @@ var GraphControlsView = new Class({

this.appContainerSel = '#app_container';

this.defaultBranchOption = 'master';

//series label ids
this.datasetLegendSel = '#su_legend';
this.datasetTestLegendSel = '#su_test_legend';
Expand Down Expand Up @@ -279,6 +281,11 @@ var GraphControlsView = new Class({
addBranch: function(branch){
var optionEl = $('<option></option>');
$(optionEl).attr('value', branch);

if(branch === this.defaultBranchOption){
$(optionEl).attr('selected', 'selected');
}

$(optionEl).text(branch);
$(this.branchSelectMenuSel).append(optionEl);
}
Expand Down
22 changes: 14 additions & 8 deletions datazilla/webapp/static/js/b2g_apps/PerformanceGraphComponent.js
Expand Up @@ -135,6 +135,7 @@ var PerformanceGraphComponent = new Class({
this.data = data;

this.chartData = {};
this.tickDisplayDates = {};

var i = 0;

Expand All @@ -143,8 +144,9 @@ var PerformanceGraphComponent = new Class({
var appName = "";
var timestamp = "";
var formattedTime = "";
var dataLength = data.length;

for(i = 0; i<data.length; i++){
for(i = 0; i<dataLength; i++){

testId = data[i]['test_id'];

Expand All @@ -161,16 +163,15 @@ var PerformanceGraphComponent = new Class({
this.chartData[ testId ][ 'lines' ] = { 'show': true };
this.chartData[ testId ][ 'data' ] = [];
this.chartData[ testId ][ 'full_data' ] = [];

}

timestamp = data[i]['date_run'];

//Don't add x-axis labels to the first and last x-axis values
if((i > 0) && (i < data.length - 1)){
if(!this.tickDisplayDates[ data[i]['test_run_id'] ]){
formattedTime = this.view.convertTimestampToDate(timestamp);
this.tickDisplayDates[ data[i]['test_run_id'] ] = formattedTime;
}
if((i > 0) && (i < dataLength - 1)){
formattedTime = this.view.convertTimestampToDate(timestamp);
this.tickDisplayDates[ i ] = formattedTime;
}

if(!data[i]['formatted_date_run']){
Expand All @@ -181,7 +182,7 @@ var PerformanceGraphComponent = new Class({

//Data for flot
this.chartData[ testId ][ 'data' ].push(
[ data[i]['test_run_id'], data[i]['avg'] ]
[ i, data[i]['avg'] ]
);

//Data for presentation
Expand Down Expand Up @@ -217,7 +218,12 @@ var PerformanceGraphComponent = new Class({
);

if(!this.replicatesInitialized && this.seriesIndexDataMap[seriesIndex]){
this._clickPlot({}, {}, { 'seriesIndex':seriesIndex, 'dataIndex':0 });
//Simulate plot click on first series, last datapoint
this._clickPlot({}, {}, {
'seriesIndex':0,
'dataIndex':this.seriesIndexDataMap[0]['data'].length - 1
});

this.view.resetSeriesLabelBackground(this.chartData);
this.replicatesInitialized = true;
}
Expand Down
2 changes: 1 addition & 1 deletion datazilla/webapp/static/js/b2g_apps/apps-summary-min.js

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions datazilla/webapp/static/js/data_views/Bases.js
Expand Up @@ -127,15 +127,20 @@ var View = new Class({
convertTimestampToDate: function(unixTimestamp, getHMS){

var dateObj = new Date(unixTimestamp * 1000);
var dateString = dateObj.getFullYear() + '-' +
this.padNumber((dateObj.getMonth() + 1), 10, '0') + '-' +
dateObj.getDate();

var year = dateObj.getFullYear();
var month = this.padNumber(dateObj.getMonth() + 1, 10, '0');
var day = this.padNumber(dateObj.getDate(), 10, '0');

var dateString = year + '-' + month + '-' + day;

if(getHMS){
dateString += ' ' +
dateObj.getHours() + ':' +
dateObj.getMinutes() + ':' +
this.padNumber(dateObj.getSeconds(), 10, '0');

var hours = this.padNumber(dateObj.getHours(), 10, '0');
var minutes = this.padNumber(dateObj.getMinutes(), 10, '0');
var seconds = this.padNumber(dateObj.getSeconds(), 10, '0');

dateString += ' ' + hours + ':' + minutes + ':' + seconds;
}

return dateString;
Expand Down
2 changes: 1 addition & 1 deletion datazilla/webapp/templates/apps.summary.html
Expand Up @@ -66,7 +66,7 @@
<div class="ui-widget ui-widget-header ui-corner-all app-graph-container">
<div id="app_perf_wait" class="app-spinner"></div>
<div id="app_perf_data_container" style="display:none;">
<div style="position:absolute; left:-60px; top:10px;" class="su-vertical-text">Average Run Time (milliseconds)</div>
<div style="position:absolute; left:-68px; top:10px;" class="su-vertical-text">Average Run Time (milliseconds)</div>
<div id="app_perf_chart" style="width:905px; height:370px; margin-top:5px; margin-left:35px;"></div>
<div id="app_perf_detail_container" class="ui-widget ui-widget-header ui-corner-all app-detail-graph-container">
<div style="width:180px;" class="app-control-element app-control-small-element">Application:<span id="app_series_application" class="app-data"></span></div>
Expand Down

0 comments on commit 4b283e1

Please sign in to comment.