Class: DRbDump::MessageSend
- Defined in:
- lib/drbdump/message_send.rb
Overview
Wraps a DRb message-send after consuming it from a stream.
Instance Attribute Summary collapse
-
#argc ⇒ Object
readonly
The number of arguments, not including the block.
-
#raw_argv ⇒ Object
readonly
The arguments, each as a Marshal::Structure.
-
#raw_block ⇒ Object
readonly
The block as a Marshal::Structure.
-
#raw_message ⇒ Object
readonly
The message sent as a Marshal::Structure.
Instance Method Summary collapse
-
#allocations ⇒ Object
The number of allocations required to load the message.
-
#argument_count ⇒ Object
Number of arguments including the block.
-
#arguments ⇒ Object
A string containing all loaded arguments including the block.
-
#argv ⇒ Object
The loaded arguments.
-
#block ⇒ Object
The loaded block.
-
#display ⇒ Object
Prints the message information to standard output.
-
#initialize(drbdump, packet, receiver, stream) ⇒ MessageSend
constructor
Creates a new MessageSend for the creating
drbdump
instance. -
#load_message ⇒ Object
Returns the message, arguments and block for the DRb message-send in
stream
. -
#message ⇒ Object
The loaded message.
-
#receiver ⇒ Object
The loaded receiver for the message.
-
#timestamp ⇒ Object
Returns the timestamp for the first packet in the incomplete stream for
packet
or the packet’s timestamp if this is the only packet in the stream. -
#update_statistics ⇒ Object
Updates the drbdump’s statistics with information from this message.
Methods inherited from Message
#destination, from_stream, #resolve_addresses, #source
Constructor Details
#initialize(drbdump, packet, receiver, stream) ⇒ MessageSend
Creates a new MessageSend for the creating drbdump
instance. The last packet in the message is packet
and the Marshal::Structure for the first argument is receiver
. The rest of the message will be loaded from stream
.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/drbdump/message_send.rb', line 32 def initialize drbdump, packet, receiver, stream super drbdump, packet @argc = nil @argv = nil @block = nil @message = nil @raw_receiver = receiver @stream = stream if stream end |
Instance Attribute Details
#argc ⇒ Object (readonly)
The number of arguments, not including the block
9 10 11 |
# File 'lib/drbdump/message_send.rb', line 9 def argc @argc end |
#raw_argv ⇒ Object (readonly)
The arguments, each as a Marshal::Structure
14 15 16 |
# File 'lib/drbdump/message_send.rb', line 14 def raw_argv @raw_argv end |
#raw_block ⇒ Object (readonly)
The block as a Marshal::Structure
19 20 21 |
# File 'lib/drbdump/message_send.rb', line 19 def raw_block @raw_block end |
#raw_message ⇒ Object (readonly)
The message sent as a Marshal::Structure
24 25 26 |
# File 'lib/drbdump/message_send.rb', line 24 def @raw_message end |
Instance Method Details
#allocations ⇒ Object
The number of allocations required to load the message.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/drbdump/message_send.rb', line 48 def allocations allocations = 0 allocations += @raw_receiver.count_allocations allocations += @raw_message.count_allocations @raw_argv.each { |arg| allocations += arg.count_allocations } allocations += @raw_block.count_allocations allocations end |
#argument_count ⇒ Object
Number of arguments including the block
71 72 73 |
# File 'lib/drbdump/message_send.rb', line 71 def argument_count @argc + (block ? 1 : 0) end |
#arguments ⇒ Object
A string containing all loaded arguments including the block.
62 63 64 65 66 |
# File 'lib/drbdump/message_send.rb', line 62 def arguments arguments = argv.map { |obj| obj.inspect } (arguments << '&block') if block arguments.join ', ' end |
#argv ⇒ Object
The loaded arguments
78 79 80 |
# File 'lib/drbdump/message_send.rb', line 78 def argv @argv ||= @raw_argv.map { |obj| @drbdump.load_marshal_data obj } end |
#block ⇒ Object
The loaded block
85 86 87 |
# File 'lib/drbdump/message_send.rb', line 85 def block @block ||= @raw_block.load end |
#display ⇒ Object
Prints the message information to standard output
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/drbdump/message_send.rb', line 92 def display update_statistics return if @drbdump.quiet = self..strftime DRbDump::TIMESTAMP_FORMAT puts "%s %s \u21d2 (%s, %p).%s(%s)" % [ , source, destination, receiver, , arguments ] end |
#load_message ⇒ Object
Returns the message, arguments and block for the DRb message-send in stream
.
108 109 110 111 112 113 |
# File 'lib/drbdump/message_send.rb', line 108 def # :nodoc: @raw_message = @loader.load @stream @argc = @loader.load(@stream).load @raw_argv = @argc.times.map { @loader.load @stream } @raw_block = @loader.load @stream end |
#message ⇒ Object
The loaded message
118 119 120 |
# File 'lib/drbdump/message_send.rb', line 118 def @message ||= @raw_message.load end |
#receiver ⇒ Object
The loaded receiver for the message
125 126 127 |
# File 'lib/drbdump/message_send.rb', line 125 def receiver @receiver ||= @raw_receiver.load end |
#timestamp ⇒ Object
Returns the timestamp for the first packet in the incomplete stream for packet
or the packet’s timestamp if this is the only packet in the stream.
134 135 136 |
# File 'lib/drbdump/message_send.rb', line 134 def @drbdump..delete(@packet.source) || @packet. end |
#update_statistics ⇒ Object
Updates the drbdump’s statistics with information from this message.
141 142 143 |
# File 'lib/drbdump/message_send.rb', line 141 def update_statistics # :nodoc: @statistics. self end |