Skip to content

Commit 3d1bc8d

Browse files
committed
CSHARP-1526: Rename PrimaryVersion to ElectionInfo.
1 parent 7fbf732 commit 3d1bc8d

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/MongoDB.Driver.Core.Tests/Core/Clusters/MultiServerClusterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-2015 MongoDB Inc.
1+
/* Copyright 2013-2016 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.

src/MongoDB.Driver.Core.Tests/Core/Connections/IsMasterResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-2015 MongoDB Inc.
1+
/* Copyright 2013-2016 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.

src/MongoDB.Driver.Core/Core/Clusters/MultiServerCluster.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-2015 MongoDB Inc.
1+
/* Copyright 2013-2016 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ internal sealed class MultiServerCluster : Cluster
3636
{
3737
// fields
3838
private readonly CancellationTokenSource _monitorServersCancellationTokenSource;
39-
private volatile PrimaryVersion _maxPrimaryVersion;
39+
private volatile ElectionInfo _maxElectionInfo;
4040
private volatile string _replicaSetName;
4141
private readonly AsyncQueue<ServerDescriptionChangedEventArgs> _serverDescriptionChangedQueue;
4242
private readonly List<IClusterableServer> _servers;
@@ -324,12 +324,14 @@ private ClusterDescription ProcessReplicaSetChange(ClusterDescription clusterDes
324324
if (args.NewServerDescription.ReplicaSetConfig.Version != null)
325325
{
326326
bool isCurrentPrimaryStale = true;
327-
if (_maxPrimaryVersion != null)
327+
if (_maxElectionInfo != null)
328328
{
329-
isCurrentPrimaryStale = _maxPrimaryVersion.IsStale(args.NewServerDescription.ReplicaSetConfig.Version.Value, args.NewServerDescription.ElectionId);
330-
if (!isCurrentPrimaryStale && args.NewServerDescription.ElectionId != null)
329+
isCurrentPrimaryStale = _maxElectionInfo.IsStale(args.NewServerDescription.ReplicaSetConfig.Version.Value, args.NewServerDescription.ElectionId);
330+
var isReportedPrimaryStale = !isCurrentPrimaryStale;
331+
332+
if (isReportedPrimaryStale && args.NewServerDescription.ElectionId != null)
331333
{
332-
// we only invalidate the "newly" reported primary if electionId was used.
334+
// we only invalidate the "newly" reported stale primary if electionId was used.
333335
lock (_serversLock)
334336
{
335337
var server = _servers.SingleOrDefault(x => EndPointHelper.Equals(args.NewServerDescription.EndPoint, x.EndPoint));
@@ -342,7 +344,7 @@ private ClusterDescription ProcessReplicaSetChange(ClusterDescription clusterDes
342344

343345
if (isCurrentPrimaryStale)
344346
{
345-
_maxPrimaryVersion = new PrimaryVersion(
347+
_maxElectionInfo = new ElectionInfo(
346348
args.NewServerDescription.ReplicaSetConfig.Version.Value,
347349
args.NewServerDescription.ElectionId);
348350
}
@@ -505,12 +507,12 @@ private static class State
505507
public const int Disposed = 2;
506508
}
507509

508-
private class PrimaryVersion
510+
private class ElectionInfo
509511
{
510512
private readonly int _setVersion;
511513
private readonly ElectionId _electionId;
512514

513-
public PrimaryVersion(int setVersion, ElectionId electionId)
515+
public ElectionInfo(int setVersion, ElectionId electionId)
514516
{
515517
_setVersion = setVersion;
516518
_electionId = electionId;

src/MongoDB.Driver.Core/Core/Connections/IsMasterResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-2015 MongoDB Inc.
1+
/* Copyright 2013-2016 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)