Class: Flydata::Helper::ActionOwnership

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/helper/action_ownership.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action_name, resource_change = false, action_class = nil) ⇒ ActionOwnership

Returns a new instance of ActionOwnership.


22
23
24
25
26
27
28
29
# File 'lib/flydata/helper/action_ownership.rb', line 22

def initialize(action_name, resource_change = false, action_class = nil)
  @action_name = action_name
  @resource_change = resource_change
  @action_class = action_class
  @owner = nil
  @last_processed_time = -1
  @retry_count = 0
end

Instance Attribute Details

#action_classObject

action_class has a actual logic


11
12
13
# File 'lib/flydata/helper/action_ownership.rb', line 11

def action_class
  @action_class
end

#action_nameObject

Returns the value of attribute action_name


4
5
6
# File 'lib/flydata/helper/action_ownership.rb', line 4

def action_name
  @action_name
end

#last_processed_timeObject

last processeed time should be updated when worker return action ownership to channel


18
19
20
# File 'lib/flydata/helper/action_ownership.rb', line 18

def last_processed_time
  @last_processed_time
end

#ownerObject

Owner should be nil(channel) or worker


14
15
16
# File 'lib/flydata/helper/action_ownership.rb', line 14

def owner
  @owner
end

#resource_changeObject

Resource change flag true -> action must be taken exclusively


8
9
10
# File 'lib/flydata/helper/action_ownership.rb', line 8

def resource_change
  @resource_change
end

#retry_countObject

Returns the value of attribute retry_count


20
21
22
# File 'lib/flydata/helper/action_ownership.rb', line 20

def retry_count
  @retry_count
end

Class Method Details

.action_ownership_mapObject


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/flydata/helper/action_ownership.rb', line 43

def self.action_ownership_map
  [
    self.new(:check_remote_actions, false, Action::CheckRemoteActions),
    self.new(:check_abnormal_shutdown, false, Action::CheckAbnormalShutdown),
    self.new(:send_logs, false, Action::SendLogs),
    self.new(:stop_agent, true, Action::StopAgent),
    self.new(:restart_agent, true, Action::RestartAgent),
    self.new(:update_helper_config, false, Action::UpdateHelperConfig),
    self.new(:repair, true, Action::Repair),
    self.new(:resync, true, Action::Resync),
    self.new(:clear, true, Action::Clear),
    self.new(:stop_helper, true, Action::StopHelper),
    self.new(:reset, true, Action::Reset),
    self.new(:flush, true, Action::Flush),
  ].inject({}) do |h, action|
    h[action.action_name] = action
    h
  end
end

Instance Method Details

#increment_retry_countObject


39
40
41
# File 'lib/flydata/helper/action_ownership.rb', line 39

def increment_retry_count
  @retry_count += 1
end

#processing?Boolean

Returns:

  • (Boolean)

31
32
33
# File 'lib/flydata/helper/action_ownership.rb', line 31

def processing?
  !@owner.nil?
end

#reset_retry_countObject


35
36
37
# File 'lib/flydata/helper/action_ownership.rb', line 35

def reset_retry_count
  @retry_count = 0
end