content_server 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/backup_server +3 -10
- data/bin/content_server +3 -10
- data/bin/testing_memory +3 -11
- data/bin/testing_server +3 -10
- data/lib/content_data/content_data.rb +9 -16
- data/lib/content_server/backup_server.rb +10 -9
- data/lib/content_server/content_receiver.rb +6 -6
- data/lib/content_server/content_server.rb +10 -10
- data/lib/content_server/file_streamer.rb +15 -13
- data/lib/content_server/queue_copy.rb +25 -23
- data/lib/content_server/queue_indexer.rb +11 -23
- data/lib/content_server/remote_content.rb +6 -6
- data/lib/content_server/server.rb +8 -7
- data/lib/content_server/version.rb +1 -1
- data/lib/file_copy/copy.rb +10 -9
- data/lib/file_monitoring/file_monitoring.rb +51 -18
- data/lib/file_monitoring/monitor_path.rb +68 -33
- data/lib/log.rb +40 -4
- data/lib/networking/tcp.rb +15 -15
- data/lib/params.rb +3 -9
- metadata +2 -2
data/lib/networking/tcp.rb
CHANGED
@@ -10,10 +10,10 @@ module Networking
|
|
10
10
|
def Networking.write_to_stream(stream, obj)
|
11
11
|
Log.debug3('Writing to stream.')
|
12
12
|
marshal_data = Marshal.dump(obj)
|
13
|
-
Log.debug2("Writing data size:
|
13
|
+
Log.debug2("Writing data size: %s", marshal_data.length)
|
14
14
|
data_size = [marshal_data.length].pack("l")
|
15
15
|
if data_size.nil? || marshal_data.nil?
|
16
|
-
Log.debug2
|
16
|
+
Log.debug2('Send data size is nil!')
|
17
17
|
end
|
18
18
|
begin
|
19
19
|
bytes_written = stream.write data_size
|
@@ -36,7 +36,7 @@ module Networking
|
|
36
36
|
begin
|
37
37
|
return [false, nil] unless size_of_data = stream.read(4)
|
38
38
|
size_of_data = size_of_data.unpack("l")[0]
|
39
|
-
Log.debug2("Reading data size
|
39
|
+
Log.debug2("Reading data size:%s", size_of_data)
|
40
40
|
data = stream.read(size_of_data)
|
41
41
|
rescue Exception => e
|
42
42
|
Log.warning("Could not read tcp/ip stream, #{e.to_s}.")
|
@@ -71,7 +71,7 @@ module Networking
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def send_obj(obj, addr_info=nil)
|
74
|
-
Log.debug3("send_obj with addr_info
|
74
|
+
Log.debug3("send_obj with addr_info:%s", addr_info)
|
75
75
|
unless addr_info.nil?
|
76
76
|
if @sockets.key?(addr_info)
|
77
77
|
Networking.write_to_stream(@sockets[addr_info], obj)
|
@@ -94,15 +94,14 @@ module Networking
|
|
94
94
|
loop {
|
95
95
|
begin
|
96
96
|
Socket.tcp_server_loop(@port) do |sock, addr_info|
|
97
|
-
Log.debug2("
|
98
|
-
Log.debug2("tcp_server_loop... #{sock} #{addr_info.inspect}")
|
97
|
+
Log.debug2("tcp_server_loop:\nport:%s\nsock:%s\naddr info:%s", @port, sock, addr_info)
|
99
98
|
@sockets[addr_info] = sock
|
100
99
|
@new_clb.call(addr_info) if @new_clb != nil
|
101
100
|
loop do
|
102
101
|
# Blocking read.
|
103
102
|
Log.debug2('read_from_stream')
|
104
103
|
stream_ok, obj = Networking.read_from_stream(sock)
|
105
|
-
Log.debug2("Server returned from read:
|
104
|
+
Log.debug2("Server returned from read: %s", stream_ok)
|
106
105
|
@obj_clb.call(addr_info, obj) if @obj_clb != nil && stream_ok
|
107
106
|
break if !stream_ok
|
108
107
|
end
|
@@ -136,7 +135,7 @@ module Networking
|
|
136
135
|
@tcp_socket = nil
|
137
136
|
@obj_clb = obj_clb
|
138
137
|
@reconnected_clb = reconnected_clb
|
139
|
-
Log.debug3("Start TCPClient initialize with @obj_clb:
|
138
|
+
Log.debug3("Start TCPClient initialize with @obj_clb: %s", @obj_clb)
|
140
139
|
if @obj_clb != nil
|
141
140
|
@tcp_thread = start_reading
|
142
141
|
@tcp_thread.abort_on_exception = true
|
@@ -156,7 +155,7 @@ module Networking
|
|
156
155
|
Log.warning('Socket not opened for writing, skipping send.')
|
157
156
|
return false
|
158
157
|
end
|
159
|
-
Log.debug2("writing... socket port:
|
158
|
+
Log.debug2("writing... socket port: %s", @tcp_socket.peeraddr)
|
160
159
|
bytes_written = Networking.write_to_stream(@tcp_socket, obj)
|
161
160
|
return bytes_written
|
162
161
|
end
|
@@ -164,13 +163,13 @@ module Networking
|
|
164
163
|
# This function may be executed only from one thread!!! or in synchronized manner.
|
165
164
|
# private
|
166
165
|
def open_socket
|
167
|
-
Log.debug1("Connecting to content server
|
166
|
+
Log.debug1("Connecting to content server %s:%s", @host, @port)
|
168
167
|
begin
|
169
168
|
@tcp_socket = TCPSocket.new(@host, @port)
|
170
169
|
rescue Errno::ECONNREFUSED
|
171
170
|
Log.warning('Connection refused')
|
172
171
|
end
|
173
|
-
Log.debug3("Reconnect clb:
|
172
|
+
Log.debug3("Reconnect clb: %s", @reconnected_clb)
|
174
173
|
if socket_good?
|
175
174
|
@remote_server_available_mutex.synchronize {
|
176
175
|
@remote_server_available.signal
|
@@ -181,8 +180,9 @@ module Networking
|
|
181
180
|
|
182
181
|
private
|
183
182
|
def socket_good?
|
184
|
-
|
185
|
-
|
183
|
+
closed = @tcp_socket != nil && !@tcp_socket.closed?
|
184
|
+
Log.debug3("socket_good? %s", closed)
|
185
|
+
return closed
|
186
186
|
end
|
187
187
|
|
188
188
|
private
|
@@ -193,14 +193,14 @@ module Networking
|
|
193
193
|
# Blocking read.
|
194
194
|
if !socket_good?
|
195
195
|
Log.warning("Socket not good, waiting for reconnection with " \
|
196
|
-
"#{Params['client_retry_delay']}
|
196
|
+
"#{Params['client_retry_delay']}[S] timeout.")
|
197
197
|
@remote_server_available_mutex.synchronize {
|
198
198
|
@remote_server_available.wait(@remote_server_available_mutex,
|
199
199
|
Params['client_retry_delay'])
|
200
200
|
}
|
201
201
|
else
|
202
202
|
read_ok, obj = Networking.read_from_stream(@tcp_socket)
|
203
|
-
Log.debug3("Client returned from read:
|
203
|
+
Log.debug3("Client returned from read: %s", read_ok)
|
204
204
|
# Handle case when socket is closed in middle.
|
205
205
|
# In that case we should not call obj_clb.
|
206
206
|
@obj_clb.call(obj) if (read_ok && @obj_clb != nil)
|
data/lib/params.rb
CHANGED
@@ -253,8 +253,8 @@ module Params
|
|
253
253
|
# Precedence is: Defined params, file and command line is highest.
|
254
254
|
def Params.init(args)
|
255
255
|
#define default configuration file
|
256
|
-
Params['conf_file'] = "~/.bbfs/etc/config_#{
|
257
|
-
|
256
|
+
Params['conf_file'] = "~/.bbfs/etc/config_#{File.basename($PROGRAM_NAME)}.yml"
|
257
|
+
|
258
258
|
@init_info_messages = []
|
259
259
|
@init_warning_messages = []
|
260
260
|
|
@@ -403,17 +403,11 @@ paths:
|
|
403
403
|
}
|
404
404
|
end
|
405
405
|
|
406
|
-
#Auxiliary method to retrieve the executable name
|
407
|
-
def Params.executable_name
|
408
|
-
/([a-zA-Z0-9\-_\.]+):\d+/ =~ caller[caller.size-1]
|
409
|
-
return $1
|
410
|
-
end
|
411
|
-
|
412
406
|
Params.path('conf_file', nil, 'Configuration file path.')
|
413
407
|
Params.boolean('print_params_to_stdout', false, 'print_params_to_stdout or not during Params.init')
|
414
408
|
|
415
409
|
private_class_method :parse_command_line_arguments, \
|
416
410
|
:raise_error_if_param_exists, :raise_error_if_param_does_not_exist, \
|
417
|
-
:read_yml_params, :override_param
|
411
|
+
:read_yml_params, :override_param
|
418
412
|
end
|
419
413
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: content_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|