Class: Baykit::BayServer::Agent::Multiplexer::RudderState

Inherits:
Object
  • Object
show all
Defined in:
lib/baykit/bayserver/agent/multiplexer/rudder_state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rd, tp = nil, timeout_sec = 0) ⇒ RudderState

Returns a new instance of RudderState.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 31

def initialize(rd, tp = nil, timeout_sec = 0)
  @rudder = rd
  @transporter = tp
  @closed = false
  @timeout_sec = timeout_sec

  if tp != nil
    @buf_size = tp.get_read_buffer_size
    @handshaking = tp.secure() ? true : false
  else
    @buf_size = 8192
    @handshaking = false
  end
  @read_buf = " ".b * @buf_size

  @accepting = false
  @connecting = false
  @write_queue = []
  @write_queue_lock = Mutex::new
  @reading_lock = Mutex::new
  @writing_lock = Mutex::new
  @reading = false
  @writing = false
  @bytes_read = 0
  @bytes_wrote = 0
end

Instance Attribute Details

#acceptingObject

Returns the value of attribute accepting.



27
28
29
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 27

def accepting
  @accepting
end

#buf_sizeObject (readonly)

Returns the value of attribute buf_size.



14
15
16
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 14

def buf_size
  @buf_size
end

#bytes_readObject

Returns the value of attribute bytes_read.



19
20
21
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 19

def bytes_read
  @bytes_read
end

#bytes_wroteObject

Returns the value of attribute bytes_wrote.



20
21
22
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 20

def bytes_wrote
  @bytes_wrote
end

#closedObject

Returns the value of attribute closed.



24
25
26
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 24

def closed
  @closed
end

#connectingObject

Returns the value of attribute connecting.



28
29
30
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 28

def connecting
  @connecting
end

#finaleObject

Returns the value of attribute finale.



25
26
27
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 25

def finale
  @finale
end

#handshakingObject

Returns the value of attribute handshaking.



16
17
18
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 16

def handshaking
  @handshaking
end

#last_access_timeObject (readonly)

Returns the value of attribute last_access_time.



11
12
13
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 11

def last_access_time
  @last_access_time
end

#multiplexerObject

Returns the value of attribute multiplexer.



9
10
11
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 9

def multiplexer
  @multiplexer
end

#read_bufObject (readonly)

Returns the value of attribute read_buf.



13
14
15
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 13

def read_buf
  @read_buf
end

#readingObject

Returns the value of attribute reading.



17
18
19
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 17

def reading
  @reading
end

#reading_lockObject (readonly)

Returns the value of attribute reading_lock.



22
23
24
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 22

def reading_lock
  @reading_lock
end

#rudderObject (readonly)

Returns the value of attribute rudder.



7
8
9
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 7

def rudder
  @rudder
end

#transporterObject (readonly)

Returns the value of attribute transporter.



8
9
10
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 8

def transporter
  @transporter
end

#write_queueObject (readonly)

Returns the value of attribute write_queue.



15
16
17
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 15

def write_queue
  @write_queue
end

#write_queue_lockObject (readonly)

Returns the value of attribute write_queue_lock.



21
22
23
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 21

def write_queue_lock
  @write_queue_lock
end

#writingObject

Returns the value of attribute writing.



18
19
20
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 18

def writing
  @writing
end

#writing_lockObject (readonly)

Returns the value of attribute writing_lock.



23
24
25
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 23

def writing_lock
  @writing_lock
end

Instance Method Details

#accessObject



64
65
66
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 64

def access
  @last_access_time = Time.now.tv_sec
end

#endObject



68
69
70
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 68

def end
  @finale = true
end

#to_sObject



58
59
60
61
# File 'lib/baykit/bayserver/agent/multiplexer/rudder_state.rb', line 58

def to_s
  str = "st(rd=#{@rudder} mpx=#{@multiplexer} tp=#{@transporter})"
  return str
end