You are looking at documentation for an older release.
Not what you want? See the
current release documentation.
Sniffing role detectionedit
When we sniff the cluster state, we detect the role of the node, whether it’s master eligible and holds data. We use this information when selecting a node to perform an API call on.
var audit = new Auditor(() => Framework.Cluster .Nodes(10) .Sniff(s => s.Fails(Always)) .Sniff(s => s.OnPort(9202) .Succeeds(Always, Framework.Cluster.Nodes(8).StoresNoData(9200, 9201, 9202)) ) .SniffingConnectionPool() .AllDefaults() ) { AssertPoolBeforeCall = (pool) => { pool.Should().NotBeNull(); pool.Nodes.Should().HaveCount(10); pool.Nodes.Where(n => n.HoldsData).Should().HaveCount(10); }, AssertPoolAfterCall = (pool) => { pool.Should().NotBeNull(); pool.Nodes.Should().HaveCount(8); pool.Nodes.Where(n => n.HoldsData).Should().HaveCount(5); } }; await audit.TraceStartup();
var audit = new Auditor(() => Framework.Cluster .Nodes(10) .Sniff(s => s.SucceedAlways() .Succeeds(Always, Framework.Cluster.Nodes(8).StoresNoData(9200, 9201, 9202).HttpDisabled(9201)) ) .SniffingConnectionPool() .AllDefaults() ) { AssertPoolBeforeCall = (pool) => { pool.Should().NotBeNull(); pool.Nodes.Should().HaveCount(10); pool.Nodes.Where(n => n.HoldsData).Should().HaveCount(10); pool.Nodes.Where(n => n.HttpEnabled).Should().HaveCount(10); pool.Nodes.Should().OnlyContain(n => n.Uri.Host == "localhost"); }, AssertPoolAfterCall = (pool) => { pool.Should().NotBeNull(); pool.Nodes.Should().HaveCount(7, "we filtered the node that stores no data"); pool.Nodes.Should().NotContain(n=>n.Uri.Port == 9201); pool.Nodes.Where(n => n.HoldsData).Should().HaveCount(5); } }; await audit.TraceStartup();
var audit = new Auditor(() => Framework.Cluster .Nodes(10) .Sniff(s => s.SucceedAlways() .Succeeds(Always, Framework.Cluster.Nodes(8).StoresNoData(9200, 9201, 9202).SniffShouldReturnFqdn()) ) .SniffingConnectionPool() .AllDefaults() ) { AssertPoolBeforeCall = (pool) => { pool.Should().NotBeNull(); pool.Nodes.Should().HaveCount(10); pool.Nodes.Where(n => n.HoldsData).Should().HaveCount(10); pool.Nodes.Should().OnlyContain(n => n.Uri.Host == "localhost"); }, AssertPoolAfterCall = (pool) => { pool.Should().NotBeNull(); pool.Nodes.Should().HaveCount(8); pool.Nodes.Where(n => n.HoldsData).Should().HaveCount(5); pool.Nodes.Should().OnlyContain(n => n.Uri.Host.StartsWith("fqdn") && !n.Uri.Host.Contains("/")); } }; await audit.TraceStartup();
var node = SniffAndReturnNode(); node.MasterEligible.Should().BeTrue(); node.HoldsData.Should().BeFalse(); node = await SniffAndReturnNodeAsync(); node.MasterEligible.Should().BeTrue(); node.HoldsData.Should().BeFalse();
var pipeline = CreatePipeline(); pipeline.Sniff();
var pipeline = CreatePipeline(); await pipeline.SniffAsync();
var uri = TestClient.CreateUri(this._cluster.Node.Port); this._settings = new ConnectionSettings(new SniffingConnectionPool(new[] { uri })); var pipeline = new RequestPipeline(this._settings, DateTimeProvider.Default, new MemoryStreamFactory(), new SearchRequestParameters());
var nodes = this._settings.ConnectionPool.Nodes; nodes.Should().NotBeEmpty().And.HaveCount(1); var node = nodes.First();
var audit = new Auditor(() => Framework.Cluster .Nodes(10) .Sniff(s => s.Fails(Always)) .Sniff(s => s.OnPort(9202) .Succeeds(Always, Framework.Cluster.Nodes(8).MasterEligible(9200, 9201, 9202)) ) .SniffingConnectionPool() .AllDefaults() ) { AssertPoolBeforeCall = (pool) => { pool.Should().NotBeNull(); pool.Nodes.Should().HaveCount(10); pool.Nodes.Where(n => n.MasterEligible).Should().HaveCount(10); }, AssertPoolAfterCall = (pool) => { pool.Should().NotBeNull(); pool.Nodes.Should().HaveCount(8); pool.Nodes.Where(n => n.MasterEligible).Should().HaveCount(3); } }; await audit.TraceStartup();