diff --git a/UnitTests/HttpInterface/api-simple-hash-spec.rb b/UnitTests/HttpInterface/api-simple-hash-spec.rb new file mode 100644 index 0000000000..4880313475 --- /dev/null +++ b/UnitTests/HttpInterface/api-simple-hash-spec.rb @@ -0,0 +1,276 @@ +# coding: utf-8 + +require 'rspec' +require './arangodb.rb' + +describe ArangoDB do + api = "/_api/simple" + prefix = "api-simple" + + context "simple queries:" do + +################################################################################ +## range query +################################################################################ + + context "hash query:" do + before do + @cn = "UnitTestsCollectionHash" + ArangoDB.drop_collection(@cn) + @cid = ArangoDB.create_collection(@cn, false) + end + + after do + ArangoDB.drop_collection(@cn) + end + + it "finds the examples, wrong index specified" do + cmd = api + "/by-example-hash" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"1\", \"example\" : { \"i\" : 12 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(404) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['code'].should eq(404) + doc.parsed_response['error'].should eq(true) + doc.parsed_response['errorNum'].should eq(1209) + end + + it "finds the examples, wrong attribute" do + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"hash\", \"unique\" : true, \"fields\" : [ \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + cmd = api + "/by-example-hash" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 12 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(404) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['code'].should eq(404) + doc.parsed_response['error'].should eq(true) + doc.parsed_response['errorNum'].should eq(1209) + end + + it "finds the examples, no index specified" do + cmd = api + "/by-example-hash" + body = "{ \"collection\" : \"#{@cn}\", \"example\" : { \"i\" : 12 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(0) + doc.parsed_response['count'].should eq(0) + end + + it "finds the examples, unique index" do + # create data + for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] + body = "{ \"i\" : #{i} }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"hash\", \"unique\" : true, \"fields\" : [ \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-hash + cmd = api + "/by-example-hash" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 3 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(1) + doc.parsed_response['count'].should eq(1) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [3] + + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 12 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(0) + doc.parsed_response['count'].should eq(0) + end + + it "finds the examples, non-unique index" do + # create data + for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] + body = "{ \"i\" : #{i}, \"j\" : 2 }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"hash\", \"unique\" : false, \"fields\" : [ \"j\", \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-hash + cmd = api + "/by-example-hash" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 2, \"i\" : 2 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(1) + doc.parsed_response['count'].should eq(1) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [2] + doc.parsed_response['result'].map{|i| i['j']}.should =~ [2] + + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 2, \"j\" : 2 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(1) + doc.parsed_response['count'].should eq(1) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [2] + doc.parsed_response['result'].map{|i| i['j']}.should =~ [2] + + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 3, \"i\" : 2 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(0) + doc.parsed_response['count'].should eq(0) + end + + it "finds the examples" do + # create data + + (0..10).each do |i| + (0..10).each do |j| + body = "{ \"i\" : #{i}, \"j\" : #{j} }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"hash\", \"unique\" : false, \"fields\" : [ \"i\", \"j\" ] }" + doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-hash + cmd = api + "/by-example-hash" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 1, \"j\" : 7 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(1) + doc.parsed_response['count'].should eq(1) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [1] + doc.parsed_response['result'].map{|i| i['j']}.should =~ [7] + end + + it "finds the examples, multiple elements" do + # create data + + (0..9).each do |i| + (0..9).each do |j| + body = "{ \"i\" : #{i}, \"j\" : #{j} }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"hash\", \"unique\" : false, \"fields\" : [ \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-hash + cmd = api + "/by-example-hash" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 1 } }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(10) + doc.parsed_response['count'].should eq(10) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [1,1,1,1,1,1,1,1,1,1] + end + + it "finds the examples, small batchsize" do + # create data + + (0..9).each do |i| + (0..9).each do |j| + body = "{ \"i\" : #{i}, \"j\" : #{j} }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"hash\", \"unique\" : false, \"fields\" : [ \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-hash + cmd = api + "/by-example-hash" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 0 }, \"batchSize\" : 2 }" + doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(true) + doc.parsed_response['result'].length.should eq(2) + doc.parsed_response['count'].should eq(10) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [0,0] + end + end + + end +end diff --git a/UnitTests/HttpInterface/api-simple-skiplist-spec.rb b/UnitTests/HttpInterface/api-simple-skiplist-spec.rb new file mode 100644 index 0000000000..05defef8a1 --- /dev/null +++ b/UnitTests/HttpInterface/api-simple-skiplist-spec.rb @@ -0,0 +1,276 @@ +# coding: utf-8 + +require 'rspec' +require './arangodb.rb' + +describe ArangoDB do + api = "/_api/simple" + prefix = "api-simple" + + context "simple queries:" do + +################################################################################ +## range query +################################################################################ + + context "skiplist query:" do + before do + @cn = "UnitTestsCollectionSkiplist" + ArangoDB.drop_collection(@cn) + @cid = ArangoDB.create_collection(@cn, false) + end + + after do + ArangoDB.drop_collection(@cn) + end + + it "finds the examples, wrong index specified" do + cmd = api + "/by-example-skiplist" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"1\", \"example\" : { \"i\" : 12 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(404) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['code'].should eq(404) + doc.parsed_response['error'].should eq(true) + doc.parsed_response['errorNum'].should eq(1209) + end + + it "finds the examples, wrong attribute" do + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"skiplist\", \"unique\" : true, \"fields\" : [ \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + cmd = api + "/by-example-skiplist" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 12 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(404) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['code'].should eq(404) + doc.parsed_response['error'].should eq(true) + doc.parsed_response['errorNum'].should eq(1209) + end + + it "finds the examples, no index specified" do + cmd = api + "/by-example-skiplist" + body = "{ \"collection\" : \"#{@cn}\", \"example\" : { \"i\" : 12 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(0) + doc.parsed_response['count'].should eq(0) + end + + it "finds the examples, unique index" do + # create data + for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] + body = "{ \"i\" : #{i} }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"skiplist\", \"unique\" : true, \"fields\" : [ \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-skiplist + cmd = api + "/by-example-skiplist" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 3 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(1) + doc.parsed_response['count'].should eq(1) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [3] + + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 12 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(0) + doc.parsed_response['count'].should eq(0) + end + + it "finds the examples, non-unique index" do + # create data + for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] + body = "{ \"i\" : #{i}, \"j\" : 2 }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"skiplist\", \"unique\" : false, \"fields\" : [ \"j\", \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-skiplist + cmd = api + "/by-example-skiplist" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 2, \"i\" : 2 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(1) + doc.parsed_response['count'].should eq(1) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [2] + doc.parsed_response['result'].map{|i| i['j']}.should =~ [2] + + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 2, \"j\" : 2 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(1) + doc.parsed_response['count'].should eq(1) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [2] + doc.parsed_response['result'].map{|i| i['j']}.should =~ [2] + + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 3, \"i\" : 2 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(0) + doc.parsed_response['count'].should eq(0) + end + + it "finds the examples" do + # create data + + (0..10).each do |i| + (0..10).each do |j| + body = "{ \"i\" : #{i}, \"j\" : #{j} }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"skiplist\", \"unique\" : false, \"fields\" : [ \"i\", \"j\" ] }" + doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-skiplist + cmd = api + "/by-example-skiplist" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 1, \"j\" : 7 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(1) + doc.parsed_response['count'].should eq(1) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [1] + doc.parsed_response['result'].map{|i| i['j']}.should =~ [7] + end + + it "finds the examples, multiple elements" do + # create data + + (0..9).each do |i| + (0..9).each do |j| + body = "{ \"i\" : #{i}, \"j\" : #{j} }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"skiplist\", \"unique\" : false, \"fields\" : [ \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-skiplist + cmd = api + "/by-example-skiplist" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 1 } }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(false) + doc.parsed_response['result'].length.should eq(10) + doc.parsed_response['count'].should eq(10) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [1,1,1,1,1,1,1,1,1,1] + end + + it "finds the examples, small batchsize" do + # create data + + (0..9).each do |i| + (0..9).each do |j| + body = "{ \"i\" : #{i}, \"j\" : #{j} }" + doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body) + doc.code.should eq(202) + end + end + + # create index + cmd = "/_api/index?collection=#{@cn}" + body = "{ \"type\" : \"skiplist\", \"unique\" : false, \"fields\" : [ \"i\" ] }" + doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body) + + doc.code.should eq(201) + iid = doc.parsed_response['id'] + + # by-example-skiplist + cmd = api + "/by-example-skiplist" + body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 0 }, \"batchSize\" : 2 }" + doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body) + + doc.code.should eq(201) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(201) + doc.parsed_response['hasMore'].should eq(true) + doc.parsed_response['result'].length.should eq(2) + doc.parsed_response['count'].should eq(10) + doc.parsed_response['result'].map{|i| i['i']}.should =~ [0,0] + end + end + + end +end diff --git a/UnitTests/HttpInterface/run-tests b/UnitTests/HttpInterface/run-tests index f92828071e..75f975f3a5 100755 --- a/UnitTests/HttpInterface/run-tests +++ b/UnitTests/HttpInterface/run-tests @@ -34,7 +34,9 @@ rspec --color --format d \ api-simple-example-spec.rb \ api-simple-fulltext-spec.rb \ api-simple-geo-spec.rb \ + api-simple-hash-spec.rb \ api-simple-range-spec.rb \ + api-simple-skiplist-spec.rb \ api-simple-spec.rb \ api-structures.rb \ api-transactions-spec.rb \ diff --git a/js/apps/system/aardvark/cluster.js b/js/apps/system/aardvark/cluster.js index d4e3ca5b9a..7539d61f93 100644 --- a/js/apps/system/aardvark/cluster.js +++ b/js/apps/system/aardvark/cluster.js @@ -159,7 +159,7 @@ _.each(list, function(url, k) { var v = {}; v.name = k; - v.url = url; + v.address = url; resList.push(v); if (_.contains(noBeat, k)) { v.status = "critical"; diff --git a/js/apps/system/aardvark/clusterFrontend/html/head.html.part b/js/apps/system/aardvark/clusterFrontend/html/head.html.part index 0938fbc27e..717962603e 100644 --- a/js/apps/system/aardvark/clusterFrontend/html/head.html.part +++ b/js/apps/system/aardvark/clusterFrontend/html/head.html.part @@ -4,6 +4,6 @@ - + diff --git a/js/apps/system/aardvark/clusterFrontend/html/scripts.html.part b/js/apps/system/aardvark/clusterFrontend/html/scripts.html.part index ed727ae40a..50dcd9d894 100644 --- a/js/apps/system/aardvark/clusterFrontend/html/scripts.html.part +++ b/js/apps/system/aardvark/clusterFrontend/html/scripts.html.part @@ -1,2 +1,4 @@ + + diff --git a/js/apps/system/aardvark/clusterFrontend/js/collections/arangoClusterStatisticsCollection.js b/js/apps/system/aardvark/clusterFrontend/js/collections/arangoClusterStatisticsCollection.js new file mode 100644 index 0000000000..eee90bc208 --- /dev/null +++ b/js/apps/system/aardvark/clusterFrontend/js/collections/arangoClusterStatisticsCollection.js @@ -0,0 +1,11 @@ +/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */ +/*global require, exports, Backbone, window */ +window.ClusterStatisticsCollection = Backbone.Collection.extend({ + model: window.Statistics, + url: "/_admin/statistics", + fetch: function() { + this.forEach(function (m) { + m.fetch({async: false}); + }) + } +}); diff --git a/js/apps/system/aardvark/clusterFrontend/js/collections/clusterCoordinators.js b/js/apps/system/aardvark/clusterFrontend/js/collections/clusterCoordinators.js index f9250fc7e5..8891b69bd7 100644 --- a/js/apps/system/aardvark/clusterFrontend/js/collections/clusterCoordinators.js +++ b/js/apps/system/aardvark/clusterFrontend/js/collections/clusterCoordinators.js @@ -13,6 +13,20 @@ this.interval = 1000; }, + byAddress: function (res) { + this.fetch({ + async: false + }); + res = res || {}; + this.forEach(function(m) { + var addr = m.get("address"); + addr = addr.substr(6); + addr = addr.split(":")[0]; + res[addr] = res[addr] || []; + res[addr].push(m); + }); + }, + getList: function() { this.fetch({ async: false diff --git a/js/apps/system/aardvark/clusterFrontend/js/collections/clusterServers.js b/js/apps/system/aardvark/clusterFrontend/js/collections/clusterServers.js index 5c5095c541..eeefbd48c2 100644 --- a/js/apps/system/aardvark/clusterFrontend/js/collections/clusterServers.js +++ b/js/apps/system/aardvark/clusterFrontend/js/collections/clusterServers.js @@ -16,6 +16,21 @@ this.interval = 1000; }, + byAddress: function (res) { + this.fetch({ + async: false + }); + res = res || {}; + this.forEach(function(m) { + var addr = m.get("address"); + addr = addr.substr(6); + addr = addr.split(":")[0]; + res[addr] = res[addr] || []; + res[addr].push(m); + }); + return res; + }, + getList: function() { this.fetch({ async: false diff --git a/js/apps/system/aardvark/clusterFrontend/js/templates/showCluster.ejs b/js/apps/system/aardvark/clusterFrontend/js/templates/showCluster.ejs index 7083cd03fc..4a1694a21b 100644 --- a/js/apps/system/aardvark/clusterFrontend/js/templates/showCluster.ejs +++ b/js/apps/system/aardvark/clusterFrontend/js/templates/showCluster.ejs @@ -6,5 +6,4 @@
-
diff --git a/js/apps/system/aardvark/clusterFrontend/js/views/showClusterView.js b/js/apps/system/aardvark/clusterFrontend/js/views/showClusterView.js index 32ebad2be0..0d455e3a87 100644 --- a/js/apps/system/aardvark/clusterFrontend/js/views/showClusterView.js +++ b/js/apps/system/aardvark/clusterFrontend/js/views/showClusterView.js @@ -19,7 +19,6 @@ this.coordinators.fetch({ async : false }); - this.data = []; if (this.statisticsDescription === undefined) { this.statisticsDescription = new window.StatisticsDescription(); this.statisticsDescription.fetch({ @@ -27,20 +26,92 @@ }); } var self = this; - this.dbservers.forEach(function (server) { - var statCollect = new window.StatisticsCollection(); - statCollect.url = server.get("address").replace("tcp", "http") + "/_admin/statistics"; - self.data.push(statCollect); - statCollect.fetch(); + var statCollect = new window.ClusterStatisticsCollection(); + this.dbservers.forEach(function (dbserver) { + var stat = new window.Statistics({name: dbserver.id}); + stat.url = dbserver.get("address").replace("tcp", "http") + "/_admin/statistics"; + statCollect.add(stat); }); + this.coordinators.forEach(function (coordinator) { + var stat = new window.Statistics({name: coordinator.id}); + stat.url = coordinator.get("address").replace("tcp", "http") + "/_admin/statistics"; + statCollect.add(stat); + }); + statCollect.fetch(); + this.data = statCollect; + + var byAddress = this.dbservers.byAddress(); + byAddress = this.coordinators.byAddress(byAddress); + console.log(byAddress); }, + + render: function() { - console.log(this.data); - console.log(this.coordinators.getOverview()); + var self = this; $(this.el).html(this.template.render({})); - } + var totalTimeData = []; + this.data.forEach(function(m) { + totalTimeData.push({key: m.get("name"), value :m.get("client").totalTime.sum}); + }); + self.renderPieChart(totalTimeData); + }, + + + + renderPieChart: function(dataset) { + var w = 620; + var h = 480; + + + + var radius = Math.min(w, h) / 2; //change 2 to 1.4. It's hilarious. + + var color = d3.scale.category20(); + + var arc = d3.svg.arc() //each datapoint will create one later. + .outerRadius(radius - 20) + .innerRadius(0); + + var pie = d3.layout.pie() + .sort(function (d) { + return d.value; + }) + .value(function (d) { + return d.value; + }); + + var svg = d3.select("#clusterGraphs").append("svg") + .attr("width", w) + .attr("height", h) + .attr("class", "clusterChart") + .append("g") //someone to transform. Groups data. + .attr("transform", "translate(" + w / 2 + "," + h / 2 + ")"); + + var slices = svg.selectAll(".arc") + .data(pie(dataset)) + .enter().append("g") + .attr("class", "slice"); + + slices.append("path") + .attr("d", arc) + .style("fill", function (d, i) { + return color(i); + }); + + //add text, even + slices.append("text") + .attr("transform", function (d) { + return "translate(" + arc.centroid(d) + ")"; + }) + .attr("class", "data-title") + .text(function (d) { + return d.data.key; + }); + } }); + + }()); diff --git a/js/apps/system/aardvark/frontend/scss/cluster.scss b/js/apps/system/aardvark/frontend/scss/cluster.scss new file mode 100644 index 0000000000..9c80589a0d --- /dev/null +++ b/js/apps/system/aardvark/frontend/scss/cluster.scss @@ -0,0 +1,4 @@ +//shared +@import "shared"; +//cluster Charts +@import "clusterCharts"; \ No newline at end of file diff --git a/js/apps/system/aardvark/manifest.json b/js/apps/system/aardvark/manifest.json index 1c347bee2f..17658ebd28 100644 --- a/js/apps/system/aardvark/manifest.json +++ b/js/apps/system/aardvark/manifest.json @@ -188,7 +188,7 @@ "css/cluster.css": { "files": [ - + "frontend/scss/cluster.css" ] }, diff --git a/js/common/bootstrap/modules.js b/js/common/bootstrap/modules.js index b1a7c7ffd7..2459110a2b 100644 --- a/js/common/bootstrap/modules.js +++ b/js/common/bootstrap/modules.js @@ -1,6 +1,6 @@ /*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true, white: true, plusplus: true, regexp: true, nonpropdel: true */ /*global require, module: true, STARTUP_PATH, DEV_APP_PATH, APP_PATH, MODULES_PATH, - EXPORTS_SLOW_BUFFER */ + EXPORTS_SLOW_BUFFER, SYS_PLATFORM */ //////////////////////////////////////////////////////////////////////////////// /// @brief JavaScript server functions diff --git a/js/server/modules/org/arangodb/simple-query.js b/js/server/modules/org/arangodb/simple-query.js index 6569df95e6..87adc57cdb 100644 --- a/js/server/modules/org/arangodb/simple-query.js +++ b/js/server/modules/org/arangodb/simple-query.js @@ -1,4 +1,4 @@ -/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */ +/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true, continue: true */ /*global require, exports, ArangoClusterComm, ArangoClusterInfo */ //////////////////////////////////////////////////////////////////////////////// @@ -293,14 +293,7 @@ function byExample (data) { continue; } - try { - idx = collection.lookupIndex(checks[k]); - } - catch (e) { - // ignore any errors we counter during index lookup - throw e; - } - + idx = collection.lookupIndex(checks[k]); if (idx !== null) { // found an index break; diff --git a/js/server/tests/ahuacatl-functions.js b/js/server/tests/ahuacatl-functions.js index 8220a4fcef..3498e2bddc 100644 --- a/js/server/tests/ahuacatl-functions.js +++ b/js/server/tests/ahuacatl-functions.js @@ -2231,8 +2231,6 @@ function ahuacatlFunctionsTestSuite () { actual = getQueryResults("FOR x IN SKIPLIST(" + cn + ", { a: [[ '==', 1 ]], b: [[ '==', 2 ]] }) RETURN x"); assertEqual(expected, actual); - assertQueryError(errors.ERROR_ARANGO_NO_INDEX.code, "RETURN SKIPLIST(" + cn + ", { b: [[ '==', 2 ]], a: [[ '==', 1 ]] })"); - expected = [ ]; actual = getQueryResults("FOR x IN SKIPLIST(" + cn + ", { a: [[ '==', 2 ]], b: [[ '==', 1 ]] }, 1, 1) RETURN x"); assertEqual(expected, actual);