roma 0.8.13 → 0.8.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eaf529b1a3ec8c250e906ce4b360cc694455159d
4
+ data.tar.gz: f566d3a0c29055ac384683ec5c7859723b9fc091
5
+ SHA512:
6
+ metadata.gz: 0d259866eb0fc71effe35310966a706bc2517959ed8d37fe793bc3bbf77ccb55b24815df765c1f90945ce397f4e8f63df8be28342290c97fe69aa9190db63af4
7
+ data.tar.gz: e7ac00f6f5a1db6e4ebfdc17e1170ae431d0a15211ec92c3b978fd1003d33b479822f0dcb0e0aff38e949f2aab8ca1e4155d4c75f074b38934d62a7908dbca1f
data/CHANGELOG CHANGED
@@ -1,3 +1,23 @@
1
+ *0.8.14 (Mar 26 2014)*
2
+
3
+ * add timeout parameter for a vnode copy [junji torii] 0522750
4
+ * add command to change routing_trans_timeout [Rui Bando] 8247698
5
+ * Added command to change klength and vlength limit when vnode copy [Paras Patel] fd14206
6
+ * Add spushv_read_timeout and reqpushv_timeout_count set Method [Paras Patel] 264d3ec
7
+ * fix : add rescue in timer_event_1sec [junji torii] 11cc4ea
8
+ * fix : warning of class variable access from toplevel(for adjust Ruby2.1.1) [junji torii] 9df1a5c
9
+ * fix : modify default value(nil -> false) of autorecover func [hiroaki-iwase] 30b18c5
10
+ * add snapshot function [junji torii] 2ab928f
11
+ * add safecopy_integration_test for snapshot [hiroaki-iwase] 8e799c1
12
+
13
+ *0.8.13-p1 (Jan 15 2014)*
14
+
15
+ * add timeout parameter for a vnode copy [junji torii] 0522750
16
+ * remove some debug log [hiroaki-iwase] 94d96dc
17
+ * Add Gemfile. [Hiroki Matsue] 9029bf8
18
+ * Ignore test related files. [Hiroki Matsue] 556a931
19
+ * fix:add rescue in timer_event_1sec [junji torii] 11cc4ea
20
+
1
21
  *0.8.13 (Sep 12 2013)*
2
22
 
3
23
  * change target ruby version about encoding problem (upper 1.9.2 => upper 1.9.1) [hiroaki-iwase] e56d2f4
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'eventmachine'
4
+
5
+ # Back-end storages
6
+ group :tokyocabinet do
7
+ gem 'tokyocabinet', :git => 'https://github.com/roma/tokyocabinet-ruby.git'
8
+ end
9
+
10
+ group :gdbm do
11
+ gem 'ffi'
12
+ gem 'gdbm'
13
+ end
14
+
15
+ group :sqlite3 do
16
+ gem 'sqlite3'
17
+ end
data/Rakefile CHANGED
@@ -39,8 +39,8 @@ EXEC_TABLE = Dir.entries(base + 'bin').reject{ |d| d =~ /^\.+$/ || d =~ /^sample
39
39
  require File.expand_path(File.join('ruby', 'server', 'lib', 'roma', 'version'), File.dirname(__FILE__))
40
40
  VER_NUM = Roma::VERSION
41
41
 
42
- if VER_NUM =~ /([0-9.]+)$/
43
- CURRENT_VERSION = $1
42
+ if VER_NUM =~ /([0-9.p-]+)$/
43
+ CURRENT_VERSION = $1.delete("-")
44
44
  else
45
45
  CURRENT_VERSION = "0.0.0"
46
46
  end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ path = File.dirname(File.expand_path($PROGRAM_NAME))
4
+ $LOAD_PATH << path + "/../lib"
5
+
6
+ require 'roma/tools/cpdb'
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ base_path = Pathname(__FILE__).dirname.parent.parent.expand_path
5
+ $LOAD_PATH.unshift("#{base_path}/server/lib")
6
+
7
+ client_base_path = Pathname(__FILE__).dirname.parent.parent.parent.parent.expand_path
8
+ $LOAD_PATH.unshift("#{client_base_path}/roma-ruby-client/lib")
9
+
10
+ require 'roma/tools/safecopy_integration_test'
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ base_path = Pathname(__FILE__).dirname.parent.parent.expand_path
5
+ $LOAD_PATH.unshift("#{base_path}/server/lib")
6
+
7
+ client_base_path = Pathname(__FILE__).dirname.parent.parent.parent.parent.expand_path
8
+ $LOAD_PATH.unshift("#{client_base_path}/roma-ruby-client/lib")
9
+
10
+ require 'roma/tools/safecopy_test'
@@ -462,11 +462,11 @@ module Roma
462
462
  Roma::Messaging::ConPool.instance.return_connection(src_nid,con)
463
463
  # waiting for pushv
464
464
  count = 0
465
- while @rttable.search_nodes(vn).include?(@stats.ap_str)==false && count < 300
465
+ while @rttable.search_nodes(vn).include?(@stats.ap_str)==false && count < @stats.reqpushv_timeout_count
466
466
  sleep 0.1
467
467
  count += 1
468
468
  end
469
- if count >= 300
469
+ if count >= @stats.reqpushv_timeout_count
470
470
  @log.warn("#{__method__}:request has been time-out.vn=#{vn} nid=#{src_nid}")
471
471
  return :timeout
472
472
  end
@@ -748,7 +748,7 @@ module Roma
748
748
  @log.error("#{__method__}:#{e.inspect} #{$@}")
749
749
 
750
750
  ensure
751
- if @stats.latency_check_time_count != nil && Time.now.to_i - @stats.latency_data[cmd]["time"] > @stats.latency_check_time_count
751
+ if @stats.latency_check_time_count && Time.now.to_i - @stats.latency_data[cmd]["time"] > @stats.latency_check_time_count
752
752
  average = @stats.latency_data[cmd]["latency"].inject(0.0){|r,i| r+=i }/@stats.latency_data[cmd]["latency"].size
753
753
  max = @stats.latency_data[cmd]["latency_max"]["current"]
754
754
  min = @stats.latency_data[cmd]["latency_min"]["current"]
@@ -770,6 +770,90 @@ module Roma
770
770
  true
771
771
  end
772
772
 
773
+ def asyncev_start_storage_flush_process(args)
774
+ hname, dn = args
775
+ @log.debug("#{__method__} #{args.inspect}")
776
+
777
+ st = @storages[hname]
778
+ if st.dbs[dn] != :safecopy_flushing
779
+ @log.error("Can not flush storage. stat = #{st.dbs[dn]}")
780
+ return true
781
+ end
782
+ t = Thread::new do
783
+ begin
784
+ st.flush_db(dn)
785
+ st.set_db_stat(dn,:safecopy_flushed)
786
+ @log.info("#{__method__}:storage has flushed. (#{hname}, #{dn})")
787
+ rescue =>e
788
+ @log.error("#{__method__}:#{e.inspect} #{$@}")
789
+ ensure
790
+ end
791
+ end
792
+ t[:name] = __method__
793
+ true
794
+ end
795
+
796
+ def asyncev_start_storage_cachecleaning_process(args)
797
+ hname, dn = args
798
+ @log.debug("#{__method__} #{args.inspect}")
799
+
800
+ st = @storages[hname]
801
+ if st.dbs[dn] != :cachecleaning
802
+ @log.error("Can not start cachecleaning process. stat = #{st.dbs[dn]}")
803
+ return true
804
+ end
805
+ t = Thread::new do
806
+ begin
807
+ storage_cachecleaning_process(hname, dn)
808
+ rescue =>e
809
+ @log.error("#{__method__}:#{e.inspect} #{$@}")
810
+ ensure
811
+ end
812
+ end
813
+ t[:name] = __method__
814
+ true
815
+ end
816
+
817
+ def storage_cachecleaning_process(hname, dn)
818
+ count = 0
819
+ rcount = 0
820
+ st = @storages[hname]
821
+
822
+ @do_storage_cachecleaning_process = true
823
+ loop do
824
+ # get keys in a cache up to 100 kyes
825
+ keys = st.get_keys_in_cache(dn)
826
+ break if keys == nil || keys.length == 0
827
+ break unless @do_storage_cachecleaning_process
828
+
829
+ # @log.debug("#{__method__}:#{keys.length} keys found")
830
+
831
+ # copy cache -> db
832
+ st.each_cache_by_keys(dn, keys) do |vn, last, clk, expt, k, v|
833
+ break unless @do_storage_cachecleaning_process
834
+ if st.load_stream_dump_for_cachecleaning(vn, last, clk, expt, k, v)
835
+ count += 1
836
+ # @log.debug("#{__method__}:[#{vn} #{last} #{clk} #{expt} #{k}] was stored.")
837
+ else
838
+ rcount += 1
839
+ # @log.debug("#{__method__}:[#{vn} #{last} #{clk} #{expt} #{k}] was rejected.")
840
+ end
841
+ end
842
+
843
+ # remove keys in a cache
844
+ keys.each { |key| st.out_cache(dn, key) }
845
+ end
846
+ if @do_storage_cachecleaning_process == false
847
+ @log.warn("#{__method__}:uncompleted")
848
+ else
849
+ st.set_db_stat(dn,:normal)
850
+ end
851
+ @log.debug("#{__method__}:#{count} keys loaded.")
852
+ @log.debug("#{__method__}:#{rcount} keys rejected.") if rcount > 0
853
+ ensure
854
+ @do_storage_cachecleaning_process = false
855
+ end
856
+
773
857
  end # module AsyncProcess
774
858
 
775
859
  end # module Roma
@@ -1,3 +1,4 @@
1
+ require 'roma/async_process'
1
2
 
2
3
  module Roma
3
4
  module Command
@@ -430,7 +431,7 @@ module Roma
430
431
  res[@stats.ap_str] = "ACTIVATED"
431
432
  elsif s[1] =="off"
432
433
  @stats.latency_check_cmd = [] #reset
433
- @stats.latency_check_time_count = nil
434
+ @stats.latency_check_time_count = false
434
435
  @stats.latency_log = false
435
436
  res[@stats.ap_str] = "DEACTIVATED"
436
437
  end
@@ -459,13 +460,13 @@ module Roma
459
460
  s.each_index {|idx|
460
461
  @stats.latency_check_cmd.push(s[idx]) if idx >= 3
461
462
  }
462
- @stats.latency_check_time_count = s[1].to_i
463
+ @stats.latency_check_time_count = s[2].to_i
463
464
  @stats.latency_log = true
464
465
  send_data("ACTIVATED\r\n")
465
466
  elsif s[1] =="off"
466
467
  @latency_data = Hash.new { |hash,key| hash[key] = {}}
467
468
  @stats.latency_check_cmd = []
468
- @stats.latency_check_time_count = nil
469
+ @stats.latency_check_time_count = false
469
470
  @stats.latency_log = false
470
471
  send_data("DEACTIVATED\r\n")
471
472
  end
@@ -581,7 +582,7 @@ module Roma
581
582
  @stats.latency_check_time_count = s[1].to_i
582
583
  @stats.latency_log = true
583
584
  elsif s[1] == "nil"
584
- @stats.latency_check_time_count = nil
585
+ @stats.latency_check_time_count = false
585
586
  @stats.latency_log = false
586
587
  end
587
588
  res[@stats.ap_str] = "CHANGED"
@@ -599,7 +600,7 @@ module Roma
599
600
  @stats.latency_check_time_count = s[1].to_i
600
601
  @stats.latency_log = true
601
602
  elsif s[1] == "nil"
602
- @stats.latency_check_time_count = nil
603
+ @stats.latency_check_time_count = false
603
604
  @stats.latency_log = false
604
605
  end
605
606
  @stats.latency_check_time_count = s[1].to_i
@@ -828,6 +829,138 @@ module Roma
828
829
  send_data("STORED\r\n")
829
830
  end
830
831
 
832
+ # set_routing_trans_timeout <sec>
833
+ def ev_set_routing_trans_timeout(s)
834
+ if s.length != 2
835
+ return send_data("CLIENT_ERROR number of arguments\n\r")
836
+ end
837
+ if s[1].to_f <= 0
838
+ return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
839
+ end
840
+ res = broadcast_cmd("rset_routing_trans_timeout #{s[1]}\r\n")
841
+ @stats.routing_trans_timeout = s[1].to_f
842
+ res[@stats.ap_str] = "STORED"
843
+
844
+ send_data("#{res}\r\n")
845
+ end
846
+
847
+ # rset_set_routing_trans_timeout <sec>
848
+ def ev_rset_routing_trans_timeout(s)
849
+ if s.length != 2
850
+ return send_data("CLIENT_ERROR number of arguments\n\r")
851
+ end
852
+ if s[1].to_f <= 0
853
+ return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
854
+ end
855
+ @stats.routing_trans_timeout = s[1].to_f
856
+
857
+ send_data("STORED\r\n")
858
+ end
859
+
860
+ # set_spushv_read_timeout <sec>
861
+ def ev_set_spushv_read_timeout(s)
862
+ if s.length != 2
863
+ return send_data("CLIENT_ERROR number of arguments\n\r")
864
+ end
865
+ if s[1].to_i <= 0
866
+ return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
867
+ end
868
+ res = broadcast_cmd("rset_spushv_read_timeout #{s[1]}\r\n")
869
+ @stats.spushv_read_timeout = s[1].to_i
870
+ res[@stats.ap_str] = "STORED"
871
+ send_data("#{res}\r\n")
872
+ end
873
+
874
+ # rset_spushv_read_timeout <sec>
875
+ def ev_rset_spushv_read_timeout(s)
876
+ if s.length != 2
877
+ return send_data("CLIENT_ERROR number of arguments\n\r")
878
+ end
879
+ if s[1].to_i <= 0
880
+ return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
881
+ end
882
+ @stats.spushv_read_timeout = s[1].to_i
883
+ send_data("STORED\r\n")
884
+ end
885
+
886
+ # set_reqpushv_timeout_count <sec>
887
+ def ev_set_reqpushv_timeout_count(s)
888
+ if s.length != 2
889
+ return send_data("CLIENT_ERROR number of arguments\n\r")
890
+ end
891
+ if s[1].to_i <= 0
892
+ return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
893
+ end
894
+ res = broadcast_cmd("rset_reqpushv_timeout_count #{s[1]}\r\n")
895
+ @stats.reqpushv_timeout_count = s[1].to_i
896
+ res[@stats.ap_str] = "STORED"
897
+ send_data("#{res}\r\n")
898
+ end
899
+
900
+ # ev_rset_reqpushv_timeout_count <sec>
901
+ def ev_rset_reqpushv_timeout_count(s)
902
+ if s.length != 2
903
+ return send_data("CLIENT_ERROR number of arguments\n\r")
904
+ end
905
+ if s[1].to_i <= 0
906
+ return send_data("CLIENT_ERROR time value must be lager than 0\r\n")
907
+ end
908
+ @stats.reqpushv_timeout_count = s[1].to_i
909
+ send_data("STORED\r\n")
910
+ end
911
+
912
+ # set_spushv_klength_warn <byte>
913
+ def ev_set_spushv_klength_warn(s)
914
+ if s.length != 2
915
+ return send_data("CLIENT_ERROR number of arguments\n\r")
916
+ end
917
+ if s[1].to_i <= 0
918
+ return send_data("CLIENT_ERROR size value must be larger than 0 \r\n")
919
+ end
920
+ res = broadcast_cmd("rset_spushv_klength_warn #{s[1]}\r\n")
921
+ @stats.spushv_klength_warn = s[1].to_i
922
+ res[@stats.ap_str] = "STORED"
923
+ send_data("#{res}\r\n")
924
+ end
925
+
926
+ # rset_set_spushv_klength_warn <byte>
927
+ def ev_rset_spushv_klength_warn(s)
928
+ if s.length != 2
929
+ return send_data("CLIENT_ERROR number of arguments\n\r")
930
+ end
931
+ if s[1].to_i <= 0
932
+ return send_data("CLIENT_ERROR size value must be larger than 0 \r\n")
933
+ end
934
+ @stats.spushv_klength_warn = s[1].to_i
935
+ send_data("STORED\r\n")
936
+ end
937
+
938
+ # set_spushv_vlength_warn <byte>
939
+ def ev_set_spushv_vlength_warn(s)
940
+ if s.length != 2
941
+ return send_data("CLIENT_ERROR number of arguments\n\r")
942
+ end
943
+ if s[1].to_i <= 0
944
+ return send_data("CLIENT_ERROR size value must be larger than 0 \r\n")
945
+ end
946
+ res = broadcast_cmd("rset_spushv_vlength_warn #{s[1]}\r\n")
947
+ @stats.spushv_vlength_warn = s[1].to_i
948
+ res[@stats.ap_str] = "STORED"
949
+ send_data("#{res}\r\n")
950
+ end
951
+
952
+ # rset_set_spushv_vlength_warn <byte>
953
+ def ev_rset_spushv_vlength_warn(s)
954
+ if s.length != 2
955
+ return send_data("CLIENT_ERROR number of arguments\n\r")
956
+ end
957
+ if s[1].to_i <= 0
958
+ return send_data("CLIENT_ERROR size value must be larger than 0\r\n")
959
+ end
960
+ @stats.spushv_vlength_warn = s[1].to_i
961
+ send_data("STORED\r\n")
962
+ end
963
+
831
964
  # wb_command_map <hash string>
832
965
  # ex.
833
966
  # {:set=>1,:append=>2,:delete=>3}
@@ -895,6 +1028,48 @@ module Roma
895
1028
  send_data("STORED\r\n")
896
1029
  end
897
1030
 
1031
+ # set_storage_status [number of file][safecopy|normal]{hash_name}
1032
+ def ev_set_storage_status(s)
1033
+ if s.length < 3
1034
+ return send_data("CLIENT_ERROR number of arguments (#{s.length - 1} for 2)\r\n")
1035
+ end
1036
+
1037
+ if s.length >= 4
1038
+ hname = s[3]
1039
+ else
1040
+ hname = 'roma'
1041
+ end
1042
+ st = @storages[hname]
1043
+ unless st
1044
+ return send_data("CLIENT_ERROR hash_name = #{hanme} dose not found\r\n")
1045
+ end
1046
+ dn = s[1].to_i
1047
+ if st.divnum <= dn
1048
+ return send_data("CLIENT_ERROR divnum <= #{dn}\r\n")
1049
+ end
1050
+ if s[2] == 'safecopy'
1051
+ if st.dbs[dn] != :normal
1052
+ return send_data("CLIENT_ERROR storage[#{dn}] != :normal status\r\n")
1053
+ end
1054
+ if st.set_db_stat(dn, :safecopy_flushing) == false
1055
+ return send_data("CLIENT_ERROR storage[#{dn}] != :normal status\r\n")
1056
+ end
1057
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_storage_flush_process',[hname, dn]))
1058
+ elsif s[2] == 'normal'
1059
+ if st.dbs[dn] != :safecopy_flushed
1060
+ return send_data("CLIENT_ERROR storage[#{dn}] != :safecopy_flushed status\r\n")
1061
+ end
1062
+ if st.set_db_stat(dn, :cachecleaning) == false
1063
+ return send_data("CLIENT_ERROR storage[#{dn}] != :safecopy_flushed status\r\n")
1064
+ end
1065
+ Roma::AsyncProcess::queue.push(Roma::AsyncMessage.new('start_storage_cachecleaning_process',[hname, dn]))
1066
+ else
1067
+ return send_data("CLIENT_ERROR status parse error\r\n")
1068
+ end
1069
+
1070
+ send_data("PUSHED\r\n")
1071
+ end
1072
+
898
1073
  private
899
1074
 
900
1075
  def dcnice(p)
@@ -960,3 +1135,4 @@ module Roma
960
1135
  end # module SystemCommandReceiver
961
1136
  end # module Command
962
1137
  end # module Roma
1138
+
@@ -45,14 +45,20 @@ module Roma
45
45
  count = rcount = 0
46
46
  @log.debug("#{__method__}:#{s.inspect} received.")
47
47
  loop {
48
- context_bin = read_bytes(20, 100)
48
+ context_bin = read_bytes(20, @stats.spushv_read_timeout)
49
49
  vn, last, clk, expt, klen = context_bin.unpack('NNNNN')
50
50
  break if klen == 0 # end of dump ?
51
51
  k = read_bytes(klen)
52
- vlen_bin = read_bytes(4, 100)
52
+ vlen_bin = read_bytes(4, @stats.spushv_read_timeout)
53
53
  vlen, = vlen_bin.unpack('N')
54
54
  if vlen != 0
55
- v = read_bytes(vlen, 100)
55
+ if klen > @stats.spushv_klength_warn
56
+ @log.warn("#{__method__}:Too long key: key = #{k}")
57
+ end
58
+ if vlen > @stats.spushv_vlength_warn
59
+ @log.warn("#{__method__}:Too long value: key = #{k} vlen = #{vlen}")
60
+ end
61
+ v = read_bytes(vlen, @stats.spushv_read_timeout)
56
62
 
57
63
  createhash(s[1]) unless @storages[s[1]]
58
64
  if @storages[s[1]].load_stream_dump(vn, last, clk, expt, k, v)