private Topology GetTopology(ClusterRequestExecutor requestExecutor) { Topology topology = null; try { topology = requestExecutor.Topology; if (topology == null) { // a bit rude way to make sure that topology has been refreshed // but it handles a case when first topology update failed using (requestExecutor.ContextPool.AllocateOperationContext(out var context)) { var operation = new GetBuildNumberOperation(); var command = operation.GetCommand(requestExecutor.Conventions, context); requestExecutor.Execute(command, context); } topology = requestExecutor.Topology; } } catch { // ignored } if (topology == null) { throw new InvalidOperationException("Could not fetch the topology."); } return(topology); }