class DRbDump::MessageSend

Wraps a DRb message-send after consuming it from a stream.

Attributes

argc[R]

The number of arguments, not including the block

raw_argv[R]

The arguments, each as a Marshal::Structure

raw_block[R]

The block as a Marshal::Structure

raw_message[R]

The message sent as a Marshal::Structure

Public Class Methods

new(drbdump, packet, receiver, stream) click to toggle source

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.

Calls superclass method DRbDump::Message.new
# 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

  load_message if stream
end

Public Instance Methods

allocations() click to toggle source

The number of allocations required to load the message.

# 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() click to toggle source

Number of arguments including the block

# File lib/drbdump/message_send.rb, line 71
def argument_count
  @argc + (block ? 1 : 0)
end
arguments() click to toggle source

A string containing all loaded arguments including the block.

# File lib/drbdump/message_send.rb, line 62
def arguments
  arguments = argv.map { |obj| obj.inspect }
  (arguments << '&block') if block
  arguments.join ', '
end
argv() click to toggle source

The loaded arguments

# File lib/drbdump/message_send.rb, line 78
def argv
  @argv ||= @raw_argv.map { |obj| @drbdump.load_marshal_data obj }
end
block() click to toggle source

The loaded block

# File lib/drbdump/message_send.rb, line 85
def block
  @block ||= @raw_block.load
end
display() click to toggle source

Prints the message information to standard output

# File lib/drbdump/message_send.rb, line 92
def display
  update_statistics

  return if @drbdump.quiet

  timestamp = self.timestamp.strftime DRbDump::TIMESTAMP_FORMAT

  puts "%s %s \u21d2 (%s, %p).%s(%s)" % [
    timestamp, source, destination, receiver, message, arguments
  ]
end
message() click to toggle source

The loaded message

# File lib/drbdump/message_send.rb, line 118
def message
  @message ||= @raw_message.load
end
receiver() click to toggle source

The loaded receiver for the message

# File lib/drbdump/message_send.rb, line 125
def receiver
  @receiver ||= @raw_receiver.load
end
timestamp() click to toggle source

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.

# File lib/drbdump/message_send.rb, line 134
def timestamp
  @drbdump.incomplete_timestamps.delete(@packet.source) || @packet.timestamp
end