Class: Bosh::Director::Jobs::ScheduledEventsCleanup

Inherits:
BaseJob show all
Defined in:
lib/bosh/director/jobs/scheduled_events_cleanup.rb

Instance Attribute Summary

Attributes inherited from BaseJob

#task_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseJob

#begin_stage, #dns_manager, #event_manager, #logger, perform, #result_file, #single_step_stage, #task_cancelled?, #task_checkpoint, #track_and_log, #username

Constructor Details

#initialize(params = {}) ⇒ ScheduledEventsCleanup

Returns a new instance of ScheduledEventsCleanup.



19
20
21
22
# File 'lib/bosh/director/jobs/scheduled_events_cleanup.rb', line 19

def initialize(params = {})
  logger.debug("ScheduledEventsCleanup initialized with params: #{params.inspect}")
  @max_events = params['max_events']
end

Class Method Details

.has_work(params = {}) ⇒ Object



10
11
12
13
# File 'lib/bosh/director/jobs/scheduled_events_cleanup.rb', line 10

def self.has_work(params = {})
  max_events = params.first['max_events']
  Models::Event.count > max_events
end

.job_typeObject



6
7
8
# File 'lib/bosh/director/jobs/scheduled_events_cleanup.rb', line 6

def self.job_type
  :scheduled_events_cleanup
end

.schedule_messageObject



15
16
17
# File 'lib/bosh/director/jobs/scheduled_events_cleanup.rb', line 15

def self.schedule_message
  "clean up events"
end

Instance Method Details

#performObject



24
25
26
27
28
# File 'lib/bosh/director/jobs/scheduled_events_cleanup.rb', line 24

def perform
  logger.info("Started cleanup of events")
  event_manager.remove_old_events(@max_events)
  "Old events were deleted"
end