Class: LS4::SlaveService::Replicator

Inherits:
Object
  • Object
show all
Defined in:
lib/ls4/service/slave.rb

Instance Method Summary collapse

Constructor Details

#initialize(storage, nid, rts) ⇒ Replicator

Returns a new instance of Replicator.



30
31
32
33
34
35
# File 'lib/ls4/service/slave.rb', line 30

def initialize(storage, nid, rts)
	@storage = storage
	@nid = nid
	@rts = rts
	@pulling = false
end

Instance Method Details

#closeObject



37
38
39
# File 'lib/ls4/service/slave.rb', line 37

def close
	@rts.close
end

#try_replicate(session, limit) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ls4/service/slave.rb', line 41

def try_replicate(session, limit)
	if @pulling
		return nil
	end
	@pulling = true

	begin
		pos = @rts.get
		session.callback(:replicate_pull, pos, limit) do |future|
			ack_replicate_pull(future)
		end

	rescue
		$log.error "try replicate #{$!}"
		$log.debug_backtrace $!.backtrace
		@pulling = false
		raise
	end
end