Class: Clustr::Adapter::SimpleDB
- Defined in:
- lib/clustr/adapter/simpledb.rb
Overview
Implements the SimpleDB adapter, which controls a cluster and its members through the usage of SimpleDB as a centralized, high-availability data store.
SimpleDB is capable of storing unique node identifiers along with additional information that is to be associated with them.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#add(id, created, properties = {}) ⇒ boolean
Add a new node to the SimpleDB domain.
-
#initialize(*a) ⇒ SimpleDB
constructor
Initializes a new SimpleDB Adapter class.
-
#members ⇒ array
Return an array of the unique identifiers for each node in the cluster.
Constructor Details
#initialize(*a) ⇒ SimpleDB
Initializes a new SimpleDB Adapter class. If the domain that has been defined in the @key attribute does not exist, it will create it.
14 15 16 17 |
# File 'lib/clustr/adapter/simpledb.rb', line 14 def initialize(*a) super sdb.domains.create(@key) unless domain.exists? end |
Instance Method Details
#add(id, created, properties = {}) ⇒ boolean
Add a new node to the SimpleDB domain.
26 27 28 29 30 31 |
# File 'lib/clustr/adapter/simpledb.rb', line 26 def add(id, created, properties = {}) item = domain.items[id] properties.each { |k, v| item.attributes[k] = v } item.attributes["joined"] = created true end |
#members ⇒ array
Return an array of the unique identifiers for each node in the cluster.
37 38 39 |
# File 'lib/clustr/adapter/simpledb.rb', line 37 def members domain.items.collect(&:name) end |