arborist 0.0.1.pre20160829140603 → 0.0.1.pre20161005112841

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
- SHA1:
3
- metadata.gz: c13d6d8931471437945bbe16acd57fa7f17a01f8
4
- data.tar.gz: 38d663d0f7fb9105727613bf61ff62a1496062f6
2
+ SHA256:
3
+ metadata.gz: 6d6da185674a9541d85ebc47e6fdf1877a6b85930053cc655cff36cc5de74923
4
+ data.tar.gz: 15bccf69dd20c885fb1266ec75a1f0f8dfef122a174af87ab2018a0e24edc548
5
5
  SHA512:
6
- metadata.gz: 49431289b8d44fc52f40cdf60062905666a6f9de12c7c6ff8bbfb04d62e2f782f084fd824df08271ed264b513953b23baae0ccf9b4fd36b390a5d4f072c5b07f
7
- data.tar.gz: 436d3fadba15758c0e9bd12656ada1ef3b7c5471c4b8ccaba431e02e338cae3576e3acbd579ea5f440937ff1af7b4717f118b6d4723691913f320c05afb82565
6
+ metadata.gz: a5ecc7f5a93aba6b92b0e8b41cbdc206f1c3ddc54b01953174a125b22923222b95dcb9d14832cc4a9432ce4f92625b94e159ca3d5be15f120f18a22c66caadd2
7
+ data.tar.gz: 5dcd90e705e8aa8ad6992f6b5bfa625a45e6684d9b19bb7e5a13544a4e18ea40f0ff4eed478f8ad396d0902cbad09881d2d60de74bbb43fa28035be5fd398500
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ Lė�u��ֶ[��%��c�!&��X ��He���l�JJ�߂>-��� �K��(~2�<�T5l����w�����ݤW��t4�9��`A��c%����qfO-?�]-��`n�p��\�
data.tar.gz.sig ADDED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,105 @@
1
+ 2016-10-04 Mahlon E. Smith <mahlon@martini.nu>
2
+
3
+ * lib/arborist/node.rb:
4
+ State transition cleanup: Only nodes in a 'down' state can
5
+ transition to 'acked'.
6
+ [eed40468bb5e] [tip]
7
+
8
+ 2016-10-03 Mahlon E. Smith <mahlon@laika.com>
9
+
10
+ * lib/arborist/command/config.rb:
11
+ Require the manager when generating a default configuration file.
12
+ [d0c5ef20e6fd]
13
+
14
+ 2016-09-28 Michael Granger <ged@FaerieMUD.org>
15
+
16
+ * TODO.md, lib/arborist/node.rb, spec/arborist/node_spec.rb:
17
+ Fix the unknown => disabled transition when updating with an ACK
18
+ [30d2548e1308] [github/master]
19
+
20
+ * lib/arborist/manager.rb, spec/arborist/manager_spec.rb:
21
+ Flatten the config into one namespace
22
+
23
+ This fixes the manager's defaults, which were never actually used.
24
+ [ae18e761d06f]
25
+
26
+ 2016-09-21 Michael Granger <ged@FaerieMUD.org>
27
+
28
+ * TODO.md, lib/arborist/manager.rb, lib/arborist/node.rb,
29
+ spec/arborist/node_spec.rb:
30
+ Fix consequential event propagation/publication
31
+ [cdf3fb9d63c8]
32
+
33
+ * lib/arborist/dependency.rb, spec/arborist/dependency_spec.rb:
34
+ Clarify dependency "down reason" to not seem like a node state
35
+ [1f8f703940cb]
36
+
37
+ * lib/arborist/manager/tree_api.rb:
38
+ Stripped spammier debugging
39
+ [dc594799b7dc]
40
+
41
+ * Events.md:
42
+ Add description of event movement to Events.md
43
+ [bfee2016aa79]
44
+
45
+ 2016-09-21 Mahlon E. Smith <mahlon@martini.nu>
46
+
47
+ * .rvmrc, lib/arborist/node.rb:
48
+ Add an event handler for disabled events, so nodes are properly
49
+ quieted when their secondary dependencies are disabled.
50
+ [d032e1820965]
51
+
52
+ 2016-09-06 Michael Granger <ged@FaerieMUD.org>
53
+
54
+ * arborist.gemspec, lib/arborist/monitor/socket.rb,
55
+ spec/arborist/monitor/socket_spec.rb:
56
+ Fix up the specs for getpeername socket monitor change
57
+ [f8c5bbc611b2]
58
+
59
+ * lib/arborist/monitor/socket.rb:
60
+ Make socket check use getpeername for testing non-blocking connect
61
+ [9715a6d9903f]
62
+
63
+ 2016-08-31 Michael Granger <ged@FaerieMUD.org>
64
+
65
+ * Protocol.md, TODO.md, lib/arborist/client.rb, lib/arborist/event.rb,
66
+ lib/arborist/event/node.rb, lib/arborist/event/node_delta.rb,
67
+ lib/arborist/manager.rb, lib/arborist/manager/tree_api.rb,
68
+ lib/arborist/monitor.rb, lib/arborist/monitor/socket.rb,
69
+ lib/arborist/node.rb, lib/arborist/observer.rb,
70
+ lib/arborist/subscription.rb,
71
+ spec/arborist/event/node_delta_spec.rb,
72
+ spec/arborist/event/node_spec.rb,
73
+ spec/arborist/manager/tree_api_spec.rb,
74
+ spec/arborist/observer_spec.rb, spec/arborist/subscription_spec.rb:
75
+ Add exclusion to subscriptions
76
+ [23b84af1ebb4]
77
+
78
+ * arborist.gemspec, lib/arborist/manager/tree_api.rb,
79
+ lib/arborist/monitor/socket.rb, lib/arborist/node.rb,
80
+ spec/arborist/manager/tree_api_spec.rb:
81
+ Include all operational values in fetched nodes.
82
+
83
+ Also error more gracefully about non-eachable updates.
84
+ [a72fc8d43adc]
85
+
86
+ * lib/arborist/client.rb:
87
+ Rearrange some methods in the client
88
+ [106b17e27a3a]
89
+
1
90
  2016-08-29 Michael Granger <ged@FaerieMUD.org>
2
91
 
92
+ * Rakefile, arborist.gemspec, certs/ged.pem:
93
+ Add public cert
94
+ [a7c6232586ad]
95
+
96
+ * Manifest.txt, arborist.gemspec:
97
+ Update the manifest with spec changes, rebuild gemspec.
98
+ [aec9f5ec88de]
99
+
3
100
  * spec/data/nodes/duir.rb:
4
101
  Merge with a5a6e5092024
5
- [c961355d10c8] [tip]
102
+ [c961355d10c8]
6
103
 
7
104
  2016-08-29 Mahlon E. Smith <mahlon@martini.nu>
8
105
 
@@ -33,7 +130,7 @@
33
130
  - Restore ack+status of serialized nodes
34
131
  - Allow services to set their own address when not bound to INADDR_ANY
35
132
  - Finish separating node events from system events
36
- [f853508dba8c] [github/master]
133
+ [f853508dba8c]
37
134
 
38
135
  * lib/arborist/monitor/socket.rb:
39
136
  Fix race to calculate select timeout in socket monitor
data/Events.md CHANGED
@@ -18,3 +18,18 @@
18
18
  sys.hearbeat
19
19
 
20
20
 
21
+ ## Event Movement
22
+
23
+ Propagation
24
+
25
+ events being sent up the tree to the root node
26
+
27
+ Broadcast
28
+
29
+ events being sent down to node children
30
+
31
+ Publishing
32
+
33
+ events being sent to subscriptions, including dependent nodes
34
+ triggered via propagation and broadcasting
35
+
data/Protocol.md CHANGED
@@ -127,6 +127,9 @@ Fetch the `address`, `description`, and `status` of all nodes.
127
127
  include_down: true,
128
128
  return: [address, description, status]
129
129
  },
130
+
131
+ Response
132
+
130
133
  {
131
134
  'theon' => {
132
135
  address: '10.2.10.4',
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
+ require 'rake/clean'
4
+
3
5
  begin
4
6
  require 'hoe'
5
7
  rescue LoadError
@@ -89,10 +91,12 @@ file GEMSPEC => __FILE__ do |task|
89
91
  spec.files.delete( 'LICENSE' )
90
92
  spec.signing_key = nil
91
93
  spec.version = "#{spec.version}.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
94
+ spec.cert_chain = [ 'certs/ged.pem' ]
92
95
  File.open( task.name, 'w' ) do |fh|
93
96
  fh.write( spec.to_ruby )
94
97
  end
95
98
  end
99
+ CLOBBER.include( GEMSPEC )
96
100
 
97
101
  task :default => :gemspec
98
102
 
data/TODO.md CHANGED
@@ -3,18 +3,9 @@
3
3
  ## First Release (0.1)
4
4
 
5
5
  * README, Tutorial, Setup docs
6
-
7
6
  * Performance/profiling examination
8
7
 
9
8
 
10
- ### Observers
11
-
12
- * Add `exclude` to observers DSL
13
- * modify tree api to accept negative criteria to subscribe
14
- * pass to manager's create_subscription()
15
- * alter subscription to no-op if event matches negative stuff
16
-
17
-
18
9
  ### Monitor
19
10
 
20
11
  * Add some default monitor types and utilities
@@ -25,6 +16,8 @@
25
16
 
26
17
  * Write a gem for `fping` monitor
27
18
 
19
+ * Redo the select loop of the UDP socket monitor to wait for them in parallel instead of in series.
20
+
28
21
 
29
22
  ## Second Release (0.2)
30
23
 
@@ -37,6 +37,47 @@ class Arborist::Client
37
37
  attr_accessor :event_api_url
38
38
 
39
39
 
40
+ #
41
+ # High-level methods
42
+ #
43
+
44
+ ### Mark a node as 'acknowledged' if it's down, or 'disabled' if
45
+ ### it's up. (A pre-emptive acknowledgement.) Requires the node
46
+ ### +identifier+, an acknowledgement +message+, and +sender+. You
47
+ ### can optionally include a +via+ (source), and override the default
48
+ ### +time+ of now.
49
+ def acknowledge( node, message, sender, via=nil, time=Time.now )
50
+ data = {
51
+ node => {
52
+ ack: {
53
+ message: message,
54
+ sender: sender,
55
+ via: via,
56
+ time: time.to_s
57
+ }
58
+ }
59
+ }
60
+
61
+ return self.update( data )
62
+ end
63
+ alias_method :ack, :acknowledge
64
+
65
+
66
+ ### Clear an acknowledged/disabled +node+.
67
+ def clear_acknowledgement( node )
68
+ data = { node => { ack: nil } }
69
+ request = self.make_update_request( data )
70
+ self.send_tree_api_request( request )
71
+ return true
72
+ end
73
+ alias_method :clear_ack, :clear_acknowledgement
74
+
75
+
76
+
77
+ #
78
+ # Protocol methods
79
+ #
80
+
40
81
  ### Return the manager's current status as a hash.
41
82
  def status
42
83
  request = self.make_status_request
@@ -85,40 +126,6 @@ class Arborist::Client
85
126
  end
86
127
 
87
128
 
88
- ### Mark a node as 'acknowledged' if it's down, or 'disabled' if
89
- ### it's up. (A pre-emptive acknowledgement.) Requires the node
90
- ### +identifier+, an acknowledgement +message+, and +sender+. You
91
- ### can optionally include a +via+ (source), and override the default
92
- ### +time+ of now.
93
- def acknowledge( node, message, sender, via=nil, time=Time.now )
94
- data = {
95
- node => {
96
- ack: {
97
- message: message,
98
- sender: sender,
99
- via: via,
100
- time: time.to_s
101
- }
102
- }
103
- }
104
-
105
- request = self.make_update_request( data )
106
- self.send_tree_api_request( request )
107
- return true
108
- end
109
- alias_method :ack, :acknowledge
110
-
111
-
112
- ### Clear an acknowledged/disabled +node+.
113
- def clear_acknowledgement( node )
114
- data = { node => { ack: nil } }
115
- request = self.make_update_request( data )
116
- self.send_tree_api_request( request )
117
- return true
118
- end
119
- alias_method :clear_ack, :clear_acknowledgement
120
-
121
-
122
129
  ### Update the identified nodes in the manager with the specified data.
123
130
  def update( *args )
124
131
  request = self.make_update_request( *args )
@@ -142,14 +149,14 @@ class Arborist::Client
142
149
 
143
150
 
144
151
  ### Make a subscription request for the specified +criteria+, +identifier+, and +event_type+.
145
- def make_subscribe_request( criteria: {}, identifier: nil, event_type: nil )
152
+ def make_subscribe_request( criteria: {}, identifier: nil, event_type: nil, exclude: {} )
146
153
  self.log.debug "Making subscription request for identifier: %p, event_type: %p, criteria: %p" %
147
154
  [ identifier, event_type, criteria ]
148
155
  header = {}
149
156
  header[ :identifier ] = identifier if identifier
150
157
  header[ :event_type ] = event_type
151
158
 
152
- return self.pack_message( :subscribe, header, criteria )
159
+ return self.pack_message( :subscribe, header, [ criteria, exclude ] )
153
160
  end
154
161
 
155
162
 
@@ -244,6 +251,9 @@ class Arborist::Client
244
251
  end
245
252
 
246
253
 
254
+ #
255
+ # Utility methods
256
+ #
247
257
 
248
258
  ### Format ruby +data+ for communicating with the Arborist manager.
249
259
  def pack_message( verb, *data )
@@ -12,6 +12,7 @@ module Arborist::CLI::Config
12
12
  command :config do |cmd|
13
13
 
14
14
  cmd.action do |globals, options, args|
15
+ require 'arborist/manager'
15
16
  $stdout.puts Configurability.default_config.dump
16
17
  end
17
18
  end
@@ -231,15 +231,15 @@ class Arborist::Dependency
231
231
  when :all
232
232
  msg = ids.first.dup
233
233
  if ids.size == 1
234
- msg << " is down"
234
+ msg << " is unavailable"
235
235
  else
236
- msg << " (and %d other%s) are down" % [ ids.size - 1, ids.size == 2 ? '' : 's' ]
236
+ msg << " (and %d other%s) are unavailable" % [ ids.size - 1, ids.size == 2 ? '' : 's' ]
237
237
  end
238
238
 
239
239
  msg << " as of %s" % [ self.earliest_down_time ]
240
240
 
241
241
  when :any
242
- msg = "%s are all down" % [ ids.to_a.join(', ') ]
242
+ msg = "%s are all unavailable" % [ ids.to_a.join(', ') ]
243
243
  msg << " as of %s" % [ self.latest_down_time ]
244
244
 
245
245
  else
@@ -47,8 +47,10 @@ class Arborist::Event
47
47
 
48
48
  ### Match operator -- returns +true+ if the other object matches this event.
49
49
  def match( object )
50
- return object.respond_to?( :event_type ) &&
50
+ rval = object.respond_to?( :event_type ) &&
51
51
  ( object.event_type.nil? || object.event_type == self.type )
52
+ self.log.debug "Base node #match: %p" % [ rval ]
53
+ return rval
52
54
  end
53
55
  alias_method :=~, :match
54
56
 
@@ -24,9 +24,11 @@ class Arborist::Event::Node < Arborist::Event
24
24
 
25
25
  ### Returns +true+ if the specified +object+ matches this event.
26
26
  def match( object )
27
- return super &&
28
- object.respond_to?( :criteria ) && self.node.matches?( object.criteria ) &&
29
- ( !object.respond_to?(:negative_criteria) || !self.node.matches?(object.negative_criteria) )
27
+ rval = super &&
28
+ self.node.matches?( object.criteria ) &&
29
+ !self.node.matches?( object.negative_criteria, if_empty: false )
30
+ self.log.debug "Node event #match: %p" % [ rval ]
31
+ return rval
30
32
  end
31
33
 
32
34
 
@@ -27,15 +27,22 @@ class Arborist::Event::NodeDelta < Arborist::Event::Node
27
27
 
28
28
  ### Returns +true+ if the specified +object+ matches this event.
29
29
  def match( object )
30
- return super &&
31
- object.respond_to?( :criteria ) && self.delta_matches?( object.criteria )
30
+ rval = super &&
31
+ self.delta_matches?( object.criteria ) &&
32
+ !self.delta_matches?( object.negative_criteria, if_empty: false )
33
+ self.log.debug "Delta event #match: %p" % [ rval ]
34
+ return rval
32
35
  end
33
36
 
34
37
 
35
38
  ### Returns +true+ if the 'delta' value of the specified +criteria+ (which
36
- ### must respond to .all?) matches the delta this event represents.
37
- def delta_matches?( criteria )
38
- delta_criteria = criteria['delta'] || {}
39
+ ### must respond to .all?) matches the delta this event represents. If the specified
40
+ ### criteria doesn't contain any `delta` criteria, the +default+ value is used instead.
41
+ def delta_matches?( criteria, if_empty: true )
42
+ self.log.debug "Delta matching %p (%p if empty)" % [ criteria, if_empty ]
43
+ delta_criteria = criteria['delta']
44
+ return if_empty if !delta_criteria || delta_criteria.empty?
45
+
39
46
  self.log.debug "Matching event against delta criteria: %p" % [ delta_criteria ]
40
47
 
41
48
  return delta_criteria.all? do |key, val|
@@ -64,9 +64,7 @@ class Arborist::Manager
64
64
 
65
65
  ### Configurability API -- configure the manager
66
66
  def self::configure( config=nil )
67
- config ||= {}
68
- config = self.defaults.merge( config[:manager] || {} )
69
-
67
+ config = self.defaults.merge( config || {} )
70
68
  self.log.debug "Config is: %p" % [ config ]
71
69
 
72
70
  self.state_file = config[:state_file] && Pathname( config[:state_file] )
@@ -731,8 +729,8 @@ class Arborist::Manager
731
729
  ### Create a subscription that publishes to the Manager's event publisher for
732
730
  ### the node with the specified +identifier+ and +event_pattern+, using the
733
731
  ### given +criteria+ when considering an event.
734
- def create_subscription( identifier, event_pattern, criteria )
735
- sub = Arborist::Subscription.new( event_pattern, criteria ) do |*args|
732
+ def create_subscription( identifier, event_pattern, criteria, negative_criteria={} )
733
+ sub = Arborist::Subscription.new( event_pattern, criteria, negative_criteria ) do |*args|
736
734
  self.event_publisher.publish( *args )
737
735
  end
738
736
  self.subscribe( identifier, sub )
@@ -755,6 +753,11 @@ class Arborist::Manager
755
753
  node.publish_events( *events )
756
754
 
757
755
  if node.parent
756
+ self.log.debug "Propagating %d events from %s -> %s" % [
757
+ events.length,
758
+ node.identifier,
759
+ node.parent
760
+ ]
758
761
  parent = self.nodes[ node.parent ] or raise "couldn't find parent %p of node %p!" %
759
762
  [ node.parent, node.identifier ]
760
763
  self.propagate_events( parent, *events )