incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [27/53] [partial] Initial commit of console v2. Sorry for the large commit
Date Mon, 17 Feb 2014 16:07:03 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/hdfs/HdfsCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/hdfs/HdfsCollector.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/hdfs/HdfsCollector.java
new file mode 100644
index 0000000..431c796
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/hdfs/HdfsCollector.java
@@ -0,0 +1,79 @@
+package org.apache.blur.agent.collectors.hdfs;
+
+/**
+ * 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.
+ */
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.apache.blur.agent.Agent;
+import org.apache.blur.agent.connections.hdfs.interfaces.HdfsDatabaseInterface;
+import org.apache.blur.agent.exceptions.HdfsThreadException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class HdfsCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(HdfsCollector.class);
+
+	private final URI defaultUri;
+	private final String hdfsName;
+	private final String user;
+	private final HdfsDatabaseInterface databaseConnection;
+	private final boolean collectHdfs;
+
+	public HdfsCollector(final String hdfsName, final String defaultUri, final String thriftUri, final String user,
+			final List<String> activeCollectors, final HdfsDatabaseInterface databaseConnection) throws HdfsThreadException {
+		try {
+			this.defaultUri = new URI(defaultUri);
+			this.hdfsName = hdfsName;
+			this.user = user;
+			this.databaseConnection = databaseConnection;
+			this.collectHdfs = activeCollectors.contains("hdfs");
+
+			initializeHdfs(hdfsName, thriftUri);
+
+		} catch (URISyntaxException e) {
+			log.error(e.getMessage(), e);
+			throw new HdfsThreadException();
+		} catch (Exception e) {
+			log.error("An unkown error occured while creating the collector.", e);
+			throw new HdfsThreadException();
+		}
+	}
+
+	@Override
+	public void run() {
+		while (true) {
+			if (this.collectHdfs) {
+				new Thread(new HdfsStatsCollector(this.hdfsName, defaultUri, this.user, this.databaseConnection), "Hdfs Collector - "
+						+ this.hdfsName).start();
+			}
+
+			try {
+				Thread.sleep(Agent.COLLECTOR_SLEEP_TIME);
+			} catch (InterruptedException e) {
+				break;
+			}
+		}
+	}
+
+	private void initializeHdfs(String name, String thriftUri) throws URISyntaxException {
+		URI parsedThriftUri = new URI(thriftUri);
+		this.databaseConnection.setHdfsInfo(name, parsedThriftUri.getHost(), parsedThriftUri.getPort());
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/hdfs/HdfsStatsCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/hdfs/HdfsStatsCollector.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/hdfs/HdfsStatsCollector.java
new file mode 100644
index 0000000..2214ddf
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/hdfs/HdfsStatsCollector.java
@@ -0,0 +1,110 @@
+package org.apache.blur.agent.collectors.hdfs;
+
+/**
+ * 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.
+ */
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.blur.agent.connections.hdfs.interfaces.HdfsDatabaseInterface;
+import org.apache.blur.agent.exceptions.NullReturnedException;
+import org.apache.blur.agent.types.TimeHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.FSConstants.DatanodeReportType;
+import org.springframework.dao.DataAccessException;
+
+
+public class HdfsStatsCollector implements Runnable {
+	private final static Log log = LogFactory.getLog(HdfsStatsCollector.class);
+
+	private final String hdfsName;
+	private final URI uri;
+	private final String host;
+	private final int port;
+	private final String user;
+	private final HdfsDatabaseInterface database;
+
+	public HdfsStatsCollector(final String hdfsName, final URI uri, final String user, final HdfsDatabaseInterface database) {
+		this.uri = uri;
+		this.host = uri.getHost();
+		this.port = uri.getPort();
+		this.hdfsName = hdfsName;
+		this.user = user;
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			int hdfsId = this.database.getHdfsId(this.hdfsName);
+			if (hdfsId == -1) {
+				log.error("The HDFS [" + this.hdfsName + "] does not exist in the database");
+				return;
+			}
+
+			// Creates a filesystem connection (if a user is given
+			// then the filesystem can get additional information)
+			FileSystem fileSystem = (this.user != null) ? FileSystem.get(this.uri, new Configuration(), this.user) : FileSystem.get(this.uri,
+					new Configuration());
+
+			if (fileSystem instanceof DistributedFileSystem) {
+				DistributedFileSystem dfs = (DistributedFileSystem) fileSystem;
+
+				// TODO: Need to figure out how to do hadoop version check for this information.
+				//FsStatus ds = dfs.getStatus();
+				long capacity = dfs.getRawCapacity();//ds.getCapacity();
+				long used = dfs.getRawUsed();//ds.getUsed();
+				long logical_used = used / dfs.getDefaultReplication();
+				long remaining = capacity - used; //ds.getRemaining();
+				long presentCapacity = used + remaining;
+
+				long liveNodes = -1;
+				long deadNodes = -1;
+				long totalNodes = -1;
+
+				try {
+					DatanodeInfo[] live = dfs.getClient().datanodeReport(DatanodeReportType.LIVE);
+					DatanodeInfo[] dead = dfs.getClient().datanodeReport(DatanodeReportType.DEAD);
+
+					liveNodes = live.length;
+					deadNodes = dead.length;
+					totalNodes = liveNodes + deadNodes;
+				} catch (Exception e) {
+					log.warn("Access denied for user. Skipping node information.");
+				}
+
+				this.database.insertHdfsStats(capacity, presentCapacity, remaining, used, logical_used, (((1.0 * used) / presentCapacity) * 100),
+						dfs.getUnderReplicatedBlocksCount(), dfs.getCorruptBlocksCount(), dfs.getMissingBlocksCount(), totalNodes, liveNodes,
+						deadNodes, TimeHelper.now().getTime(), host, port, hdfsId);
+
+				dfs.close();
+			}
+		} catch (IOException e) {
+			log.error("An IO error occurred while communicating with the DFS.", e);
+		} catch (DataAccessException e) {
+			log.error("An error occurred while writing the HDFSStats to the DB.", e);
+		} catch (NullReturnedException e) {
+			log.error(e.getMessage(), e);
+		} catch (Exception e) {
+			log.error("An unknown error occurred in the CollectorManager.", e);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ClusterCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ClusterCollector.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ClusterCollector.java
new file mode 100644
index 0000000..66299ef
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ClusterCollector.java
@@ -0,0 +1,87 @@
+package org.apache.blur.agent.collectors.zookeeper;
+
+/**
+ * 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.
+ */
+import java.util.List;
+
+import org.apache.blur.agent.connections.zookeeper.interfaces.ClusterDatabaseInterface;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.data.Stat;
+
+
+public class ClusterCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(ClusterCollector.class);
+
+	private final int zookeeperId;
+	private final ZooKeeper zookeeper;
+	private final ClusterDatabaseInterface database;
+
+	public ClusterCollector(int zookeeperId, ZooKeeper zookeeper, ClusterDatabaseInterface database) {
+		this.zookeeperId = zookeeperId;
+		this.zookeeper = zookeeper;
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		List<String> onlineClusters;
+		try {
+			onlineClusters = zookeeper.getChildren("/blur/clusters", false);
+		} catch (Exception e) {
+			log.error("Error getting clusters from zookeeper in ClusterCollector.", e);
+			return;
+		}
+
+		for (String cluster : onlineClusters) {
+			try {
+				boolean safeMode = isClusterInSafeMode(cluster);
+				int clusterId = this.database.insertOrUpdateCluster(safeMode, cluster, zookeeperId);
+
+				new Thread(new ShardCollector(clusterId, cluster, this.zookeeper, this.database), "Shard Collector - " + cluster).start();
+				new Thread(new TableCollector(clusterId, cluster, this.zookeeper, this.database), "Table Collector - " + cluster).start();
+			} catch (KeeperException e) {
+				log.error("Error talking to zookeeper in ClusterCollector.", e);
+			} catch (InterruptedException e) {
+				log.error("Zookeeper session expired in ClusterCollector.", e);
+			}
+		}
+
+	}
+
+	private boolean isClusterInSafeMode(String cluster) throws KeeperException, InterruptedException {
+		String blurSafemodePath = "/blur/clusters/" + cluster + "/safemode";
+		Stat stat = this.zookeeper.exists(blurSafemodePath, false);
+		if (stat == null) {
+			return false;
+		}
+
+		byte[] data = this.zookeeper.getData(blurSafemodePath, false, stat);
+		if (data == null) {
+			return false;
+		}
+
+		long timestamp = Long.parseLong(new String(data));
+		long waitTime = timestamp - System.currentTimeMillis();
+		if (waitTime > 0) {
+			return true;
+		}
+		return false;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ControllerCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ControllerCollector.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ControllerCollector.java
new file mode 100644
index 0000000..9a99b98
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ControllerCollector.java
@@ -0,0 +1,71 @@
+package org.apache.blur.agent.collectors.zookeeper;
+
+/**
+ * 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.
+ */
+import java.util.List;
+
+import org.apache.blur.agent.connections.zookeeper.interfaces.ControllerDatabaseInterface;
+import org.apache.blur.agent.notifications.Notifier;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooKeeper;
+
+
+public class ControllerCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(ControllerCollector.class);
+
+	private final int zookeeperId;
+	private final ZooKeeper zookeeper;
+	private final ControllerDatabaseInterface database;
+
+	public ControllerCollector(int zookeeperId, ZooKeeper zookeeper, ControllerDatabaseInterface database) {
+		this.zookeeperId = zookeeperId;
+		this.zookeeper = zookeeper;
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			List<String> onlineControllers = this.zookeeper.getChildren("/blur/online-controller-nodes", false);
+			int recentlyOffline = this.database.markOfflineControllers(onlineControllers, this.zookeeperId);
+			if (recentlyOffline > 0) {
+				Notifier.getNotifier().notifyControllerOffline(this.database.getRecentOfflineControllerNames(recentlyOffline));
+			}
+			updateOnlineControllers(onlineControllers);
+		} catch (KeeperException e) {
+			log.error("Error talking to zookeeper in ControllerCollector.", e);
+		} catch (InterruptedException e) {
+			log.error("Zookeeper session expired in ControllerCollector.", e);
+		}
+
+	}
+
+	private void updateOnlineControllers(List<String> controllers) throws KeeperException, InterruptedException {
+		for (String controller : controllers) {
+			String blurVersion = "UNKNOWN";
+
+			byte[] b = this.zookeeper.getData("/blur/online-controller-nodes/" + controller, false, null);
+			if (b != null && b.length > 0) {
+				blurVersion = new String(b);
+			}
+
+			this.database.updateOnlineController(controller, zookeeperId, blurVersion);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ShardCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ShardCollector.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ShardCollector.java
new file mode 100644
index 0000000..0b4ba5d
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ShardCollector.java
@@ -0,0 +1,72 @@
+package org.apache.blur.agent.collectors.zookeeper;
+
+/**
+ * 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.
+ */
+import java.util.List;
+
+import org.apache.blur.agent.connections.zookeeper.interfaces.ShardsDatabaseInterface;
+import org.apache.blur.agent.notifications.Notifier;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooKeeper;
+
+
+public class ShardCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(ShardCollector.class);
+
+	private final int clusterId;
+	private final String clusterName;
+	private final ZooKeeper zookeeper;
+	private final ShardsDatabaseInterface database;
+
+	public ShardCollector(int clusterId, String clusterName, ZooKeeper zookeeper, ShardsDatabaseInterface database) {
+		this.clusterId = clusterId;
+		this.clusterName = clusterName;
+		this.zookeeper = zookeeper;
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			List<String> shards = this.zookeeper.getChildren("/blur/clusters/" + clusterName + "/online-nodes", false);
+			int recentlyOffline = this.database.markOfflineShards(shards, this.clusterId);
+			if (recentlyOffline > 0) {
+				Notifier.getNotifier().notifyShardOffline(this.database.getRecentOfflineShardNames(recentlyOffline));
+			}
+			updateOnlineShards(shards);
+		} catch (KeeperException e) {
+			log.error("Error talking to zookeeper in ShardCollector.", e);
+		} catch (InterruptedException e) {
+			log.error("Zookeeper session expired in ShardCollector.", e);
+		}
+	}
+
+	private void updateOnlineShards(List<String> shards) throws KeeperException, InterruptedException {
+		for (String shard : shards) {
+			String blurVersion = "UNKNOWN";
+
+			byte[] b = this.zookeeper.getData("/blur/clusters/" + clusterName + "/online-nodes/" + shard, false, null);
+			if (b != null && b.length > 0) {
+				blurVersion = new String(b);
+			}
+
+			this.database.updateOnlineShard(shard, this.clusterId, blurVersion);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/TableCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/TableCollector.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/TableCollector.java
new file mode 100644
index 0000000..42db6b4
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/TableCollector.java
@@ -0,0 +1,66 @@
+package org.apache.blur.agent.collectors.zookeeper;
+
+/**
+ * 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.
+ */
+import java.util.List;
+
+import org.apache.blur.agent.connections.zookeeper.interfaces.TableDatabaseInterface;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooKeeper;
+
+
+public class TableCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(TableCollector.class);
+
+	private final int clusterId;
+	private final String clusterName;
+	private final ZooKeeper zookeeper;
+	private final TableDatabaseInterface database;
+
+	public TableCollector(int clusterId, String clusterName, ZooKeeper zookeeper, TableDatabaseInterface database) {
+		this.clusterId = clusterId;
+		this.clusterName = clusterName;
+		this.zookeeper = zookeeper;
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			List<String> tables = this.zookeeper.getChildren("/blur/clusters/" + clusterName + "/tables", false);
+			this.database.markDeletedTables(tables, this.clusterId);
+			updateOnlineTables(tables);
+		} catch (KeeperException e) {
+			log.error("Error talking to zookeeper in TableCollector.", e);
+		} catch (InterruptedException e) {
+			log.error("Zookeeper session expired in TableCollector.", e);
+		}
+	}
+
+	private void updateOnlineTables(List<String> tables) throws KeeperException, InterruptedException {
+		for (String table : tables) {
+			String tablePath = "/blur/clusters/" + clusterName + "/tables/" + table;
+
+			String uri = new String(this.zookeeper.getData(tablePath + "/uri", false, null));
+			boolean enabled = this.zookeeper.getChildren(tablePath, false).contains("enabled");
+
+			this.database.updateOnlineTable(table, this.clusterId, uri, enabled);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ZookeeperCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ZookeeperCollector.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ZookeeperCollector.java
new file mode 100644
index 0000000..666dad5
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/collectors/zookeeper/ZookeeperCollector.java
@@ -0,0 +1,161 @@
+package org.apache.blur.agent.collectors.zookeeper;
+
+/**
+ * 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.
+ */
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.URI;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.blur.agent.Agent;
+import org.apache.blur.agent.connections.zookeeper.interfaces.ZookeeperDatabaseInterface;
+import org.apache.blur.agent.notifications.Notifier;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.Watcher.Event.KeeperState;
+import org.apache.zookeeper.ZooKeeper;
+import org.codehaus.jackson.map.ObjectMapper;
+
+
+public class ZookeeperCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(ZookeeperCollector.class);
+
+	private ZooKeeper zookeeper;
+	private boolean connected;
+
+	private final String url;
+	private final String name;
+	private final int id;
+	private final ZookeeperDatabaseInterface database;
+
+	public ZookeeperCollector(String url, String name, String blurConnection, ZookeeperDatabaseInterface database) {
+		this.url = url;
+		this.name = name;
+		this.database = database;
+		this.id = database.insertOrUpdateZookeeper(name, url, blurConnection);
+	}
+
+	@Override
+	public void run() {
+		while (true) {
+			try {
+				if (!this.connected) {
+					this.zookeeper = new ZooKeeper(this.url, 3000, new Watcher() {
+						@Override
+						public void process(WatchedEvent event) {
+							KeeperState state = event.getState();
+							if (state == KeeperState.Disconnected || state == KeeperState.Expired) {
+								log.warn("Zookeeper [" + name + "] disconnected event.");
+								database.setZookeeperOffline(id);
+								Notifier.getNotifier().notifyZookeeperOffline(name);
+								connected = false;
+							} else if (state == KeeperState.SyncConnected) {
+								log.info("Zookeeper [" + name + "] session established.");
+								connected = true;
+							}
+						}
+					});
+				}
+			} catch (IOException e) {
+				log.error("A zookeeper [" + this.name + "] connection could not be created, waiting 30 seconds.");
+				// Sleep the thread for 30secs to give the Zookeeper a chance to become
+				// available.
+				try {
+					Thread.sleep(30000);
+					continue;
+				} catch (InterruptedException ex) {
+					log.info("Exiting Zookeeper [" + this.name + "] instance");
+					return;
+				}
+			}
+
+			if (this.connected) {
+				new Thread(new ControllerCollector(this.id, this.zookeeper, this.database), "Controller Collector - " + this.name).start();
+				new Thread(new ClusterCollector(this.id, this.zookeeper, this.database), "Cluster Collector - " + this.name).start();
+			}
+
+			testEnsembleHealth();
+
+			try {
+				Thread.sleep(Agent.COLLECTOR_SLEEP_TIME);
+			} catch (InterruptedException e) {
+				log.info("Exiting Zookeeper [" + this.name + "] instance");
+				return;
+			}
+		}
+	}
+
+	private void testEnsembleHealth() {
+		String[] connections = this.url.split(",");
+		List<String> onlineZookeepers = new ArrayList<String>();
+		for (String connection : connections) {
+			try {
+				URI parsedConnection = new URI("my://" + connection);
+				String host = parsedConnection.getHost();
+				int port = parsedConnection.getPort() >= 0 ? parsedConnection.getPort() : 2181;
+				byte[] reqBytes = new byte[4];
+				ByteBuffer req = ByteBuffer.wrap(reqBytes);
+				req.putInt(ByteBuffer.wrap("ruok".getBytes()).getInt());
+				Socket socket = new Socket();
+				socket.setSoLinger(false, 10);
+				socket.setSoTimeout(20000);
+				parsedConnection.getPort();
+				socket.connect(new InetSocketAddress(host, port));
+
+				InputStream response = socket.getInputStream();
+				OutputStream question = socket.getOutputStream();
+
+				question.write(reqBytes);
+
+				byte[] resBytes = new byte[4];
+
+				response.read(resBytes);
+				String status = new String(resBytes);
+				if (status.equals("imok")) {
+					onlineZookeepers.add(connection);
+				}
+				socket.close();
+				response.close();
+				question.close();
+			} catch (Exception e) {
+				log.error("A connection to " + connection + " could not be made.", e);
+			}
+		}
+		try {
+			if (connections.length == onlineZookeepers.size()){
+				this.database.setZookeeperOnline(id);
+			} else if (connections.length < onlineZookeepers.size() * 2) {
+				this.database.setZookeeperWarning(this.id);
+			} else if (this.connected){
+				this.database.setZookeeperFailure(this.id);
+			} else {
+				this.database.setZookeeperOffline(this.id);
+			}
+			this.database.setOnlineEnsembleNodes(new ObjectMapper().writeValueAsString(onlineZookeepers), this.id);
+		} catch (Exception e) {
+			log.error("The online ensemble nodes array could not be created, writing that they are all offline!");
+			this.database.setOnlineEnsembleNodes("{}", this.id);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/JdbcConnection.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/JdbcConnection.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/JdbcConnection.java
new file mode 100644
index 0000000..01c6f24
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/JdbcConnection.java
@@ -0,0 +1,42 @@
+package org.apache.blur.agent.connections;
+
+/**
+ * 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.
+ */
+import java.util.Properties;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+public class JdbcConnection {
+	public static JdbcTemplate createDBConnection(Properties props) {
+		String url = props.getProperty("store.url");
+		BasicDataSource dataSource = new BasicDataSource();
+		dataSource.setDriverClassName("com.mysql.jdbc.Driver");
+		dataSource.setUrl(url);
+		dataSource.setUsername(props.getProperty("store.user"));
+		dataSource.setPassword(props.getProperty("store.password"));
+		dataSource.setMaxActive(80);
+		dataSource.setMinIdle(2);
+		dataSource.setMaxWait(10000);
+		dataSource.setMaxIdle(-1);
+		dataSource.setRemoveAbandoned(true);
+		dataSource.setRemoveAbandonedTimeout(60);
+		dataSource.setDefaultAutoCommit(true);
+
+		return new JdbcTemplate(dataSource);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/BlurDatabaseConnection.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/BlurDatabaseConnection.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/BlurDatabaseConnection.java
new file mode 100644
index 0000000..73082d4
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/BlurDatabaseConnection.java
@@ -0,0 +1,165 @@
+package org.apache.blur.agent.connections.blur;
+
+/**
+ * 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.
+ */
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.blur.agent.connections.blur.interfaces.BlurDatabaseInterface;
+import org.apache.blur.agent.exceptions.TableCollisionException;
+import org.apache.blur.agent.exceptions.TableMissingException;
+import org.apache.blur.agent.exceptions.ZookeeperNameCollisionException;
+import org.apache.blur.agent.exceptions.ZookeeperNameMissingException;
+import org.apache.blur.agent.types.TimeHelper;
+import org.apache.blur.thrift.generated.BlurQueryStatus;
+import org.apache.blur.thrift.generated.Query;
+import org.apache.commons.lang.StringUtils;
+import org.json.simple.JSONValue;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+
+public class BlurDatabaseConnection implements BlurDatabaseInterface {
+
+	private final JdbcTemplate jdbc;
+
+	public BlurDatabaseConnection(JdbcTemplate jdbc) {
+		this.jdbc = jdbc;
+	}
+
+	@Override
+	public String resolveConnectionString(int zookeeperId) {
+		String queryString = "select distinct node_name from blur_controllers where zookeeper_id = ? and controller_status = 1";
+		List<String> controller_uris = jdbc.queryForList(queryString, new String[] { Integer.toString(zookeeperId) }, String.class);
+		String connection = StringUtils.join(controller_uris, ',');
+		this.jdbc.update("update zookeepers set blur_urls=? where id = ?", connection, zookeeperId);
+		return connection;
+	}
+
+	@Override
+	public String getZookeeperId(final String zookeeperName) throws ZookeeperNameMissingException, ZookeeperNameCollisionException {
+		List<Map<String, Object>> zookeepers = jdbc.queryForList("select id from zookeepers where name = ?", zookeeperName);
+		switch (zookeepers.size()) {
+		case 0:
+			throw new ZookeeperNameMissingException(zookeeperName);
+		case 1:
+			return zookeepers.get(0).get("ID").toString();
+		default:
+			throw new ZookeeperNameCollisionException(zookeepers.size(), zookeeperName);
+		}
+	}
+
+	@Override
+	public List<Map<String, Object>> getClusters(final int zookeeperId) {
+		return jdbc.queryForList("select id, name from clusters where zookeeper_id = ?", zookeeperId);
+	}
+
+	@Override
+	public Map<String, Object> getExistingTable(final String table, final Integer clusterId) throws TableMissingException,
+			TableCollisionException {
+		List<Map<String, Object>> existingTable = jdbc.queryForList(
+				"select id, cluster_id from blur_tables where table_name=? and cluster_id=?", table, clusterId);
+		switch (existingTable.size()) {
+		case 0:
+			throw new TableMissingException(table);
+		case 1:
+			return existingTable.get(0);
+		default:
+			throw new TableCollisionException(existingTable.size(), table);
+		}
+	}
+
+	@Override
+	public int getTableId(int clusterId, String tableName) {
+		try {
+			return jdbc.queryForInt("select id from blur_tables where cluster_id=? and table_name =?", clusterId, tableName);
+		} catch (IncorrectResultSizeDataAccessException e) {
+			return -1;
+		}
+	}
+
+	@Override
+	public void updateTableSchema(final int tableId, final String schema, final String tableAnalyzer) {
+		jdbc.update("update blur_tables set table_schema=?, table_analyzer=? where id=?", new Object[] { schema, tableAnalyzer, tableId });
+	}
+
+	@Override
+	public void updateTableServer(final int tableId, String server) {
+		jdbc.update("update blur_tables set server=? where id=?", new Object[] { server, tableId });
+	}
+
+	@Override
+	public void updateTableStats(final int tableId, Long tableBytes, Long tableRecordCount, Long tableRowCount) {
+		jdbc.update("update blur_tables set current_size=?, record_count=?, row_count=? where id=?", new Object[] { tableBytes,
+				tableRecordCount, tableRowCount, tableId });
+	}
+
+	public Map<String, Object> getQuery(int tableId, String UUID) {
+		try {
+			return this.jdbc.queryForMap("select id, complete_shards, times, state from blur_queries where blur_table_id=? and uuid=?", tableId,
+					UUID);
+		} catch (IncorrectResultSizeDataAccessException e) {
+			return null;
+		}
+	}
+
+	public void createQuery(BlurQueryStatus status, Query query, String times, Date startTime, int tableId) {
+		this.jdbc
+				.update(
+						"insert into blur_queries (query_string, times, complete_shards, total_shards, state, uuid, created_at, updated_at, blur_table_id, super_query_on, facets, start, fetch_num, pre_filters, post_filters, selector_column_families, selector_columns, userid, record_only) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+						query.getQuery(),
+						times,
+						status.getCompleteShards(),
+						status.getTotalShards(),
+						status.getState().getValue(),
+						status.getUuid(),
+						startTime,
+						TimeHelper.now().getTime(),
+						tableId,
+						query.isRowQuery(),
+						StringUtils.join(status.getQuery().getFacets(), ", "),
+						status.getQuery().getStart(),
+						status.getQuery().getFetch(),
+						query.getRecordFilter(),
+						query.getRowFilter(),
+						status.getQuery().getSelector() == null ? null : JSONValue.toJSONString(status.getQuery().getSelector()
+								.getColumnFamiliesToFetch()),
+						status.getQuery().getSelector() == null ? null : JSONValue.toJSONString(status.getQuery().getSelector().getColumnsToFetch()),
+						status.getQuery().getUserContext(), status.getQuery().getSelector() == null ? null : status.getQuery().getSelector()
+								.isRecordOnly());
+	}
+
+	public void updateQuery(BlurQueryStatus status, String times, int queryId) {
+		jdbc.update("update blur_queries set times=?, complete_shards=?, total_shards=?, state=?, updated_at=? where id=?", times,
+				status.getCompleteShards(), status.getTotalShards(), status.getState().getValue(), TimeHelper.now().getTime(), queryId);
+	}
+
+	@Override
+	public List<Long> getRunningQueries(Long tableId) {
+		return this.jdbc.queryForList("select uuid from blur_queries where state = 0 and blur_table_id = ?", new Object[]{tableId}, Long.class);
+	}
+
+	@Override
+	public void markOrphanedRunningQueriesComplete(Collection<Long> queries) {
+		if (!queries.isEmpty()) {
+			this.jdbc.update("update blur_queries set state=3 where uuid in (" + StringUtils.join(queries, ", ") + ")");
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/BlurDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/BlurDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/BlurDatabaseInterface.java
new file mode 100644
index 0000000..7b6ecae
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/BlurDatabaseInterface.java
@@ -0,0 +1,38 @@
+package org.apache.blur.agent.connections.blur.interfaces;
+
+/**
+ * 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.
+ */
+import java.util.List;
+import java.util.Map;
+
+import org.apache.blur.agent.connections.blur.interfaces.TableDatabaseInterface;
+import org.apache.blur.agent.exceptions.TableCollisionException;
+import org.apache.blur.agent.exceptions.TableMissingException;
+import org.apache.blur.agent.exceptions.ZookeeperNameCollisionException;
+import org.apache.blur.agent.exceptions.ZookeeperNameMissingException;
+
+
+public interface BlurDatabaseInterface extends TableDatabaseInterface, QueryDatabaseInterface {
+	String resolveConnectionString(int zookeeperId);
+
+	String getZookeeperId(final String zookeeperName) throws ZookeeperNameMissingException, ZookeeperNameCollisionException;
+
+	List<Map<String, Object>> getClusters(final int zookeeperId);
+
+	Map<String, Object> getExistingTable(final String table, final Integer clusterId) throws TableMissingException, TableCollisionException;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/QueryDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/QueryDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/QueryDatabaseInterface.java
new file mode 100644
index 0000000..b60dd19
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/QueryDatabaseInterface.java
@@ -0,0 +1,37 @@
+package org.apache.blur.agent.connections.blur.interfaces;
+
+/**
+ * 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.
+ */
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.blur.thrift.generated.BlurQueryStatus;
+import org.apache.blur.thrift.generated.Query;
+
+public interface QueryDatabaseInterface {
+	Map<String, Object> getQuery(int tableId, String UUID);
+
+	List<Long> getRunningQueries(Long tableId);
+
+	void createQuery(BlurQueryStatus status, Query query, String times, Date startTime, int tableId);
+
+	void updateQuery(BlurQueryStatus status, String times, int queryId);
+	
+	void markOrphanedRunningQueriesComplete(Collection<Long> queries);
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/TableDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/TableDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/TableDatabaseInterface.java
new file mode 100644
index 0000000..96ae435
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/blur/interfaces/TableDatabaseInterface.java
@@ -0,0 +1,27 @@
+package org.apache.blur.agent.connections.blur.interfaces;
+
+/**
+ * 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.
+ */
+public interface TableDatabaseInterface {
+	int getTableId(int clusterId, String tableName);
+
+	void updateTableSchema(final int tableId, final String schema, final String tableAnalyzer);
+
+	void updateTableServer(final int tableId, final String server);
+
+	void updateTableStats(final int tableId, final Long tableBytes, final Long tableRecordCount, final Long tableRowCount);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/CleanerDatabaseConnection.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/CleanerDatabaseConnection.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/CleanerDatabaseConnection.java
new file mode 100644
index 0000000..bf6e588
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/CleanerDatabaseConnection.java
@@ -0,0 +1,60 @@
+package org.apache.blur.agent.connections.cleaners;
+
+/**
+ * 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.
+ */
+import java.util.Calendar;
+
+import org.apache.blur.agent.connections.cleaners.interfaces.CleanerDatabaseInterface;
+import org.apache.blur.agent.types.TimeHelper;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+
+public class CleanerDatabaseConnection implements CleanerDatabaseInterface {
+	private final JdbcTemplate jdbc;
+
+	// Query Expiration Times
+	private final int expireThreshold = 2 * 60 * 1000;
+	private final int deleteThreshold = 2 * 60 * 60 * 1000;
+
+	// Hdfs Expiration Times
+	private final int timeToLive = 14 * 24 * 60 * 60 * 1000;
+
+	public CleanerDatabaseConnection(JdbcTemplate jdbc) {
+		this.jdbc = jdbc;
+	}
+
+	@Override
+	public int deleteOldQueries() {
+		Calendar twoHoursAgo = TimeHelper.getTimeAgo(deleteThreshold);
+		return this.jdbc.update("delete from blur_queries where created_at < ?", twoHoursAgo.getTime());
+	}
+
+	@Override
+	public int expireOldQueries() {
+		Calendar now = TimeHelper.now();
+		Calendar twoMinutesAgo = TimeHelper.getTimeAgo(expireThreshold);
+		return this.jdbc.update("update blur_queries set state=1, updated_at=? where updated_at < ? and state = 0", now.getTime(),
+				twoMinutesAgo);
+	}
+
+	@Override
+	public int deleteOldStats() {
+		Calendar ttlDaysAgo = TimeHelper.getTimeAgo(timeToLive);
+		return jdbc.update("delete from hdfs_stats where created_at < ?", ttlDaysAgo);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/CleanerDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/CleanerDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/CleanerDatabaseInterface.java
new file mode 100644
index 0000000..bbe3bbd
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/CleanerDatabaseInterface.java
@@ -0,0 +1,21 @@
+package org.apache.blur.agent.connections.cleaners.interfaces;
+
+/**
+ * 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.
+ */
+public interface CleanerDatabaseInterface extends HdfsDatabaseCleanerInterface, QueryDatabaseCleanerInterface {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/HdfsDatabaseCleanerInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/HdfsDatabaseCleanerInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/HdfsDatabaseCleanerInterface.java
new file mode 100644
index 0000000..adc84d2
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/HdfsDatabaseCleanerInterface.java
@@ -0,0 +1,21 @@
+package org.apache.blur.agent.connections.cleaners.interfaces;
+
+/**
+ * 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.
+ */
+public interface HdfsDatabaseCleanerInterface {
+	int deleteOldStats();
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/QueryDatabaseCleanerInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/QueryDatabaseCleanerInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/QueryDatabaseCleanerInterface.java
new file mode 100644
index 0000000..539d991
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/cleaners/interfaces/QueryDatabaseCleanerInterface.java
@@ -0,0 +1,24 @@
+package org.apache.blur.agent.connections.cleaners.interfaces;
+
+/**
+ * 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.
+ */
+public interface QueryDatabaseCleanerInterface {
+	int deleteOldQueries();
+
+	int expireOldQueries();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/hdfs/HdfsDatabaseConnection.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/hdfs/HdfsDatabaseConnection.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/hdfs/HdfsDatabaseConnection.java
new file mode 100644
index 0000000..9e917db
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/hdfs/HdfsDatabaseConnection.java
@@ -0,0 +1,65 @@
+package org.apache.blur.agent.connections.hdfs;
+
+/**
+ * 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.
+ */
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.blur.agent.connections.hdfs.interfaces.HdfsDatabaseInterface;
+import org.apache.blur.agent.exceptions.NullReturnedException;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+
+public class HdfsDatabaseConnection implements HdfsDatabaseInterface {
+	private final JdbcTemplate jdbc;
+
+	public HdfsDatabaseConnection(JdbcTemplate jdbc) {
+		this.jdbc = jdbc;
+	}
+
+	@Override
+	public void setHdfsInfo(String name, String host, int port) {
+		List<Map<String, Object>> existingHdfs = jdbc.queryForList("select id from hdfs where name=?", name);
+
+		if (existingHdfs.isEmpty()) {
+			jdbc.update("insert into hdfs (name, host, port) values (?, ?, ?)", name, host, port);
+		} else {
+			jdbc.update("update hdfs set host=?, port=? where id=?", host, port, existingHdfs.get(0).get("ID"));
+		}
+	}
+
+	@Override
+	public int getHdfsId(String name) throws NullReturnedException {
+		try {
+			return jdbc.queryForInt("select id from hdfs where name = ?", name);
+		} catch (IncorrectResultSizeDataAccessException e) {
+			return -1;
+		}
+	}
+
+	@Override
+	public void insertHdfsStats(long capacity, long presentCapacity, long remaining, long used, long logical_used, double d,
+			long underReplicatedBlocksCount, long corruptBlocksCount, long missingBlocksCount, long totalNodes, long liveNodes, long deadNodes,
+			Date time, String host, int port, int hdfsId) {
+		jdbc.update(
+				"insert into hdfs_stats (config_capacity, present_capacity, dfs_remaining, dfs_used_real, dfs_used_logical, dfs_used_percent, under_replicated, corrupt_blocks, missing_blocks, total_nodes, live_nodes, dead_nodes, created_at, host, port, hdfs_id) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+				capacity, presentCapacity, remaining, used, logical_used, (((1.0 * used) / presentCapacity) * 100), underReplicatedBlocksCount,
+				corruptBlocksCount, missingBlocksCount, totalNodes, liveNodes, deadNodes, time, host, port, hdfsId);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/hdfs/interfaces/HdfsDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/hdfs/interfaces/HdfsDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/hdfs/interfaces/HdfsDatabaseInterface.java
new file mode 100644
index 0000000..0fb8c27
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/hdfs/interfaces/HdfsDatabaseInterface.java
@@ -0,0 +1,32 @@
+package org.apache.blur.agent.connections.hdfs.interfaces;
+
+/**
+ * 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.
+ */
+import java.util.Date;
+
+import org.apache.blur.agent.exceptions.NullReturnedException;
+
+
+public interface HdfsDatabaseInterface {
+	void setHdfsInfo(String name, String host, int port);
+
+	int getHdfsId(String name) throws NullReturnedException;
+
+	void insertHdfsStats(long capacity, long presentCapacity, long remaining, long used, long logical_used, double d,
+			long underReplicatedBlocksCount, long corruptBlocksCount, long missingBlocksCount, long totalNodes, long liveNodes, long deadNodes,
+			Date time, String host, int port, int hdfsId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/ZookeeperDatabaseConnection.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/ZookeeperDatabaseConnection.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/ZookeeperDatabaseConnection.java
new file mode 100644
index 0000000..eb90f67
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/ZookeeperDatabaseConnection.java
@@ -0,0 +1,179 @@
+package org.apache.blur.agent.connections.zookeeper;
+
+/**
+ * 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.
+ */
+import java.util.List;
+
+import org.apache.blur.agent.connections.zookeeper.interfaces.ClusterDatabaseInterface;
+import org.apache.blur.agent.connections.zookeeper.interfaces.ControllerDatabaseInterface;
+import org.apache.blur.agent.connections.zookeeper.interfaces.ShardsDatabaseInterface;
+import org.apache.blur.agent.connections.zookeeper.interfaces.TableDatabaseInterface;
+import org.apache.blur.agent.connections.zookeeper.interfaces.ZookeeperDatabaseInterface;
+import org.apache.blur.agent.types.TimeHelper;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+
+public class ZookeeperDatabaseConnection implements ZookeeperDatabaseInterface, ControllerDatabaseInterface, TableDatabaseInterface,
+		ShardsDatabaseInterface, ClusterDatabaseInterface {
+
+	private final JdbcTemplate jdbc;
+
+	public ZookeeperDatabaseConnection(JdbcTemplate jdbc) {
+		this.jdbc = jdbc;
+	}
+
+	@Override
+	public void setZookeeperOnline(int zookeeperId) {
+		this.jdbc.update("update zookeepers set zookeeper_status=? where id=?", 1, zookeeperId);
+	}
+
+	@Override
+	public void setZookeeperWarning(int zookeeperId) {
+		this.jdbc.update("update zookeepers set zookeeper_status=? where id=?", 2, zookeeperId);
+	}
+
+	@Override
+	public void setZookeeperFailure(int zookeeperId) {
+		this.jdbc.update("update zookeepers set zookeeper_status=? where id=?", 3, zookeeperId);
+	}
+
+	@Override
+	public void setZookeeperOffline(int zookeeperId) {
+		this.jdbc.update("update zookeepers set zookeeper_status=? where id=?", 0, zookeeperId);
+	}
+
+	@Override
+	public int insertOrUpdateZookeeper(String name, String url, String blurConnection) {
+		int updatedCount = jdbc.update("update zookeepers set url=? where name=?", url, name);
+
+		if (updatedCount == 0) {
+			jdbc.update("insert into zookeepers (name, url, blur_urls) values (?, ?, ?)", name, url, blurConnection);
+		}
+
+		return jdbc.queryForInt("select id from zookeepers where name = ?", name);
+	}
+
+	@Override
+	public int insertOrUpdateCluster(boolean safeMode, String cluster, int zookeeperId) {
+		int updateCount = this.jdbc.update("update clusters set safe_mode=? where name=? and zookeeper_id=?", safeMode, cluster, zookeeperId);
+		if (updateCount == 0) {
+			this.jdbc.update("insert into clusters (name, zookeeper_id, safe_mode) values (?, ?, ?)", cluster, zookeeperId, safeMode);
+		}
+		return this.jdbc.queryForInt("select id from clusters where name=? and zookeeper_id=?", cluster, zookeeperId);
+	}
+
+	@Override
+	public int markOfflineControllers(List<String> onlineControllers, int zookeeperId) {
+		if (onlineControllers.isEmpty()) {
+			return this.jdbc.update("update blur_controllers set controller_status=0, updated_at=? where zookeeper_id = ?", TimeHelper.now().getTime(),
+					zookeeperId);
+		} else {
+			return this.jdbc.update(
+					"update blur_controllers set controller_status=0, updated_at=? where controller_status!=0 and node_name not in ('"
+							+ StringUtils.join(onlineControllers, "','") + "') and zookeeper_id = ?", TimeHelper.now().getTime(), zookeeperId);
+		}
+	}
+
+	@Override
+	public int markOfflineShards(List<String> onlineShards, int clusterId) {
+		if (onlineShards.isEmpty()) {
+			return this.jdbc.update("update blur_shards set shard_status=0 updated_at=? where cluster_id = ?", TimeHelper.now().getTime(), clusterId);
+		} else {
+			return this.jdbc.update(
+					"update blur_shards set shard_status=0, updated_at=? where shard_status!=0 and node_name not in ('" + StringUtils.join(onlineShards, "','")
+							+ "') and cluster_id=?", TimeHelper.now().getTime(), clusterId);
+		}
+	}
+
+	@Override
+	public void markDeletedTables(List<String> onlineTables, int clusterId) {
+		if (onlineTables.isEmpty()) {
+			this.jdbc.update("delete from blur_tables where cluster_id=?", clusterId);
+		} else {
+			this.jdbc.update("delete from blur_tables where cluster_id=? and table_name not in ('"
+					+ StringUtils.join(onlineTables, "','") + "')", clusterId);
+		}
+	}
+
+	@Override
+	public void updateOnlineController(String controller, int zookeeperId, String blurVersion) {
+		int zookeeperStatus = this.jdbc.queryForInt("select zookeeper_status from zookeepers where id=?", zookeeperId);
+		int status = (zookeeperStatus == 0 || zookeeperStatus == 2) ? 2 : 1;
+		int updatedCount = this.jdbc.update(
+				"update blur_controllers set controller_status=?, blur_version=?, updated_at=? where node_name=? and zookeeper_id =?", status, blurVersion,
+				TimeHelper.now().getTime(), controller, zookeeperId);
+
+		if (updatedCount == 0) {
+			this.jdbc.update(
+					"insert into blur_controllers (node_name, controller_status, zookeeper_id, blur_version, created_at, updated_at) values (?, ?, ?, ?, ?, ?)",
+					controller, status, zookeeperId, blurVersion, TimeHelper.now().getTime(), TimeHelper.now().getTime());
+		}
+	}
+
+	@Override
+	public void updateOnlineShard(String shard, int clusterId, String blurVersion) {
+		int zookeeperStatus = this.jdbc.queryForInt(
+				"select zookeepers.zookeeper_status from zookeepers, clusters where clusters.id=? and clusters.zookeeper_id=zookeepers.id;",
+				clusterId);
+		int status = (zookeeperStatus == 0 || zookeeperStatus == 2) ? 2 : 1;
+		int updatedCount = this.jdbc.update("update blur_shards set shard_status=?, blur_version=?, updated_at=? where node_name=? and cluster_id=?",
+				status, blurVersion, TimeHelper.now().getTime(), shard, clusterId);
+
+		if (updatedCount == 0) {
+			this.jdbc.update(
+					"insert into blur_shards (node_name, shard_status, cluster_id, blur_version, created_at, updated_at) values (?, ?, ?, ?, ?, ?)", shard,
+					status, clusterId, blurVersion, TimeHelper.now().getTime(), TimeHelper.now().getTime());
+		}
+	}
+
+	@Override
+	public void updateOnlineTable(String table, int clusterId, String uri, boolean enabled) {
+		try{
+			int currentStatus = this.jdbc.queryForInt("select table_status from blur_tables where table_name=? and cluster_id=?", table, clusterId);
+			if (enabled && currentStatus != 3){
+				this.jdbc.update("update blur_tables set table_uri=?, table_status=?, updated_at=? where table_name=? and cluster_id=?",
+						uri, 4, TimeHelper.now().getTime(), table, clusterId);
+				
+			}
+			if (!enabled && currentStatus != 5) {
+				this.jdbc.update("update blur_tables set table_uri=?, table_status=?, updated_at=? where table_name=? and cluster_id=?",
+						uri, 2, TimeHelper.now().getTime(), table, clusterId);
+			}
+		} catch(EmptyResultDataAccessException e){
+			this.jdbc.update("insert into blur_tables (table_name, table_uri, table_status, cluster_id, updated_at) values (?, ?, ?, ?, ?)", table,
+					uri, (enabled ? 4 : 2), clusterId, TimeHelper.now().getTime());
+		}
+	}
+
+	@Override
+	public void setOnlineEnsembleNodes(String ensembleArray, int zookeeperId) {
+		this.jdbc.update("update zookeepers set online_ensemble_nodes=? where id=?", ensembleArray, zookeeperId);
+	}
+
+	@Override
+	public List<String> getRecentOfflineShardNames(int amount) {
+		return this.jdbc.queryForList("select node_name from blur_shards where shard_status=0 order by updated_at limit 0, " + amount, String.class);
+	}
+
+	@Override
+	public List<String> getRecentOfflineControllerNames(int amount) {
+		return this.jdbc.queryForList("select node_name from blur_controllers where controller_status=0 order by updated_at limit 0, " + amount,
+				String.class);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ClusterDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ClusterDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ClusterDatabaseInterface.java
new file mode 100644
index 0000000..558ce26
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ClusterDatabaseInterface.java
@@ -0,0 +1,23 @@
+package org.apache.blur.agent.connections.zookeeper.interfaces;
+
+/**
+ * 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.
+ */
+public interface ClusterDatabaseInterface extends ShardsDatabaseInterface, TableDatabaseInterface {
+
+	int insertOrUpdateCluster(boolean safeMode, String cluster, int zookeeperId);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ControllerDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ControllerDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ControllerDatabaseInterface.java
new file mode 100644
index 0000000..bed267f
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ControllerDatabaseInterface.java
@@ -0,0 +1,28 @@
+package org.apache.blur.agent.connections.zookeeper.interfaces;
+
+/**
+ * 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.
+ */
+import java.util.List;
+
+public interface ControllerDatabaseInterface {
+
+	int markOfflineControllers(List<String> onlineControllers, int zookeeperId);
+
+	void updateOnlineController(String controller, int zookeeperId, String blurVersion);
+
+	List<String> getRecentOfflineControllerNames(int amount);
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ShardsDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ShardsDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ShardsDatabaseInterface.java
new file mode 100644
index 0000000..dd1f618
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ShardsDatabaseInterface.java
@@ -0,0 +1,29 @@
+package org.apache.blur.agent.connections.zookeeper.interfaces;
+
+/**
+ * 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.
+ */
+import java.util.List;
+
+public interface ShardsDatabaseInterface {
+
+	int markOfflineShards(List<String> onlineShards, int clusterId);
+
+	void updateOnlineShard(String shard, int clusterId, String blurVersion);
+
+	List<String> getRecentOfflineShardNames(int amount);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/TableDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/TableDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/TableDatabaseInterface.java
new file mode 100644
index 0000000..80299b2
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/TableDatabaseInterface.java
@@ -0,0 +1,27 @@
+package org.apache.blur.agent.connections.zookeeper.interfaces;
+
+/**
+ * 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.
+ */
+import java.util.List;
+
+public interface TableDatabaseInterface {
+
+	void markDeletedTables(List<String> onlineTables, int clusterId);
+
+	void updateOnlineTable(String table, int clusterId, String uri, boolean enabled);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ZookeeperDatabaseInterface.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ZookeeperDatabaseInterface.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ZookeeperDatabaseInterface.java
new file mode 100644
index 0000000..6432d2d
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/connections/zookeeper/interfaces/ZookeeperDatabaseInterface.java
@@ -0,0 +1,33 @@
+package org.apache.blur.agent.connections.zookeeper.interfaces;
+
+/**
+ * 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.
+ */
+public interface ZookeeperDatabaseInterface extends ControllerDatabaseInterface, ClusterDatabaseInterface {
+
+	void setZookeeperOnline(int id);
+
+	void setZookeeperWarning(int id);
+
+	void setZookeeperOffline(int id);
+
+  void setZookeeperFailure(int id);
+
+	int insertOrUpdateZookeeper(String name, String url, String blurConnection);
+
+	void setOnlineEnsembleNodes(String ensembleArray, int zookeeperId);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/CollisionException.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/CollisionException.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/CollisionException.java
new file mode 100644
index 0000000..a14e4ea
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/CollisionException.java
@@ -0,0 +1,24 @@
+package org.apache.blur.agent.exceptions;
+
+/**
+ * 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.
+ */
+@SuppressWarnings("serial")
+public class CollisionException extends Exception {
+	public CollisionException(int size, String type, String name) {
+		super("Found [" + size + "] " + type + " by identifier [" + name + "].  Need one and only one result.  Skipping collection.");
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/HdfsThreadException.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/HdfsThreadException.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/HdfsThreadException.java
new file mode 100644
index 0000000..146e3a6
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/HdfsThreadException.java
@@ -0,0 +1,28 @@
+package org.apache.blur.agent.exceptions;
+
+/**
+ * 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.
+ */
+@SuppressWarnings("serial")
+public class HdfsThreadException extends Exception {
+	public HdfsThreadException() {
+		super();
+	}
+
+	public HdfsThreadException(String message) {
+		super(message);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/InvalidLicenseException.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/InvalidLicenseException.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/InvalidLicenseException.java
new file mode 100644
index 0000000..2f7fb2a
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/InvalidLicenseException.java
@@ -0,0 +1,29 @@
+package org.apache.blur.agent.exceptions;
+
+/**
+ * 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.
+ */
+public class InvalidLicenseException extends Exception {
+	private static final long serialVersionUID = 1317409878802094298L;
+
+	public InvalidLicenseException(String message) {
+		super(message);
+	}
+
+	public InvalidLicenseException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/MissingException.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/MissingException.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/MissingException.java
new file mode 100644
index 0000000..9599b40
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/MissingException.java
@@ -0,0 +1,24 @@
+package org.apache.blur.agent.exceptions;
+
+/**
+ * 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.
+ */
+@SuppressWarnings("serial")
+public class MissingException extends Exception {
+	public MissingException(String type, String name) {
+		super("Couldn't Find a " + type + " by name [" + name + "].  Need a single result.  Skipping collection.");
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/11a2529a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/NullReturnedException.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/NullReturnedException.java b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/NullReturnedException.java
new file mode 100644
index 0000000..67efec6
--- /dev/null
+++ b/contrib/blur-console-v1/blur-agent/src/main/java/org/apache/blur/agent/exceptions/NullReturnedException.java
@@ -0,0 +1,28 @@
+package org.apache.blur.agent.exceptions;
+
+/**
+ * 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.
+ */
+@SuppressWarnings("serial")
+public class NullReturnedException extends Exception {
+	public NullReturnedException() {
+		super();
+	}
+
+	public NullReturnedException(String message) {
+		super(message);
+	}
+}


Mime
View raw message