incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [2/2] git commit: Fixed a bug where polling would stop if a non-200 response was received and added a UI logging module
Date Sat, 24 May 2014 19:46:16 GMT
Fixed a bug where polling would stop if a non-200 response was received and added a UI logging
module


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/d71f322a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/d71f322a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/d71f322a

Branch: refs/heads/console-v2
Commit: d71f322a50f36123b072abb65d896249f5a7f1f6
Parents: 55ac45b
Author: Chris Rohr <crohr@nearinfinity.com>
Authored: Sat May 24 15:46:06 2014 -0400
Committer: Chris Rohr <crohr@nearinfinity.com>
Committed: Sat May 24 15:46:06 2014 -0400

----------------------------------------------------------------------
 contrib/blur-console/src/main/webapp/index.html | 14 ++--
 .../src/main/webapp/js/blurconsole.data.js      | 55 +++++++++----
 .../src/main/webapp/js/blurconsole.logging.js   | 85 ++++++++++++++++++++
 .../src/main/webapp/js/blurconsole.model.js     | 61 ++++++++++----
 .../src/main/webapp/js/blurconsole.shell.js     | 14 ++++
 .../src/main/webapp/sass/blurconsole.shell.scss | 16 ++--
 6 files changed, 200 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d71f322a/contrib/blur-console/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/index.html b/contrib/blur-console/src/main/webapp/index.html
index 5f82068..455671a 100644
--- a/contrib/blur-console/src/main/webapp/index.html
+++ b/contrib/blur-console/src/main/webapp/index.html
@@ -36,7 +36,12 @@ under the License.
     <body>
         <nav class="navbar navbar-inverse navbar-fixed-top">
             <a class="navbar-brand" href="#">Blur Console</a>
-
+            <div class="pull-right">
+                <button type="button" id="view_logging_trigger" class="btn btn-default
btn-sm">
+                    Logs
+                    <span class="badge badge-warning"></span>
+                </button>
+            </div>
         </nav>
         <nav class="side-nav">
             <ul>
@@ -60,16 +65,10 @@ under the License.
         <script src="js/utils/jquery.uriAnchor.js"></script>
         <script src="js/utils/jquery.event.gevent.js"></script>
 
-        <!-- <script src="bower_components/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/affix.js"></script>
-        <script src="bower_components/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/alert.js"></script>
-        <script src="bower_components/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/dropdown.js"></script>
-->
         <script src="libs/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/tooltip.js"></script>
         <script src="libs/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/modal.js"></script>
         <script src="libs/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/transition.js"></script>
-        <!-- <script src="bower_components/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/button.js"></script>
-->
         <script src="libs/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/popover.js"></script>
-        <!-- <script src="bower_components/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/carousel.js"></script>
-        <script src="bower_components/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/scrollspy.js"></script>
-->
         <script src="libs/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/collapse.js"></script>
         <script src="libs/twbs-bootstrap-sass/vendor/assets/javascripts/bootstrap/tab.js"></script>
         <script src="libs/flot/jquery.flot.js"></script>
@@ -81,6 +80,7 @@ under the License.
         <script src="js/blurconsole.utils.js"></script>
         <script src="js/blurconsole.b_utils.js"></script>
         <script src="js/blurconsole.shell.js"></script>
+        <script src="js/blurconsole.logging.js"></script>
         <script src="js/blurconsole.dashboard.js"></script>
         <script src="js/blurconsole.tables.js"></script>
         <script src="js/blurconsole.queries.js"></script>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d71f322a/contrib/blur-console/src/main/webapp/js/blurconsole.data.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.data.js b/contrib/blur-console/src/main/webapp/js/blurconsole.data.js
index 003e791..54a1024 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.data.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.data.js
@@ -20,22 +20,31 @@ under the License.
 /*global blurconsole:false */
 blurconsole.data = (function() {
 	'use strict';
-	var getTableList, getNodeList, getQueryPerformance, getQueries, cancelQuery, disableTable,
enableTable, deleteTable, getSchema, findTerms, sendSearch;
+	var getTableList, getNodeList, getQueryPerformance, getQueries, cancelQuery, disableTable,
enableTable, deleteTable, getSchema, findTerms, sendSearch,
+		logError;
 
 	getTableList = function(callback) {
-		$.getJSON('/service/tables', callback);
+		$.getJSON('/service/tables', callback).fail(function(xhr) {
+			logError(xhr.responseText, xhr.status, 'tables', callback);
+		});
 	};
 
 	getNodeList = function(callback) {
-		$.getJSON('/service/nodes', callback);
+		$.getJSON('/service/nodes', callback).fail(function(xhr) {
+			logError(xhr.responseText, xhr.status, 'tables', callback);
+		});
 	};
 
 	getQueryPerformance = function(callback) {
-		$.getJSON('/service/queries/performance', callback);
+		$.getJSON('/service/queries/performance', callback).fail(function(xhr) {
+			logError(xhr.responseText, xhr.status, 'tables', callback);
+		});
 	};
 
 	getQueries = function(callback) {
-		$.getJSON('/service/queries', callback);
+		$.getJSON('/service/queries', callback).fail(function(xhr) {
+			logError(xhr.responseText, xhr.status, 'tables', callback);
+		});
 	};
 
 	cancelQuery = function(table, uuid) {
@@ -43,24 +52,24 @@ blurconsole.data = (function() {
 			data: {
 				table: table
 			},
-			error: function(xhr, msg) {
-				$.gevent.publish('query-cancel-error', uuid, msg);
+			error: function(xhr) {
+				logError(xhr.responseText, xhr.status, 'tables');
 			}
 		});
 	};
 
 	disableTable = function(table) {
 		$.ajax('/service/tables/' + table + '/disable', {
-			error: function(xhr, msg) {
-				$.gevent.publish('table-disable-error', table, msg);
+			error: function(xhr) {
+				logError(xhr.responseText, xhr.status, 'tables');
 			}
 		});
 	};
 
 	enableTable = function(table) {
 		$.ajax('/service/tables/' + table + '/enable', {
-			error: function(xhr, msg) {
-				$.gevent.publish('table-enable-error', table, msg);
+			error: function(xhr) {
+				logError(xhr.responseText, xhr.status, 'tables');
 			}
 		});
 	};
@@ -70,18 +79,22 @@ blurconsole.data = (function() {
 			data: {
 				includeFiles: includeFiles
 			},
-			error: function(xhr, msg) {
-				$.gevent.publish('table-delete-error', table, msg);
+			error: function(xhr) {
+				logError(xhr.responseText, xhr.status, 'tables');
 			}
 		});
 	};
 
 	getSchema = function(table, callback) {
-		$.getJSON('/service/tables/' + table + '/schema', callback);
+		$.getJSON('/service/tables/' + table + '/schema', callback).fail(function(xhr) {
+			logError(xhr.responseText, xhr.status, 'tables');
+		});
 	};
 
 	findTerms = function(table, family, column, startsWith, callback) {
-		$.getJSON('/service/tables/' + table + '/' + family + '/' + column + '/terms', {startsWith:
startsWith}, callback);
+		$.getJSON('/service/tables/' + table + '/' + family + '/' + column + '/terms', {startsWith:
startsWith}, callback).fail(function(xhr) {
+			logError(xhr.responseText, xhr.status, 'tables');
+		});
 	};
 
 	sendSearch = function(query, table, args, callback) {
@@ -89,10 +102,20 @@ blurconsole.data = (function() {
 		$.ajax('/service/search', {
 			'type': 'POST',
 			'data': params,
-			'success': callback
+			'success': callback,
+			'error': function(xhr) {
+				logError(xhr.responseText, xhr.status, 'tables');
+			}
 		});
 	};
 
+	logError = function(errorMsg, status, module, callback) {
+		blurconsole.model.logs.logError(status + ' - ' + errorMsg, module);
+		if (callback) {
+			callback('error');
+		}
+	};
+
 	return {
 		getTableList : getTableList,
 		getNodeList : getNodeList,

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d71f322a/contrib/blur-console/src/main/webapp/js/blurconsole.logging.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.logging.js b/contrib/blur-console/src/main/webapp/js/blurconsole.logging.js
new file mode 100644
index 0000000..00afb8f
--- /dev/null
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.logging.js
@@ -0,0 +1,85 @@
+/*
+
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+/*global blurconsole:false */
+blurconsole.logging = (function () {
+	'use strict';
+	var configMap = {
+		emptyLogMsg: 'No Errors! Yay!',
+		mainHtml: '<div class="log_display"></div>',
+		buttons: [
+			{ 'classes': 'btn-default', 'id': 'clear-log-button', 'label': 'Clear Logs' },
+			{ 'classes': 'btn-primary', 'id': 'close-logs', 'label': 'Close', 'data': {'dismiss':'modal'}
}
+		]
+	},
+	jqueryMap = {
+		modal: null
+	},
+	initModule, showLogging, clearLogging, drawLogs;
+
+	initModule = function() {
+		$.gevent.subscribe($(document), 'show-logging', showLogging);
+		$.gevent.subscribe($(document), 'logging-updated', drawLogs);
+	};
+
+	showLogging = function() {
+		if (jqueryMap.modal === null) {
+			jqueryMap.modal = $(blurconsole.browserUtils.modal('error_log_modal', 'Error Logs', configMap.mainHtml,
configMap.buttons, 'large'));
+			jqueryMap.modal.modal()
+			.on('shown.bs.modal', function(){
+				jqueryMap.logHolder = $('.log_display', jqueryMap.modal);
+				console.log(jqueryMap.logHolder);
+				drawLogs();
+			})
+			.on('click', '#clear-log-button', clearLogging);
+		} else {
+			jqueryMap.modal.modal('show');
+		}
+	};
+
+	clearLogging = function() {
+		jqueryMap.logHolder.html(configMap.emptyLogMsg);
+		blurconsole.model.logs.clearErrors();
+	};
+
+	drawLogs = function() {
+		var errors = blurconsole.model.logs.getLogs();
+
+		if (jqueryMap.logHolder) {
+			if (errors.length === 0) {
+				jqueryMap.logHolder.html(configMap.emptyLogMsg);
+			} else {
+				var errorList = '<ul>';
+				errors.sort(function(a, b) {
+					return a.timestamp.getTime() > b.timestamp.getTime();
+				});
+				$.each(errors, function(i, error){
+					errorList += '<li><strong>' + error.error + ' (' + error.module + ')</strong><div
class="pull-right"><em>' + error.timestamp.toTimeString() + '</em></div></li>';
+				});
+				errorList += '</ul>';
+				jqueryMap.logHolder.html(errorList);
+			}
+		}
+	};
+
+	return {
+		initModule : initModule
+	};
+}());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d71f322a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js b/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
index 0420e65..9e8fc41 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -29,9 +29,10 @@ blurconsole.model = (function() {
 			currentClusters: [],
 			nodeMap : null,
 			queryPerformance : [],
-			queries : {}
+			queries : {},
+			errors: []
 		},
-		tables, metrics, nodes, queries, search, initModule, nodePoller, updateNodes, tablePoller,
updateTables, queryPerformancePoller, updateQueryPerformance, queryPoller, updateQueries;
+		tables, metrics, nodes, queries, search, logs, initModule, nodePoller, updateNodes, tablePoller,
updateTables, queryPerformancePoller, updateQueryPerformance, queryPoller, updateQueries;
 
 	tables = (function() {
 		var getClusters, getEnabledTables, getDisabledTables, isDataLoaded, disableTable, enableTable,
deleteTable, getSchema, findTerms, getAllEnabledTables, getFamilies;
@@ -425,12 +426,37 @@ blurconsole.model = (function() {
 		};
 	}());
 
+	logs = (function() {
+		var logError, clearErrors, getLogs;
+
+		logError = function(error, module) {
+			stateMap.errors.push({error: error, module: module, timestamp: new Date()});
+			$.gevent.publish('logging-updated');
+		};
+
+		clearErrors = function() {
+			delete stateMap.errors;
+			stateMap.errors = [];
+			$.gevent.publish('logging-updated');
+		};
+
+		getLogs = function() {
+			return stateMap.errors;
+		};
+
+		return {
+			logError: logError,
+			clearErrors: clearErrors,
+			getLogs: getLogs
+		};
+	}());
+
 	nodePoller = function() {
 		configMap.poller.getNodeList(updateNodes);
 	};
 
 	updateNodes = function(nodes) {
-		if (!blurconsole.utils.equals(nodes, stateMap.nodeMap)) {
+		if (nodes !== 'error' && !blurconsole.utils.equals(nodes, stateMap.nodeMap)) {
 			stateMap.nodeMap = nodes;
 			$.gevent.publish('node-status-updated');
 		}
@@ -442,11 +468,13 @@ blurconsole.model = (function() {
 	};
 
 	updateTables = function(data) {
-		var tables = data.tables, clusters = data.clusters;
-		if (!blurconsole.utils.equals(tables, stateMap.currentTables) || !blurconsole.utils.equals(clusters,
stateMap.currentClusters)) {
-			stateMap.currentTables = tables;
-			stateMap.currentClusters = clusters;
-			$.gevent.publish('tables-updated');
+		if (data !== 'error') {
+			var tables = data.tables, clusters = data.clusters;
+			if (!blurconsole.utils.equals(tables, stateMap.currentTables) || !blurconsole.utils.equals(clusters,
stateMap.currentClusters)) {
+				stateMap.currentTables = tables;
+				stateMap.currentClusters = clusters;
+				$.gevent.publish('tables-updated');
+			}
 		}
 		setTimeout(tablePoller, 5000);
 	};
@@ -456,12 +484,14 @@ blurconsole.model = (function() {
 	};
 
 	updateQueryPerformance = function(performanceMetric) {
-		if (stateMap.queryPerformance.length === 100) {
-			stateMap.queryPerformance.shift();
-		}
+		if (performanceMetric !== 'error') {
+			if (stateMap.queryPerformance.length === 100) {
+				stateMap.queryPerformance.shift();
+			}
 
-		stateMap.queryPerformance.push(performanceMetric);
-		$.gevent.publish('query-perf-updated');
+			stateMap.queryPerformance.push(performanceMetric);
+			$.gevent.publish('query-perf-updated');
+		}
 		setTimeout(queryPerformancePoller, 5000);
 	};
 
@@ -470,7 +500,7 @@ blurconsole.model = (function() {
 	};
 
 	updateQueries = function(queries) {
-		if (!blurconsole.utils.equals(queries, stateMap.queries)) {
+		if (queries !== 'error' && !blurconsole.utils.equals(queries, stateMap.queries))
{
 			stateMap.queries = queries;
 			$.gevent.publish('queries-updated');
 		}
@@ -492,6 +522,7 @@ blurconsole.model = (function() {
 		metrics: metrics,
 		nodes : nodes,
 		queries : queries,
-		search : search
+		search : search,
+		logs: logs
 	};
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d71f322a/contrib/blur-console/src/main/webapp/js/blurconsole.shell.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.shell.js b/contrib/blur-console/src/main/webapp/js/blurconsole.shell.js
index ee19283..ba0572a 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.shell.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.shell.js
@@ -153,6 +153,11 @@ blurconsole.shell = (function () {
 		setJqueryMap();
 
 		blurconsole.schema.initModule();
+		blurconsole.logging.initModule();
+
+		$('#view_logging_trigger').on('click', function() {
+			$.gevent.publish('show-logging');
+		});
 
 		$('.side-nav li').tooltip();
 
@@ -171,6 +176,15 @@ blurconsole.shell = (function () {
 				tab: configMap.defaultTab
 			});
 		}
+
+		$.gevent.subscribe($(document), 'logging-updated', function() {
+			var errors = blurconsole.model.logs.getLogs();
+			if (errors.length === 0) {
+				$('#view_logging_trigger .badge').html('');
+			} else {
+				$('#view_logging_trigger .badge').html(errors.length);
+			}
+		});
 	};
 
 	return {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d71f322a/contrib/blur-console/src/main/webapp/sass/blurconsole.shell.scss
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/sass/blurconsole.shell.scss b/contrib/blur-console/src/main/webapp/sass/blurconsole.shell.scss
index a258fa4..be169ef 100644
--- a/contrib/blur-console/src/main/webapp/sass/blurconsole.shell.scss
+++ b/contrib/blur-console/src/main/webapp/sass/blurconsole.shell.scss
@@ -18,13 +18,6 @@ specific language governing permissions and limitations
 under the License.
  */
 
-.browsehappy {
-    margin: 0.2em 0;
-    background: $silver;
-    color: $black;
-    padding: 0.2em 0;
-}
-
 .input-group-btn > .btn {
   height: $input-height-base;
 }
@@ -40,6 +33,10 @@ nav.navbar-fixed-top {
     .navbar-brand {
         color: $white;
     }
+    #view_logging_trigger {
+        margin-right: 20px;
+        margin-top: 14px;
+    }
 }
 
 /* Side Navigation */
@@ -72,4 +69,9 @@ nav.navbar-fixed-top {
             }
         }
     }
+}
+
+#error_log_modal .modal-body {
+    height: 400px;
+    overflow: auto;
 }
\ No newline at end of file


Mime
View raw message