roma-client 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +22 -15
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +34 -18
  5. data/README.md +4 -0
  6. data/lib/roma/client/client_pool.rb +15 -25
  7. data/lib/roma/client/client_rttable.rb +1 -2
  8. data/lib/roma/client/tools/showbalance.rb +0 -1
  9. data/lib/roma/client/version.rb +1 -1
  10. data/spec/roma/client/client_pool_spec.rb +133 -173
  11. data/spec/spec_helper.rb +9 -0
  12. metadata +3 -79
  13. data/doc/CHANGELOG_md.html +0 -119
  14. data/doc/README_md.html +0 -161
  15. data/doc/Roma.html +0 -95
  16. data/doc/Roma/Client.html +0 -95
  17. data/doc/Roma/Client/ClientPool.html +0 -716
  18. data/doc/Roma/Client/ClientRoutingTable.html +0 -495
  19. data/doc/Roma/Client/ConPool.html +0 -484
  20. data/doc/Roma/Client/Plugin.html +0 -95
  21. data/doc/Roma/Client/Plugin/Alist.html +0 -1276
  22. data/doc/Roma/Client/Plugin/Map.html +0 -531
  23. data/doc/Roma/Client/Plugin/MapCount.html +0 -401
  24. data/doc/Roma/Client/Proxy.html +0 -95
  25. data/doc/Roma/Client/Proxy/ClientHandler.html +0 -273
  26. data/doc/Roma/Client/Proxy/Conpool.html +0 -394
  27. data/doc/Roma/Client/Proxy/Daemon.html +0 -305
  28. data/doc/Roma/Client/Proxy/RomaHandler.html +0 -217
  29. data/doc/Roma/Client/RomaClient.html +0 -1339
  30. data/doc/Roma/Client/Sender.html +0 -482
  31. data/doc/Roma/Client/Stats.html +0 -162
  32. data/doc/Roma/Client/VERSION.html +0 -141
  33. data/doc/Roma/Logging.html +0 -95
  34. data/doc/Roma/Logging/RLogger.html +0 -786
  35. data/doc/Roma/Logging/RLogger/ExtLogDev.html +0 -159
  36. data/doc/Roma/Logging/RLogger/ExtShiftAge.html +0 -95
  37. data/doc/Roma/Logging/RLogger/ExtTrace.html +0 -109
  38. data/doc/Roma/Logging/RLogger/Severity.html +0 -139
  39. data/doc/Roma/Routing.html +0 -95
  40. data/doc/Roma/Routing/RoutingData.html +0 -912
  41. data/doc/Roma/Routing/RoutingData/RandomNodeListMaker.html +0 -311
  42. data/doc/created.rid +0 -20
  43. data/doc/css/fonts.css +0 -167
  44. data/doc/css/rdoc.css +0 -590
  45. data/doc/fonts/Lato-Light.ttf +0 -0
  46. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  47. data/doc/fonts/Lato-Regular.ttf +0 -0
  48. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  49. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  50. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  51. data/doc/images/add.png +0 -0
  52. data/doc/images/arrow_up.png +0 -0
  53. data/doc/images/brick.png +0 -0
  54. data/doc/images/brick_link.png +0 -0
  55. data/doc/images/bug.png +0 -0
  56. data/doc/images/bullet_black.png +0 -0
  57. data/doc/images/bullet_toggle_minus.png +0 -0
  58. data/doc/images/bullet_toggle_plus.png +0 -0
  59. data/doc/images/date.png +0 -0
  60. data/doc/images/delete.png +0 -0
  61. data/doc/images/find.png +0 -0
  62. data/doc/images/loadingAnimation.gif +0 -0
  63. data/doc/images/macFFBgHack.png +0 -0
  64. data/doc/images/package.png +0 -0
  65. data/doc/images/page_green.png +0 -0
  66. data/doc/images/page_white_text.png +0 -0
  67. data/doc/images/page_white_width.png +0 -0
  68. data/doc/images/plugin.png +0 -0
  69. data/doc/images/ruby.png +0 -0
  70. data/doc/images/tag_blue.png +0 -0
  71. data/doc/images/tag_green.png +0 -0
  72. data/doc/images/transparent.png +0 -0
  73. data/doc/images/wrench.png +0 -0
  74. data/doc/images/wrench_orange.png +0 -0
  75. data/doc/images/zoom.png +0 -0
  76. data/doc/index.html +0 -210
  77. data/doc/js/darkfish.js +0 -161
  78. data/doc/js/jquery.js +0 -4
  79. data/doc/js/navigation.js +0 -142
  80. data/doc/js/navigation.js.gz +0 -0
  81. data/doc/js/search.js +0 -109
  82. data/doc/js/search_index.js +0 -1
  83. data/doc/js/search_index.js.gz +0 -0
  84. data/doc/js/searcher.js +0 -228
  85. data/doc/js/searcher.js.gz +0 -0
  86. data/doc/table_of_contents.html +0 -972
  87. data/lib/roma/client/routing/routing_data.rb +0 -241
@@ -1,241 +0,0 @@
1
- require 'yaml'
2
-
3
- module Roma
4
- module Routing
5
-
6
- class RoutingData
7
- attr_accessor :dgst_bits
8
- attr_accessor :div_bits
9
- attr_accessor :rn
10
- attr_accessor :nodes
11
- attr_accessor :v_idx
12
- attr_accessor :v_clk
13
-
14
- def initialize(dgst_bits,div_bits,rn)
15
- @dgst_bits=dgst_bits
16
- @div_bits=div_bits
17
- @rn=rn
18
- @nodes=[]
19
- @v_idx={}
20
- @v_clk={}
21
- end
22
-
23
- def save(fname)
24
- @nodes.sort!
25
- open(fname,'wb'){|io|
26
- io.write(YAML.dump(self))
27
- }
28
- end
29
-
30
- def self.load(fname)
31
- rd=load_snapshot(fname)
32
- rd.load_log_all(fname)
33
- rd
34
- end
35
-
36
- def self.load_snapshot(fname)
37
- rd=nil
38
- open(fname,'rb'){|io|
39
- rd = YAML.load(io.read)
40
- }
41
- rd
42
- end
43
-
44
- def self.snapshot(fname)
45
- rd=load_snapshot(fname)
46
- loglist=rd.get_file_list(fname)
47
- if loglist.length<2
48
- return false
49
- end
50
- loglist.delete(loglist.last)
51
- loglist.each{|i,f|
52
- rd.load_log_one(f)
53
- File.rename(f,"#{f}~")
54
- }
55
- File.rename(fname,"#{fname}~")
56
- rd.save(fname)
57
- true
58
- end
59
-
60
- def each_log_all(fname)
61
- loglist=get_file_list(fname)
62
- loglist.each{|i,f|
63
- each_log_one(f){|t,l| yield t,l}
64
- }
65
- end
66
-
67
- def each_log_one(fname)
68
- File.open(fname,"r"){|f|
69
- while((line=f.gets)!=nil)
70
- line.chomp!
71
- next if line[0]=="#" || line.length==0
72
- if line =~ /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.\d+\s(.+)/
73
- yield Time.mktime($1, $2, $3, $4, $5, $6), $7
74
- end
75
- end
76
- }
77
- end
78
-
79
- def load_log_all(fname)
80
- each_log_all(fname){|t,line|
81
- parse_log(t,line)
82
- }
83
- @nodes.sort!
84
- end
85
-
86
- def load_log_one(fname)
87
- each_log_one(fname){|t,line|
88
- parse_log(t,line)
89
- }
90
- @nodes.sort!
91
- end
92
-
93
- def parse_log(t,line)
94
- s=line.split(' ')
95
- case s[0]
96
- when 'setroute'
97
- # setroute <vnode-id> <clock> <node-id> ...
98
- nids=[]
99
- s[3..-1].each{ |nid| nids << nid }
100
- @v_idx[s[1].to_i]=nids
101
- @v_clk[s[1].to_i]=s[2].to_i
102
- when 'join'
103
- # join <node-id>
104
- @nodes << s[1] unless @nodes.include?(s[1])
105
- when 'leave'
106
- # leave <node-id>
107
- @nodes.delete(s[1])
108
- else
109
- raise "RoutingData.parse_log:parse error #{line}"
110
- end
111
- end
112
-
113
- def search_mask
114
- 2**@div_bits-1<<(@dgst_bits-@div_bits)
115
- end
116
-
117
- def next_vnode(vn)
118
- n = (vn >> (@dgst_bits-@div_bits)) + 1
119
- n = 0 if n == (2**@div_bits)
120
- n << (@dgst_bits-@div_bits)
121
- end
122
-
123
- def create_nodes_from_v_idx
124
- buf_nodes={}
125
- v_idx.each_value{|nids|
126
- nids.each{|nid| buf_nodes[nid]=nid }
127
- }
128
- @nodes=buf_nodes.values.sort
129
- end
130
-
131
- # Returns the losted vnode-id list.
132
- def get_lost_vnodes
133
- ret=[]
134
- v_idx.each_pair{|vn,nids|
135
- ret << vn if nids.length == 0
136
- }
137
- ret
138
- end
139
-
140
- def self.create(dgst_bits,div_bits,rn,nodes,repethost=false)
141
- ret=RoutingData.new(dgst_bits,div_bits,rn)
142
- ret.nodes=nodes.clone
143
-
144
- rnlm=RandomNodeListMaker.new(nodes,repethost)
145
-
146
- (2**div_bits).times{|i|
147
- vn=i<<(dgst_bits-div_bits)
148
- ret.v_clk[vn]=0
149
- ret.v_idx[vn]=rnlm.list(rn)
150
- }
151
- ret
152
- end
153
-
154
- # Returns the log file list by old ordered.
155
- # +fname+:: Prefix of a log file.(ex.roma0_3300.route)
156
- # One of the following example:
157
- # [[1, "roma0_3300.route.1"], [2, "roma0_3300.route.2"]]
158
- def get_file_list(fname)
159
- l={}
160
- files=Dir.glob("#{fname}*")
161
- files.each{ |file|
162
- if /#{fname}\.(\d+)$/=~file
163
- l[$1.to_i]=$&
164
- end
165
- }
166
- # sorted by old order
167
- l.to_a.sort{|a,b| a[0]<=>b[0]}
168
- end
169
-
170
- def get_histgram
171
- ret = {}
172
- nodes.each{|nid|
173
- ret[nid] = Array.new(rn,0)
174
- }
175
- v_idx.each_pair{|vn,nids|
176
- nids.each_with_index{|nid,i|
177
- ret[nid][i] += 1
178
- }
179
- }
180
- ret
181
- end
182
-
183
- private
184
-
185
- class RandomNodeListMaker
186
- def initialize(nodes,repethost)
187
- @repethost=repethost
188
- @nodes=nodes
189
- @host_idx={}
190
- nodes.each{|nid|
191
- h,p=nid.split('_')
192
- if @host_idx.key?(h)
193
- @host_idx[h] << nid
194
- else
195
- @host_idx[h]=[nid]
196
- end
197
- }
198
- end
199
-
200
- # Returns the random node-list without repetition.
201
- # +n+:: list length
202
- def list(n)
203
- ret=[]
204
- hosts=[]
205
- proc_other_one = :get_other_one
206
- proc_other_one = :get_other_one_repethost if @repethost
207
- n.times{
208
- nid=nil
209
- nid=send(proc_other_one,hosts,ret)
210
- break unless nid
211
- hosts << nid.split('_')[0]
212
- ret << nid
213
- }
214
- ret
215
- end
216
-
217
- # +exp_hosts+:: ignore
218
- # +exp_nodes+:: exceptional nodes(ex.['roma0_11211'])
219
- def get_other_one_repethost(exp_hosts,exp_nodes)
220
- buf=@nodes.clone
221
- buf.delete_if{|nid| exp_nodes.include?(nid)}
222
- buf[rand(buf.length)]
223
- end
224
-
225
- # +exp_hosts+:: exceptional hosts(ex.['roma0','roma1'])
226
- # +exp_nodes+:: ignore
227
- def get_other_one(exp_hosts,exp_nodes)
228
- hidx=@host_idx.clone
229
- exp_hosts.each{|h| hidx.delete(h) }
230
- return nil if hidx.length == 0
231
-
232
- rh=hidx.keys[rand(hidx.keys.length)]
233
- nodes=hidx[rh]
234
- nodes[rand(nodes.length)]
235
- end
236
- end # class RandomNodeListMaker
237
-
238
- end # class RoutingData
239
-
240
- end # module Routing
241
- end # module Roma