65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/testing_server/testing_server.rb', line 65
def run_content_testing_server
Log.info('Testing server started')
init_log4r
$log4r.info 'Testing server started'
all_threads = [];
messages = Queue.new
all_threads << Thread.new do
ContentServer.run_content_server
end
all_threads << Thread.new do
fg = FileGenerator::FileGenerator.new
fg.run
end
receive_msg_proc = lambda do |addr_info, message|
$log4r.info("message received: #{message}")
messages.push(message)
end
tcp = Networking::TCPServer.new(Params['testing_server_port'], receive_msg_proc)
all_threads << tcp.tcp_thread
while(true) do
msg_type, validation_timestamp = messages.pop
if msg_type == :GET_INDEX
cur_index = ContentData::ContentData.new
cur_index.from_file(Params['local_content_data_path'])
tcp.send_obj([:PUT_INDEX, validation_timestamp, cur_index])
$log4r.info "PUT_INDEX sent with timestamp #{validation_timestamp}"
is_index_ok = cur_index.validate
tcp.send_obj([:PUT_VALIDATION, validation_timestamp, is_index_ok])
$log4r.info "PUT_VALIDATION sent with timestamp #{validation_timestamp}"
end
end
end
|