Class: DCell::Registry::CassandraAdapter
- Inherits:
-
Object
- Object
- DCell::Registry::CassandraAdapter
show all
- Defined in:
- lib/dcell/registries/cassandra_adapter.rb
Defined Under Namespace
Classes: GlobalRegistry, NodeRegistry
Constant Summary
collapse
- DEFAULT_KEYSPACE =
"dcell"
- DEFAULT_CF =
"dcell"
Instance Method Summary
collapse
Constructor Details
Returns a new instance of CassandraAdapter.
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 34
def initialize(options)
options = options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
keyspace = options[:keyspace] || DEFAULT_KEYSPACE
columnfamily = options[:columnfamily] || DEFAULT_CF
options[:servers] ||= []
options[:servers] << options[:server] if options[:server]
options[:servers] << "localhost:9160" unless options[:servers].any?
cass = Cassandra.new(keyspace, options[:servers])
@node_registry = NodeRegistry.new(cass, columnfamily)
@global_registry = GlobalRegistry.new(cass, columnfamily)
end
|
Instance Method Details
#clear_all_nodes ⇒ Object
55
56
57
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 55
def clear_all_nodes
@node_registry.clear_all
end
|
#clear_globals ⇒ Object
59
60
61
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 59
def clear_globals
@global_registry.clear_all
end
|
#get_global(key) ⇒ Object
121
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 121
def get_global(key); @global_registry.get(key) end
|
#get_node(node_id) ⇒ Object
90
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 90
def get_node(node_id); @node_registry.get(node_id) end
|
#global_keys ⇒ Object
123
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 123
def global_keys; @global_registry.global_keys end
|
#nodes ⇒ Object
92
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 92
def nodes; @node_registry.nodes end
|
#remove_node(node) ⇒ Object
51
52
53
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 51
def remove_node(node)
@node_registry.remove node
end
|
#set_global(key, value) ⇒ Object
122
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 122
def set_global(key, value); @global_registry.set(key, value) end
|
#set_node(node_id, addr) ⇒ Object
91
|
# File 'lib/dcell/registries/cassandra_adapter.rb', line 91
def set_node(node_id, addr); @node_registry.set(node_id, addr) end
|