Class: RedisRing::Application
- Inherits:
-
Object
- Object
- RedisRing::Application
- Defined in:
- lib/redis_ring/application.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#master ⇒ Object
readonly
Returns the value of attribute master.
-
#master_rpc ⇒ Object
readonly
Returns the value of attribute master_rpc.
-
#node_provider ⇒ Object
readonly
Returns the value of attribute node_provider.
-
#process_manager ⇒ Object
readonly
Returns the value of attribute process_manager.
-
#shards ⇒ Object
readonly
Returns the value of attribute shards.
-
#slave ⇒ Object
readonly
Returns the value of attribute slave.
-
#slave_rpc ⇒ Object
readonly
Returns the value of attribute slave_rpc.
-
#zookeeper_connection ⇒ Object
readonly
Returns the value of attribute zookeeper_connection.
-
#zookeeper_observer ⇒ Object
readonly
Returns the value of attribute zookeeper_observer.
Instance Method Summary collapse
-
#initialize(config) ⇒ Application
constructor
A new instance of Application.
- #start ⇒ Object
- #stop ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(config) ⇒ Application
Returns a new instance of Application.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/redis_ring/application.rb', line 7 def initialize(config) @configuration = config @process_manager = ProcessManager.new @http_client = HttpClient.new @master_rpc = MasterRPC.new(http_client) @slave_rpc = SlaveRPC.new(http_client) @node_provider = NodeProvider.new(slave_rpc) @zookeeper_connection = ZookeeperConnection.new(config.cluster_name, config.host_name, config.base_port, config.zookeeper_address) @master = Master.new(zookeeper_connection, config.ring_size, node_provider) @slave = Slave.new(configuration, master_rpc, process_manager) @zookeeper_observer = ZookeeperObserver.new(zookeeper_connection, master, slave) @web_interface_runner = WebInterfaceRunner.new(config.base_port, master, slave) end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def configuration @configuration end |
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def http_client @http_client end |
#master ⇒ Object (readonly)
Returns the value of attribute master.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def master @master end |
#master_rpc ⇒ Object (readonly)
Returns the value of attribute master_rpc.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def master_rpc @master_rpc end |
#node_provider ⇒ Object (readonly)
Returns the value of attribute node_provider.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def node_provider @node_provider end |
#process_manager ⇒ Object (readonly)
Returns the value of attribute process_manager.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def process_manager @process_manager end |
#shards ⇒ Object (readonly)
Returns the value of attribute shards.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def shards @shards end |
#slave ⇒ Object (readonly)
Returns the value of attribute slave.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def slave @slave end |
#slave_rpc ⇒ Object (readonly)
Returns the value of attribute slave_rpc.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def slave_rpc @slave_rpc end |
#zookeeper_connection ⇒ Object (readonly)
Returns the value of attribute zookeeper_connection.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def zookeeper_connection @zookeeper_connection end |
#zookeeper_observer ⇒ Object (readonly)
Returns the value of attribute zookeeper_observer.
5 6 7 |
# File 'lib/redis_ring/application.rb', line 5 def zookeeper_observer @zookeeper_observer end |
Instance Method Details
#start ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/redis_ring/application.rb', line 24 def start self.stop @web_thread = @web_interface_runner.run @zookeeper_connection.connect @slave.node_id = @zookeeper_connection.current_node @zookeeper_thread = @zookeeper_observer.run @pm_thread = @process_manager.run [:INT, :TERM, :QUIT].each do |sig| trap(sig) { self.stop } end end |
#stop ⇒ Object
46 47 48 49 50 |
# File 'lib/redis_ring/application.rb', line 46 def stop @process_manager.halt @zookeeper_observer.halt @web_interface_runner.halt end |
#wait ⇒ Object
40 41 42 43 44 |
# File 'lib/redis_ring/application.rb', line 40 def wait @pm_thread.join if @pm_thread @zookeeper_thread.join if @zookeeper_thread @web_thread.join if @web_thread end |