Class: VCAP::Services::Base::AsyncJob::Snapshot::BaseRollbackSnapshotJob
- Inherits:
-
SnapshotJob
- Object
- SnapshotJob
- VCAP::Services::Base::AsyncJob::Snapshot::BaseRollbackSnapshotJob
- Defined in:
- lib/base/job/snapshot.rb
Constant Summary
Constants included from VCAP::Services::Base::AsyncJob::Snapshot
FILTER_KEYS, MAX_NAME_LENGTH, SNAPSHOT_ID, SNAPSHOT_KEY_PREFIX
Instance Attribute Summary collapse
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
-
#snapshot_files ⇒ Object
readonly
Returns the value of attribute snapshot_files.
Attributes inherited from SnapshotJob
Instance Method Summary collapse
-
#perform ⇒ Object
workflow template Subclass implement execute method which returns true for a successful rollback.
Methods inherited from SnapshotJob
#cleanup, #create_lock, #fmt_error, #get_dump_path, #handle_error, #init_worker_logger, #initialize, #parse_config, queue_lookup_key, #required_options, select_queue
Methods included from VCAP::Services::Base::AsyncJob::Snapshot
#client, #delete_snapshot, #filter_keys, #fmt_time, #new_snapshot_id, redis_connect, redis_init, #save_snapshot, #service_snapshots, #service_snapshots_count, #snapshot_details, #snapshot_filepath, #update_name
Methods included from Error
#failure, #internal_fail, #parse_msg, #success, #timeout_fail
Constructor Details
This class inherits a constructor from VCAP::Services::Base::AsyncJob::Snapshot::SnapshotJob
Instance Attribute Details
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
316 317 318 |
# File 'lib/base/job/snapshot.rb', line 316 def manifest @manifest end |
#snapshot_files ⇒ Object (readonly)
Returns the value of attribute snapshot_files.
316 317 318 |
# File 'lib/base/job/snapshot.rb', line 316 def snapshot_files @snapshot_files end |
Instance Method Details
#perform ⇒ Object
workflow template Subclass implement execute method which returns true for a successful rollback
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/base/job/snapshot.rb', line 319 def perform begin :service_id, :snapshot_id @name = ["service_id"] @snapshot_id = ["snapshot_id"] @logger.info("Launch job: #{self.class} for #{name}") lock = create_lock @snapshot_files = [] lock.lock do # extract origin files from package dump_path = get_dump_path(name, snapshot_id) package_file = "#{snapshot_id}.zip" package = Package.load(File.join(dump_path, package_file)) @manifest = package.manifest @snapshot_files = package.unpack(dump_path) @logger.debug("Unpack files from #{package_file}: #{@snapshot_files}") raise "Package file doesn't contain snapshot file." if @snapshot_files.empty? result = execute @logger.info("Results of rollback snapshot: #{result}") completed(Yajl::Encoder.encode({:result => :ok})) @logger.info("Complete job: #{self.class} for #{name}") end rescue => e handle_error(e) ensure set_status({:complete_time => Time.now.to_s}) @snapshot_files.each{|f| File.delete(f) if File.exists? f} if @snapshot_files end end |