Skip to content

Commit

Permalink
raftNodeInstance.IsLeader(optional parameter entityName) will help to…
Browse files Browse the repository at this point in the history
… understand either node is a Leader or not
  • Loading branch information
hhblaze committed Oct 17, 2019
1 parent a875681 commit 54b17ce
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Deployment/!!!Raft.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Raft</id>
<version>1.5.1</version>
<version>1.6</version>
<title>Raft.NET dotnet consensus algorithm implementation</title>
<authors>Alex Solovyov</authors>
<owners>tiesky.com / Alex Solovyov</owners>
Expand All @@ -11,7 +11,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Implementation of the RAFT consensus algorithm among TCP peers with disk or memory persistence</description>
<summary>Raft.NET dotnet consensus algorithm implementation</summary>
<releaseNotes>raftNodeInstance.NodeIsInLatestState can help to understand if started node is in the latest update state</releaseNotes>
<releaseNotes>raftNodeInstance.IsLeader(optional parameter entityName) will help to understand either node is a Leader or not</releaseNotes>
<copyright>Copyright © 2018 tiesky.com / Alex Solovyov</copyright>
<language>es-US</language>
<tags>RAFT Raft.NET dotnet dbreeze netcore netstandard net framework</tags>
Expand Down
Binary file added Deployment/Raft.1.6.0.nupkg
Binary file not shown.
21 changes: 15 additions & 6 deletions Raft/RaftNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,22 @@ public void Dispose()
//}
}




/// <summary>
/// We need this value to calculate majority while leader election
/// Is node a leader
/// </summary>
public void SetNodesQuantityInTheCluster(uint nodesQuantityInTheCluster)
public bool IsLeader
{
get
{
return this.NodeState == eNodeState.Leader;
}
}


/// <summary>
/// We need this value to calculate majority while leader election
/// </summary>
public void SetNodesQuantityInTheCluster(uint nodesQuantityInTheCluster)
{
lock (lock_Operations)
{
Expand Down Expand Up @@ -1321,7 +1330,7 @@ internal void Commited()
});
}


public void EmulationStop()
{
this.NodeStop();
Expand Down
15 changes: 15 additions & 0 deletions Raft/Transport/TcpRaftNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ public TcpRaftNode(NodeSettings nodeSettings, string dbreezePath, Func<string, u
}
}

/// <summary>
/// Gets raft node by entity and returns if it is a leader
/// </summary>
/// <param name="entityName"></param>
/// <returns></returns>
public bool IsLeader(string entityName = "default")
{
if(this.raftNodes.TryGetValue(entityName, out var rn))
{
return rn.IsLeader;
}

return false;
}

/// <summary>
///
/// </summary>
Expand Down
Binary file modified Raft/bin/Release-NET47/Raft.dll
Binary file not shown.
Binary file modified Raft/bin/Release-NET47/Raft.pdb
Binary file not shown.
12 changes: 12 additions & 0 deletions Raft/bin/Release-NET47/Raft.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Raft/bin/Release/Raft.dll
Binary file not shown.
12 changes: 12 additions & 0 deletions Raft/bin/Release/Raft.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified RaftStandard/bin/Release/netstandard2.0/Raft.dll
Binary file not shown.
12 changes: 12 additions & 0 deletions RaftStandard/bin/Release/netstandard2.0/Raft.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 54b17ce

Please sign in to comment.