incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [1/2] git commit: Small fix to stop driving cluster list off of table list
Date Sat, 24 May 2014 19:46:15 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/console-v2 6cdce8ec6 -> d71f322a5


Small fix to stop driving cluster list off of table list


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

Branch: refs/heads/console-v2
Commit: 55ac45bd7f956e3f9f63125b13a31b8cc05b28fe
Parents: 6cdce8e
Author: Chris Rohr <crohr@nearinfinity.com>
Authored: Sat May 24 06:57:27 2014 -0400
Committer: Chris Rohr <crohr@nearinfinity.com>
Committed: Sat May 24 06:57:27 2014 -0400

----------------------------------------------------------------------
 .../blur/console/servlets/TablesServlet.java    |  4 ++-
 .../org/apache/blur/console/util/TableUtil.java |  9 ++++--
 .../src/main/webapp/js/blurconsole.fake.js      |  2 +-
 .../src/main/webapp/js/blurconsole.model.js     | 29 ++++++++++----------
 .../src/main/webapp/js/blurconsole.search.js    | 14 ++++++----
 .../apache/blur/console/util/TableUtilTest.java | 21 +++++++-------
 6 files changed, 45 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/55ac45bd/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/TablesServlet.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/TablesServlet.java
b/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/TablesServlet.java
index 8f9321e..13d8280 100644
--- a/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/TablesServlet.java
+++ b/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/TablesServlet.java
@@ -19,6 +19,7 @@ package org.apache.blur.console.servlets;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -63,8 +64,9 @@ public class TablesServlet extends BaseConsoleServlet {
 		}
 	}
 	
+	@SuppressWarnings("rawtypes")
 	private void sendSummaries(HttpServletResponse response) throws IOException {
-		List<Map<String, Object>> tableSummaries = new ArrayList<Map<String,Object>>();
+		Map<String, List> tableSummaries = new HashMap<String, List>();
 		try {
 			tableSummaries = TableUtil.getTableSummaries();
 		} catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/55ac45bd/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
b/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
index 3aad7f1..4b12308 100644
--- a/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
+++ b/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
@@ -35,7 +35,8 @@ import org.apache.blur.thrift.generated.TableStats;
 
 public class TableUtil {
 	
-	public static List<Map<String, Object>> getTableSummaries() throws IOException,
BlurException, TException {
+	@SuppressWarnings("rawtypes")
+	public static Map<String, List> getTableSummaries() throws IOException, BlurException,
TException {
 		Iface client = BlurClient.getClient(Config.getConnectionString());
 		
 		List<Map<String, Object>> summaries = new ArrayList<Map<String, Object>>();
@@ -69,7 +70,11 @@ public class TableUtil {
 			}
 		}
 		
-		return summaries;
+		Map<String, List> data = new HashMap<String, List>();
+		data.put("tables", summaries);
+		data.put("clusters", clusters);
+		
+		return data;
 	}
 	
 	public static Map<String, Map<String, Map<String, Object>>> getSchema(String
table) throws IOException, BlurException, TException {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/55ac45bd/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js b/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
index 64f2587..1a817e2 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
@@ -38,7 +38,7 @@ blurconsole.fake = (function() {
 		}
 
 		setTimeout(function() {
-			callback(data);
+			callback({'tables':data, 'clusters':clusters});
 		}, randomNumber(1000));
 	};
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/55ac45bd/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 146c548..0420e65 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -25,7 +25,8 @@ blurconsole.model = (function() {
 			poller : null
 		},
 		stateMap = {
-			tableNameMap: null,
+			currentTables: null,
+			currentClusters: [],
 			nodeMap : null,
 			queryPerformance : [],
 			queries : {}
@@ -36,19 +37,17 @@ blurconsole.model = (function() {
 		var getClusters, getEnabledTables, getDisabledTables, isDataLoaded, disableTable, enableTable,
deleteTable, getSchema, findTerms, getAllEnabledTables, getFamilies;
 
 		getClusters = function() {
-			if (stateMap.tableNameMap === null) {
+			if (stateMap.currentClusters === null) {
 				return [];
 			}
 
-			return blurconsole.utils.unique($.map(stateMap.tableNameMap, function(table){
-				return table.cluster;
-			}), true);
+			return blurconsole.utils.unique(stateMap.currentClusters, true);
 		};
 
 		getEnabledTables = function(cluster) {
 			var data = [];
 
-			$.each(stateMap.tableNameMap, function(idx, table) {
+			$.each(stateMap.currentTables, function(idx, table) {
 				if (table.cluster === cluster && table.enabled) {
 					data.push({name:table.name, rowCount:table.rows, recordCount:table.records});
 				}
@@ -60,7 +59,7 @@ blurconsole.model = (function() {
 		getDisabledTables = function(cluster) {
 			var data = [];
 
-			$.each(stateMap.tableNameMap, function(idx, table) {
+			$.each(stateMap.currentTables, function(idx, table) {
 				if (table.cluster === cluster && !table.enabled) {
 					data.push({name:table.name, rowCount:table.rows, recordCount:table.records});
 				}
@@ -80,7 +79,7 @@ blurconsole.model = (function() {
 		};
 
 		isDataLoaded = function() {
-			return stateMap.tableNameMap !== null;
+			return stateMap.currentTables !== null;
 		};
 
 		disableTable = function(tableName) {
@@ -102,7 +101,7 @@ blurconsole.model = (function() {
 		getFamilies = function(tableName) {
 			var table;
 
-			$.each(stateMap.tableNameMap, function(idx, t) {
+			$.each(stateMap.currentTables, function(idx, t) {
 				if (t.name === tableName) {
 					table = t;
 					return false;
@@ -197,7 +196,7 @@ blurconsole.model = (function() {
 		};
 
 		getTableChartData = function() {
-			var enabledData = blurconsole.utils.reduce(stateMap.tableNameMap, [], function(accumulator,
table){
+			var enabledData = blurconsole.utils.reduce(stateMap.currentTables, [], function(accumulator,
table){
 				var currentCluster = $.grep(accumulator, function(item){
 					return item[0] === table.cluster;
 				});
@@ -215,7 +214,7 @@ blurconsole.model = (function() {
 				return accumulator;
 			});
 
-			var disabledData = blurconsole.utils.reduce(stateMap.tableNameMap, [], function(accumulator,
table){
+			var disabledData = blurconsole.utils.reduce(stateMap.currentTables, [], function(accumulator,
table){
 				var currentCluster = $.grep(accumulator, function(item){
 					return item[0] === table.cluster;
 				});
@@ -442,9 +441,11 @@ blurconsole.model = (function() {
 		configMap.poller.getTableList(updateTables);
 	};
 
-	updateTables = function(tables) {
-		if (!blurconsole.utils.equals(tables, stateMap.tableNameMap)) {
-			stateMap.tableNameMap = tables;
+	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');
 		}
 		setTimeout(tablePoller, 5000);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/55ac45bd/contrib/blur-console/src/main/webapp/js/blurconsole.search.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.search.js b/contrib/blur-console/src/main/webapp/js/blurconsole.search.js
index 023d64f..678d334 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.search.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.search.js
@@ -255,12 +255,14 @@ blurconsole.search = (function () {
 		$.each(tableMap, function(cluster, tables) {
 			var optGroupString;
 
-			optGroupString = '<optgroup label="' + cluster + '">';
-			$.each(tables, function(t, table){
-				optGroupString += '<option value="' + table.name + '"' + (table.name === stateMap.$currentTable
? ' selected' : '') + '>' + table.name + '</option>';
-			});
-			optGroupString += '</optgroup>';
-			jqueryMap.$tableField.append(optGroupString);
+			if (tables.length > 0) {
+				optGroupString = '<optgroup label="' + cluster + '">';
+				$.each(tables, function(t, table){
+					optGroupString += '<option value="' + table.name + '"' + (table.name === stateMap.$currentTable
? ' selected' : '') + '>' + table.name + '</option>';
+				});
+				optGroupString += '</optgroup>';
+				jqueryMap.$tableField.append(optGroupString);
+			}
 		});
 
 		jqueryMap.$tableSelectorStatusOption.html('Choose Table');

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/55ac45bd/contrib/blur-console/src/test/java/org/apache/blur/console/util/TableUtilTest.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/test/java/org/apache/blur/console/util/TableUtilTest.java
b/contrib/blur-console/src/test/java/org/apache/blur/console/util/TableUtilTest.java
index 17a3109..e3d580c 100644
--- a/contrib/blur-console/src/test/java/org/apache/blur/console/util/TableUtilTest.java
+++ b/contrib/blur-console/src/test/java/org/apache/blur/console/util/TableUtilTest.java
@@ -47,14 +47,15 @@ public class TableUtilTest extends ConsoleTestBase {
 		}
 	}
 	
+	@SuppressWarnings("rawtypes")
 	@Test
 	public void testGetTableSummariesNoTables() throws BlurException, IOException, TException
{
-		List<Map<String, Object>> summaries = TableUtil.getTableSummaries();
+		Map<String, List> data = TableUtil.getTableSummaries();
 		
-		assertEquals(0, summaries.size());
+		assertEquals(0, data.get("tables").size());
 	}
 	
-	@SuppressWarnings("unchecked")
+	@SuppressWarnings({ "unchecked", "rawtypes" })
 	@Test
 	public void testGetTableSummaries() throws BlurException, TException, IOException {
 		Iface client = BlurClient.getClient(Config.getConnectionString());
@@ -67,13 +68,13 @@ public class TableUtilTest extends ConsoleTestBase {
 		td.setEnabled(true);
 		client.createTable(td);
 		
-		List<Map<String, Object>> summaries = TableUtil.getTableSummaries();
+		Map<String, List> data = TableUtil.getTableSummaries();
 		
-		assertEquals(1, summaries.size());
-		assertEquals(0l, summaries.get(0).get("rows"));
-		assertEquals(0l, summaries.get(0).get("records"));
-		assertEquals("default", summaries.get(0).get("cluster"));
-		assertEquals("tableUnitTable", summaries.get(0).get("name"));
-		assertEquals(0, ((List<String>) summaries.get(0).get("families")).size());
+		assertEquals(1, data.get("tables").size());
+		assertEquals(0l, ((Map<String, Object>) data.get("tables").get(0)).get("rows"));
+		assertEquals(0l, ((Map<String,Object>) data.get("tables").get(0)).get("records"));
+		assertEquals("default", ((Map<String,Object>) data.get("tables").get(0)).get("cluster"));
+		assertEquals("tableUnitTable", ((Map<String,Object>) data.get("tables").get(0)).get("name"));
+		assertEquals(0, ((List<String>) ((Map<String,Object>) data.get("tables").get(0)).get("families")).size());
 	}
 }


Mime
View raw message