Method: ContentServer::FileCopyClient#handle
- Defined in:
- lib/content_server/queue_copy.rb
#handle(message) ⇒ Object
This is a function which receives the messages (file or ack) and return answer in case of ack. Note that it is being executed from the class thread only!
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/content_server/queue_copy.rb', line 287 def handle() , = Log.debug1("backup copy message: Type %s. message: %s", , ) if == :SEND_COPY_MESSAGE bytes_written = @tcp_client.send_obj([:COPY_MESSAGE, ]) Log.debug2("Sending copy message succeeded? bytes_written: %s.", bytes_written) elsif == :COPY_CHUNK if @file_receiver.receive_chunk(*) file_checksum, offset, file_size, content, content_checksum = @tcp_client.send_obj([:COPY_CHUNK_FROM_REMOTE, file_checksum]) else file_checksum, offset, file_size, content, content_checksum = Log.error("receive_chunk failed for chunk checksum:#{content_checksum}") end elsif == :ACK_MESSAGE checksum, = # check if checksum exists in final destination dest_path = FileReceiver.destination_filename(Params['backup_destination_folder'][0]['path'], checksum) need_to_copy = !File.exists?(dest_path) Log.debug1("Returning ack for content:'%s' timestamp:'%s' Ack:'%s'", checksum, , need_to_copy) @tcp_client.send_obj([:ACK_MESSAGE, [, need_to_copy, checksum]]) elsif == :ABORT_COPY @tcp_client.send_obj([:ABORT_COPY, ]) elsif == :RESET_RESUME_COPY @tcp_client.send_obj([:RESET_RESUME_COPY, ]) else Log.error("Unexpected message type: #{message_type}") end end |