Class: VCAP::Services::Base::AsyncJob::Snapshot::BaseDeleteSnapshotJob

Inherits:
SnapshotJob show all
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

Attributes inherited from SnapshotJob

#name, #snapshot_id

Instance Method Summary collapse

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 Method Details

#executeObject



310
311
312
# File 'lib/base/job/snapshot.rb', line 310

def execute
  cleanup(name, snapshot_id)
end

#performObject



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/base/job/snapshot.rb', line 285

def perform
  begin
    required_options :service_id, :snapshot_id
    @name = options["service_id"]
    @snapshot_id = options["snapshot_id"]
    @logger.info("Launch job: #{self.class} for #{name}")

    lock = create_lock

    lock.lock do
      result = execute
      @logger.info("Results of delete snapshot: #{result}")

      delete_snapshot(name, snapshot_id)

      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})
  end
end