This repository has been archived by the owner on May 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from nathannis/master
Excessive Blacklisting when using a load balancer to access nodes
- Loading branch information
Showing
9 changed files
with
101 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,63 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Diagnostics; | |||
|
|||
namespace FluentCassandra.Connections | |||
{ | |||
public class SingleServerManager : IServerManager | |||
{ | |||
private readonly object _lock = new object(); | |||
private Server _server; | |||
|
|||
public SingleServerManager(IConnectionBuilder builder) | |||
{ | |||
_server = builder.Servers[0]; | |||
} | |||
|
|||
#region IServerManager Members | |||
|
|||
public bool HasNext | |||
{ | |||
get { return true; } | |||
} | |||
|
|||
public Server Next() | |||
{ | |||
return _server; | |||
} | |||
|
|||
public void ErrorOccurred(Server server, Exception exc = null) | |||
{ | |||
Debug.WriteLineIf(exc != null, exc, "connection"); | |||
} | |||
|
|||
public void Add(Server server) | |||
{ | |||
_server = server; | |||
} | |||
public void Remove(Server server) | |||
{ | |||
throw new NotImplementedException ("SingleServerManager does not implement Remove(server)"); | |||
} | |||
#endregion | |||
#region IEnumerable<Server> Members | |||
|
|||
public IEnumerator<Server> GetEnumerator() | |||
{ | |||
throw new NotImplementedException("SingleServerManager does not implement Enumerable(server)"); | |||
} | |||
|
|||
#endregion | |||
|
|||
#region IEnumerable Members | |||
|
|||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | |||
{ | |||
return GetEnumerator(); | |||
} | |||
|
|||
#endregion | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/FluentCassandra.Tests/Connections/SingleServerManagerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
|
|||
namespace FluentCassandra.Connections.Tests | |||
{ | |||
public class SingleServerManagerTests | |||
{ | |||
[Fact] | |||
public void CanGetServerAfterError() | |||
{ | |||
SingleServerManager target = new SingleServerManager(new ConnectionBuilder("Server=unit-test-1")); | |||
|
|||
Server original = target.Next(); | |||
|
|||
for (int i = 0; i < 10; i++) | |||
{ | |||
Assert.True(target.HasNext, "SingleServerManager should always have another server available."); | |||
Server next = target.Next(); | |||
Assert.True(original.ToString().Equals(next.ToString(), StringComparison.OrdinalIgnoreCase), | |||
"SingleServerManager always returns the same server."); | |||
//mark the server as failing to set up the next test iteration. | |||
target.ErrorOccurred(next); | |||
} | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters