right_agent 2.6.1-x86-mingw32 → 2.6.2-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/right_agent/agent.rb +2 -0
- data/lib/right_agent/offline_handler.rb +4 -2
- data/lib/right_agent/packets.rb +18 -13
- data/lib/right_agent/platform/unix/linux/platform.rb +1 -0
- data/lib/right_agent/sender.rb +3 -3
- data/right_agent.gemspec +2 -2
- data/spec/offline_handler_spec.rb +10 -8
- data/spec/sender_spec.rb +4 -4
- metadata +4 -4
data/lib/right_agent/agent.rb
CHANGED
@@ -676,10 +676,12 @@ module RightScale
|
|
676
676
|
when "Push"
|
677
677
|
packet = RightScale::Push.new(event[:path], event[:data], {:from => event[:from], :token => event[:uuid]})
|
678
678
|
packet.expires_at = event[:expires_at].to_i if event.has_key?(:expires_at)
|
679
|
+
packet.skewed_by = event[:skewed_by].to_i if event.has_key?(:skewed_by)
|
679
680
|
when "Request"
|
680
681
|
options = {:from => event[:from], :token => event[:uuid], :reply_to => event[:reply_to], :tries => event[:tries]}
|
681
682
|
packet = RightScale::Request.new(event[:path], event[:data], options)
|
682
683
|
packet.expires_at = event[:expires_at].to_i if event.has_key?(:expires_at)
|
684
|
+
packet.skewed_by = event[:skewed_by].to_i if event.has_key?(:skewed_by)
|
683
685
|
end
|
684
686
|
packet
|
685
687
|
end
|
@@ -168,6 +168,7 @@ module RightScale
|
|
168
168
|
# token(String):: Token uniquely identifying request
|
169
169
|
# expires_at(Integer):: Time in seconds in Unix-epoch when this request expires and
|
170
170
|
# is to be ignored by the receiver; value 0 means never expire
|
171
|
+
# skewed_by(Integer):: Amount of skew already applied to expires_at in seconds
|
171
172
|
#
|
172
173
|
# === Block
|
173
174
|
# Optional block used to process response asynchronously with the following parameter:
|
@@ -175,9 +176,10 @@ module RightScale
|
|
175
176
|
#
|
176
177
|
# === Return
|
177
178
|
# true:: Always return true
|
178
|
-
def queue_request(kind, type, payload, target, token, expires_at, &callback)
|
179
|
+
def queue_request(kind, type, payload, target, token, expires_at, skewed_by, &callback)
|
179
180
|
request = {:kind => kind, :type => type, :payload => payload, :target => target,
|
180
|
-
:token => token, :expires_at => expires_at, :
|
181
|
+
:token => token, :expires_at => expires_at, :skewed_by => skewed_by,
|
182
|
+
:callback => callback}
|
181
183
|
Log.info("[offline] Queuing request: #{request.inspect}")
|
182
184
|
vote_to_restart if (@restart_vote_count += 1) >= MAX_QUEUED_REQUESTS
|
183
185
|
if @state == :initializing
|
data/lib/right_agent/packets.rb
CHANGED
@@ -285,7 +285,7 @@ module RightScale
|
|
285
285
|
class Request < Packet
|
286
286
|
|
287
287
|
attr_accessor :from, :scope, :payload, :type, :token, :reply_to, :selector, :target, :persistent, :expires_at,
|
288
|
-
:tags, :tries
|
288
|
+
:skewed_by, :tags, :tries
|
289
289
|
|
290
290
|
DEFAULT_OPTIONS = {:selector => :any}
|
291
291
|
|
@@ -306,6 +306,7 @@ module RightScale
|
|
306
306
|
# by the AMQP broker
|
307
307
|
# :expires_at(Integer|nil):: Time in seconds in Unix-epoch when this request expires and
|
308
308
|
# is to be ignored by the receiver; value 0 means never expire; defaults to 0
|
309
|
+
# :skewed_by(Integer|nil):: Amount of skew already applied to expires_at in seconds
|
309
310
|
# :tags(Array(Symbol)):: List of tags to be used for selecting target for this request
|
310
311
|
# :tries(Array):: List of tokens for previous attempts to send this request
|
311
312
|
# version(Array):: Protocol version of the original creator of the packet followed by the
|
@@ -324,6 +325,7 @@ module RightScale
|
|
324
325
|
@target = opts[:target]
|
325
326
|
@persistent = opts[:persistent]
|
326
327
|
@expires_at = opts[:expires_at] || 0
|
328
|
+
@skewed_by = opts[:skewed_by] || 0
|
327
329
|
@tags = opts[:tags] || []
|
328
330
|
@tries = opts[:tries] || []
|
329
331
|
@version = version
|
@@ -348,16 +350,17 @@ module RightScale
|
|
348
350
|
def self.create(o)
|
349
351
|
i = o['data']
|
350
352
|
expires_at = if i.has_key?('created_at')
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
353
|
+
created_at = i['created_at'].to_i
|
354
|
+
created_at > 0 ? created_at + (15 * 60) : 0
|
355
|
+
else
|
356
|
+
i['expires_at']
|
357
|
+
end
|
356
358
|
new(i['type'], i['payload'], { :from => self.compatible(i['from']), :scope => i['scope'],
|
357
359
|
:token => i['token'], :reply_to => self.compatible(i['reply_to']),
|
358
360
|
:selector => i['selector'], :target => self.compatible(i['target']),
|
359
361
|
:persistent => i['persistent'], :tags => i['tags'],
|
360
|
-
:expires_at => expires_at, :
|
362
|
+
:expires_at => expires_at, :skewed_by => i['skewed_by'],
|
363
|
+
:tries => i['tries'] },
|
361
364
|
i['version'] || [DEFAULT_VERSION, DEFAULT_VERSION], o['size'])
|
362
365
|
end
|
363
366
|
|
@@ -416,7 +419,7 @@ module RightScale
|
|
416
419
|
class Push < Packet
|
417
420
|
|
418
421
|
attr_accessor :from, :scope, :payload, :type, :token, :selector, :target, :persistent, :confirm,
|
419
|
-
:expires_at, :tags
|
422
|
+
:expires_at, :skewed_by, :tags
|
420
423
|
|
421
424
|
DEFAULT_OPTIONS = {:selector => :any}
|
422
425
|
|
@@ -437,6 +440,7 @@ module RightScale
|
|
437
440
|
# to which request was published but not necessarily delivered
|
438
441
|
# :expires_at(Integer|nil):: Time in seconds in Unix-epoch when this request expires and
|
439
442
|
# is to be ignored by the receiver; value 0 means never expire; defaults to 0
|
443
|
+
# :skewed_by(Integer|nil):: Amount of skew already applied to expires_at in seconds
|
440
444
|
# :tags(Array(Symbol)):: List of tags to be used for selecting target for this request
|
441
445
|
# version(Array):: Protocol version of the original creator of the packet followed by the
|
442
446
|
# protocol version of the packet contents to be used when sending
|
@@ -454,6 +458,7 @@ module RightScale
|
|
454
458
|
@persistent = opts[:persistent]
|
455
459
|
@confirm = opts[:confirm]
|
456
460
|
@expires_at = opts[:expires_at] || 0
|
461
|
+
@skewed_by = opts[:skewed_by] || 0
|
457
462
|
@tags = opts[:tags] || []
|
458
463
|
@version = version
|
459
464
|
@size = size
|
@@ -485,11 +490,11 @@ module RightScale
|
|
485
490
|
# (Push):: New packet
|
486
491
|
def self.create(o)
|
487
492
|
i = o['data']
|
488
|
-
new(i['type'], i['payload'], { :from
|
489
|
-
:token
|
490
|
-
:target
|
491
|
-
:confirm
|
492
|
-
:tags
|
493
|
+
new(i['type'], i['payload'], { :from => self.compatible(i['from']), :scope => i['scope'],
|
494
|
+
:token => i['token'], :selector => i['selector'],
|
495
|
+
:target => self.compatible(i['target']), :persistent => i['persistent'],
|
496
|
+
:confirm => i['confirm'], :expires_at => i['expires_at'],
|
497
|
+
:skewed_by => i['skewed_by'], :tags => i['tags'] },
|
493
498
|
i['version'] || [DEFAULT_VERSION, DEFAULT_VERSION], o['size'])
|
494
499
|
end
|
495
500
|
|
@@ -268,6 +268,7 @@ module RightScale
|
|
268
268
|
private
|
269
269
|
|
270
270
|
def scan_for_failed_packages(output_text, regex)
|
271
|
+
output_text = output_text.force_encoding("UTF-8") if output_text.respond_to?(:force_encoding)
|
271
272
|
@output = output_text
|
272
273
|
failed_packages = []
|
273
274
|
output_text.scan(regex) { |package| failed_packages << package.last }
|
data/lib/right_agent/sender.rb
CHANGED
@@ -346,7 +346,7 @@ module RightScale
|
|
346
346
|
end
|
347
347
|
|
348
348
|
if queueing?
|
349
|
-
@offline_handler.queue_request(kind, type, payload, target, packet.token, packet.expires_at, &callback)
|
349
|
+
@offline_handler.queue_request(kind, type, payload, target, packet.token, packet.expires_at, packet.skewed_by, &callback)
|
350
350
|
nil
|
351
351
|
else
|
352
352
|
packet
|
@@ -637,7 +637,7 @@ module RightScale
|
|
637
637
|
result = error_result(e.message)
|
638
638
|
rescue Exceptions::ConnectivityFailure => e
|
639
639
|
if queueing?
|
640
|
-
@offline_handler.queue_request(kind, packet.type, packet.payload, target, packet.token, packet.expires_at, &callback)
|
640
|
+
@offline_handler.queue_request(kind, packet.type, packet.payload, target, packet.token, packet.expires_at, packet.skewed_by, &callback)
|
641
641
|
result = nil
|
642
642
|
else
|
643
643
|
result = retry_result(e.message)
|
@@ -696,7 +696,7 @@ module RightScale
|
|
696
696
|
rescue TemporarilyOffline => e
|
697
697
|
if queueing?
|
698
698
|
# Queue request until come back online
|
699
|
-
@offline_handler.queue_request(kind, packet.type, packet.payload, target, packet.token, packet.expires_at, &callback)
|
699
|
+
@offline_handler.queue_request(kind, packet.type, packet.payload, target, packet.token, packet.expires_at, packet.skewed_by, &callback)
|
700
700
|
@pending_requests.delete(packet.token) if callback
|
701
701
|
else
|
702
702
|
# Send retry response so that requester, e.g., RetryableRequest, can retry
|
data/right_agent.gemspec
CHANGED
@@ -25,8 +25,8 @@ require 'rbconfig'
|
|
25
25
|
|
26
26
|
Gem::Specification.new do |spec|
|
27
27
|
spec.name = 'right_agent'
|
28
|
-
spec.version = '2.6.
|
29
|
-
spec.date = '2015-
|
28
|
+
spec.version = '2.6.2'
|
29
|
+
spec.date = '2015-09-16'
|
30
30
|
spec.authors = ['Lee Kirchhoff', 'Raphael Simon', 'Tony Spataro', 'Scott Messier']
|
31
31
|
spec.email = 'lee@rightscale.com'
|
32
32
|
spec.homepage = 'https://github.com/rightscale/right_agent'
|
@@ -196,14 +196,15 @@ describe RightScale::OfflineHandler do
|
|
196
196
|
@now = Time.now
|
197
197
|
flexmock(Time).should_receive(:now).and_return(@now)
|
198
198
|
@expires_at = @now + 25
|
199
|
+
@skewed_by = 1
|
199
200
|
@callback = lambda { |_| }
|
200
201
|
end
|
201
202
|
|
202
203
|
it "queues request at head of queue if still initializing" do
|
203
204
|
@handler.init
|
204
|
-
@handler.queue_request(@kind, @type, @payload, "target1", "token1", @expires_at, &@callback).should be_true
|
205
|
+
@handler.queue_request(@kind, @type, @payload, "target1", "token1", @expires_at, @skewed_by, &@callback).should be_true
|
205
206
|
@handler.queue.size.should == 1
|
206
|
-
@handler.queue_request(@kind, @type, @payload, "target2", "token2", @expires_at, &@callback).should be_true
|
207
|
+
@handler.queue_request(@kind, @type, @payload, "target2", "token2", @expires_at, @skewed_by, &@callback).should be_true
|
207
208
|
@handler.queue.size.should == 2
|
208
209
|
@handler.queue.first[:target] == "target2"
|
209
210
|
end
|
@@ -211,9 +212,9 @@ describe RightScale::OfflineHandler do
|
|
211
212
|
it "queues request at end of queue if no longer initializing" do
|
212
213
|
@handler.init
|
213
214
|
@handler.start
|
214
|
-
@handler.queue_request(@kind, @type, @payload, "target1", "token1", @expires_at, &@callback)
|
215
|
+
@handler.queue_request(@kind, @type, @payload, "target1", "token1", @expires_at, @skewed_by, &@callback)
|
215
216
|
@handler.queue.size.should == 1
|
216
|
-
@handler.queue_request(@kind, @type, @payload, "target2", "token2", @expires_at, &@callback)
|
217
|
+
@handler.queue_request(@kind, @type, @payload, "target2", "token2", @expires_at, @skewed_by, &@callback)
|
217
218
|
@handler.queue.size.should == 2
|
218
219
|
@handler.queue.first[:target] == "target1"
|
219
220
|
end
|
@@ -223,7 +224,7 @@ describe RightScale::OfflineHandler do
|
|
223
224
|
@handler.start
|
224
225
|
flexmock(@handler).should_receive(:vote_to_restart).once
|
225
226
|
RightScale::OfflineHandler::MAX_QUEUED_REQUESTS.times do |i|
|
226
|
-
@handler.queue_request(@kind, @type, @payload, @target, @token, @expires_at, &@callback)
|
227
|
+
@handler.queue_request(@kind, @type, @payload, @target, @token, @expires_at, @skewed_by, &@callback)
|
227
228
|
end
|
228
229
|
end
|
229
230
|
end
|
@@ -249,6 +250,7 @@ describe RightScale::OfflineHandler do
|
|
249
250
|
@now = Time.now
|
250
251
|
flexmock(Time).should_receive(:now).and_return(@now)
|
251
252
|
@expires_at = (@now + 25).to_i
|
253
|
+
@skewed_by = 1
|
252
254
|
@result = nil
|
253
255
|
@callback = lambda { |result| @result = result }
|
254
256
|
end
|
@@ -259,9 +261,9 @@ describe RightScale::OfflineHandler do
|
|
259
261
|
@handler.start
|
260
262
|
flexmock(@handler).should_receive(:start_timer)
|
261
263
|
@handler.enable
|
262
|
-
@handler.queue_request(:send_push, @type, @payload, @target, @token, 0)
|
263
|
-
@handler.queue_request(:send_request, @type, @payload, @target, @token, @expires_at, &@callback)
|
264
|
-
@handler.queue_request(:send_request, @type, @payload, @target, @token, @now.to_i, &@callback)
|
264
|
+
@handler.queue_request(:send_push, @type, @payload, @target, @token, 0, 0)
|
265
|
+
@handler.queue_request(:send_request, @type, @payload, @target, @token, @expires_at, @skewed_by, &@callback)
|
266
|
+
@handler.queue_request(:send_request, @type, @payload, @target, @token, @now.to_i, @skewed_by, &@callback)
|
265
267
|
@handler.queue.size.should == 3
|
266
268
|
flexmock(EM).should_receive(:next_tick).and_yield.twice
|
267
269
|
@sender.should_receive(:send_push).with(@type, @payload, @target, {:token => @token}).once.ordered
|
data/spec/sender_spec.rb
CHANGED
@@ -427,7 +427,7 @@ describe RightScale::Sender do
|
|
427
427
|
@sender = create_sender(:http, :offline_queueing => true)
|
428
428
|
flexmock(@sender.offline_handler).should_receive(:queueing?).and_return(true)
|
429
429
|
flexmock(@sender.offline_handler).should_receive(:queue_request).
|
430
|
-
with(kind, @type, @payload, @target, @token, (@now + @ttl).to_i, @callback).once
|
430
|
+
with(kind, @type, @payload, @target, @token, (@now + @ttl).to_i, 0, @callback).once
|
431
431
|
@sender.build_packet(kind, @type, @payload, @target, @options, &@callback).should be nil
|
432
432
|
end
|
433
433
|
end
|
@@ -779,7 +779,7 @@ describe RightScale::Sender do
|
|
779
779
|
@sender.enable_offline_mode
|
780
780
|
@client.should_receive(:request).and_raise(RightScale::Exceptions::ConnectivityFailure, "disconnected").once
|
781
781
|
flexmock(@sender.offline_handler).should_receive(:queue_request).
|
782
|
-
with(:send_push, @type, @payload, @target, @token, (@now + @ttl).to_i).once
|
782
|
+
with(:send_push, @type, @payload, @target, @token, (@now + @ttl).to_i, 0).once
|
783
783
|
flexmock(@sender).should_receive(:handle_response).never
|
784
784
|
@sender.send(:http_send_once, :send_push, @target, @packet, @received_at).should be_true
|
785
785
|
end
|
@@ -792,7 +792,7 @@ describe RightScale::Sender do
|
|
792
792
|
@sender.enable_offline_mode
|
793
793
|
@client.should_receive(:request).and_raise(RightScale::Exceptions::ConnectivityFailure, "disconnected").once
|
794
794
|
flexmock(@sender.offline_handler).should_receive(:queue_request).
|
795
|
-
with(:send_request, @type, @payload, @target, @token, (@now + @ttl).to_i, @callback).once
|
795
|
+
with(:send_request, @type, @payload, @target, @token, (@now + @ttl).to_i, 0, @callback).once
|
796
796
|
flexmock(@sender).should_receive(:handle_response).never
|
797
797
|
@sender.send(:http_send_once, :send_request, @target, @packet, @received_at, &@callback).should be_true
|
798
798
|
end
|
@@ -886,7 +886,7 @@ describe RightScale::Sender do
|
|
886
886
|
@sender.initialize_offline_queue
|
887
887
|
@sender.enable_offline_mode
|
888
888
|
flexmock(@sender.offline_handler).should_receive(:queue_request).
|
889
|
-
with(:send_push, @type, @payload, @target, @token, (@now + @ttl).to_i).once
|
889
|
+
with(:send_push, @type, @payload, @target, @token, (@now + @ttl).to_i, 0).once
|
890
890
|
flexmock(@sender).should_receive(:amqp_send_once).and_raise(RightScale::Sender::TemporarilyOffline).once
|
891
891
|
@sender.send(:amqp_send, :send_push, @target, @packet, @received_at).should be_true
|
892
892
|
@sender.pending_requests[@token].should be_nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: x86-mingw32
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-
|
15
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: right_support
|
@@ -447,10 +447,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
447
447
|
version: '0'
|
448
448
|
segments:
|
449
449
|
- 0
|
450
|
-
hash:
|
450
|
+
hash: 1050806856707624160
|
451
451
|
requirements: []
|
452
452
|
rubyforge_project:
|
453
|
-
rubygems_version: 1.8.
|
453
|
+
rubygems_version: 1.8.23
|
454
454
|
signing_key:
|
455
455
|
specification_version: 3
|
456
456
|
summary: Agent for interfacing server with RightScale system
|