Class: Madeleine::Recoverer

Inherits:
Object
  • Object
show all
Defined in:
lib/madeleine.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(directory_name, marshaller) ⇒ Recoverer

Returns a new instance of Recoverer.



213
214
215
# File 'lib/madeleine.rb', line 213

def initialize(directory_name, marshaller)
  @directory_name, @marshaller = directory_name, marshaller
end

Instance Method Details

#recover_logs(executer) ⇒ Object



231
232
233
234
235
236
237
238
239
# File 'lib/madeleine.rb', line 231

def recover_logs(executer)
  executer.recovery do
    CommandLog.log_file_names(@directory_name, FileService.new).each do |file_name|
      open("#{@directory_name}#{File::SEPARATOR}#{file_name}", "rb") do |log|
        recover_log(executer, log)
      end
    end
  end
end

#recover_snapshot(new_system_block) ⇒ Object



217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/madeleine.rb', line 217

def recover_snapshot(new_system_block)
  system = nil
  id = SnapshotFile.highest_id(@directory_name)
  if id > 0
    snapshot_file = SnapshotFile.new(@directory_name, id).name
    open(snapshot_file, "rb") do |snapshot|
      system = @marshaller.load(snapshot)
    end
  else
    system = new_system_block.call
  end
  system
end