Class: Deckard

Inherits:
Object
  • Object
show all
Defined in:
lib/deckard.rb,
lib/deckard/ec2.rb,
lib/deckard/log.rb,
lib/deckard/chef.rb,
lib/deckard/util.rb,
lib/deckard/stats.rb,
lib/deckard/config.rb,
lib/deckard/monitoring.rb

Defined Under Namespace

Classes: Chef, Config, Ec2, Log, Monitor, Stats, Util

Class Method Summary collapse

Class Method Details

.content_checkObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/deckard.rb', line 32

def self.content_check
  retry_count = Deckard::Config.content_check_retry
  db_name = Deckard::Config.content_check_db
  delay = Deckard::Config.content_check_delay
  upper_bound = Deckard::Config.content_check_delay_upper_bound
  list = Array.new

  nodes = Deckard::Util.get_nodes(db_name)

  nodes.each do |node|
    run = Thread.new {
      Deckard::Monitor.content_check(node["url"], node["content"], node["priority"], retry_count, node["schedule"])
      }
    if delay
	  sleep(rand(upper_bound))
    end 
    list << run
  end

  list.each { |x|
   	  x.join
  }
end

.fo_checkObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/deckard.rb', line 74

def self.fo_check
  retry_count = Deckard::Config.fo_check_retry
  db_name = Deckard::Config.fo_check_db
  list = Array.new

  nodes = Deckard::Util.get_nodes(db_name)

  nodes.each do |node|
    run = Thread.new {
      check = Deckard::Monitor.content_check(node["url"], node["content"], node["priority"], retry_count, node["schedule"])
      unless check
        Deckard::Monitor.failover(node["elastic_ip"], node["primary_instance_id"], node["secondary_instance_id"], node["priority"], node["schedule"], node["failover"], node["region"])
        Deckard::Util.flip_failover(node)
      end
      }
    list << run
  end

  list.each { |x|
    x.join
  }
end

.mainObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/deckard.rb', line 97

def self.main
  list = Array.new

  case ARGV[0]
  when "--all"
    list << Thread.new { content_check }
    list << Thread.new { rep_check }
    list << Thread.new { fo_check }
  when "--content"
    list << Thread.new { content_check }
  when "--replication"
    list << Thread.new { rep_check }
  when "--failover"
    list << Thread.new { fo_check }
  end

  list.each { |x|
    x.join
  }
end

.rep_checkObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/deckard.rb', line 56

def self.rep_check
  db_name = Deckard::Config.rep_check_db
  list = Array.new

  nodes = Deckard::Util.get_nodes(db_name)

  nodes.each do |node|
    run = Thread.new {
      Deckard::Monitor.rep_check(node["name"], node["master_url"], node["slave_url"], node["offset"], node["priority"], node["schedule"])
      }
    list << run
  end

  list.each { |x|
   	  x.join
  }
end