Module: Roma::Command::UtilCommandReceiver

Included in:
Receiver
Defined in:
lib/roma/command/util_command_receiver.rb

Instance Method Summary collapse

Instance Method Details

#async_broadcast_cmd(cmd, without_nids = nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/roma/command/util_command_receiver.rb', line 52

def async_broadcast_cmd(cmd,without_nids=nil)
  without_nids=[@stats.ap_str] unless without_nids
  res = {}
  @rttable.nodes.each{ |nid|
    res[nid] = async_send_cmd(nid,cmd) unless without_nids.include?(nid)
  }
  res
rescue => e
  @log.error("#{e}\n#{$@}")
  nil
end

#async_send_cmd(nid, cmd) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/roma/command/util_command_receiver.rb', line 34

def async_send_cmd(nid, cmd)
  con = Roma::Messaging::ConPool.instance.get_connection(nid)
  con.write(cmd)
  res = con.gets
  Roma::Messaging::ConPool.instance.return_connection(nid, con)
  if res
    res.chomp!
    @rttable.proc_succeed(nid)
  else
    @rttable.proc_failed(nid)
  end
  res
rescue => e
  @rttable.proc_failed(nid)
  @log.error("#{e}\n#{$@}")
  nil
end

#broadcast_cmd(cmd) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/roma/command/util_command_receiver.rb', line 26

def broadcast_cmd(cmd)
  res={}
  @rttable.nodes.each{|nid|
    res[nid] = send_cmd(nid,cmd) if nid != @stats.ap_str
  }
  res
end

#chg_time_expt(expt) ⇒ Object

change to actual time for a memcached’s expire time value



65
66
67
68
69
70
71
72
# File 'lib/roma/command/util_command_receiver.rb', line 65

def chg_time_expt(expt)
  if expt == 0
    expt = 0x7fffffff
  elsif expt < 2592000
    expt += Time.now.to_i
  end
  expt
end

#send_cmd(nid, cmd) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/roma/command/util_command_receiver.rb', line 8

def send_cmd(nid, cmd)
  con = get_connection(nid)
  con.send(cmd)
  res = con.gets
  if res == nil
    @rttable.proc_failed(nid)
    return nil
  elsif res.start_with?("ERROR") == false
    @rttable.proc_succeed(nid)
    return_connection(nid, con)
  end
  res.chomp
rescue => e
  @rttable.proc_failed(nid)
  @log.error("#{e}\n#{$@}")
  nil
end