File tree Expand file tree Collapse file tree 2 files changed +98
-0
lines changed
lib/elasticsearch/api/actions/nodes
spec/elasticsearch/api/actions/nodes Expand file tree Collapse file tree 2 files changed +98
-0
lines changed Original file line number Diff line number Diff line change 1+ module Elasticsearch
2+ module API
3+ module Nodes
4+ module Actions
5+
6+ # Shutdown one or all nodes
7+ #
8+ # @example Shut down node named _Bloke_
9+ #
10+ # client.nodes.shutdown node_id: 'Bloke'
11+ #
12+ # @option arguments [List] :node_id A comma-separated list of node IDs or names to perform the operation on; use
13+ # `_local` to shutdown the node you're connected to, leave empty to
14+ # shutdown all nodes
15+ # @option arguments [Time] :delay Set the delay for the operation (default: 1s)
16+ # @option arguments [Boolean] :exit Exit the JVM as well (default: true)
17+ #
18+ # @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown/
19+ #
20+ def shutdown ( arguments = { } )
21+ method = HTTP_POST
22+ path = Utils . __pathify '_cluster/nodes' , Utils . __listify ( arguments [ :node_id ] ) , '_shutdown'
23+
24+ params = Utils . __validate_and_extract_params arguments , ParamsRegistry . get ( __method__ )
25+ body = nil
26+
27+ perform_request ( method , path , params , body ) . body
28+ end
29+
30+ # Register this action with its valid params when the module is loaded.
31+ #
32+ # @since 6.2.0
33+ ParamsRegistry . register ( :shutdown , [
34+ :delay ,
35+ :exit ] . freeze )
36+ end
37+ end
38+ end
39+ end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe 'client.nodes#shutdown' do
4+
5+ let ( :expected_args ) do
6+ [
7+ 'POST' ,
8+ url ,
9+ params ,
10+ nil ,
11+ nil
12+ ]
13+ end
14+
15+ let ( :url ) do
16+ '_cluster/nodes/_shutdown'
17+ end
18+
19+ it 'performs the request' do
20+ expect ( client_double . nodes . shutdown ) . to eq ( { } )
21+ end
22+
23+ let ( :params ) do
24+ { }
25+ end
26+
27+ context 'when the node id is specified' do
28+
29+ let ( :url ) do
30+ '_cluster/nodes/foo/_shutdown'
31+ end
32+
33+ it 'performs the request' do
34+ expect ( client_double . nodes . shutdown ( node_id : 'foo' ) ) . to eq ( { } )
35+ end
36+ end
37+
38+ context 'when multiple node ids are specified as a list' do
39+
40+ let ( :url ) do
41+ '_cluster/nodes/A,B,C/_shutdown'
42+ end
43+
44+ it 'performs the request' do
45+ expect ( client_double . nodes . shutdown ( node_id : [ 'A' , 'B' , 'C' ] ) ) . to eq ( { } )
46+ end
47+ end
48+
49+ context 'when multiple node ids are specified as a String' do
50+
51+ let ( :url ) do
52+ '_cluster/nodes/A,B,C/_shutdown'
53+ end
54+
55+ it 'performs the request' do
56+ expect ( client_double . nodes . shutdown ( node_id : 'A,B,C' ) ) . to eq ( { } )
57+ end
58+ end
59+ end
You can’t perform that action at this time.
0 commit comments