Module: Roma::Command::SystemCommandReceiver

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

Instance Method Summary collapse

Instance Method Details

#ev_add_latency_avg_calc_cmd(s) ⇒ Object

add_calc_latency_average <command1> <command2>.…



518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/roma/command/sys_command_receiver.rb', line 518

def ev_add_latency_avg_calc_cmd(s)
  #check argument
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 2)\r\n")
  end
  #check support commands
  s.each_index {|idx|
    if idx >= 1 && (!Event::Handler::ev_list.include?(s[idx]) || Event::Handler::system_commands.include?(s[idx]))
       return send_data("NOT SUPPORT [#{s[idx]}] command\r\n")
    end
    if idx >= 1 && @stats.latency_check_cmd.include?(s[idx])
      return send_data("ALREADY SET [#{s[idx]}] command\r\n")
    end
  }

  arg ="radd_latency_avg_calc_cmd"
  s.each_index {|idx|
    arg += " #{s[idx]}" if idx>=1
  }
  res = broadcast_cmd("#{arg}\r\n")

  s.each_index {|idx|
    @stats.latency_check_cmd.push(s[idx]) if idx >= 1
  }
  res[@stats.ap_str] = "SET"
  send_data("#{res}\r\n")
end

#ev_balse(s) ⇒ Object

balse [reason]



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

def ev_balse(s)
  send_data("Are you sure?(yes/no)\r\n")
  if gets != "yes\r\n"
    close_connection_after_writing
    return
  end

  if s.length == 2
    @log.info("Receive a balse #{s[1]}")
  else
    @log.info("Receive a balse command.")
  end
  @rttable.enabled_failover = false
  res = broadcast_cmd("rbalse\r\n")
  res[@stats.ap_str] = "BYE"
  send_data("#{res.inspect}\r\n")
  close_connection_after_writing
  @stop_event_loop = true
end

#ev_chg_latency_avg_calc_time_count(s) ⇒ Object

chg_calc_latency_average_denominator <count>



612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
# File 'lib/roma/command/sys_command_receiver.rb', line 612

def ev_chg_latency_avg_calc_time_count(s)
  #check argument
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments (0 for 2)\r\n")
  elsif s[1] != "nil" && s[1].to_i < 1
    return send_data("s[1].class = #{s[1].class}\r\n")
    return send_data("<count> must be greater than zero or nil[DEACTIVATE]\r\n")
  end

  res = broadcast_cmd("rchg_latency_avg_calc_time_count #{s[1]}\r\n")

  if s[1] != "nil"
    @stats.latency_check_time_count = s[1].to_i
    @stats.latency_log = true
  elsif s[1] == "nil"
    @stats.latency_check_time_count = false
    @stats.latency_log = false
  end
  res[@stats.ap_str] = "CHANGED"
  send_data("#{res}\r\n")
end

#ev_dcnice(s) ⇒ Object

dcnice command is setting priority for a data-copy thread. a niceness of 1 is the highest priority and 5 is the lowest priority. dcnice <priority:1 to 5>



230
231
232
233
234
235
236
237
# File 'lib/roma/command/sys_command_receiver.rb', line 230

def ev_dcnice(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end
  res = broadcast_cmd("rdcnice #{s[1]}\r\n")
  res[@stats.ap_str] = dcnice(s[1].to_i)
  send_data("#{res}\r\n")
end

#ev_del_latency_avg_calc_cmd(s) ⇒ Object

del_calc_latency_average <command1> <command2>.…



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'lib/roma/command/sys_command_receiver.rb', line 566

def ev_del_latency_avg_calc_cmd(s)
  #check argument
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 2)\r\n")
  end
  
  #check support commands
  s.each_index {|idx|
    if idx >= 1 && !@stats.latency_check_cmd.include?(s[idx])
      return send_data("[#{s[idx]}] command is NOT set\r\n")
    end
  }

  arg ="rdel_latency_avg_calc_cmd"
  s.each_index {|idx|
    arg += " #{s[idx]}" if idx>=1
  }
  res = broadcast_cmd("#{arg}\r\n")

  s.each_index {|idx|
    @stats.latency_check_cmd.delete(s[idx]) if idx >= 1
    @stats.latency_data.delete(s[idx]) if idx >= 1
  }
  res[@stats.ap_str] = "DELETED"
  send_data("#{res}\r\n")
end

#ev_forcedly_start(s) ⇒ Object



363
364
365
366
367
368
369
370
# File 'lib/roma/command/sys_command_receiver.rb', line 363

def ev_forcedly_start(s)
  @log.info("ROMA forcedly start.")
  AsyncProcess::queue.clear
  @rttable.enabled_failover = true
  Command::Receiver::mk_evlist
  $roma.startup = false
  send_data("STARTED\r\n")
end

#ev_out(s) ⇒ Object

out <key> <vn>



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/roma/command/sys_command_receiver.rb', line 292

def ev_out(s)
  key,hname = s[1].split("\e")
  hname ||= @defhash
  if s.length >= 3
    vn = s[2].to_i
  else
    d = Digest::SHA1.hexdigest(key).hex % @rttable.hbits
    vn = @rttable.get_vnode_id(d)
  end
  res = @storages[hname].out(vn, key, 0)
  @stats.out_message_count += 1
  unless res
    return send_data("NOT_DELETED\r\n")
  end
  send_data("DELETED\r\n")
end

#ev_quit(s) ⇒ Object

quit



103
104
105
# File 'lib/roma/command/sys_command_receiver.rb', line 103

def ev_quit(s)
  close_connection
end

#ev_radd_latency_avg_calc_cmd(s) ⇒ Object



546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/roma/command/sys_command_receiver.rb', line 546

def ev_radd_latency_avg_calc_cmd(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 2)\r\n")
  end
  s.each_index {|idx|
    if idx >= 2 && (!Event::Handler::ev_list.include?(s[idx]) || Event::Handler::system_commands.include?(s[idx]))
       return send_data("NOT SUPPORT [#{s[idx]}] command\r\n")
    end
    if idx >= 1 && @stats.latency_check_cmd.include?(s[idx])
      return send_data("ALREADY SET [#{s[idx]}] command\r\n")
    end
  }

  s.each_index {|idx|
    @stats.latency_check_cmd.push(s[idx]) if idx >= 1
  }
  send_data("SET\r\n")
end

#ev_rbalse(s) ⇒ Object

rbalse [reason]



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/roma/command/sys_command_receiver.rb', line 30

def ev_rbalse(s)
  if s.length == 2
    @log.info("Receive a rbalse #{s[1]}")
  else
    @log.info("Receive a rbalse command.")
  end
  @rttable.enabled_failover = false
  send_data("BYE\r\n")
  close_connection_after_writing
  @stop_event_loop = true
end

#ev_rchg_latency_avg_calc_time_count(s) ⇒ Object



634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File 'lib/roma/command/sys_command_receiver.rb', line 634

def ev_rchg_latency_avg_calc_time_count(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments (0 for 2)\r\n")
  elsif s[1] != "nil" && s[1].to_i < 1
    return send_data("<count> must be greater than zero\r\n")
  end

  if s[1] != "nil"
    @stats.latency_check_time_count = s[1].to_i
    @stats.latency_log = true
  elsif s[1] == "nil"
    @stats.latency_check_time_count = false
    @stats.latency_log = false
  end
  @stats.latency_check_time_count = s[1].to_i
  send_data("CHANGED\r\n")
end

#ev_rdcnice(s) ⇒ Object



239
240
241
242
243
244
245
# File 'lib/roma/command/sys_command_receiver.rb', line 239

def ev_rdcnice(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end

  send_data("#{dcnice(s[1].to_i)}\r\n")
end

#ev_rdel_latency_avg_calc_cmd(s) ⇒ Object



593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'lib/roma/command/sys_command_receiver.rb', line 593

def ev_rdel_latency_avg_calc_cmd(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 2)\r\n")
  end

  # reset
  s.each_index {|idx|
    if idx >= 1 && !@stats.latency_check_cmd.include?(s[idx])
      return send_data("[#{s[idx]}] command is NOT set\r\n")
    end
  }
  s.each_index {|idx|
    @stats.latency_check_cmd.delete(s[idx]) if idx >= 1
    @stats.latency_data.delete(s[idx]) if idx >= 1
  }
  send_data("DELETED\r\n")
end

#ev_restart(s) ⇒ Object



247
248
249
250
251
252
253
254
255
256
# File 'lib/roma/command/sys_command_receiver.rb', line 247

def ev_restart(s)
  res = broadcast_cmd("rrestart\r\n")
  $roma.eventloop = true
  @rttable.enabled_failover = false
  Messaging::ConPool.instance.close_all
  Event::EMConPool::instance.close_all
  EventMachine::stop_event_loop
  res[@stats.ap_str] = "RESTARTED"
  send_data("#{res}\r\n")
end

#ev_rrestart(s) ⇒ Object



258
259
260
261
262
263
264
265
# File 'lib/roma/command/sys_command_receiver.rb', line 258

def ev_rrestart(s)
  $roma.eventloop = true
  @rttable.enabled_failover = false
  Messaging::ConPool.instance.close_all
  Event::EMConPool::instance.close_all
  EventMachine::stop_event_loop
  send_data("RESTARTED\r\n")
end

#ev_rset(s) ⇒ Object

rset <key> <hash value> <timelimit> <length> “set” means “store this data”. <command name> <key> <digest> <exptime> <bytes> [noreply]rn <data block>rn



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/roma/command/sys_command_receiver.rb', line 313

def ev_rset(s)
  key,hname = s[1].split("\e")
  hname ||= @defhash
  d = s[2].to_i
  d = Digest::SHA1.hexdigest(key).hex % @rttable.hbits if d == 0
  data = read_bytes(s[5].to_i)
  read_bytes(2)
  vn = @rttable.get_vnode_id(d)
  unless @storages.key?(hname)
    send_data("SERVER_ERROR #{hname} does not exists.\r\n")
    return
  end
  if @storages[hname].rset(vn, key, d, s[3].to_i, s[4].to_i, data)
    send_data("STORED\r\n")
  else
    @log.error("rset NOT_STORED:#{@storages[hname].error_message} #{vn} #{s[1]} #{d} #{s[3]} #{s[4]}")
    send_data("NOT_STORED\r\n")
  end
  @stats.redundant_count += 1
end

#ev_rset_accepted_connection_expire_time(s) ⇒ Object

rset_accepted_connection_expire_time <sec>



750
751
752
753
754
755
756
# File 'lib/roma/command/sys_command_receiver.rb', line 750

def ev_rset_accepted_connection_expire_time(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  Event::Handler::connection_expire_time = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rset_connection_pool_expire_time(s) ⇒ Object

rset_connection_pool_expire_time <sec>



772
773
774
775
776
777
778
# File 'lib/roma/command/sys_command_receiver.rb', line 772

def ev_rset_connection_pool_expire_time(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  Messaging::ConPool.instance.expire_time = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rset_connection_pool_maxlength(s) ⇒ Object

rset_connection_pool_maxlength <length>



695
696
697
698
699
700
701
702
703
704
705
# File 'lib/roma/command/sys_command_receiver.rb', line 695

def ev_rset_connection_pool_maxlength(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  if s[1].to_i < 1
    return send_data("CLIENT_ERROR length must be greater than zero\r\n")
  end

  Messaging::ConPool.instance.maxlength = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rset_continuous_limit(s) ⇒ Object



667
668
669
670
671
672
673
674
675
676
# File 'lib/roma/command/sys_command_receiver.rb', line 667

def ev_rset_continuous_limit(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end
  if Event::Handler.set_ccl(s[1])
    send_data("STORED\r\n")
  else
    send_data("NOT_STORED\r\n")
  end
end

#ev_rset_descriptor_table_size(s) ⇒ Object



428
429
430
431
432
433
434
435
436
437
# File 'lib/roma/command/sys_command_receiver.rb', line 428

def ev_rset_descriptor_table_size(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  elsif s[1].to_i < 1024
    return send_data("CLIENT_ERROR length must be greater than 1024\r\n")
  end

  EM.set_descriptor_table_size(s[1].to_i)
  send_data("STORED\r\n")
end

#ev_rset_emconnection_pool_expire_time(s) ⇒ Object

rset_emconnection_pool_expire_time <sec>



798
799
800
801
802
803
804
# File 'lib/roma/command/sys_command_receiver.rb', line 798

def ev_rset_emconnection_pool_expire_time(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  Event::EMConPool::instance.expire_time = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rset_emconnection_pool_maxlength(s) ⇒ Object

rset_connection_pool_maxlength <length>



724
725
726
727
728
729
730
731
732
733
734
# File 'lib/roma/command/sys_command_receiver.rb', line 724

def ev_rset_emconnection_pool_maxlength(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  if s[1].to_i < 1
    return send_data("CLIENT_ERROR length must be greater than zero\r\n")
  end

  Event::EMConPool.instance.maxlength = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rset_gui_last_snapshot(s) ⇒ Object

rset_gui_last_snapshot(s)



1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
# File 'lib/roma/command/sys_command_receiver.rb', line 1148

def ev_rset_gui_last_snapshot(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1] !~ /^\d+\/\d+\/\d+T\d+:\d+:\d+$/
    return send_data("CLIENT_ERROR format is [%Y/%m/%dT%H:%M:%S]\r\n")
  end
  @stats.gui_last_snapshot = s[1]
  send_data("PUSHED\r\n")
end

#ev_rset_hilatency_warn_time(s) ⇒ Object

rset_hilatency_warn_time <sec>



863
864
865
866
867
868
869
870
871
872
# File 'lib/roma/command/sys_command_receiver.rb', line 863

def ev_rset_hilatency_warn_time(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  if s[1].to_f <= 0
    return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
  end
  @stats.hilatency_warn_time = s[1].to_f
  send_data("STORED\r\n")
end

#ev_rset_latency_avg_calc_rule(s) ⇒ Object



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/roma/command/sys_command_receiver.rb', line 484

def ev_rset_latency_avg_calc_rule(s)
  if /^on$|^off$/ !~ s[1]
    return send_data("CLIENT_ERROR argument 1: please input \"on\" or \"off\"\r\n")
  elsif s[1] == "on" && (s.length <= 3 || s[2].to_i < 1)
    return send_data("CLIENT_ERROR number of arguments (0 for 3) and <count> must be greater than zero\r\n")
  elsif s[1] == "off" && !(s.length == 2)
    return send_data("CLIENT_ERROR number of arguments (0 for 1, or more 3)\r\n")
  end

  s.each_index {|idx|
    if idx >= 3 && (!Event::Handler::ev_list.include?(s[idx]) || Event::Handler::system_commands.include?(s[idx]))
       return send_data("NOT SUPPORT [#{s[idx]}] command\r\n")
    end
  }

  if s[1] =="on"
    @latency_data = Hash.new { |hash,key| hash[key] = {}}
    @stats.latency_check_cmd = []
    s.each_index {|idx|
      @stats.latency_check_cmd.push(s[idx]) if idx >= 3
    }
    @stats.latency_check_time_count = s[2].to_i
    @stats.latency_log = true
    send_data("ACTIVATED\r\n")
  elsif s[1] =="off"
    @latency_data = Hash.new { |hash,key| hash[key] = {}}
    @stats.latency_check_cmd = []
    @stats.latency_check_time_count = false
    @stats.latency_log = false
    send_data("DEACTIVATED\r\n")
  end
end

#ev_rset_log_shift_age(s) ⇒ Object



1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
# File 'lib/roma/command/sys_command_receiver.rb', line 1225

def ev_rset_log_shift_age(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  elsif s[1].to_i < 1 && !['0', 'min', 'hour', 'daily', 'weekly', 'monthly'].include?(s[1])
    return send_data("CLIENT_ERROR invalid arguments\r\n")
  end

  if s[1].to_i > 0 || s[1] == '0'
    @log.set_log_shift_age(s[1].to_i)
    @stats.log_shift_age = s[1].to_i
  else
    @log.set_log_shift_age(s[1])
    @stats.log_shift_age = s[1]
  end
  send_data("STORED\r\n")
end

#ev_rset_log_shift_size(s) ⇒ Object



1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
# File 'lib/roma/command/sys_command_receiver.rb', line 1192

def ev_rset_log_shift_size(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  elsif s[1].to_i < 1
    return send_data("CLIENT_ERROR length must be greater than zero\r\n")
  end
  
  @log.set_log_shift_size(s[1].to_i)
  @stats.log_shift_size = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rset_reqpushv_timeout_count(s) ⇒ Object

ev_rset_reqpushv_timeout_count <sec>



943
944
945
946
947
948
949
950
951
952
# File 'lib/roma/command/sys_command_receiver.rb', line 943

def ev_rset_reqpushv_timeout_count(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1].to_i <= 0
    return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
  end
  @stats.reqpushv_timeout_count = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rset_routing_trans_timeout(s) ⇒ Object

rset_set_routing_trans_timeout <sec>



890
891
892
893
894
895
896
897
898
899
900
# File 'lib/roma/command/sys_command_receiver.rb', line 890

def ev_rset_routing_trans_timeout(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1].to_f <= 0
    return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
  end
  @stats.routing_trans_timeout = s[1].to_f

  send_data("STORED\r\n")
end

#ev_rset_spushv_klength_warn(s) ⇒ Object

rset_set_spushv_klength_warn <byte>



969
970
971
972
973
974
975
976
977
978
# File 'lib/roma/command/sys_command_receiver.rb', line 969

def ev_rset_spushv_klength_warn(s)
  if s.length != 2   
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1].to_i <= 0
    return send_data("CLIENT_ERROR size value must be larger than 0 \r\n")
  end 
  @stats.spushv_klength_warn = s[1].to_i 
  send_data("STORED\r\n") 
end

#ev_rset_spushv_read_timeout(s) ⇒ Object

rset_spushv_read_timeout <sec>



917
918
919
920
921
922
923
924
925
926
# File 'lib/roma/command/sys_command_receiver.rb', line 917

def ev_rset_spushv_read_timeout(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1].to_i <= 0
    return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
  end
  @stats.spushv_read_timeout = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rset_spushv_vlength_warn(s) ⇒ Object

rset_set_spushv_vlength_warn <byte>



995
996
997
998
999
1000
1001
1002
1003
1004
# File 'lib/roma/command/sys_command_receiver.rb', line 995

def ev_rset_spushv_vlength_warn(s)
  if s.length != 2   
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1].to_i <= 0
    return send_data("CLIENT_ERROR size value must be larger than 0\r\n")
  end 
  @stats.spushv_vlength_warn = s[1].to_i 
  send_data("STORED\r\n") 
end

#ev_rset_wb_shift_size(s) ⇒ Object



1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
# File 'lib/roma/command/sys_command_receiver.rb', line 1062

def ev_rset_wb_shift_size(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  elsif s[1].to_i < 1
    return send_data("CLIENT_ERROR length must be greater than zero\r\n")
  end

  $roma.wb_writer.shift_size = s[1].to_i
  send_data("STORED\r\n")
end

#ev_rshutdown(s) ⇒ Object

rshutdown [reason]



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/roma/command/sys_command_receiver.rb', line 64

def ev_rshutdown(s)
  if s.length == 2
    @log.info("Receive a rshutdown #{s[1]}")
  else
    @log.info("Receive a rshutdown command.")
  end
  @rttable.enabled_failover = false
  send_data("BYE\r\n")
  close_connection_after_writing
  @stop_event_loop = true
end

#ev_rswitch_dns_caching(s) ⇒ Object

rswitch_dns_caching <on|off|true|false>



828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
# File 'lib/roma/command/sys_command_receiver.rb', line 828

def ev_rswitch_dns_caching(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end

  if s[1] == 'on' || s[1] == 'true'
    DNSCache.instance.enable_dns_cache
    @log.info("DNS caching enabled")
    return send_data("ENABLED\r\n")
  elsif s[1] == 'off' || s[1] == 'false'
    DNSCache.instance.disable_dns_cache
    @log.info("DNS caching disabled")
    return send_data("DISABLED\r\n")
  else
    send_data("NOTSWITCHED\r\n")
  end
end

#ev_rswitch_failover(s) ⇒ Object

rswitch_failover <on|off>



395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/roma/command/sys_command_receiver.rb', line 395

def ev_rswitch_failover(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  if s[1] == 'on'
    Messaging::ConPool.instance.close_all
    Event::EMConPool::instance.close_all
    @rttable.enabled_failover = true
    @log.info("failover enabled")
    return send_data("ENABLED\r\n")
  elsif s[1] == 'off'
    @rttable.enabled_failover = false
    @log.info("failover disabled")
    return send_data("DISABLED\r\n")
  else
    send_data("NOTSWITCHED\r\n")
  end
end

#ev_rwb_command_map(s) ⇒ Object



1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
# File 'lib/roma/command/sys_command_receiver.rb', line 1030

def ev_rwb_command_map(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  map = {}
  cmd = s[1..-1].join
  if cmd =~ /^\{(.+)\}$/
    $1.split(',').each do |kv|
      k, v = kv.split('=>')
      map[k[1..-1].to_sym] = v.to_i if v && k[0]==':'
    end
    @stats.wb_command_map = map
    send_data("#{map}\r\n")
  else
    send_data("CLIENT_ERROR hash string parse error\r\n")
  end        
end

#ev_rwritebehind_get_current_file(s) ⇒ Object

rwritebehind_get_current_file [hash_name]



215
216
217
218
219
220
221
222
223
224
225
# File 'lib/roma/command/sys_command_receiver.rb', line 215

def ev_rwritebehind_get_current_file(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end
  ret = $roma.wb_get_current_file_path(s[1])
  if ret
    send_data("#{ret}\r\n")
  else
    send_data("NOT_OPEND\r\n")
  end
end

#ev_rwritebehind_get_path(s) ⇒ Object

rwritebehind_get_path [hash_name]



189
190
191
192
193
194
195
196
# File 'lib/roma/command/sys_command_receiver.rb', line 189

def ev_rwritebehind_get_path(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end
  
  ret = $roma.wb_get_path(s[1])
  send_data("#{ret}\r\n")
end

#ev_rwritebehind_rotate(s) ⇒ Object

rwritebehind_rotate [hash_name]



164
165
166
167
168
169
170
171
172
173
# File 'lib/roma/command/sys_command_receiver.rb', line 164

def ev_rwritebehind_rotate(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end
  if $roma.wb_rotate(s[1])
    send_data("ROTATED\r\n")
  else
    send_data("NOT_OPEND\r\n")
  end
end

#ev_rzset(s) ⇒ Object

<command name> <key> <digest> <exptime> <bytes> [noreply]rn <compressed data block>rn



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/roma/command/sys_command_receiver.rb', line 336

def ev_rzset(s)
  key,hname = s[1].split("\e")
  hname ||= @defhash
  d = s[2].to_i
  d = Digest::SHA1.hexdigest(key).hex % @rttable.hbits if d == 0
  zdata = read_bytes(s[5].to_i)
  read_bytes(2)
  vn = @rttable.get_vnode_id(d)
  unless @storages.key?(hname)
    send_data("SERVER_ERROR #{hname} does not exists.\r\n")
    return
  end

  data = Zlib::Inflate.inflate(zdata)
# @log.debug("data = #{data}")
  if @storages[hname].rset(vn, key, d, s[3].to_i, s[4].to_i, data)
    send_data("STORED\r\n")
  else
    @log.error("rzset NOT_STORED:#{@storages[hname].error_message} #{vn} #{s[1]} #{d} #{s[3]} #{s[4]}")
    send_data("NOT_STORED\r\n")
  end
  @stats.redundant_count += 1
rescue Zlib::DataError => e
  @log.error("rzset NOT_STORED:#{e} #{vn} #{s[1]} #{d} #{s[3]} #{s[4]}")
  send_data("NOT_STORED\r\n")
end

#ev_set_accepted_connection_expire_time(s) ⇒ Object

set_accepted_connection_expire_time <sec> set to expired time(sec) for accepted connections



738
739
740
741
742
743
744
745
746
747
# File 'lib/roma/command/sys_command_receiver.rb', line 738

def ev_set_accepted_connection_expire_time(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end

  res = broadcast_cmd("rset_accepted_connection_expire_time #{s[1]}\r\n")
  Event::Handler::connection_expire_time = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_cleanup_regexp(s) ⇒ Object

set_cleanup_regexp <regexp>



1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
# File 'lib/roma/command/sys_command_receiver.rb', line 1160

def ev_set_cleanup_regexp(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments #{s.length-1} to 1\r\n")
  end

  # failover check
  unless @rttable.enabled_failover
    return send_data("CLIENT_ERROR failover disable now!!\r\n")
  end

  @storages.each{|hname,st|
    st.cleanup_regexp = s[1]
    st.stop_clean_up
    send_data("STORED\r\n")
  }
end

#ev_set_connection_pool_expire_time(s) ⇒ Object

set_connection_pool_expire_time <sec> set to expired time(sec) for connection_pool expire time



760
761
762
763
764
765
766
767
768
769
# File 'lib/roma/command/sys_command_receiver.rb', line 760

def ev_set_connection_pool_expire_time(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end

  res = broadcast_cmd("rset_connection_pool_expire_time #{s[1]}\r\n")
  Messaging::ConPool.instance.expire_time = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_connection_pool_maxlength(s) ⇒ Object

set_connection_pool_maxlength <length> set to max length of the connection pool



680
681
682
683
684
685
686
687
688
689
690
691
692
# File 'lib/roma/command/sys_command_receiver.rb', line 680

def ev_set_connection_pool_maxlength(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  if s[1].to_i < 1
    return send_data("CLIENT_ERROR length must be greater than zero\r\n")
  end

  res = broadcast_cmd("rset_connection_pool_maxlength #{s[1]}\r\n")
  Messaging::ConPool.instance.maxlength = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_continuous_limit(s) ⇒ Object



652
653
654
655
656
657
658
659
660
661
662
663
664
665
# File 'lib/roma/command/sys_command_receiver.rb', line 652

def ev_set_continuous_limit(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end

  res = broadcast_cmd("rset_continuous_limit #{s[1]}\r\n")

  if Event::Handler.set_ccl(s[1])
    res[@stats.ap_str] = "STORED"
  else
    res[@stats.ap_str] = "NOT_STORED"
  end
  send_data("#{res}\r\n")
end

#ev_set_descriptor_table_size(s) ⇒ Object



414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/roma/command/sys_command_receiver.rb', line 414

def ev_set_descriptor_table_size(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  elsif s[1].to_i < 1024
    return send_data("CLIENT_ERROR length must be greater than 1024\r\n")
  end

  res = broadcast_cmd("rset_descriptor_table_size #{s[1]}\r\n")

  EM.set_descriptor_table_size(s[1].to_i)
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_emconnection_pool_expire_time(s) ⇒ Object

set_emconnection_pool_expire_time <sec>



781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# File 'lib/roma/command/sys_command_receiver.rb', line 781

def ev_set_emconnection_pool_expire_time(s)
  # chcking s incude command and value (NOT check digit)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end

  #if ARGV is 0, expire time become infinity(NOT happen expire)
  if s[1].to_i == 0
    s[1] = "2147483647"
  end
  res = broadcast_cmd("rset_emconnection_pool_expire_time #{s[1]}\r\n")
  Event::EMConPool::instance.expire_time = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_emconnection_pool_maxlength(s) ⇒ Object

set_connection_pool_maxlength <length> set to max length of the connection pool



709
710
711
712
713
714
715
716
717
718
719
720
721
# File 'lib/roma/command/sys_command_receiver.rb', line 709

def ev_set_emconnection_pool_maxlength(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  if s[1].to_i < 1
    return send_data("CLIENT_ERROR length must be greater than zero\r\n")
  end

  res = broadcast_cmd("rset_emconnection_pool_maxlength #{s[1]}\r\n")
  Event::EMConPool.instance.maxlength = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_gui_last_snapshot(s) ⇒ Object

set_gui_last_snapshot_date [%Y/%m/%d %H:%M:%S]



1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
# File 'lib/roma/command/sys_command_receiver.rb', line 1134

def ev_set_gui_last_snapshot(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1] !~ /^\d+\/\d+\/\d+T\d+:\d+:\d+$/
    return send_data("CLIENT_ERROR format is [%Y/%m/%dT%H:%M:%S]\r\n")
  end
  res = broadcast_cmd("rset_gui_last_snapshot #{s[1]}\r\n")
  @stats.gui_last_snapshot = s[1]
  res[@stats.ap_str] = "PUSHED"
  send_data("#{res}\r\n")
end

#ev_set_gui_run_snapshot(s) ⇒ Object

set_gui_run_snapshot [true|false]



1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
# File 'lib/roma/command/sys_command_receiver.rb', line 1116

def ev_set_gui_run_snapshot(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end

  case s[1]
  when 'true'
    @stats.gui_run_snapshot = true
    send_data("STORED\r\n")
  when 'false'
    @stats.gui_run_snapshot = false
    send_data("STORED\r\n")
  else
    return send_data("CLIENT_ERROR value must be true or false\r\n")
  end
end

#ev_set_hilatency_warn_time(s) ⇒ Object

set_hilatency_warn_time <sec> set to threshold of warn message into a log when hilatency occured in a command.



848
849
850
851
852
853
854
855
856
857
858
859
860
# File 'lib/roma/command/sys_command_receiver.rb', line 848

def ev_set_hilatency_warn_time(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  if s[1].to_f <= 0
    return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
  end

  res = broadcast_cmd("rset_hilatency_warn_time #{s[1]}\r\n")
  @stats.hilatency_warn_time = s[1].to_f
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_latency_avg_calc_rule(s) ⇒ Object

set_latency_avg_calc_rule <mode> <count> <command1> <command2>.… <mode> is on/off <count> is denominator to calculate average. <commandx> is target command



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/roma/command/sys_command_receiver.rb', line 443

def ev_set_latency_avg_calc_rule(s)
  #check argument
  if /^on$|^off$/ !~ s[1]
    return send_data("CLIENT_ERROR argument 1: please input \"on\" or \"off\"\r\n")
  elsif s[1] == "on" && (s.length <= 3 || s[2].to_i < 1)
    return send_data("CLIENT_ERROR number of arguments (0 for 3) and <count> must be greater than zero\r\n")
  elsif s[1] == "off" && !(s.length == 2)
    return send_data("CLIENT_ERROR number of arguments (0 for 1, or more 3)\r\n")
  end

  #check support commands
  s.each_index {|idx|
    if idx >= 3 && (!Event::Handler::ev_list.include?(s[idx]) || Event::Handler::system_commands.include?(s[idx]))
       return send_data("NOT SUPPORT [#{s[idx]}] command\r\n")
    end
  }

  arg ="rset_latency_avg_calc_rule"
  s.each_index {|idx|
    arg += " #{s[idx]}" if idx>=1
  }
  res = broadcast_cmd("#{arg}\r\n")

  if s[1] =="on"
    @stats.latency_check_cmd = [] #reset
    s.each_index {|idx|
      @stats.latency_check_cmd.push(s[idx]) if idx >= 3
    }
    @stats.latency_check_time_count = s[2].to_i
    @stats.latency_log = true
    res[@stats.ap_str] = "ACTIVATED"
  elsif s[1] =="off"
    @stats.latency_check_cmd = [] #reset
    @stats.latency_check_time_count = false
    @stats.latency_log = false
    res[@stats.ap_str] = "DEACTIVATED"
  end
  @stats.latency_data = Hash.new { |hash,key| hash[key] = {}}
  send_data("#{res}\r\n")
end

#ev_set_log_level(s) ⇒ Object

set_log_level [ ‘debug’ | ‘info’ | ‘warn’ | ‘error’ ]



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/roma/command/sys_command_receiver.rb', line 268

def ev_set_log_level(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end

  case s[1].downcase
  when 'debug'
    @log.level = Roma::Logging::RLogger::Severity::DEBUG
  when 'info'
    @log.level = Roma::Logging::RLogger::Severity::INFO
  when 'warn'
    @log.level = Roma::Logging::RLogger::Severity::WARN
  when 'error'
    @log.level = Roma::Logging::RLogger::Severity::ERROR
  else
    return send_data("CLIENT_ERROR no match log-level string\r\n")
  end

  @stats.log_level = s[1].downcase

  send_data("STORED\r\n")
end

#ev_set_log_shift_age(s) ⇒ Object

set_log_shift_age <age>



1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
# File 'lib/roma/command/sys_command_receiver.rb', line 1205

def ev_set_log_shift_age(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  elsif s[1].to_i < 1 && !['0', 'min', 'hour', 'daily', 'weekly', 'monthly'].include?(s[1])
    return send_data("CLIENT_ERROR invalid arguments\r\n")
  end

  res = broadcast_cmd("rset_log_shift_age #{s[1]}\r\n")

  if s[1].to_i > 0 || s[1] == '0'
    @log.set_log_shift_age(s[1].to_i)
    @stats.log_shift_age = s[1].to_i
  else
    @log.set_log_shift_age(s[1])
    @stats.log_shift_age = s[1]
  end
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_log_shift_size(s) ⇒ Object

set_log_shift_size <size>



1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
# File 'lib/roma/command/sys_command_receiver.rb', line 1178

def ev_set_log_shift_size(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  elsif s[1].to_i < 1
    return send_data("CLIENT_ERROR length must be greater than zero\r\n")
  end

  res = broadcast_cmd("rset_log_shift_size #{s[1]}\r\n")
  @log.set_log_shift_size(s[1].to_i)
  @stats.log_shift_size = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_reqpushv_timeout_count(s) ⇒ Object

set_reqpushv_timeout_count <sec>



929
930
931
932
933
934
935
936
937
938
939
940
# File 'lib/roma/command/sys_command_receiver.rb', line 929

def ev_set_reqpushv_timeout_count(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1].to_i <= 0
    return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
  end
  res = broadcast_cmd("rset_reqpushv_timeout_count #{s[1]}\r\n")
  @stats.reqpushv_timeout_count = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_routing_trans_timeout(s) ⇒ Object

set_routing_trans_timeout <sec>



875
876
877
878
879
880
881
882
883
884
885
886
887
# File 'lib/roma/command/sys_command_receiver.rb', line 875

def ev_set_routing_trans_timeout(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1].to_f <= 0
    return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
  end
  res = broadcast_cmd("rset_routing_trans_timeout #{s[1]}\r\n")
  @stats.routing_trans_timeout = s[1].to_f
  res[@stats.ap_str] = "STORED"

  send_data("#{res}\r\n")
end

#ev_set_spushv_klength_warn(s) ⇒ Object

set_spushv_klength_warn <byte>



955
956
957
958
959
960
961
962
963
964
965
966
# File 'lib/roma/command/sys_command_receiver.rb', line 955

def ev_set_spushv_klength_warn(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")        
  end
  if s[1].to_i <= 0
    return send_data("CLIENT_ERROR size value must be larger than 0 \r\n")
  end
  res = broadcast_cmd("rset_spushv_klength_warn #{s[1]}\r\n")
  @stats.spushv_klength_warn = s[1].to_i 
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_spushv_read_timeout(s) ⇒ Object

set_spushv_read_timeout <sec>



903
904
905
906
907
908
909
910
911
912
913
914
# File 'lib/roma/command/sys_command_receiver.rb', line 903

def ev_set_spushv_read_timeout(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")
  end
  if s[1].to_i <= 0
    return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
  end
  res = broadcast_cmd("rset_spushv_read_timeout #{s[1]}\r\n")
  @stats.spushv_read_timeout = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_spushv_vlength_warn(s) ⇒ Object

set_spushv_vlength_warn <byte>



981
982
983
984
985
986
987
988
989
990
991
992
# File 'lib/roma/command/sys_command_receiver.rb', line 981

def ev_set_spushv_vlength_warn(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\n\r")       
  end
  if s[1].to_i <= 0
    return send_data("CLIENT_ERROR size value must be larger than 0 \r\n")
  end
  res = broadcast_cmd("rset_spushv_vlength_warn #{s[1]}\r\n")
  @stats.spushv_vlength_warn = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_set_storage_status(s) ⇒ Object

set_storage_status [number of file]hash_name



1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
# File 'lib/roma/command/sys_command_receiver.rb', line 1074

def ev_set_storage_status(s)
  if s.length < 3
    return send_data("CLIENT_ERROR number of arguments (#{s.length - 1} for 2)\r\n")
  end

  if s.length >= 4
    hname = s[3]
  else
    hname = 'roma'
  end
  st = @storages[hname]
  unless st
    return send_data("CLIENT_ERROR hash_name = #{hanme} does not found\r\n")
  end
  dn = s[1].to_i
  if st.divnum <= dn
    return send_data("CLIENT_ERROR divnum <= #{dn}\r\n")
  end
  if s[2] == 'safecopy'
    if st.dbs[dn] != :normal
      return send_data("CLIENT_ERROR storage[#{dn}] != :normal status\r\n")
    end
    if st.set_db_stat(dn, :safecopy_flushing) == false
      return send_data("CLIENT_ERROR storage[#{dn}] status can't changed\r\n")
    end
    Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_storage_flush_process',[hname, dn]))
  elsif s[2] ==  'normal'
    if st.dbs[dn] != :safecopy_flushed
      return send_data("CLIENT_ERROR storage[#{dn}] != :safecopy_flushed status\r\n")
    end
    if st.set_db_stat(dn, :cachecleaning) == false
      return send_data("CLIENT_ERROR storage[#{dn}] status can't changed\r\n")
    end
    Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_storage_cachecleaning_process',[hname, dn]))
  else
    return send_data("CLIENT_ERROR status parse error\r\n")
  end
  
  send_data("PUSHED\r\n")
end

#ev_set_wb_shift_size(s) ⇒ Object

set_wb_shift_size <size>



1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
# File 'lib/roma/command/sys_command_receiver.rb', line 1049

def ev_set_wb_shift_size(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  elsif s[1].to_i < 1
    return send_data("CLIENT_ERROR length must be greater than zero\r\n")
  end

  res = broadcast_cmd("rset_wb_shift_size #{s[1]}\r\n")
  $roma.wb_writer.shift_size = s[1].to_i
  res[@stats.ap_str] = "STORED"
  send_data("#{res}\r\n")
end

#ev_shutdown(s) ⇒ Object

shutdown [reason]



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/roma/command/sys_command_receiver.rb', line 43

def ev_shutdown(s)
  send_data("*** ARE YOU REALLY SURE TO SHUTDOWN? *** (yes/no)\r\n")
  if gets != "yes\r\n"
    close_connection_after_writing
    return
  end

  if s.length == 2
    @log.info("Receive a shutdown #{s[1]}")
  else
    @log.info("Receive a shutdown command.")
  end
  @rttable.enabled_failover = false
  res = broadcast_cmd("rshutdown\r\n")
  res[@stats.ap_str] = "BYE"
  send_data("#{res.inspect}\r\n")
  close_connection_after_writing
  @stop_event_loop = true
end

#ev_shutdown_self(s) ⇒ Object

shutdown_self



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/roma/command/sys_command_receiver.rb', line 77

def ev_shutdown_self(s)
  if s.length != 1
    send_data("ERROR: shutdown_instance has irregular argument.\r\n")
  else
    send_data("\r\n=================================================================\r\n")
    send_data("CAUTION!!: \r\n\tThis command kill the instance!\r\n\tThere is some possibility of occuring redundancy down!\r\n")
    send_data("=================================================================\r\n")
    send_data("\r\nAre you sure to shutdown this instance?(yes/no)\r\n")
    if gets != "yes\r\n"
      close_connection_after_writing
      return
    end
    @log.info("Receive a shutdown_self command.")
    @rttable.enabled_failover = false
    send_data("BYE\r\n")
    @stop_event_loop = true
    close_connection_after_writing
  end
end

#ev_stat(s) ⇒ Object

stat [regexp]



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/roma/command/sys_command_receiver.rb', line 115

def ev_stat(s)
  regexp = s[1] if s.length == 2
  h = {}
  h['version'] = Roma::VERSION
  send_stat_result(nil,h,regexp)
  send_stat_result(nil,get_config_stat,regexp)
  send_stat_result(nil,@stats.get_stat,regexp)
  @storages.each{|hname,st|
    send_stat_result("storages[#{hname}].",st.get_stat,regexp)
  }
  send_stat_result(nil,$roma.wb_get_stat,regexp)
  send_stat_result(nil,@rttable.get_stat(@stats.ap_str),regexp)
  send_stat_result(nil,conn_get_stat,regexp)
  send_stat_result(nil,DNSCache.instance.get_stat,regexp)
  send_data("END\r\n")
end

#ev_stats(s) ⇒ Object

stats [regexp]



112
# File 'lib/roma/command/sys_command_receiver.rb', line 112

def ev_stats(s); ev_stat(s); end

#ev_switch_dns_caching(s) ⇒ Object

switch_dns_caching <on|off|true|false>



807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
# File 'lib/roma/command/sys_command_receiver.rb', line 807

def ev_switch_dns_caching(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end

  res = broadcast_cmd("rswitch_dns_caching #{s[1]}\r\n")
  if s[1] == 'on' || s[1] == 'true'
    DNSCache.instance.enable_dns_cache
    @log.info("DNS caching enabled")
    res[@stats.ap_str] = "ENABLED"
  elsif s[1] == 'off' || s[1] == 'false'
    DNSCache.instance.disable_dns_cache
    @log.info("DNS caching disabled")
    res[@stats.ap_str] = "DISABLED"
  else
    res[@stats.ap_str] = "NOTSWITCHED"
  end
  send_data("#{res}\r\n")
end

#ev_switch_failover(s) ⇒ Object

switch_failover <on|off>



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/roma/command/sys_command_receiver.rb', line 373

def ev_switch_failover(s)
  if s.length != 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  res = broadcast_cmd("rswitch_failover #{s[1]}\r\n")
  if s[1] == 'on'
    Messaging::ConPool.instance.close_all
    Event::EMConPool::instance.close_all
    @rttable.enabled_failover = true
    @log.info("failover enabled")
    res[@stats.ap_str] = "ENABLED"
  elsif s[1] == 'off'
    @rttable.enabled_failover = false
    @log.info("failover disabled")
    res[@stats.ap_str] = "DISABLED"
  else
    res[@stats.ap_str] = "NOTSWITCHED"
  end
  send_data("#{res}\r\n")
end

#ev_version(s) ⇒ Object

version



98
99
100
# File 'lib/roma/command/sys_command_receiver.rb', line 98

def ev_version(s)
  send_data("VERSION ROMA-#{Roma::VERSION}\r\n")
end

#ev_wb_command_map(s) ⇒ Object

wb_command_map <hash string> ex. :set=>1,:append=>2,:delete=>3



1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
# File 'lib/roma/command/sys_command_receiver.rb', line 1009

def ev_wb_command_map(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments\r\n")
  end
  map = {}
  cmd = s[1..-1].join
  if cmd =~ /^\{(.+)\}$/
    $1.split(',').each do |kv|
      k, v = kv.split('=>')
      map[k[1..-1].to_sym] = v.to_i if v && k[0]==':'
    end

    res = broadcast_cmd("rwb_command_map #{s[1..-1].join}\r\n")
    @stats.wb_command_map = map
    res[@stats.ap_str] = map.inspect
    send_data("#{res}\r\n")
  else
    send_data("CLIENT_ERROR hash string parse error\r\n")
  end
end

#ev_whoami(s) ⇒ Object



107
108
109
# File 'lib/roma/command/sys_command_receiver.rb', line 107

def ev_whoami(s)
  send_data("#{@stats.name}\r\n")
end

#ev_writebehind_get_current_file(s) ⇒ Object

writebehind_get_current_file [hash_name]



199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/roma/command/sys_command_receiver.rb', line 199

def ev_writebehind_get_current_file(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end
  res = broadcast_cmd("rwritebehind_get_current_file #{s[1]}\r\n")

  ret = $roma.wb_get_current_file_path(s[1])
  if ret
    res[@stats.ap_str] = ret
  else
    res[@stats.ap_str] = "NOT_OPEND"
  end
  send_data("#{res}\r\n")
end

#ev_writebehind_get_path(s) ⇒ Object

writebehind_get_path [hash_name]



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/roma/command/sys_command_receiver.rb', line 176

def ev_writebehind_get_path(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end
  res = broadcast_cmd("rwritebehind_get_path #{s[1]}\r\n")
  
  ret = $roma.wb_get_path(s[1])
  res[@stats.ap_str] = ret

  send_data("#{res}\r\n")
end

#ev_writebehind_rotate(s) ⇒ Object

writebehind_rotate [hash_name]



149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/roma/command/sys_command_receiver.rb', line 149

def ev_writebehind_rotate(s)
  if s.length < 2
    return send_data("CLIENT_ERROR number of arguments (0 for 1)\r\n")
  end
  res = broadcast_cmd("rwritebehind_rotate #{s[1]}\r\n")

  if $roma.wb_rotate(s[1])
    res[@stats.ap_str] = "ROTATED"
  else
    res[@stats.ap_str] = "NOT_OPEND"
  end
  send_data("#{res}\r\n")
end