Skip to content

Commit

Permalink
CSHARP-315: add support for reading tags from isMaster result.
Browse files Browse the repository at this point in the history
  • Loading branch information
craiggwilson committed Aug 20, 2012
1 parent 58df048 commit cdd29cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 21 additions & 0 deletions Driver/Core/CommandResults/IsMasterResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,27 @@ public string ReplicaSetName
}
}

/// <summary>
/// Gets the tags.
/// </summary>
public ReplicaSetTagSet Tags
{
get
{
var tagSet = new ReplicaSetTagSet();
if (Response.Contains("tags"))
{
var tags = Response["tags"].AsBsonDocument;
foreach (var tag in tags)
{
tagSet.Add(tag.Name, tag.Value.ToString());
}
}

return tagSet;
}
}

// private methods
private IEnumerable<MongoServerAddress> GetInstanceAddressesFromNamedResponseElement(string elementName)
{
Expand Down
3 changes: 1 addition & 2 deletions Driver/Core/MongoServerInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,8 @@ private void LookupServerInformation(MongoConnection connection)
MongoServerInstanceType instanceType = MongoServerInstanceType.StandAlone;
if (isMasterResult.ReplicaSetName != null)
{
var tagSet = new ReplicaSetTagSet();
var peers = isMasterResult.Hosts.Concat(isMasterResult.Passives).Concat(isMasterResult.Arbiters).ToList();
replicaSetInformation = new ReplicaSetInformation(isMasterResult.ReplicaSetName, isMasterResult.Primary, peers, tagSet);
replicaSetInformation = new ReplicaSetInformation(isMasterResult.ReplicaSetName, isMasterResult.Primary, peers, isMasterResult.Tags);
instanceType = MongoServerInstanceType.ReplicaSetMember;
}
else if (isMasterResult.Message != null && isMasterResult.Message == "isdbgrid")
Expand Down

0 comments on commit cdd29cb

Please sign in to comment.