incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [27/58] [partial] Initial setup of new console
Date Tue, 08 Oct 2013 17:59:35 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/matchers_spec.rb
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/matchers_spec.rb b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/matchers_spec.rb
new file mode 100755
index 0000000..9e4eefe
--- /dev/null
+++ b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/matchers_spec.rb
@@ -0,0 +1,33 @@
+require "spec_helper"
+
+describe "be_able_to" do
+  it "delegates to can?" do
+    object = Object.new
+    object.should_receive(:can?).with(:read, 123) { true }
+    object.should be_able_to(:read, 123)
+  end
+
+  it "reports a nice failure message for should" do
+    object = Object.new
+    object.should_receive(:can?).with(:read, 123) { false }
+    expect do
+      object.should be_able_to(:read, 123)
+    end.should raise_error('expected to be able to :read 123')
+  end
+
+  it "reports a nice failure message for should not" do
+    object = Object.new
+    object.should_receive(:can?).with(:read, 123) { true }
+    expect do
+      object.should_not be_able_to(:read, 123)
+    end.should raise_error('expected not to be able to :read 123')
+  end
+
+  it "delegates additional arguments to can? and reports in failure message" do
+    object = Object.new
+    object.should_receive(:can?).with(:read, 123, 456) { false }
+    expect do
+      object.should be_able_to(:read, 123, 456)
+    end.should raise_error('expected to be able to :read 123 456')
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/active_record_adapter_spec.rb
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/active_record_adapter_spec.rb b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/active_record_adapter_spec.rb
new file mode 100755
index 0000000..6013368
--- /dev/null
+++ b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/active_record_adapter_spec.rb
@@ -0,0 +1,278 @@
+if ENV["MODEL_ADAPTER"].nil? || ENV["MODEL_ADAPTER"] == "active_record"
+  require "spec_helper"
+
+  class Category
+    has_many :articles
+  end
+
+  class Article < ActiveRecord::Base
+    connection.create_table(table_name) do |t|
+      t.integer :category_id
+      t.string :name
+      t.boolean :published
+      t.boolean :secret
+      t.integer :priority
+    end
+    belongs_to :category
+    has_many :comments
+  end
+
+  class Comment < ActiveRecord::Base
+    connection.create_table(table_name) do |t|
+      t.integer :article_id
+      t.boolean :spam
+    end
+    belongs_to :article
+  end
+
+  describe CanCan::ModelAdapters::ActiveRecordAdapter do
+    before(:each) do
+      Article.delete_all
+      Comment.delete_all
+      @ability = Object.new
+      @ability.extend(CanCan::Ability)
+      @article_table = Article.table_name
+      @comment_table = Comment.table_name
+    end
+
+    it "is for only active record classes" do
+      CanCan::ModelAdapters::ActiveRecordAdapter.should_not be_for_class(Object)
+      CanCan::ModelAdapters::ActiveRecordAdapter.should be_for_class(Article)
+      CanCan::ModelAdapters::AbstractAdapter.adapter_class(Article).should == CanCan::ModelAdapters::ActiveRecordAdapter
+    end
+
+    it "finds record" do
+      article = Article.create!
+      CanCan::ModelAdapters::ActiveRecordAdapter.find(Article, article.id).should == article
+    end
+
+    it "does not fetch any records when no abilities are defined" do
+      Article.create!
+      Article.accessible_by(@ability).should be_empty
+    end
+
+    it "fetches all articles when one can read all" do
+      @ability.can :read, :articles
+      article = Article.create!
+      Article.accessible_by(@ability).should == [article]
+    end
+
+    it "fetches only the articles that are published" do
+      @ability.can :read, :articles, :published => true
+      article1 = Article.create!(:published => true)
+      article2 = Article.create!(:published => false)
+      Article.accessible_by(@ability).should == [article1]
+    end
+
+    it "fetches any articles which are published or secret" do
+      @ability.can :read, :articles, :published => true
+      @ability.can :read, :articles, :secret => true
+      article1 = Article.create!(:published => true, :secret => false)
+      article2 = Article.create!(:published => true, :secret => true)
+      article3 = Article.create!(:published => false, :secret => true)
+      article4 = Article.create!(:published => false, :secret => false)
+      Article.accessible_by(@ability).should == [article1, article2, article3]
+    end
+
+    it "fetches only the articles that are published and not secret" do
+      @ability.can :read, :articles, :published => true
+      @ability.cannot :read, :articles, :secret => true
+      article1 = Article.create!(:published => true, :secret => false)
+      article2 = Article.create!(:published => true, :secret => true)
+      article3 = Article.create!(:published => false, :secret => true)
+      article4 = Article.create!(:published => false, :secret => false)
+      Article.accessible_by(@ability).should == [article1]
+    end
+
+    it "only reads comments for articles which are published" do
+      @ability.can :read, :comments, :article => { :published => true }
+      comment1 = Comment.create!(:article => Article.create!(:published => true))
+      comment2 = Comment.create!(:article => Article.create!(:published => false))
+      Comment.accessible_by(@ability).should == [comment1]
+    end
+
+    it "only reads comments for visible categories through articles" do
+      pending "does ActiveRecord no longer support a deep nested hash of conditions?"
+      @ability.can :read, :comments, :article => { :category => { :visible => true } }
+      comment1 = Comment.create!(:article => Article.create!(:category => Category.create!(:visible => true)))
+      comment2 = Comment.create!(:article => Article.create!(:category => Category.create!(:visible => false)))
+      Comment.accessible_by(@ability).should == [comment1]
+    end
+
+    it "allows conditions in SQL and merge with hash conditions" do
+      @ability.can :read, :articles, :published => true
+      @ability.can :read, :articles, ["secret=?", true]
+      article1 = Article.create!(:published => true, :secret => false)
+      article2 = Article.create!(:published => true, :secret => true)
+      article3 = Article.create!(:published => false, :secret => true)
+      article4 = Article.create!(:published => false, :secret => false)
+      Article.accessible_by(@ability).should == [article1, article2, article3]
+    end
+
+    it "allows a scope for conditions" do
+      @ability.can :read, :articles, Article.where(:secret => true)
+      article1 = Article.create!(:secret => true)
+      article2 = Article.create!(:secret => false)
+      Article.accessible_by(@ability).should == [article1]
+    end
+
+    it "fetches only associated records when using with a scope for conditions" do
+      @ability.can :read, :articles, Article.where(:secret => true)
+      category1 = Category.create!(:visible => false)
+      category2 = Category.create!(:visible => true)
+      article1 = Article.create!(:secret => true, :category => category1)
+      article2 = Article.create!(:secret => true, :category => category2)
+      # for some reason the objects aren't comparing equally here so it's necessary to compare by id
+      category1.articles.accessible_by(@ability).map(&:id).should == [article1.id]
+    end
+
+    it "raises an exception when trying to merge scope with other conditions" do
+      @ability.can :read, :articles, :published => true
+      @ability.can :read, :articles, Article.where(:secret => true)
+      lambda { Article.accessible_by(@ability) }.should raise_error(CanCan::Error, "Unable to merge an Active Record scope with other conditions. Instead use a hash or SQL for read articles ability.")
+    end
+
+    it "does not allow to fetch records when ability with just block present" do
+      @ability.can :read, :articles do
+        false
+      end
+      lambda { Article.accessible_by(@ability) }.should raise_error(CanCan::Error)
+    end
+
+    it "does not allow to check ability on object against SQL conditions without block" do
+      @ability.can :read, :articles, ["secret=?", true]
+      lambda { @ability.can? :read, Article.new }.should raise_error(CanCan::Error)
+    end
+
+    it "has false conditions if no abilities match" do
+      @ability.model_adapter(Article, :read).conditions.should == "'t'='f'"
+    end
+
+    it "returns false conditions for cannot clause" do
+      @ability.cannot :read, :articles
+      @ability.model_adapter(Article, :read).conditions.should == "'t'='f'"
+    end
+
+    it "returns SQL for single `can` definition in front of default `cannot` condition" do
+      @ability.cannot :read, :articles
+      @ability.can :read, :articles, :published => false, :secret => true
+      @ability.model_adapter(Article, :read).conditions.should orderlessly_match(%Q["#{@article_table}"."published" = 'f' AND "#{@article_table}"."secret" = 't'])
+    end
+
+    it "returns true condition for single `can` definition in front of default `can` condition" do
+      @ability.can :read, :articles
+      @ability.can :read, :articles, :published => false, :secret => true
+      @ability.model_adapter(Article, :read).conditions.should eq(:secret => true, :published => false)
+    end
+
+    it "returns `false condition` for single `cannot` definition in front of default `cannot` condition" do
+      @ability.cannot :read, :articles
+      @ability.cannot :read, :articles, :published => false, :secret => true
+      @ability.model_adapter(Article, :read).conditions.should  == "'t'='f'"
+    end
+
+    it "returns `not (sql)` for single `cannot` definition in front of default `can` condition" do
+      @ability.can :read, :articles
+      @ability.cannot :read, :articles, :published => false, :secret => true
+      @ability.model_adapter(Article, :read).conditions.should orderlessly_match(%Q["not (#{@article_table}"."published" = 'f' AND "#{@article_table}"."secret" = 't')])
+    end
+
+    it "returns appropriate sql conditions in complex case" do
+      @ability.can :read, :articles
+      @ability.can :access, :articles, :id => 1
+      @ability.can :update, :articles, :published => true
+      @ability.cannot :update, :articles, :secret => true
+      @ability.model_adapter(Article, :update).conditions.should == %Q[not ("#{@article_table}"."secret" = 't') AND (("#{@article_table}"."published" = 't') OR ("#{@article_table}"."id" = 1))]
+      @ability.model_adapter(Article, :access).conditions.should == {:id => 1}
+      @ability.model_adapter(Article, :read).conditions.should == {:id => 1} # used to be "t=t" but changed with new specificity rule (issue #321)
+    end
+
+    it "does not forget conditions when calling with SQL string" do
+      @ability.can :read, :articles, :published => true
+      @ability.can :read, :articles, ['secret=?', false]
+      adapter = @ability.model_adapter(Article, :read)
+      2.times do
+        adapter.conditions.should == %Q[(secret='f') OR ("#{@article_table}"."published" = 't')]
+      end
+    end
+
+    it "has nil joins if no rules" do
+      @ability.model_adapter(Article, :read).joins.should be_nil
+    end
+
+    it "has nil joins if no nested hashes specified in conditions" do
+      @ability.can :read, :articles, :published => false
+      @ability.can :read, :articles, :secret => true
+      @ability.model_adapter(Article, :read).joins.should be_nil
+    end
+
+    it "merges separate joins into a single array" do
+      @ability.can :read, :articles, :project => { :blocked => false }
+      @ability.can :read, :articles, :company => { :admin => true }
+      @ability.model_adapter(Article, :read).joins.inspect.should orderlessly_match([:company, :project].inspect)
+    end
+
+    it "merges same joins into a single array" do
+      @ability.can :read, :articles, :project => { :blocked => false }
+      @ability.can :read, :articles, :project => { :admin => true }
+      @ability.model_adapter(Article, :read).joins.should == [:project]
+    end
+
+    it "restricts articles given a MetaWhere condition" do
+      pending
+      @ability.can :read, :articles, :priority.lt => 2
+      article1 = Article.create!(:priority => 1)
+      article2 = Article.create!(:priority => 3)
+      Article.accessible_by(@ability).should == [article1]
+      @ability.should be_able_to(:read, article1)
+      @ability.should_not be_able_to(:read, article2)
+    end
+
+    it "should merge MetaWhere and non-MetaWhere conditions" do
+      pending
+      @ability.can :read, Article, :priority.lt => 2
+      @ability.can :read, Article, :priority => 1
+      article1 = Article.create!(:priority => 1)
+      article2 = Article.create!(:priority => 3)
+      Article.accessible_by(@ability).should == [article1]
+      @ability.should be_able_to(:read, article1)
+      @ability.should_not be_able_to(:read, article2)
+    end
+
+    it "matches any MetaWhere condition" do
+      pending
+      adapter = CanCan::ModelAdapters::ActiveRecordAdapter
+      article1 = Article.new(:priority => 1, :name => "Hello World")
+      adapter.matches_condition?(article1, :priority.eq, 1).should be_true
+      adapter.matches_condition?(article1, :priority.eq, 2).should be_false
+      adapter.matches_condition?(article1, :priority.eq_any, [1, 2]).should be_true
+      adapter.matches_condition?(article1, :priority.eq_any, [2, 3]).should be_false
+      adapter.matches_condition?(article1, :priority.eq_all, [1, 1]).should be_true
+      adapter.matches_condition?(article1, :priority.eq_all, [1, 2]).should be_false
+      adapter.matches_condition?(article1, :priority.ne, 2).should be_true
+      adapter.matches_condition?(article1, :priority.ne, 1).should be_false
+      adapter.matches_condition?(article1, :priority.in, [1, 2]).should be_true
+      adapter.matches_condition?(article1, :priority.in, [2, 3]).should be_false
+      adapter.matches_condition?(article1, :priority.nin, [2, 3]).should be_true
+      adapter.matches_condition?(article1, :priority.nin, [1, 2]).should be_false
+      adapter.matches_condition?(article1, :priority.lt, 2).should be_true
+      adapter.matches_condition?(article1, :priority.lt, 1).should be_false
+      adapter.matches_condition?(article1, :priority.lteq, 1).should be_true
+      adapter.matches_condition?(article1, :priority.lteq, 0).should be_false
+      adapter.matches_condition?(article1, :priority.gt, 0).should be_true
+      adapter.matches_condition?(article1, :priority.gt, 1).should be_false
+      adapter.matches_condition?(article1, :priority.gteq, 1).should be_true
+      adapter.matches_condition?(article1, :priority.gteq, 2).should be_false
+      adapter.matches_condition?(article1, :name.like, "%ello worl%").should be_true
+      adapter.matches_condition?(article1, :name.like, "hello world").should be_true
+      adapter.matches_condition?(article1, :name.like, "hello%").should be_true
+      adapter.matches_condition?(article1, :name.like, "h%d").should be_true
+      adapter.matches_condition?(article1, :name.like, "%helo%").should be_false
+      adapter.matches_condition?(article1, :name.like, "hello").should be_false
+      adapter.matches_condition?(article1, :name.like, "hello.world").should be_false
+      # For some reason this is reporting "The not_matches MetaWhere condition is not supported."
+      # adapter.matches_condition?(article1, :name.nlike, "%helo%").should be_true
+      # adapter.matches_condition?(article1, :name.nlike, "%ello worl%").should be_false
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/data_mapper_adapter_spec.rb
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/data_mapper_adapter_spec.rb b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/data_mapper_adapter_spec.rb
new file mode 100755
index 0000000..6aeba69
--- /dev/null
+++ b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/data_mapper_adapter_spec.rb
@@ -0,0 +1,120 @@
+if ENV["MODEL_ADAPTER"] == "data_mapper"
+  require "spec_helper"
+
+  DataMapper.setup(:default, 'sqlite::memory:')
+
+  class DataMapperArticle
+    include DataMapper::Resource
+    property :id, Serial
+    property :published, Boolean, :default => false
+    property :secret, Boolean, :default => false
+    property :priority, Integer
+    has n, :data_mapper_comments
+  end
+
+  class DataMapperComment
+    include DataMapper::Resource
+    property :id, Serial
+    property :spam, Boolean, :default => false
+    belongs_to :data_mapper_article
+  end
+
+  DataMapper.finalize
+  DataMapper.auto_migrate!
+
+  describe CanCan::ModelAdapters::DataMapperAdapter do
+    before(:each) do
+      DataMapperArticle.destroy
+      DataMapperComment.destroy
+      @ability = Object.new
+      @ability.extend(CanCan::Ability)
+    end
+
+    it "is for only data mapper classes" do
+      CanCan::ModelAdapters::DataMapperAdapter.should_not be_for_class(Object)
+      CanCan::ModelAdapters::DataMapperAdapter.should be_for_class(DataMapperArticle)
+      CanCan::ModelAdapters::AbstractAdapter.adapter_class(DataMapperArticle).should == CanCan::ModelAdapters::DataMapperAdapter
+    end
+
+    it "finds record" do
+      article = DataMapperArticle.create
+      CanCan::ModelAdapters::DataMapperAdapter.find(DataMapperArticle, article.id).should == article
+    end
+
+    it "does not fetch any records when no abilities are defined" do
+      DataMapperArticle.create
+      DataMapperArticle.accessible_by(@ability).should be_empty
+    end
+
+    it "fetches all articles when one can read all" do
+      @ability.can :read, :data_mapper_articles
+      article = DataMapperArticle.create
+      DataMapperArticle.accessible_by(@ability).should == [article]
+    end
+
+    it "fetches only the articles that are published" do
+      @ability.can :read, :data_mapper_articles, :published => true
+      article1 = DataMapperArticle.create(:published => true)
+      article2 = DataMapperArticle.create(:published => false)
+      DataMapperArticle.accessible_by(@ability).should == [article1]
+    end
+
+    it "fetches any articles which are published or secret" do
+      @ability.can :read, :data_mapper_articles, :published => true
+      @ability.can :read, :data_mapper_articles, :secret => true
+      article1 = DataMapperArticle.create(:published => true, :secret => false)
+      article2 = DataMapperArticle.create(:published => true, :secret => true)
+      article3 = DataMapperArticle.create(:published => false, :secret => true)
+      article4 = DataMapperArticle.create(:published => false, :secret => false)
+      DataMapperArticle.accessible_by(@ability).should == [article1, article2, article3]
+    end
+
+    it "fetches only the articles that are published and not secret" do
+      pending "the `cannot` may require some custom SQL, maybe abstract out from Active Record adapter"
+      @ability.can :read, :data_mapper_articles, :published => true
+      @ability.cannot :read, :data_mapper_articles, :secret => true
+      article1 = DataMapperArticle.create(:published => true, :secret => false)
+      article2 = DataMapperArticle.create(:published => true, :secret => true)
+      article3 = DataMapperArticle.create(:published => false, :secret => true)
+      article4 = DataMapperArticle.create(:published => false, :secret => false)
+      DataMapperArticle.accessible_by(@ability).should == [article1]
+    end
+
+    it "only reads comments for articles which are published" do
+      @ability.can :read, :data_mapper_comments, :data_mapper_article => { :published => true }
+      comment1 = DataMapperComment.create(:data_mapper_article => DataMapperArticle.create!(:published => true))
+      comment2 = DataMapperComment.create(:data_mapper_article => DataMapperArticle.create!(:published => false))
+      DataMapperComment.accessible_by(@ability).should == [comment1]
+    end
+
+    it "allows conditions in SQL and merge with hash conditions" do
+      @ability.can :read, :data_mapper_articles, :published => true
+      @ability.can :read, :data_mapper_articles, ["secret=?", true]
+      article1 = DataMapperArticle.create(:published => true, :secret => false)
+      article4 = DataMapperArticle.create(:published => false, :secret => false)
+      DataMapperArticle.accessible_by(@ability).should == [article1]
+    end
+
+    it "matches gt comparison" do
+      @ability.can :read, :data_mapper_articles, :priority.gt => 3
+      article1 = DataMapperArticle.create(:priority => 4)
+      article2 = DataMapperArticle.create(:priority => 3)
+      DataMapperArticle.accessible_by(@ability).should == [article1]
+      @ability.should be_able_to(:read, article1)
+      @ability.should_not be_able_to(:read, article2)
+    end
+
+    it "matches gte comparison" do
+      @ability.can :read, :data_mapper_articles, :priority.gte => 3
+      article1 = DataMapperArticle.create(:priority => 4)
+      article2 = DataMapperArticle.create(:priority => 3)
+      article3 = DataMapperArticle.create(:priority => 2)
+      DataMapperArticle.accessible_by(@ability).should == [article1, article2]
+      @ability.should be_able_to(:read, article1)
+      @ability.should be_able_to(:read, article2)
+      @ability.should_not be_able_to(:read, article3)
+    end
+
+    # TODO: add more comparison specs
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/default_adapter_spec.rb
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/default_adapter_spec.rb b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/default_adapter_spec.rb
new file mode 100755
index 0000000..c2edb4d
--- /dev/null
+++ b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/default_adapter_spec.rb
@@ -0,0 +1,7 @@
+require "spec_helper"
+
+describe CanCan::ModelAdapters::DefaultAdapter do
+  it "is default for generic classes" do
+    CanCan::ModelAdapters::AbstractAdapter.adapter_class(Object).should == CanCan::ModelAdapters::DefaultAdapter
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/mongoid_adapter_spec.rb
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/mongoid_adapter_spec.rb b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/mongoid_adapter_spec.rb
new file mode 100755
index 0000000..451e609
--- /dev/null
+++ b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/model_adapters/mongoid_adapter_spec.rb
@@ -0,0 +1,227 @@
+if ENV["MODEL_ADAPTER"] == "mongoid"
+  require "spec_helper"
+
+  class MongoidCategory
+    include Mongoid::Document
+    references_many :mongoid_projects
+  end
+
+  class MongoidProject
+    include Mongoid::Document
+    referenced_in :mongoid_category
+  end
+
+  Mongoid.configure do |config|
+    config.master = Mongo::Connection.new('127.0.0.1', 27017).db("cancan_mongoid_spec")
+  end
+
+  describe CanCan::ModelAdapters::MongoidAdapter do
+    context "Mongoid defined" do
+      before(:each) do
+        @ability = Object.new
+        @ability.extend(CanCan::Ability)
+      end
+
+      after(:each) do
+        Mongoid.master.collections.select do |collection|
+          collection.name !~ /system/
+        end.each(&:drop)
+      end
+
+      it "is for only Mongoid classes" do
+        CanCan::ModelAdapters::MongoidAdapter.should_not be_for_class(Object)
+        CanCan::ModelAdapters::MongoidAdapter.should be_for_class(MongoidProject)
+        CanCan::ModelAdapters::AbstractAdapter.adapter_class(MongoidProject).should == CanCan::ModelAdapters::MongoidAdapter
+      end
+
+      it "finds record" do
+        project = MongoidProject.create
+        CanCan::ModelAdapters::MongoidAdapter.find(MongoidProject, project.id).should == project
+      end
+
+      it "compares properties on mongoid documents with the conditions hash" do
+        model = MongoidProject.new
+        @ability.can :read, :mongoid_projects, :id => model.id
+        @ability.should be_able_to(:read, model)
+      end
+
+      it "is able to read hashes when field is array" do
+        one_to_three = MongoidProject.create(:numbers => ['one', 'two', 'three'])
+        two_to_five  = MongoidProject.create(:numbers => ['two', 'three', 'four', 'five'])
+
+        @ability.can :foo, :mongoid_projects, :numbers => 'one'
+        @ability.should be_able_to(:foo, one_to_three)
+        @ability.should_not be_able_to(:foo, two_to_five)
+      end
+
+      it "returns [] when no ability is defined so no records are found" do
+        MongoidProject.create(:title => 'Sir')
+        MongoidProject.create(:title => 'Lord')
+        MongoidProject.create(:title => 'Dude')
+
+        MongoidProject.accessible_by(@ability, :read).entries.should == []
+      end
+
+      it "returns the correct records based on the defined ability" do
+        @ability.can :read, :mongoid_projects, :title => "Sir"
+        sir   = MongoidProject.create(:title => 'Sir')
+        lord  = MongoidProject.create(:title => 'Lord')
+        dude  = MongoidProject.create(:title => 'Dude')
+
+        MongoidProject.accessible_by(@ability, :read).entries.should == [sir]
+      end
+
+      it "returns the correct records when a mix of can and cannot rules in defined ability" do
+        pending "TODO figure out why this isn't working"
+        @ability.can :manage, :mongoid_projects, :title => 'Sir'
+        @ability.cannot :destroy, :mongoid_projects
+
+        sir   = MongoidProject.create(:title => 'Sir')
+        lord  = MongoidProject.create(:title => 'Lord')
+        dude  = MongoidProject.create(:title => 'Dude')
+
+        MongoidProject.accessible_by(@ability, :destroy).entries.should == [sir]
+      end
+
+      it "is able to mix empty conditions and hashes" do
+        pending "TODO figure out why this isn't working"
+        @ability.can :read, :mongoid_projects
+        @ability.can :read, :mongoid_projects, :title => 'Sir'
+        sir  = MongoidProject.create(:title => 'Sir')
+        lord = MongoidProject.create(:title => 'Lord')
+
+        MongoidProject.accessible_by(@ability, :read).count.should == 2
+      end
+
+      it "returns everything when the defined ability is access all" do
+        @ability.can :access, :all
+        sir   = MongoidProject.create(:title => 'Sir')
+        lord  = MongoidProject.create(:title => 'Lord')
+        dude  = MongoidProject.create(:title => 'Dude')
+
+        MongoidProject.accessible_by(@ability, :read).entries.should == [sir, lord, dude]
+      end
+
+      it "allows a scope for conditions" do
+        @ability.can :read, :mongoid_projects, MongoidProject.where(:title => 'Sir')
+        sir   = MongoidProject.create(:title => 'Sir')
+        lord  = MongoidProject.create(:title => 'Lord')
+        dude  = MongoidProject.create(:title => 'Dude')
+
+        MongoidProject.accessible_by(@ability, :read).entries.should == [sir]
+      end
+
+      describe "Mongoid::Criteria where clause Symbol extensions using MongoDB expressions" do
+        it "handles :field.in" do
+          obj = MongoidProject.create(:title => 'Sir')
+          @ability.can :read, :mongoid_projects, :title.in => ["Sir", "Madam"]
+          @ability.can?(:read, obj).should == true
+          MongoidProject.accessible_by(@ability, :read).should == [obj]
+
+          obj2 = MongoidProject.create(:title => 'Lord')
+          @ability.can?(:read, obj2).should == false
+        end
+
+        describe "activates only when there are Criteria in the hash" do
+          it "Calls where on the model class when there are criteria" do
+            obj = MongoidProject.create(:title => 'Bird')
+            @conditions = {:title.nin => ["Fork", "Spoon"]}
+
+            @ability.can :read, :mongoid_projects, @conditions
+            @ability.should be_able_to(:read, obj)
+          end
+          it "Calls the base version if there are no mongoid criteria" do
+            obj = MongoidProject.new(:title => 'Bird')
+            @conditions = {:id => obj.id}
+            @ability.can :read, :mongoid_projects, @conditions
+            @ability.should be_able_to(:read, obj)
+          end
+        end
+
+        it "handles :field.nin" do
+          obj = MongoidProject.create(:title => 'Sir')
+          @ability.can :read, :mongoid_projects, :title.nin => ["Lord", "Madam"]
+          @ability.can?(:read, obj).should == true
+          MongoidProject.accessible_by(@ability, :read).should == [obj]
+
+          obj2 = MongoidProject.create(:title => 'Lord')
+          @ability.can?(:read, obj2).should == false
+        end
+
+        it "handles :field.size" do
+          obj = MongoidProject.create(:titles => ['Palatin', 'Margrave'])
+          @ability.can :read, :mongoid_projects, :titles.size => 2
+          @ability.can?(:read, obj).should == true
+          MongoidProject.accessible_by(@ability, :read).should == [obj]
+
+          obj2 = MongoidProject.create(:titles => ['Palatin', 'Margrave', 'Marquis'])
+          @ability.can?(:read, obj2).should == false
+        end
+
+        it "handles :field.exists" do
+          obj = MongoidProject.create(:titles => ['Palatin', 'Margrave'])
+          @ability.can :read, :mongoid_projects, :titles.exists => true
+          @ability.can?(:read, obj).should == true
+          MongoidProject.accessible_by(@ability, :read).should == [obj]
+
+          obj2 = MongoidProject.create
+          @ability.can?(:read, obj2).should == false
+        end
+
+        it "handles :field.gt" do
+          obj = MongoidProject.create(:age => 50)
+          @ability.can :read, :mongoid_projects, :age.gt => 45
+          @ability.can?(:read, obj).should == true
+          MongoidProject.accessible_by(@ability, :read).should == [obj]
+
+          obj2 = MongoidProject.create(:age => 40)
+          @ability.can?(:read, obj2).should == false
+        end
+
+        it "handles instance not saved to database" do
+          obj = MongoidProject.new(:title => 'Sir')
+          @ability.can :read, :mongoid_projects, :title.in => ["Sir", "Madam"]
+          @ability.can?(:read, obj).should == true
+
+          # accessible_by only returns saved records
+          MongoidProject.accessible_by(@ability, :read).entries.should == []
+
+          obj2 = MongoidProject.new(:title => 'Lord')
+          @ability.can?(:read, obj2).should == false
+        end
+      end
+
+      it "calls where with matching ability conditions" do
+        obj = MongoidProject.create(:foo => {:bar => 1})
+        @ability.can :read, :mongoid_projects, :foo => {:bar => 1}
+        MongoidProject.accessible_by(@ability, :read).entries.first.should == obj
+      end
+
+      it "excludes from the result if set to cannot" do
+        obj = MongoidProject.create(:bar => 1)
+        obj2 = MongoidProject.create(:bar => 2)
+        @ability.can :read, :mongoid_projects
+        @ability.cannot :read, :mongoid_projects, :bar => 2
+        MongoidProject.accessible_by(@ability, :read).entries.should == [obj]
+      end
+
+      it "combines the rules" do
+        obj = MongoidProject.create(:bar => 1)
+        obj2 = MongoidProject.create(:bar => 2)
+        obj3 = MongoidProject.create(:bar => 3)
+        @ability.can :read, :mongoid_projects, :bar => 1
+        @ability.can :read, :mongoid_projects, :bar => 2
+        MongoidProject.accessible_by(@ability, :read).entries.should =~ [obj, obj2]
+      end
+
+      it "does not allow to fetch records when ability with just block present" do
+        @ability.can :read, :mongoid_projects do
+          false
+        end
+        lambda {
+          MongoidProject.accessible_by(@ability)
+        }.should raise_error(CanCan::Error)
+      end
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/rule_spec.rb
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/rule_spec.rb b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/rule_spec.rb
new file mode 100755
index 0000000..5aacc2c
--- /dev/null
+++ b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/cancan/rule_spec.rb
@@ -0,0 +1,55 @@
+require "spec_helper"
+require "ostruct" # for OpenStruct below
+
+# Most of Rule functionality is tested in Ability specs
+describe CanCan::Rule do
+  before(:each) do
+    @conditions = {}
+    @rule = CanCan::Rule.new(true, :read, :integers, @conditions)
+  end
+
+  it "returns no association joins if none exist" do
+    @rule.associations_hash.should == {}
+  end
+
+  it "returns no association for joins if just attributes" do
+    @conditions[:foo] = :bar
+    @rule.associations_hash.should == {}
+  end
+
+  it "returns single association for joins" do
+    @conditions[:foo] = {:bar => 1}
+    @rule.associations_hash.should == {:foo => {}}
+  end
+
+  it "returns multiple associations for joins" do
+    @conditions[:foo] = {:bar => 1}
+    @conditions[:test] = {1 => 2}
+    @rule.associations_hash.should == {:foo => {}, :test => {}}
+  end
+
+  it "returns nested associations for joins" do
+    @conditions[:foo] = {:bar => {1 => 2}}
+    @rule.associations_hash.should == {:foo => {:bar => {}}}
+  end
+
+  it "returns no association joins if conditions is nil" do
+    rule = CanCan::Rule.new(true, :read, :integers)
+    rule.associations_hash.should == {}
+  end
+
+  it "has higher specificity for attributes/conditions" do
+    CanCan::Rule.new(true, :read, :integers).specificity.should eq(1)
+    CanCan::Rule.new(true, :read, :integers, :foo => :bar).specificity.should eq(2)
+    CanCan::Rule.new(true, :read, :integers, :foo).specificity.should eq(2)
+    CanCan::Rule.new(false, :read, :integers).specificity.should eq(3)
+    CanCan::Rule.new(false, :read, :integers, :foo => :bar).specificity.should eq(4)
+    CanCan::Rule.new(false, :read, :integers, :foo).specificity.should eq(4)
+  end
+
+  it "should not be mergeable if conditions are not simple hashes" do
+    meta_where = OpenStruct.new(:name => 'metawhere', :column => 'test')
+    @conditions[meta_where] = :bar
+    @rule.should be_unmergeable
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/matchers.rb
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/matchers.rb b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/matchers.rb
new file mode 100755
index 0000000..b98bd24
--- /dev/null
+++ b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/matchers.rb
@@ -0,0 +1,13 @@
+RSpec::Matchers.define :orderlessly_match do |original_string|
+  match do |given_string|
+    original_string.split('').sort == given_string.split('').sort
+  end
+
+  failure_message_for_should do |given_string|
+    "expected \"#{given_string}\" to have the same characters as \"#{original_string}\""
+  end
+
+  failure_message_for_should_not do |given_string|
+    "expected \"#{given_string}\" not to have the same characters as \"#{original_string}\""
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/spec_helper.rb
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/spec_helper.rb b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/spec_helper.rb
new file mode 100755
index 0000000..706ed82
--- /dev/null
+++ b/contrib/blur-console-old/blur-admin/vendor/gems/cancan/spec/spec_helper.rb
@@ -0,0 +1,49 @@
+require 'rubygems'
+require 'bundler/setup'
+
+require "sqlite3"
+require "active_record"
+
+case ENV["MODEL_ADAPTER"]
+when "data_mapper"
+  require "dm-core"
+  require "dm-sqlite-adapter"
+  require "dm-migrations"
+when "mongoid"
+  require "mongoid"
+end
+
+require 'active_support/all'
+require 'matchers'
+require 'cancan'
+require 'cancan/matchers'
+
+RSpec.configure do |config|
+  config.treat_symbols_as_metadata_keys_with_true_values = true
+  config.filter_run :focus => true
+  config.run_all_when_everything_filtered = true
+end
+
+class Ability
+  include CanCan::Ability
+
+  def initialize(user)
+  end
+end
+
+ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
+
+class Category < ActiveRecord::Base
+  connection.create_table(table_name) do |t|
+    t.boolean :visible
+  end
+  has_many :projects
+end
+
+class Project < ActiveRecord::Base
+  connection.create_table(table_name) do |t|
+    t.integer :category_id
+    t.string :name
+  end
+  belongs_to :category
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/.gitignore
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/.gitignore b/contrib/blur-console-old/blur-agent/.gitignore
new file mode 100644
index 0000000..bb50561
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/.gitignore
@@ -0,0 +1,3 @@
+agent.pid
+agent.log*
+tmp

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/pom.xml b/contrib/blur-console-old/blur-agent/pom.xml
new file mode 100644
index 0000000..e9e5c23
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/pom.xml
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+		<parent>
+		<groupId>org.apache.blur</groupId>
+		<artifactId>blur</artifactId>
+		<version>0.2.0-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+	</parent>
+	<groupId>org.apache.blur</groupId>
+	<artifactId>blur-agent</artifactId>
+	<packaging>jar</packaging>
+	<name>Blur Agent</name>
+
+	<dependencies>
+		<!-- RUNTIME DEPENDENCIES -->
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-jdbc</artifactId>
+			<version>3.0.5.RELEASE</version>
+			<exclusions>
+				<exclusion>
+					<artifactId>aopalliance</artifactId>
+					<groupId>aopalliance</groupId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.6</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-collections</groupId>
+			<artifactId>commons-collections</artifactId>
+			<version>3.2.1</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>2.0.1</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-codec</groupId>
+			<artifactId>commons-codec</artifactId>
+			<version>1.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>1.4</version>
+		</dependency>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<version>5.1.16</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.blur</groupId>
+			<artifactId>blur-thrift</artifactId>
+			<version>0.2.0-incubating-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.blur</groupId>
+			<artifactId>blur-util</artifactId>
+			<version>0.2.0-incubating-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+			<version>1.6.1</version>
+		</dependency>
+		<dependency>
+			<groupId>com.googlecode.json-simple</groupId>
+			<artifactId>json-simple</artifactId>
+			<version>1.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.codehaus.jackson</groupId>
+			<artifactId>jackson-mapper-asl</artifactId>
+			<version>1.8.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.codehaus.jackson</groupId>
+			<artifactId>jackson-core-asl</artifactId>
+			<version>1.8.1</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.mail</groupId>
+			<artifactId>mail</artifactId>
+			<version>1.4</version>
+		</dependency>
+		
+		<!-- COMPILE DEPENDENCIES -->
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.6.1</version>
+			<scope>compile</scope>
+		</dependency>
+		
+		<!-- TEST DEPENDENCIES -->
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.9</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.blur</groupId>
+			<artifactId>blur-core</artifactId>
+			<version>0.2.0-incubating-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.blur</groupId>
+			<artifactId>blur-core</artifactId>
+			<version>0.2.0-incubating-SNAPSHOT</version>
+			<type>test-jar</type>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.hadoop</groupId>
+			<artifactId>hadoop-test</artifactId>
+			<version>1.2.1</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.blur</groupId>
+			<artifactId>blur-store</artifactId>
+			<version>0.2.0-incubating-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.subethamail</groupId>
+			<artifactId>subethasmtp</artifactId>
+			<version>3.1.7</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.vysper</groupId>
+			<artifactId>vysper-core</artifactId>
+			<version>0.7</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+        	<groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-core</artifactId>
+            <version>1.14</version>
+            <scope>test</scope>
+       	</dependency>
+		            
+	</dependencies>
+
+	<repositories>
+		<repository>
+			<id>libdir</id>
+			<url>file://${basedir}/lib</url>
+		</repository>
+	</repositories>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>2.0.2</version>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-eclipse-plugin</artifactId>
+				<version>2.9</version>
+				<configuration>
+					<downloadSources>true</downloadSources>
+					<downloadJavadocs>true</downloadJavadocs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-dependency-plugin</artifactId>
+				<version>2.3</version>
+				<executions>
+					<execution>
+						<id>copy-dependencies</id>
+						<phase>package</phase>
+						<goals>
+							<goal>copy-dependencies</goal>
+						</goals>
+						<configuration>
+							<outputDirectory>${project.build.directory}/lib</outputDirectory>
+							<overWriteReleases>false</overWriteReleases>
+							<overWriteSnapshots>false</overWriteSnapshots>
+							<overWriteIfNewer>true</overWriteIfNewer>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/Agent.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/Agent.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/Agent.java
new file mode 100644
index 0000000..594359a
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/Agent.java
@@ -0,0 +1,205 @@
+package org.apache.blur.agent;
+
+/**
+ * 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.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.blur.agent.cleaners.AgentCleaners;
+import org.apache.blur.agent.collectors.blur.BlurCollector;
+import org.apache.blur.agent.collectors.hdfs.HdfsCollector;
+import org.apache.blur.agent.collectors.zookeeper.ZookeeperCollector;
+import org.apache.blur.agent.connections.JdbcConnection;
+import org.apache.blur.agent.connections.blur.BlurDatabaseConnection;
+import org.apache.blur.agent.connections.cleaners.CleanerDatabaseConnection;
+import org.apache.blur.agent.connections.hdfs.HdfsDatabaseConnection;
+import org.apache.blur.agent.connections.zookeeper.ZookeeperDatabaseConnection;
+import org.apache.blur.agent.exceptions.HdfsThreadException;
+import org.apache.blur.agent.notifications.Notifier;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+
+public class Agent {
+	public static final long COLLECTOR_SLEEP_TIME = TimeUnit.SECONDS.toMillis(15);
+	public static final long CLEAN_UP_SLEEP_TIME = TimeUnit.SECONDS.toMillis(30);
+
+	private static final Log log = LogFactory.getLog(Agent.class);
+
+	private Agent(Properties props) {
+
+		// Setup database connection
+		JdbcTemplate jdbc = JdbcConnection.createDBConnection(props);
+
+		// Setup the notifier
+		Notifier.getNotifier(props, true);
+
+		List<String> activeCollectors = props.containsKey("active.collectors") ? new ArrayList<String>(Arrays.asList(props.getProperty(
+				"active.collectors").split("\\|"))) : new ArrayList<String>();
+
+		// Setup the collectors
+		setupHdfs(props, jdbc, activeCollectors);
+		setupBlur(props, jdbc, activeCollectors);
+		setupZookeeper(props, jdbc);
+		setupCleaners(jdbc, activeCollectors);
+	}
+
+	public static void main(String[] args) {
+		writePidFile();
+		Properties configProps = loadConfigParams(args);
+		setupLogger(configProps);
+		new Agent(configProps);
+	}
+
+	private void setupCleaners(JdbcTemplate jdbc, List<String> activeCollectors) {
+		new Thread(new AgentCleaners(activeCollectors, new CleanerDatabaseConnection(jdbc)), "Agent Cleaner Thread").start();
+	}
+
+	private void setupBlur(Properties props, JdbcTemplate jdbc, List<String> activeCollectors) {
+		Map<String, String> blurInstances = loadBlurInstances(props);
+		for (Map.Entry<String, String> blurEntry : blurInstances.entrySet()) {
+			final String zookeeperName = blurEntry.getKey();
+			final String connection = blurEntry.getValue();
+			new Thread(new BlurCollector(zookeeperName, connection, activeCollectors, new BlurDatabaseConnection(jdbc), jdbc),
+					"Blur Collector thread - " + zookeeperName).start();
+		}
+	}
+
+	private void setupHdfs(Properties props, final JdbcTemplate jdbc, List<String> activeCollectors) {
+		Map<String, Map<String, String>> hdfsInstances = loadHdfsInstances(props);
+		for (Map<String, String> instance : hdfsInstances.values()) {
+			final String name = instance.get("name");
+			final String thriftUri = instance.get("url.thrift");
+			final String defaultUri = instance.get("url.default");
+			final String user = props.getProperty("hdfs." + name + ".login.user");
+			try {
+				new Thread(new HdfsCollector(name, defaultUri, thriftUri, user, activeCollectors, new HdfsDatabaseConnection(jdbc)),
+						"Hdfs Collector - " + name).start();
+			} catch (HdfsThreadException e) {
+				log.error("The collector for hdfs [" + name + "] will not execute.");
+				continue;
+			}
+		}
+	}
+
+	private void setupZookeeper(Properties props, JdbcTemplate jdbc) {
+		if (props.containsKey("zk.instances")) {
+			List<String> zooKeeperInstances = new ArrayList<String>(Arrays.asList(props.getProperty("zk.instances").split("\\|")));
+			for (String zkInstance : zooKeeperInstances) {
+				String zkUrl = props.getProperty("zk." + zkInstance + ".url");
+				String blurConnection = props.getProperty("blur." + zkInstance + ".url");
+				new Thread(new ZookeeperCollector(zkUrl, zkInstance, blurConnection, new ZookeeperDatabaseConnection(jdbc)), "Zookeeper - "
+						+ zkInstance).start();
+			}
+		}
+	}
+
+	private static void setupLogger(Properties props) {
+		String log4jPropsFile = props.getProperty("log4j.properties", "../conf/log4j.properties");
+
+		if (new File(log4jPropsFile).exists()) {
+			PropertyConfigurator.configure(log4jPropsFile);
+		} else {
+			log.warn("Unable to find log4j properties file.  Using default logging");
+		}
+	}
+
+	private static Properties loadConfigParams(String[] args) {
+		String configFileName;
+		if (args.length == 0) {
+			configFileName = "../conf/blur-agent.config";
+		} else {
+			configFileName = args[0];
+		}
+		File configFile = new File(configFileName);
+
+		if (!configFile.exists() || !configFile.isFile()) {
+			log.fatal("Unable to find config file at " + configFile.getAbsolutePath());
+			System.exit(1);
+		}
+
+		Properties configProps = new Properties();
+		try {
+			configProps.load(new FileInputStream(configFile));
+		} catch (Exception e) {
+			log.fatal("Config File is not a valid properties file: " + e.getMessage());
+			System.exit(1);
+		}
+		return configProps;
+	}
+
+	private static void writePidFile() {
+		try {
+			File pidFile = new File("../agent.pid");
+			PrintWriter pidOut = new PrintWriter(pidFile);
+			log.info("Wrote pid file to: " + pidFile.getAbsolutePath());
+			String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName();
+			int p = nameOfRunningVM.indexOf('@');
+			String pid = nameOfRunningVM.substring(0, p);
+			pidOut.write(pid);
+			pidOut.write("\n");
+			pidOut.close();
+		} catch (FileNotFoundException e) {
+			log.fatal("Unable to find pid file. " + e.getMessage());
+			System.exit(1);
+		}
+	}
+
+	private Map<String, String> loadBlurInstances(Properties props) {
+		Map<String, String> instances = new HashMap<String, String>();
+
+		if (props.containsKey("blur.instances")) {
+			String[] blurNames = props.getProperty("blur.instances").split("\\|");
+
+			for (String blur : blurNames) {
+				instances.put(blur, props.getProperty("blur." + blur + ".url"));
+			}
+		}
+
+		return instances;
+	}
+
+	private Map<String, Map<String, String>> loadHdfsInstances(Properties props) {
+		Map<String, Map<String, String>> instances = new HashMap<String, Map<String, String>>();
+
+		if (props.containsKey("hdfs.instances")) {
+			String[] hdfsNames = props.getProperty("hdfs.instances").split("\\|");
+
+			for (String hdfs : hdfsNames) {
+				Map<String, String> instanceInfo = new HashMap<String, String>();
+				instanceInfo.put("url.thrift", props.getProperty("hdfs." + hdfs + ".thrift.url"));
+				instanceInfo.put("url.default", props.getProperty("hdfs." + hdfs + ".url"));
+				instanceInfo.put("name", hdfs);
+				instances.put(hdfs, instanceInfo);
+			}
+		}
+
+		return instances;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/AgentCleaners.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/AgentCleaners.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/AgentCleaners.java
new file mode 100644
index 0000000..7047507
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/AgentCleaners.java
@@ -0,0 +1,56 @@
+package org.apache.blur.agent.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.List;
+
+import org.apache.blur.agent.Agent;
+import org.apache.blur.agent.connections.cleaners.interfaces.CleanerDatabaseInterface;
+
+
+public class AgentCleaners implements Runnable {
+
+	private final boolean cleanQueries;
+	private final boolean cleanHdfsStats;
+	private final CleanerDatabaseInterface database;
+
+	public AgentCleaners(final List<String> activeCollectors, CleanerDatabaseInterface database) {
+		this.cleanQueries = activeCollectors.contains("queries");
+		this.cleanHdfsStats = activeCollectors.contains("hdfs");
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		while (true) {
+			if (this.cleanQueries) {
+				new Thread(new QueriesCleaner(this.database), "Query Cleaner").start();
+			}
+
+			if (this.cleanHdfsStats) {
+				new Thread(new HdfsStatsCleaner(this.database), "Hdfs Stats Cleaner").start();
+			}
+
+			try {
+				Thread.sleep(Agent.CLEAN_UP_SLEEP_TIME);
+			} catch (InterruptedException e) {
+				break;
+			}
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/HdfsStatsCleaner.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/HdfsStatsCleaner.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/HdfsStatsCleaner.java
new file mode 100644
index 0000000..ea9e3a5
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/HdfsStatsCleaner.java
@@ -0,0 +1,44 @@
+package org.apache.blur.agent.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 org.apache.blur.agent.connections.cleaners.interfaces.HdfsDatabaseCleanerInterface;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.dao.DataAccessException;
+
+
+public class HdfsStatsCleaner implements Runnable {
+	private static final Log log = LogFactory.getLog(QueriesCleaner.class);
+
+	private final HdfsDatabaseCleanerInterface database;
+
+	public HdfsStatsCleaner(HdfsDatabaseCleanerInterface database) {
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			this.database.deleteOldStats();
+		} catch (DataAccessException e) {
+			log.error("An error occured while deleting hdfs stats from the database!", e);
+		} catch (Exception e) {
+			log.error("An unkown error occured while cleaning up the hdfs stats!", e);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/QueriesCleaner.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/QueriesCleaner.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/QueriesCleaner.java
new file mode 100644
index 0000000..bff64d6
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/cleaners/QueriesCleaner.java
@@ -0,0 +1,48 @@
+package org.apache.blur.agent.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 org.apache.blur.agent.connections.cleaners.interfaces.QueryDatabaseCleanerInterface;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.dao.DataAccessException;
+
+
+public class QueriesCleaner implements Runnable {
+	private static final Log log = LogFactory.getLog(QueriesCleaner.class);
+
+	private final QueryDatabaseCleanerInterface database;
+
+	public QueriesCleaner(final QueryDatabaseCleanerInterface database) {
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			int deletedQueries = this.database.deleteOldQueries();
+			int expiredQueries = this.database.expireOldQueries();
+			if ((deletedQueries + expiredQueries) > 0) {
+				log.info("Removed " + deletedQueries + " queries and " + "Expired " + expiredQueries + " queries, in this pass!");
+			}
+		} catch (DataAccessException e) {
+			log.error("An error occured while deleting queries from the database!", e);
+		} catch (Exception e) {
+			log.error("An unkown error occured while cleaning up the queries!", e);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/BlurCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/BlurCollector.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/BlurCollector.java
new file mode 100644
index 0000000..70ed215
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/BlurCollector.java
@@ -0,0 +1,135 @@
+package org.apache.blur.agent.collectors.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.List;
+import java.util.Map;
+
+import org.apache.blur.agent.Agent;
+import org.apache.blur.agent.collectors.blur.query.QueryCollector;
+import org.apache.blur.agent.collectors.blur.table.TableCollector;
+import org.apache.blur.agent.connections.blur.interfaces.BlurDatabaseInterface;
+import org.apache.blur.agent.exceptions.ZookeeperNameCollisionException;
+import org.apache.blur.agent.exceptions.ZookeeperNameMissingException;
+import org.apache.blur.thrift.BlurClient;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+
+public class BlurCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(BlurCollector.class);
+
+	private final String zookeeperName;
+	private final BlurDatabaseInterface database;
+	private final boolean collectTables;
+	private final boolean collectQueries;
+
+	private String connection;
+
+	public BlurCollector(final String zookeeperName, final String connection, final List<String> activeCollectors,
+			final BlurDatabaseInterface database, final JdbcTemplate jdbc) {
+		this.zookeeperName = zookeeperName;
+		this.connection = connection;
+		this.database = database;
+		this.collectTables = activeCollectors.contains("tables");
+		this.collectQueries = activeCollectors.contains("queries");
+	}
+
+	@Override
+	public void run() {
+		while (true) {
+			// Retrieve the zookeeper id
+			int zookeeperId = getZookeeperId();
+
+			// If the connection string is blank then we need to build it from the
+			// online controllers from the database
+			String resolvedConnection = getResolvedConnection(zookeeperId);
+
+			if (StringUtils.isBlank(resolvedConnection)) {
+				try {
+					Thread.sleep(Agent.COLLECTOR_SLEEP_TIME);
+				} catch (InterruptedException e) {
+					break;
+				}
+				continue;
+			}
+
+			Iface blurConnection = BlurClient.getClient(resolvedConnection);
+
+			/* Retrieve the clusters and their info */
+			for (Map<String, Object> cluster : this.database.getClusters(zookeeperId)) {
+				String clusterName = (String) cluster.get("NAME");
+				Integer clusterId = (Integer) cluster.get("ID");
+
+				List<String> tables;
+				try {
+					tables = blurConnection.tableListByCluster(clusterName);
+				} catch (Exception e) {
+					log.error("An error occured while trying to retrieve the table list for cluster[" + clusterName + "], skipping cluster", e);
+					continue;
+				}
+
+				for (final String tableName : tables) {
+					int tableId = this.database.getTableId(clusterId, tableName);
+					if (tableId == -1) {
+						continue;
+					}
+
+					if (this.collectTables) {
+						new Thread(new TableCollector(blurConnection, tableName, tableId, this.database), "Table Collector - " + tableName).start();
+					}
+
+					if (this.collectQueries) {
+						new Thread(new QueryCollector(blurConnection, tableName, tableId, this.database), "Query Collector - " + tableName).start();
+					}
+				}
+			}
+
+			try {
+				Thread.sleep(Agent.COLLECTOR_SLEEP_TIME);
+			} catch (InterruptedException e) {
+				break;
+			}
+		}
+	}
+
+	private String getResolvedConnection(int zookeeperId) {
+		if (StringUtils.isBlank(this.connection)) {
+			return this.database.resolveConnectionString(zookeeperId);
+		} else {
+			return this.connection;
+		}
+	}
+
+	private int getZookeeperId() {
+		try {
+			return Integer.parseInt(this.database.getZookeeperId(this.zookeeperName));
+		} catch (NumberFormatException e) {
+			log.error("The returned zookeeperId is not a valid number", e);
+			return -1;
+		} catch (ZookeeperNameMissingException e) {
+			log.error(e.getMessage(), e);
+			return -1;
+		} catch (ZookeeperNameCollisionException e) {
+			log.error(e.getMessage(), e);
+			return -1;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/query/QueryCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/query/QueryCollector.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/query/QueryCollector.java
new file mode 100644
index 0000000..1b62127
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/query/QueryCollector.java
@@ -0,0 +1,105 @@
+package org.apache.blur.agent.collectors.blur.query;
+
+/**
+ * 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.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.blur.agent.connections.blur.interfaces.QueryDatabaseInterface;
+import org.apache.blur.agent.types.TimeHelper;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurQueryStatus;
+import org.apache.blur.thrift.generated.Query;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.map.ObjectMapper;
+
+
+public class QueryCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(QueryCollector.class);
+
+	private final Iface blurConnection;
+	private final String tableName;
+	private final int tableId;
+	private final QueryDatabaseInterface database;
+
+	public QueryCollector(Iface connection, String tableName, int tableId, QueryDatabaseInterface database) {
+		this.blurConnection = connection;
+		this.tableName = tableName;
+		this.tableId = tableId;
+		this.database = database;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public void run() {
+		Set<String> currentQueries = new HashSet<String>();
+		try {
+			currentQueries.addAll(blurConnection.queryStatusIdList(tableName));
+			//currentQueries.addAll(this.database.getRunningQueries());
+		} catch (Exception e) {
+			log.error("Unable to get the list of current queries [" + tableName + "]." + e.getMessage());
+			return;
+		}
+		
+		// Mark running queries that can't be found as complete - unknown
+		this.database.markOrphanedRunningQueriesComplete(CollectionUtils.subtract(this.database.getRunningQueries((long)tableId), currentQueries));
+		
+
+		for (String queryUUID : currentQueries) {
+			BlurQueryStatus status;
+			try {
+				status = blurConnection.queryStatusById(tableName, queryUUID);
+			} catch (Exception e) {
+				log.error("Unable to get query status for query [" + queryUUID + "]." + e.getMessage());
+				continue;
+			}
+
+			Map<String, Object> oldQuery = this.database.getQuery(this.tableId, queryUUID);
+
+			String times;
+			try {
+				times = new ObjectMapper().writeValueAsString(status.getCpuTimes());
+			} catch (Exception e) {
+				log.error("Unable to parse cpu times.", e);
+				times = null;
+			}
+
+			if (oldQuery == null) {
+				Query query = status.getQuery().getQuery();
+				long startTimeLong = status.getQuery().getStartTime();
+
+				// Set the query creation time to now or given start time
+				Date startTime = (startTimeLong > 0) ? TimeHelper.getAdjustedTime(startTimeLong).getTime() : TimeHelper.now().getTime();
+
+				this.database.createQuery(status, query, times, startTime, this.tableId);
+			} else if (queryHasChanged(status, times, oldQuery)) {
+				this.database.updateQuery(status, times, (Integer) oldQuery.get("ID"));
+			}
+		}
+	}
+
+	private static boolean queryHasChanged(BlurQueryStatus blurQueryStatus, String timesJSON, Map<String, Object> oldQueryInfo) {
+		return blurQueryStatus.getState().getValue() == 0
+				|| !(timesJSON.equals(oldQueryInfo.get("TIMES"))
+						&& blurQueryStatus.getCompleteShards() == (Integer) oldQueryInfo.get("COMPLETE_SHARDS") && blurQueryStatus.getState()
+						.getValue() == (Integer) oldQueryInfo.get("STATE"));
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/SchemaCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/SchemaCollector.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/SchemaCollector.java
new file mode 100644
index 0000000..38d0911
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/SchemaCollector.java
@@ -0,0 +1,101 @@
+package org.apache.blur.agent.collectors.blur.table;
+
+/**
+ * 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.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.blur.agent.connections.blur.interfaces.TableDatabaseInterface;
+import org.apache.blur.agent.exceptions.NullReturnedException;
+import org.apache.blur.agent.types.Column;
+import org.apache.blur.agent.types.Family;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.ColumnDefinition;
+import org.apache.blur.thrift.generated.Schema;
+import org.apache.blur.thrift.generated.TableDescriptor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.springframework.dao.DataAccessException;
+
+
+public class SchemaCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(SchemaCollector.class);
+
+	private final Iface blurConnection;
+	private final String tableName;
+	private final int tableId;
+	private final TableDescriptor descriptor;
+	private final TableDatabaseInterface database;
+
+	public SchemaCollector(Iface connection, String tableName, int tableId, TableDescriptor descriptor, TableDatabaseInterface database) {
+		this.blurConnection = connection;
+		this.tableName = tableName;
+		this.tableId = tableId;
+		this.descriptor = descriptor;
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			Schema schema = null;
+			schema = blurConnection.schema(tableName);
+			if (schema == null || descriptor == null) {
+				throw new NullReturnedException("No Schema or Descriptor Defined!");
+			}
+
+			List<Family> columnDefs = getColumnDefinitions(schema);
+
+			this.database.updateTableSchema(this.tableId, new ObjectMapper().writeValueAsString(columnDefs), "UNKNOWN");
+		} catch (BlurException e) {
+			log.error("Unable to get the shard schema for table [" + tableName + "].", e);
+		} catch (JsonProcessingException e) {
+			log.error("Unable to convert shard schema to json.", e);
+		} catch (DataAccessException e) {
+			log.error("An error occurred while writing the schema to the database.", e);
+		} catch (NullReturnedException e) {
+			log.error(e.getMessage(), e);
+		} catch (Exception e) {
+			log.error("An unknown error occurred in the TableSchemaCollector.", e);
+		}
+	}
+
+	private List<Family> getColumnDefinitions(final Schema schema) {
+		List<Family> columnDefs = new ArrayList<Family>();
+		Map<String, Map<String, ColumnDefinition>> columnFamilies = schema.getFamilies();
+		if (columnFamilies != null) {
+			for (Map.Entry<String, Map<String, ColumnDefinition>> schemaEntry : columnFamilies.entrySet()) {
+				Family family = new Family(schemaEntry.getKey());
+				for (ColumnDefinition def : schemaEntry.getValue().values()) {
+					Column column = new Column(def.getColumnName());
+					column.setFullText(def.isFieldLessIndexed());
+					//TODO: Rename this type
+					column.setAnalyzer(def.getFieldType());
+					//TODO: Do anything with subcolumns?
+					
+					family.getColumns().add(column);
+				}
+				columnDefs.add(family);
+			}
+		}
+		return columnDefs;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/ServerCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/ServerCollector.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/ServerCollector.java
new file mode 100644
index 0000000..483923f
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/ServerCollector.java
@@ -0,0 +1,85 @@
+package org.apache.blur.agent.collectors.blur.table;
+
+/**
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.blur.agent.connections.blur.interfaces.TableDatabaseInterface;
+import org.apache.blur.agent.exceptions.NullReturnedException;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.springframework.dao.DataAccessException;
+
+
+public class ServerCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(ServerCollector.class);
+
+	private final Iface blurConnection;
+	private final String tableName;
+	private final int tableId;
+	private final TableDatabaseInterface database;
+
+	public ServerCollector(Iface connection, String tableName, int tableId, TableDatabaseInterface database) {
+		this.blurConnection = connection;
+		this.tableName = tableName;
+		this.tableId = tableId;
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			Map<String, String> shardServerLayout = blurConnection.shardServerLayout(tableName);
+			if (shardServerLayout == null) {
+				throw new NullReturnedException("No server layout was returned!");
+			}
+			Map<String, ArrayList<String>> serverLayout = getServerLayout(shardServerLayout);
+			this.database.updateTableServer(tableId, new ObjectMapper().writeValueAsString(serverLayout));
+
+		} catch (BlurException e) {
+			log.error("Unable to get shard server layout for table [" + tableName + "].", e);
+		} catch (JsonProcessingException e) {
+			log.error("Unable to convert the shard layout to json.", e);
+		} catch (DataAccessException e) {
+			log.error("An error occurred while writing the server to the database.", e);
+		} catch (NullReturnedException e) {
+			log.error(e.getMessage(), e);
+		} catch (Exception e) {
+			log.error("An unknown error occurred in the TableServerCollector.", e);
+		}
+	}
+
+	private Map<String, ArrayList<String>> getServerLayout(Map<String, String> shardServerLayout) {
+		Map<String, ArrayList<String>> formattedShard = new HashMap<String, ArrayList<String>>();
+		for (String shard : shardServerLayout.keySet()) {
+			String host = shardServerLayout.get(shard);
+			if (formattedShard.get(host) != null) {
+				formattedShard.get(host).add(shard);
+			} else {
+				formattedShard.put(host, new ArrayList<String>(Arrays.asList(shard)));
+			}
+		}
+		return formattedShard;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/StatsCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/StatsCollector.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/StatsCollector.java
new file mode 100644
index 0000000..8701960
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/StatsCollector.java
@@ -0,0 +1,64 @@
+package org.apache.blur.agent.collectors.blur.table;
+
+/**
+ * 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 org.apache.blur.agent.connections.blur.interfaces.TableDatabaseInterface;
+import org.apache.blur.agent.exceptions.NullReturnedException;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.TableStats;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.dao.DataAccessException;
+
+
+public class StatsCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(StatsCollector.class);
+
+	private final Iface blurConnection;
+	private final String tableName;
+	private final int tableId;
+	private final TableDatabaseInterface database;
+
+	public StatsCollector(Iface connection, String tableName, int tableId, TableDatabaseInterface database) {
+		this.blurConnection = connection;
+		this.tableName = tableName;
+		this.tableId = tableId;
+		this.database = database;
+	}
+
+	@Override
+	public void run() {
+		try {
+			TableStats tableStats = blurConnection.tableStats(this.tableName);
+
+			if (tableStats == null) {
+				throw new NullReturnedException("No table statistics were returned!");
+			}
+
+			this.database.updateTableStats(tableId, tableStats.getBytes(), tableStats.getRecordCount(),	tableStats.getRowCount());
+		} catch (BlurException e) {
+			log.error("Unable to get table stats for table [" + tableId + "].", e);
+		} catch (DataAccessException e) {
+			log.error("An error occurred while writing the server to the database.", e);
+		} catch (NullReturnedException e) {
+			log.error(e.getMessage(), e);
+		} catch (Exception e) {
+			log.error("An unknown error occurred in the TableServerCollector.", e);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/688e9d08/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/TableCollector.java
----------------------------------------------------------------------
diff --git a/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/TableCollector.java b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/TableCollector.java
new file mode 100644
index 0000000..d0b8e99
--- /dev/null
+++ b/contrib/blur-console-old/blur-agent/src/main/java/org/apache/blur/agent/collectors/blur/table/TableCollector.java
@@ -0,0 +1,66 @@
+package org.apache.blur.agent.collectors.blur.table;
+
+/**
+ * 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 org.apache.blur.agent.connections.blur.interfaces.TableDatabaseInterface;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.TableDescriptor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class TableCollector implements Runnable {
+	private static final Log log = LogFactory.getLog(TableCollector.class);
+
+	private final Iface blurConnection;
+	private final String tableName;
+	private final int tableId;
+	private final TableDatabaseInterface database;
+
+	public TableCollector(Iface connection, String tableName, int tableId, TableDatabaseInterface database) {
+		this.blurConnection = connection;
+		this.tableName = tableName;
+		this.database = database;
+		this.tableId = tableId;
+	}
+
+	@Override
+	public void run() {
+		try {
+			TableDescriptor descriptor;
+			try {
+				descriptor = blurConnection.describe(tableName);
+			} catch (Exception e) {
+				log.error("An error occured while trying to describe the table [" + tableName + "], skipping table", e);
+				return;
+			}
+
+			/* spawn the different table info collectors */
+			if (descriptor.enabled) {
+				new Thread(new SchemaCollector(this.blurConnection, this.tableName, this.tableId, descriptor, this.database),
+						"Table Schema Collector - " + this.tableName).start();
+			}
+			new Thread(new ServerCollector(this.blurConnection, this.tableName, this.tableId, this.database), "Table Server Collector - "
+					+ this.tableName).start();
+			new Thread(new StatsCollector(this.blurConnection, this.tableName, this.tableId, this.database), "Table Stats Collector - "
+					+ this.tableName).start();
+
+		} catch (Exception e) {
+			log.error("An unknown error occurred.", e);
+		}
+	}
+}


Mime
View raw message