Skip to content

Commit

Permalink
[API] [1.0] Changed the namespace for cluster.nodes_* APIs to nodes
Browse files Browse the repository at this point in the history
Due to changes in Elasticsearch 1.0 API, the client "namespaces" have been
changed to reflect the change in URLs: `_cluster/nodes` => `_nodes`

Thus, instead of:

    client.cluster.nodes_info

the new API is:

    client.nodes.info

Related:

* elastic/elasticsearch#4055
* elastic/elasticsearch#4336
* elastic/elasticsearch#4769
  • Loading branch information
karmi committed Jan 29, 2014
1 parent 8801997 commit 560647b
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 38 deletions.
1 change: 1 addition & 0 deletions elasticsearch-api/lib/elasticsearch/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def self.included(base)
Elasticsearch::API::Common,
Elasticsearch::API::Actions,
Elasticsearch::API::Cluster,
Elasticsearch::API::Nodes,
Elasticsearch::API::Indices
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Elasticsearch
module API
module Cluster
module Nodes
module Actions

# Returns information about the hottest threads in the cluster or on a specific node as a String.
Expand All @@ -11,7 +11,7 @@ module Actions
#
# @example Return 10 hottest threads
#
# client.cluster.node_hot_threads threads: 10
# client.nodes.hot_threads threads: 10
#
# @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information;
# use `_local` to return information from the node you're connecting to,
Expand All @@ -25,7 +25,7 @@ module Actions
#
# @see http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-hot-threads/
#
def node_hot_threads(arguments={})
def hot_threads(arguments={})
valid_params = [
:interval,
:snapshots,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Elasticsearch
module API
module Cluster
module Nodes
module Actions

# Returns information about nodes in the cluster (cluster settings, JVM version, etc).
Expand All @@ -12,7 +12,7 @@ module Actions
#
# @example Return information about JVM
#
# client.cluster.node_info jvm: true
# client.nodes.info jvm: true
#
# @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information;
# use `_local` to return information from the node you're connecting to, leave
Expand All @@ -31,7 +31,7 @@ module Actions
#
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-info/
#
def node_info(arguments={})
def info(arguments={})
valid_params = [
:all,
:clear,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module Elasticsearch
module API
module Cluster
module Nodes
module Actions

# Shutdown one or all nodes
#
# @example Shut down node named _Bloke_
#
# client.cluster.node_shutdown node_id: 'Bloke'
# client.nodes.shutdown node_id: 'Bloke'
#
# @option arguments [List] :node_id A comma-separated list of node IDs or names to perform the operation on; use
# `_local` to shutdown the node you're connected to, leave empty to
Expand All @@ -17,7 +17,7 @@ module Actions
#
# @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown/
#
def node_shutdown(arguments={})
def shutdown(arguments={})
valid_params = [
:delay,
:exit ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module Elasticsearch
module API
module Cluster
module Nodes
module Actions

# Returns statistical information about nodes in the cluster.
#
# @example Return statistics about JVM
#
# client.cluster.node_stats metric: 'jvm'
# client.nodes.stats metric: 'jvm'
#
# @example Return statistics about field data structures for all fields
#
# client.cluster.node_stats metric: 'indices', index_metric: 'fielddata', fields: '*', human: true
# client.nodes.stats metric: 'indices', index_metric: 'fielddata', fields: '*', human: true
#
# @option arguments [List] :metric Limit the information returned to the specified metrics
# (options: _all, breaker, fs, http, indices, jvm, network,
Expand Down Expand Up @@ -40,7 +40,7 @@ module Actions
#
# @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html
#
def node_stats(arguments={})
def stats(arguments={})
arguments = arguments.clone

valid_params = [
Expand Down
20 changes: 20 additions & 0 deletions elasticsearch-api/lib/elasticsearch/api/namespace/nodes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Elasticsearch
module API
module Nodes
module Actions; end

# Client for the "nodes" namespace (includes the {Nodes::Actions} methods)
#
class NodesClient
include Common::Client, Common::Client::Base, Nodes::Actions
end

# Proxy method for {NodesClient}, available in the receiving object
#
def nodes
@nodes ||= NodesClient.new(self)
end

end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module Elasticsearch
module Test
class ClusterNodeHotThreadsTest < ::Test::Unit::TestCase
class NodesHotThreadsTest < ::Test::Unit::TestCase

context "Cluster: Node hot threads" do
context "Nodes: Hot Threads" do
subject { FakeClient.new }

should "perform correct request" do
Expand All @@ -16,7 +16,7 @@ class ClusterNodeHotThreadsTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_hot_threads
subject.nodes.hot_threads
end

should "send :node_id correctly" do
Expand All @@ -25,7 +25,7 @@ class ClusterNodeHotThreadsTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_hot_threads :node_id => 'foo'
subject.nodes.hot_threads :node_id => 'foo'
end

should "URL-escape the parts" do
Expand All @@ -34,7 +34,7 @@ class ClusterNodeHotThreadsTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_hot_threads :node_id => 'foo^bar'
subject.nodes.hot_threads :node_id => 'foo^bar'
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module Elasticsearch
module Test
class ClusterNodeInfoTest < ::Test::Unit::TestCase
class NodesInfoTest < ::Test::Unit::TestCase

context "Cluster: Node info" do
context "Nodes: Info" do
subject { FakeClient.new }

should "perform correct request" do
Expand All @@ -16,7 +16,7 @@ class ClusterNodeInfoTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_info
subject.nodes.info
end

should "send :node_id correctly" do
Expand All @@ -25,7 +25,7 @@ class ClusterNodeInfoTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_info :node_id => 'foo'
subject.nodes.info :node_id => 'foo'
end

should "send multiple :node_id-s correctly" do
Expand All @@ -34,8 +34,8 @@ class ClusterNodeInfoTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new).twice

subject.cluster.node_info :node_id => 'A,B,C'
subject.cluster.node_info :node_id => ['A', 'B', 'C']
subject.nodes.info :node_id => 'A,B,C'
subject.nodes.info :node_id => ['A', 'B', 'C']
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module Elasticsearch
module Test
class ClusterNodeShutdownTest < ::Test::Unit::TestCase
class NodesShutdownTest < ::Test::Unit::TestCase

context "Cluster: Node shutdown" do
context "Nodes: Shutdown" do
subject { FakeClient.new }

should "perform correct request" do
Expand All @@ -16,7 +16,7 @@ class ClusterNodeShutdownTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_shutdown
subject.nodes.shutdown
end

should "send :node_id correctly" do
Expand All @@ -25,7 +25,7 @@ class ClusterNodeShutdownTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_shutdown :node_id => 'foo'
subject.nodes.shutdown :node_id => 'foo'
end

should "send multiple :node_id-s correctly" do
Expand All @@ -34,8 +34,8 @@ class ClusterNodeShutdownTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new).twice

subject.cluster.node_shutdown :node_id => 'A,B,C'
subject.cluster.node_shutdown :node_id => ['A', 'B', 'C']
subject.nodes.shutdown :node_id => 'A,B,C'
subject.nodes.shutdown :node_id => ['A', 'B', 'C']
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module Elasticsearch
module Test
class ClusterNodeStatsTest < ::Test::Unit::TestCase
class NodesStatsTest < ::Test::Unit::TestCase

context "Cluster: Node stats" do
context "Nodes: Stats" do
subject { FakeClient.new }

should "perform correct request" do
Expand All @@ -16,7 +16,7 @@ class ClusterNodeStatsTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_stats
subject.nodes.stats
end

should "send :node_id correctly" do
Expand All @@ -25,7 +25,7 @@ class ClusterNodeStatsTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_stats :node_id => 'foo'
subject.nodes.stats :node_id => 'foo'
end

should "get specific metric families" do
Expand All @@ -35,7 +35,7 @@ class ClusterNodeStatsTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_stats :metric => [:http, :fs]
subject.nodes.stats :metric => [:http, :fs]
end

should "get specific metric for the indices family" do
Expand All @@ -44,7 +44,7 @@ class ClusterNodeStatsTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new)

subject.cluster.node_stats :metric => :indices, :index_metric => 'filter_cache'
subject.nodes.stats :metric => :indices, :index_metric => 'filter_cache'
end

should "get fielddata statistics for the indices family" do
Expand All @@ -54,8 +54,8 @@ class ClusterNodeStatsTest < ::Test::Unit::TestCase
true
end.returns(FakeResponse.new).twice

subject.cluster.node_stats :metric => 'indices', :index_metric => 'fielddata', :fields => 'foo,bar'
subject.cluster.node_stats :metric => 'indices', :index_metric => 'fielddata', :fields => ['foo','bar']
subject.nodes.stats :metric => 'indices', :index_metric => 'fielddata', :fields => 'foo,bar'
subject.nodes.stats :metric => 'indices', :index_metric => 'fielddata', :fields => ['foo','bar']
end

end
Expand Down

0 comments on commit 560647b

Please sign in to comment.