Showing posts with label zookeeper. Show all posts
Showing posts with label zookeeper. Show all posts

Friday, June 24, 2016

Collections and config names in Solr Cloud

Leave a Comment

In a Solr Cloud of 3 zookeeper and 3 solr instances, should we define a collection oder do we need more collections? What about config names? How many config names do we need?

Solr.xml looks like this :

<?xml version="1.0" encoding="UTF-8" ?>   <solr>  <!--  <cores adminPath="/admin/multicore">     <core name="core0" instanceDir="multicore/core0"/>      <core name="core1" config="solrconfig.xml" instanceDir="multicore\core0" schema="schema.xml" dataDir=".\solr\data"/> </cores> -->    <bool name="shareSchema">false</bool>  <solrcloud>     <str name="host">localhost</str>     <int name="hostPort">8082</int>     <str name="hostContext">solr</str>     <str name="zkHost">localhost:2181,localhost:2182,localhost:2183</str>     <int name="zkClientTimeout">15000</int>     <bool name="genericCoreNodeNames">true</bool>   </solrcloud>    <shardHandlerFactory name="shardHandlerFactory"     class="HttpShardHandlerFactory">     <int name="socketTimeout">0</int>     <int name="connTimeout">0</int>   </shardHandlerFactory>   </solr> 

In the picture you can see that my cluster doesn't look nice. In each Solr node I have two cores. and not core.properties file. And on the other hand the nodes are down! , whereas in their Solr Admin GUI I see that they are up!

First I had the definitions collection1, collection2, collection3 in the core.properties of core0 in different cluster nodes, but then i completely removed the core.properties files and now they are still there!

Solr Cloud of 3 nodes

0 Answers

Read More

Sunday, June 19, 2016

zookeeper watcher in ruby

Leave a Comment

I am using this gem: https://github.com/zk-ruby/zk for connecting to zookeeper, and get and set commands are working correctly.

I have tried adding a watcher client using the sample zookeeper client that comes along with the server build, and all works well there. I can add a watcher and when I update some znode from another client, the client is notified.

But I wish to integrate a watcher in ruby code, I am not getting any events when data on the node is changed.

This is a sample class:

class ZkConnect    attr_accessor :z, :sub, :k   include Singleton    @z = nil   @sub = nil   @watcher = nil   @callback = nil   @watcher = nil    def initialize     initialize_conns   end    def initialize_conns     @z = ZK.new("localhost:2181")     Rails.logger.info @z.inspect     # Rails.logger.info z.get_children(:path => "/system/production")     # Rails.logger.info z.get(:path => "/system/production")[:data]      # @sub = @z.register("/mypath") do |event, zookeeper_client|     #   Rails.logger.info "got an event"     #   Rails.logger.info "got an event on: #{event.inspect} #{zookeeper_client.inspect}"     # end     # Rails.logger.info @sub.inspect     w = watch     Rails.logger.info "dsmcldsm: #{w.inspect}"   end    # def watcher_callback   #   @callback ||= Proc.new do |event|   #     Rails.logger.info "dcbskcn : #{event.inspect}"   #     # Set new watcher   #     watch   #     # Rediscover   #     # discover   #   end   #   Rails.logger.info "nckdj cudsnciu sdcn: #{@callback.inspect}"   #   return @callback   # end    def watch     # return if @z.nil?     Rails.logger.info "synapse: setting watch at "      # @watcher = @z.register("/mypath", &watcher_callback)     @watcher = @z.register("/mypath") do |event|       Rails.logger.info "dcbskcn : #{event.inspect}"       puts "dcbskcn : #{event.inspect}"       watch     end     Rails.logger.info "cudsnciu: #{@watcher.inspect}"     return @watcher      # Verify that we actually set up the watcher.     # unless @zk.exists?(@discovery['path'], :watch => true)     #   log.error "synapse: zookeeper watcher path #{@discovery['path']} does not exist!"     #   zk_cleanup     # end     # log.debug "synapse: set watch at #{@discovery['path']}"   end end 

I took some code from here https://github.com/airbnb/synapse/blob/master/lib/synapse/service_watcher/zookeeper.rb for this, but didn't help.

I tried it on a rails project, tried running on thin and passenger, though I don't see how it would help.

I also don't see eventmachine as a dependency for this gem, so I don't really know how callbacks would be received.

1 Answers

Answers 1

I read changelog and decided to put a @z.stat("/mypath", :watch => true) after registering the watcher. And it started working. No idea why.

Read More