class Elastomer::Client::Nodes

Attributes

client[R]
node_id[R]

Public Class Methods

new( client, node_id ) click to toggle source

Create a new nodes client for making API requests that pertain to the health and management individual nodes.

client - Elastomer::Client used for HTTP requests to the server node_id - The node ID as a String or an Array of node IDs

# File lib/elastomer/client/nodes.rb, line 25
def initialize( client, node_id )
  @client  = client
  @node_id = node_id
end

Public Instance Methods

hot_threads( params = {} ) click to toggle source

Get the current hot threads on each node in the cluster. The return value is a human formatted String - i.e. a String with newlines and other formatting characters suitable for display in a terminal window.

params - Parameters Hash

:node_id  - a single node ID or Array of node IDs
:threads  - number of hot threads to provide
:interval - sampling interval [default is 500ms]
:type     - the type to sample: "cpu", "wait", or "block"

See www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html

Returns the response as a String

# File lib/elastomer/client/nodes.rb, line 89
def hot_threads( params = {} )
  response = client.get "/_nodes{/node_id}/hot_threads", update_params(params, action: "nodes.hot_threads", rest_api: "nodes.hot_threads")
  response.body
end
info( params = {} ) click to toggle source

Retrieve one or more (or all) of the cluster nodes information. By default all information is returned from all ndoes. You can select the information to be returned by passing in the `:info` from the list of “settings”, “os”, “process”, “jvm”, “thread_pool”, “network”, “transport”, “http” and “plugins”.

params - Parameters Hash

:node_id - a single node ID or Array of node IDs
:info    - a single information attribute or an Array

Examples

info(info: "_all")
info(info: "os")
info(info: %w[os jvm process])

See www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html

Returns the response as a Hash

# File lib/elastomer/client/nodes.rb, line 51
def info( params = {} )
  response = client.get "/_nodes{/node_id}{/info}", update_params(params, action: "nodes.info", rest_api: "nodes.info")
  response.body
end
stats( params = {} ) click to toggle source

Retrieve one or more (or all) of the cluster nodes statistics. For 1.x stats filtering, use the :stats parameter key.

params - Parameters Hash

:node_id - a single node ID or Array of node IDs
:stats   - a single stats value or an Array of stats values

Examples

stats(stats: "thread_pool")
stats(stats: %w[os process])

See www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html

Returns the response as a Hash

# File lib/elastomer/client/nodes.rb, line 71
def stats( params = {} )
  response = client.get "/_nodes{/node_id}/stats{/stats}", update_params(params, action: "nodes.stats", rest_api: "nodes.stats")
  response.body
end
update_params( params, overrides = nil ) click to toggle source

Internal: Add default parameters to the `params` Hash and then apply `overrides` to the params if any are given.

params - Parameters Hash overrides - Optional parameter overrides as a Hash

Returns a new params Hash.

# File lib/elastomer/client/nodes.rb, line 101
def update_params( params, overrides = nil )
  h = { :node_id => node_id }.update params
  h.update overrides unless overrides.nil?
  h
end