Class: Elastomer::CLI::Cluster
- Defined in:
- lib/elastomer/cli/cluster.rb
Instance Method Summary collapse
Instance Method Details
#allocation(command) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/elastomer/cli/cluster.rb', line 60 def allocation(command) if client.version =~ /^0.90/ setting = "cluster.routing.allocation.disable_allocation" value = case command when 'enable' false when 'disable' true else raise Thor::Error, "ERROR: Unknown allocation command: #{command}" end elsif client.version =~ /^1./ setting = "cluster.routing.allocation.enable" value = case command when 'enable' 'all' when 'disable' 'none' when 'all', 'primaries', 'new_primaries', 'none' command else raise Thor::Error, "ERROR: Unknown allocation command: #{command}" end else raise Thor::Error, "ERROR: Unknown Elasticsearch version: #{client.version}" return end cluster.update_settings("persistent" => {setting => value}) puts "Successfully set #{setting}=#{value}" end |
#health ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/elastomer/cli/cluster.rb', line 5 def health name = client.info["name"] response = cluster.health puts Terminal::Table.new( :headings => ['CLUSTER HEALTH', name], :rows => [ ['Name', response["cluster_name"]], ['Status', response["status"]], ['Timed Out', response["timed_out"]], ['Number of Nodes', response["number_of_nodes"]], ['Number of Data Nodes', response["number_of_data_nodes"]], ['Active Primary Shards', response["active_primary_shards"]], ['Active Shards', response["active_shards"]], ['Relocating Shards', response["relocating_shards"]], ['Initializing Shards', response["initializing_shards"]], ['Unassigned Shards', response["unassigned_shards"]] ]) end |
#settings ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/elastomer/cli/cluster.rb', line 25 def settings response = cluster.get_settings(:flat_settings => true) persistent_settings = response["persistent"].collect do |key, value| [key, value] end transient_settings = response["transient"].collect do |key, value| [key, value] end puts Terminal::Table.new( :headings => ['SETTING NAME', "VALUE"], :rows => [ ['PERSISTENT', ''] ] + persistent_settings + [ ['TRANSIENT', ''] ] + transient_settings ) end |