You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Anshuman Singh <si...@gmail.com> on 2020/07/31 06:15:29 UTC

Custom Snitch for Rack Awareness

Hi,

I'm using Solr-7.4 and I want to create collections in my cluster such that
no two replicas should be assigned to the same Rack.

I read about Rule-based Replica Placement
https://lucene.apache.org/solr/guide/7_4/rule-based-replica-placement.html.
What I got is I have to create a tag/snitch which marks which node belongs
to which Rack and then I can specify the rule in the Collection creation
API. But I didn't get how to create this custom Snitch.

It is unclear to me how to create a custom Snitch. Can someone tell me how
to do it?

Regards,
Anshuman

Re: Custom Snitch for Rack Awareness

Posted by Matt Pearce <mp...@opensourceconnections.com>.
Hi Anshuman,

Rather than creating a custom Snitch, is it possible for you to supply 
the rack number in a system property, and use that in your placement rule?

If you do have to create a custom Snitch, you'll need to extend the 
abstract Snitch class, and put it in your Solr library directory. 
Javadoc for Snitch is here, if I've found the right place for it (it 
took some digging, and wasn't obvious, so apologies if I've got it 
wrong): 
https://lucene.apache.org/solr/8_0_0//solr-solrj/org/apache/solr/common/cloud/rule/Snitch.html

May be worth having a dig around in the source code, around the 
org.apache.solr.cloud.rule.ServerSnitchContext class to see how that works.

All the best,
Matt

On 31/07/2020 07:15, Anshuman Singh wrote:
> Hi,
> 
> I'm using Solr-7.4 and I want to create collections in my cluster such that
> no two replicas should be assigned to the same Rack.
> 
> I read about Rule-based Replica Placement
> https://lucene.apache.org/solr/guide/7_4/rule-based-replica-placement.html.
> What I got is I have to create a tag/snitch which marks which node belongs
> to which Rack and then I can specify the rule in the Collection creation
> API. But I didn't get how to create this custom Snitch.
> 
> It is unclear to me how to create a custom Snitch. Can someone tell me how
> to do it?
> 
> Regards,
> Anshuman
>