[CSHARP-722] Provide a method to inspect the state of a cluster Created: 09/Apr/13 Updated: 18/Aug/14 Resolved: 18/Aug/14 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | API, Connectivity |
| Affects Version/s: | 1.8 |
| Fix Version/s: | 2.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Craig Wilson | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | Adopt Core Library | ||||||||
| Description |
|
Currently, there isn't a friendly way to get an up-to-date state of a cluster (single server, replica set, shards). We need to provide a strongly-typed method that will invoke the appropriate server commands and aggregate the results back in an easy to use object model. |
| Comments |
| Comment by Robert Stam [ 21/May/13 ] |
|
There already are properties to inspect the state of the cluster, though there are some issues to consider (see below). The MongoServer class represents the cluster, and has the following properties and methods that expose information about the cluster:
The MongoServerInstance class represents a node in the cluster, and has the following properties and methods that expose information about the node:
The main issue to consider is that this information is all cached. This is both good and bad. The good part is that it is essentially free to query these properties because there is no round trip to the server. The bad part is that it can be slightly out of date. The driver refreshes this information every 10 seconds. You can also call VerifyState yourself if you want the information to be as current as possible (taking into account that VerifyState requires round trips to the nodes). Another issue is that there is a bug in VerifyState: if you call VerifyState when the cluster is disconnected it does nothing, so as a work around you currently have to call Connect first to ensure the cluster is in a Connected state before you call VerifyState. The final issue is that there are some properties of nodes that are not yet exposed. That can be rectified by adding them. In hindsight I wish the MongoServer and MongoServerInstance classes where called MongoCluster and MongoNode, as those names would be clearer. Perhaps in version 2.0 we can rectify that, although it would be a breaking change. It also would have been better if VerifyState had been named RefreshState to emphasize that it refreshes the cached information. This JIRA ticket proposes an alternative way of getting information about the cluster which doesn't use cached information, so it would always incur the expense of a round trip to one or more servers. Another consideration is that as of version 2.4 of the server the replSetGetStatus command requires clusterAdmin privilege, so if the proposed helper method was implemented using replSetGetStatus it couldn't be called by ordinary applications that don't have clusterAdmin privilege. |