Class: Solr::Cloud::ZookeeperConnection
- Inherits:
-
Object
- Object
- Solr::Cloud::ZookeeperConnection
- Defined in:
- lib/solr/cloud/zookeeper_connection.rb
Instance Attribute Summary collapse
-
#zookeeper_auth_password ⇒ Object
readonly
Returns the value of attribute zookeeper_auth_password.
-
#zookeeper_auth_user ⇒ Object
readonly
Returns the value of attribute zookeeper_auth_user.
-
#zookeeper_url ⇒ Object
readonly
Returns the value of attribute zookeeper_url.
Instance Method Summary collapse
- #collection_state_znode_path(collection_name) ⇒ Object
- #get_collection_state(collection_name, watch: true) ⇒ Object
-
#initialize(zookeeper_url:, zookeeper_auth_user: nil, zookeeper_auth_password: nil) ⇒ ZookeeperConnection
constructor
A new instance of ZookeeperConnection.
- #watch_collection_state(collection_name, &block) ⇒ Object
Constructor Details
#initialize(zookeeper_url:, zookeeper_auth_user: nil, zookeeper_auth_password: nil) ⇒ ZookeeperConnection
Returns a new instance of ZookeeperConnection.
8 9 10 11 12 |
# File 'lib/solr/cloud/zookeeper_connection.rb', line 8 def initialize(zookeeper_url:, zookeeper_auth_user: nil, zookeeper_auth_password: nil) @zookeeper_url = zookeeper_url @zookeeper_auth_user = zookeeper_auth_user @zookeeper_auth_password = zookeeper_auth_password end |
Instance Attribute Details
#zookeeper_auth_password ⇒ Object (readonly)
Returns the value of attribute zookeeper_auth_password.
6 7 8 |
# File 'lib/solr/cloud/zookeeper_connection.rb', line 6 def zookeeper_auth_password @zookeeper_auth_password end |
#zookeeper_auth_user ⇒ Object (readonly)
Returns the value of attribute zookeeper_auth_user.
6 7 8 |
# File 'lib/solr/cloud/zookeeper_connection.rb', line 6 def zookeeper_auth_user @zookeeper_auth_user end |
#zookeeper_url ⇒ Object (readonly)
Returns the value of attribute zookeeper_url.
6 7 8 |
# File 'lib/solr/cloud/zookeeper_connection.rb', line 6 def zookeeper_url @zookeeper_url end |
Instance Method Details
#collection_state_znode_path(collection_name) ⇒ Object
31 32 33 |
# File 'lib/solr/cloud/zookeeper_connection.rb', line 31 def collection_state_znode_path(collection_name) "/collections/#{collection_name}/state.json" end |
#get_collection_state(collection_name, watch: true) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/solr/cloud/zookeeper_connection.rb', line 24 def get_collection_state(collection_name, watch: true) collection_state_znode = collection_state_znode_path(collection_name) znode_data = zookeeper_connection.get(collection_state_znode, watch: watch) return unless znode_data JSON.parse(znode_data.first)[collection_name.to_s] end |
#watch_collection_state(collection_name, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/solr/cloud/zookeeper_connection.rb', line 14 def watch_collection_state(collection_name, &block) collection_state_znode = collection_state_znode_path(collection_name) zookeeper_connection.register(collection_state_znode) do |event| state = get_collection_state(collection_name, watch: true) block.call(state) end state = get_collection_state(collection_name, watch: true) block.call(state) end |