cassandra-utils 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e37957c030dfb9729a4d2b98df7db3acc002f68
4
- data.tar.gz: b56baf5d6d2a88963a0803e1f0abfd1931ea7f77
3
+ metadata.gz: 7669e6c8e65ba8d0f99b6f6e0a3d851b2d331206
4
+ data.tar.gz: e4e42e9f78743fe47a245407a28cbaee51e5a725
5
5
  SHA512:
6
- metadata.gz: ce642b41f5a82d32cf9005a7fa263dd00be640c747b2dd70266d9876ce476845db347301dbe52a74707bafddd1b1d42186cdaa4301a1370578e2b9be8f403b65
7
- data.tar.gz: ec1f02d0538917e2a6b64ffbeaeddce83c226b68e27215b21bfdd8602706208c71a1a1f573a7030372c65861e6854fa0ddac493007d4e2656166760e0c4106cd
6
+ metadata.gz: ae0b349f3ad4ecbe8eadf7cb93c9194f5870a1bc98531b4e05bd7c98008794e1ac4aead9159805d380256d800fb5c3e79a499908ba1b2c36ae1f7e0179f61bfc
7
+ data.tar.gz: 99a46df29e78d2df53daaeb8ab14a653e2cba623746f829cca96e51685f11c3d74740cc308722e7151442c858954405f99fa7fd3c379cbd64ac719ec3c0af50f
@@ -55,3 +55,6 @@ DEPENDENCIES
55
55
  minitest (~> 5.0)
56
56
  rake (~> 10.0)
57
57
  thor-scmversion (= 1.7.0)
58
+
59
+ BUNDLED WITH
60
+ 1.12.5
@@ -5,8 +5,8 @@ module Cassandra
5
5
  def run!
6
6
  running = true
7
7
  if state == :normal
8
- running &&= nodetool_statusgossip.strip == 'running'
9
- running &&= nodetool_statusthrift.strip == 'running'
8
+ running &&= gossipstate == 'true'
9
+ running &&= thriftstate == 'true'
10
10
  end
11
11
  Utils::Statsd.new(metric_name).to_dd(running).push!
12
12
  running
@@ -16,11 +16,42 @@ module Cassandra
16
16
  'cassandra.service.running'
17
17
  end
18
18
 
19
+ # Return the state of nodetool info gossip
20
+ #
21
+ # The returned state is reported by "nodetool info".
22
+ #
23
+ # @return [String, nil]
24
+ def gossipstate
25
+ results = (nodetool_info || '').split("\n")
26
+ results.map! { |line| line.strip }
27
+ results.select! { |line| line.include? 'Gossip active' }
28
+ results.map! { |line| line.split(':')[1] }
29
+ results.compact!
30
+ return nil if results.size != 1
31
+ results.first.strip.downcase
32
+ end
33
+
34
+
35
+ # Return the state of nodetool info thrift
36
+ #
37
+ # The returned state is reported by "nodetool info".
38
+ #
39
+ # @return [String, nil]
40
+ def thriftstate
41
+ results = (nodetool_info || '').split("\n")
42
+ results.map! { |line| line.strip }
43
+ results.select! { |line| line.include? 'Thrift active' }
44
+ results.map! { |line| line.split(':')[1] }
45
+ results.compact!
46
+ return nil if results.size != 1
47
+ results.first.strip.downcase
48
+ end
49
+
19
50
  # Return the state of the Cassandra node
20
51
  #
21
52
  # The returned state is reported by "nodetool netstats".
22
53
  #
23
- # @return [state, nil]
54
+ # @return [Symbol, nil]
24
55
  #
25
56
  def state
26
57
  results = (nodetool_netstats || '').split("\n")
@@ -38,25 +69,16 @@ module Cassandra
38
69
 
39
70
  private
40
71
 
41
- # Run the "nodetool statusgossip' command and return the output
72
+ # Shell out via DaemonRunner to run 'nodetool info'
42
73
  #
43
- # @return [String, nil] Output from the "nodetool statusgossip" command
74
+ # The returned state is either true or false
44
75
  #
45
- def nodetool_statusgossip
46
- @nodetool_statusgossip ||= DaemonRunner::ShellOut.new(command: 'nodetool statusgossip')
47
- @nodetool_statusgossip.run!
48
- @nodetool_statusgossip.stdout
49
- end
50
-
51
- # Run the "nodetool statusthrift' command and return the output
52
- #
53
- # @return [String, nil] Output from the "nodetool statusthrift" command
54
- #
55
- def nodetool_statusthrift
56
- @nodetool_statusthrift||= DaemonRunner::ShellOut.new(command: 'nodetool statusthrift')
57
- @nodetool_statusthrift.run!
58
- @nodetool_statusthrift.stdout
59
- end
76
+ # @return [String, nil] Output from the "nodetool info" command
77
+ def nodetool_info
78
+ @nodetool_info ||= DaemonRunner::ShellOut.new(command: 'nodetool info')
79
+ @nodetool_info.run!
80
+ @nodetool_info.stdout
81
+ end
60
82
 
61
83
  # Run the "nodetool netstats' command and return the output
62
84
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandra-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-05 00:00:00.000000000 Z
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout