Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from managedfusion/master

Updating My Fork.
  • Loading branch information...
commit 92bc9b8a2701bef74195c0d0ede5b3f09a3af5b1 2 parents 4423a23 + 0a960d9
@eplowe eplowe authored
Showing with 584 additions and 452 deletions.
  1. +1 −1  FluentCassandra.sln
  2. +5 −5 src/Apache/Cassandra/AuthenticationException.cs
  3. +5 −5 src/Apache/Cassandra/AuthenticationRequest.cs
  4. +5 −5 src/Apache/Cassandra/AuthorizationException.cs
  5. +5 −5 src/Apache/Cassandra/Cassandra.cs
  6. +5 −5 src/Apache/Cassandra/CfDef.cs
  7. +5 −5 src/Apache/Cassandra/Column.cs
  8. +5 −5 src/Apache/Cassandra/ColumnDef.cs
  9. +5 −5 src/Apache/Cassandra/ColumnOrSuperColumn.cs
  10. +5 −5 src/Apache/Cassandra/ColumnParent.cs
  11. +5 −5 src/Apache/Cassandra/ColumnPath.cs
  12. +1 −1  src/Apache/Cassandra/Compression.cs
  13. +1 −1  src/Apache/Cassandra/ConsistencyLevel.cs
  14. +3 −3 src/Apache/Cassandra/Constants.cs
  15. +5 −5 src/Apache/Cassandra/CounterColumn.cs
  16. +5 −5 src/Apache/Cassandra/CounterSuperColumn.cs
  17. +5 −5 src/Apache/Cassandra/CqlMetadata.cs
  18. +5 −5 src/Apache/Cassandra/CqlPreparedResult.cs
  19. +5 −5 src/Apache/Cassandra/CqlResult.cs
  20. +1 −1  src/Apache/Cassandra/CqlResultType.cs
  21. +5 −5 src/Apache/Cassandra/CqlRow.cs
  22. +5 −5 src/Apache/Cassandra/Deletion.cs
  23. +5 −5 src/Apache/Cassandra/EndpointDetails.cs
  24. +5 −5 src/Apache/Cassandra/IndexClause.cs
  25. +5 −5 src/Apache/Cassandra/IndexExpression.cs
  26. +1 −1  src/Apache/Cassandra/IndexOperator.cs
  27. +1 −1  src/Apache/Cassandra/IndexType.cs
  28. +5 −5 src/Apache/Cassandra/InvalidRequestException.cs
  29. +5 −5 src/Apache/Cassandra/KeyCount.cs
  30. +5 −5 src/Apache/Cassandra/KeyRange.cs
  31. +5 −5 src/Apache/Cassandra/KeySlice.cs
  32. +5 −5 src/Apache/Cassandra/KsDef.cs
  33. +5 −5 src/Apache/Cassandra/Mutation.cs
  34. +5 −5 src/Apache/Cassandra/NotFoundException.cs
  35. +5 −5 src/Apache/Cassandra/SchemaDisagreementException.cs
  36. +5 −5 src/Apache/Cassandra/SlicePredicate.cs
  37. +5 −5 src/Apache/Cassandra/SliceRange.cs
  38. +5 −5 src/Apache/Cassandra/SuperColumn.cs
  39. +5 −5 src/Apache/Cassandra/TimedOutException.cs
  40. +5 −5 src/Apache/Cassandra/TokenRange.cs
  41. +5 −5 src/Apache/Cassandra/UnavailableException.cs
  42. +1 −1  src/CassandraColumnFamilySchema.cs
  43. +1 −1  src/CassandraColumnSchema.cs
  44. +1 −1  src/CassandraContext.cs
  45. +1 −1  src/CassandraCqlRowSchema.cs
  46. +1 −1  src/CassandraKeyspace.cs
  47. +1 −1  src/CassandraKeyspaceSchema.cs
  48. +11 −5 src/CassandraSession.cs
  49. +5 −4 src/Connections/Connection.cs
  50. +31 −7 src/Connections/ConnectionBuilder.cs
  51. +2 −0  src/Connections/ConnectionProvider.cs
  52. +1 −1  src/Connections/IConnection.cs
  53. +2 −1  src/Connections/IConnectionBuilder.cs
  54. +2 −1  src/Connections/IConnectionProvider.cs
  55. +0 −1  src/Connections/IServerManager.cs
  56. +7 −1 src/Connections/NormalConnectionProvider.cs
  57. +19 −3 src/Connections/PooledConnectionProvider.cs
  58. +133 −113 src/Connections/RoundRobinServerManager.cs
  59. +20 −1 src/Connections/Server.cs
  60. +1 −1  src/Operations/BatchMutate.cs
  61. +1 −1  src/Operations/CassandraIndexClauseBuilder.cs
  62. +12 −2 src/Operations/CassandraOperationException.cs
  63. +1 −1  src/Operations/GetSuperColumn.cs
  64. +1 −1  src/Operations/Helper.cs
  65. +35 −8 src/Operations/Operation.cs
  66. +1 −1  src/Thrift/Collections/THashSet.cs
  67. +1 −1  src/Thrift/Protocol/TBase.cs
  68. +1 −1  src/Thrift/Protocol/TBase64Utils.cs
  69. +2 −2 src/Thrift/Protocol/TBinaryProtocol.cs
  70. +2 −2 src/Thrift/Protocol/TCompactProtocol.cs
  71. +1 −1  src/Thrift/Protocol/TField.cs
  72. +2 −2 src/Thrift/Protocol/TJSONProtocol.cs
  73. +1 −1  src/Thrift/Protocol/TList.cs
  74. +1 −1  src/Thrift/Protocol/TMap.cs
  75. +1 −1  src/Thrift/Protocol/TMessage.cs
  76. +1 −1  src/Thrift/Protocol/TMessageType.cs
  77. +2 −2 src/Thrift/Protocol/TProtocol.cs
  78. +1 −1  src/Thrift/Protocol/TProtocolException.cs
  79. +2 −2 src/Thrift/Protocol/TProtocolFactory.cs
  80. +1 −1  src/Thrift/Protocol/TProtocolUtil.cs
  81. +1 −1  src/Thrift/Protocol/TSet.cs
  82. +1 −1  src/Thrift/Protocol/TStruct.cs
  83. +1 −1  src/Thrift/Protocol/TType.cs
  84. +3 −3 src/Thrift/Server/TServer.cs
  85. +3 −3 src/Thrift/Server/TSimpleServer.cs
  86. +3 −3 src/Thrift/Server/TThreadPoolServer.cs
  87. +4 −4 src/Thrift/Server/TThreadedServer.cs
  88. +2 −2 src/Thrift/TApplicationException.cs
  89. +2 −2 src/Thrift/TProcessor.cs
  90. +1 −1  src/Thrift/Transport/TBufferedTransport.cs
  91. +1 −1  src/Thrift/Transport/TFramedTransport.cs
  92. +1 −1  src/Thrift/Transport/THttpClient.cs
  93. +2 −2 src/Thrift/Transport/THttpHandler.cs
  94. +1 −1  src/Thrift/Transport/TServerSocket.cs
  95. +1 −1  src/Thrift/Transport/TServerTransport.cs
  96. +1 −1  src/Thrift/Transport/TSocket.cs
  97. +1 −1  src/Thrift/Transport/TStreamTransport.cs
  98. +1 −1  src/Thrift/Transport/TTransport.cs
  99. +1 −1  src/Thrift/Transport/TTransportException.cs
  100. +1 −1  src/Thrift/Transport/TTransportFactory.cs
  101. +62 −62 test/FluentCassandra.Tests/Connections/RoundRobinServerManagerTests.cs
  102. +1 −1  test/FluentCassandra.Tests/Operations/CassandraIndexClauseTest.cs
View
2  FluentCassandra.sln
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
+# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentCassandra", "src\FluentCassandra.csproj", "{EAA32600-3C2A-4B34-B9B2-5764F280FCE3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentCassandra.Sandbox", "test\FluentCassandra.Sandbox\FluentCassandra.Sandbox.csproj", "{DE6B46DE-C37A-49AF-8B9A-B9B6D4F03A55}"
View
10 src/Apache/Cassandra/AuthenticationException.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/AuthenticationRequest.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/AuthorizationException.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/Cassandra.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
public partial class Cassandra {
public interface Iface {
View
10 src/Apache/Cassandra/CfDef.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/Column.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/ColumnDef.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/ColumnOrSuperColumn.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/ColumnParent.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/ColumnPath.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
2  src/Apache/Cassandra/Compression.cs
@@ -5,7 +5,7 @@
* @generated
*/
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
/// CQL query compression
View
2  src/Apache/Cassandra/ConsistencyLevel.cs
@@ -5,7 +5,7 @@
* @generated
*/
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
/// The ConsistencyLevel is an enum that controls both read and write
View
6 src/Apache/Cassandra/Constants.cs
@@ -9,11 +9,11 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
public class Constants
{
View
10 src/Apache/Cassandra/CounterColumn.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/CounterSuperColumn.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/CqlMetadata.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/CqlPreparedResult.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/CqlResult.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
2  src/Apache/Cassandra/CqlResultType.cs
@@ -5,7 +5,7 @@
* @generated
*/
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
public enum CqlResultType
{
View
10 src/Apache/Cassandra/CqlRow.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/Deletion.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/EndpointDetails.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/IndexClause.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/IndexExpression.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
2  src/Apache/Cassandra/IndexOperator.cs
@@ -5,7 +5,7 @@
* @generated
*/
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
public enum IndexOperator
{
View
2  src/Apache/Cassandra/IndexType.cs
@@ -5,7 +5,7 @@
* @generated
*/
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
public enum IndexType
{
View
10 src/Apache/Cassandra/InvalidRequestException.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/KeyCount.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/KeyRange.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/KeySlice.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/KsDef.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
#if !SILVERLIGHT
View
10 src/Apache/Cassandra/Mutation.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/NotFoundException.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/SchemaDisagreementException.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/SlicePredicate.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/SliceRange.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/SuperColumn.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/TimedOutException.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/TokenRange.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
10 src/Apache/Cassandra/UnavailableException.cs
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
-using Thrift;
-using Thrift.Collections;
+using FluentCassandra.Thrift;
+using FluentCassandra.Thrift.Collections;
using System.Runtime.Serialization;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Apache.Cassandra
+namespace FluentCassandra.Apache.Cassandra
{
/// <summary>
View
2  src/CassandraColumnFamilySchema.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
using FluentCassandra.Types;
namespace FluentCassandra
View
2  src/CassandraColumnSchema.cs
@@ -1,5 +1,5 @@
using System;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
using FluentCassandra.Types;
namespace FluentCassandra
View
2  src/CassandraContext.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
using FluentCassandra.Connections;
using FluentCassandra.Linq;
using FluentCassandra.Operations;
View
2  src/CassandraCqlRowSchema.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
using FluentCassandra.Types;
namespace FluentCassandra
View
2  src/CassandraKeyspace.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
using FluentCassandra.Operations;
using FluentCassandra.Types;
View
2  src/CassandraKeyspaceSchema.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
namespace FluentCassandra
{
View
16 src/CassandraSession.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
using FluentCassandra.Connections;
using FluentCassandra.Operations;
@@ -117,6 +117,12 @@ internal CassandraClientWrapper GetClient(bool setKeyspace = true, bool? setCqlV
return new CassandraClientWrapper(_connection.Client);
}
+ internal void MarkCurrentConnectionAsUnhealthy(Exception exc)
+ {
+ ConnectionProvider.ErrorOccurred(_connection, exc);
+ _connection = null;
+ }
+
/// <summary>
///
/// </summary>
@@ -154,12 +160,12 @@ public void Login(string username, string password)
}
/// <summary>
- /// The last error that occured during the execution of an operation.
+ /// The last error that occurred during the execution of an operation.
/// </summary>
public CassandraException LastError { get; private set; }
/// <summary>
- /// Indicates if errors should be thrown when occuring on opperation.
+ /// Indicates if errors should be thrown when occurring on operation.
/// </summary>
public bool ThrowErrors { get; set; }
@@ -221,7 +227,7 @@ public void Dispose()
/// </param>
protected virtual void Dispose(bool disposing)
{
- if (!WasDisposed && disposing && _connection != null)
+ if (!WasDisposed && disposing && _connection != null)
ConnectionProvider.Close(_connection);
WasDisposed = true;
@@ -237,4 +243,4 @@ protected virtual void Dispose(bool disposing)
#endregion
}
-}
+}
View
9 src/Connections/Connection.cs
@@ -1,7 +1,7 @@
using System;
-using Thrift.Transport;
-using Thrift.Protocol;
-using Apache.Cassandra;
+using FluentCassandra.Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Apache.Cassandra;
namespace FluentCassandra.Connections
{
@@ -16,6 +16,7 @@ public class Connection : IConnection, IDisposable
private Cassandra.Client _client;
private string _activeKeyspace;
private string _activeCqlVersion;
+ private bool _healthy;
private readonly object _lock = new object();
/// <summary>
@@ -38,7 +39,7 @@ public Connection(Server server, ConnectionType connectionType, int bufferSize)
Server = server;
ConnectionType = connectionType;
BufferSize = bufferSize;
-
+ _healthy = true;
InitTransportAndClient();
}
View
38 src/Connections/ConnectionBuilder.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
namespace FluentCassandra.Connections
{
@@ -14,7 +14,7 @@ public class ConnectionBuilder : FluentCassandra.Connections.IConnectionBuilder
/// <param name="host"></param>
/// <param name="port"></param>
/// <param name="timeout"></param>
- public ConnectionBuilder(string keyspace, string host, int port = Server.DefaultPort, int connectionTimeout = Server.DefaultTimeout, bool pooling = false, int minPoolSize = 0, int maxPoolSize = 100, int connectionLifetime = 0, ConnectionType connectionType = ConnectionType.Framed, int bufferSize = 1024, ConsistencyLevel read = ConsistencyLevel.QUORUM, ConsistencyLevel write = ConsistencyLevel.QUORUM, string cqlVersion = FluentCassandra.Connections.CqlVersion.ServerDefault, bool compressCqlQueries = true, string username = null, string password = null)
+ public ConnectionBuilder(string keyspace, string host, int port = Server.DefaultPort, int connectionTimeout = Server.DefaultTimeout, bool pooling = false, int minPoolSize = 0, int maxPoolSize = 100, int connectionLifetime = 0, ConnectionType connectionType = ConnectionType.Framed, int bufferSize = 1024, ConsistencyLevel read = ConsistencyLevel.QUORUM, ConsistencyLevel write = ConsistencyLevel.QUORUM, string cqlVersion = FluentCassandra.Connections.CqlVersion.ServerDefault, bool compressCqlQueries = true, string username = null, string password = null, int maxRetries = 0)
{
Keyspace = keyspace;
Servers = new List<Server>() { new Server(host, port) };
@@ -22,6 +22,7 @@ public ConnectionBuilder(string keyspace, string host, int port = Server.Default
Pooling = pooling;
MinPoolSize = minPoolSize;
MaxPoolSize = maxPoolSize;
+ MaxRetries = maxRetries;
ConnectionLifetime = TimeSpan.FromSeconds(connectionLifetime);
ConnectionType = connectionType;
BufferSize = bufferSize;
@@ -35,7 +36,7 @@ public ConnectionBuilder(string keyspace, string host, int port = Server.Default
ConnectionString = GetConnectionString();
}
- public ConnectionBuilder(string keyspace, Server server, bool pooling = false, int minPoolSize = 0, int maxPoolSize = 100, int connectionLifetime = 0, ConnectionType connectionType = ConnectionType.Framed, int bufferSize = 1024, ConsistencyLevel read = ConsistencyLevel.QUORUM, ConsistencyLevel write = ConsistencyLevel.QUORUM, string cqlVersion = FluentCassandra.Connections.CqlVersion.ServerDefault, bool compressCqlQueries = true, string username = null, string password = null)
+ public ConnectionBuilder(string keyspace, Server server, bool pooling = false, int minPoolSize = 0, int maxPoolSize = 100, int connectionLifetime = 0, ConnectionType connectionType = ConnectionType.Framed, int bufferSize = 1024, ConsistencyLevel read = ConsistencyLevel.QUORUM, ConsistencyLevel write = ConsistencyLevel.QUORUM, string cqlVersion = FluentCassandra.Connections.CqlVersion.ServerDefault, bool compressCqlQueries = true, string username = null, string password = null, int maxRetries = 0)
{
Keyspace = keyspace;
Servers = new List<Server>() { server };
@@ -43,6 +44,7 @@ public ConnectionBuilder(string keyspace, Server server, bool pooling = false, i
Pooling = pooling;
MinPoolSize = minPoolSize;
MaxPoolSize = maxPoolSize;
+ MaxRetries = maxRetries;
ConnectionLifetime = TimeSpan.FromSeconds(connectionLifetime);
ConnectionType = connectionType;
BufferSize = bufferSize;
@@ -82,7 +84,7 @@ private void InitializeConnectionString(string connectionString)
if (nameValue.Length != 2)
continue;
- pairs.Add(nameValue[0].Trim(), nameValue[1].Trim());
+ pairs.Add(nameValue[0].Trim(), nameValue[1].Trim());
}
#region Keyspace
@@ -154,6 +156,23 @@ private void InitializeConnectionString(string connectionString)
#endregion
+ #region MaxRetries
+
+ if (pairs.ContainsKey("Max Retries"))
+ {
+ int maxRetries;
+
+ if (!Int32.TryParse(pairs["Max Retries"], out maxRetries))
+ maxRetries = 0;
+
+ if (maxRetries < 0)
+ maxRetries = 0;
+
+ MaxRetries = maxRetries;
+ }
+
+ #endregion
+
#region ConnectionTimeout
if (!pairs.ContainsKey("Connection Timeout"))
@@ -330,18 +349,18 @@ private void InitializeConnectionString(string connectionString)
foreach (var server in servers)
{
string[] serverParts = server.Split(':');
- string host = serverParts[0].Trim();
+ string host = serverParts[0].Trim();
if (serverParts.Length == 2)
{
int port;
- if (Int32.TryParse(serverParts[1].Trim(), out port))
+ if (Int32.TryParse(serverParts[1].Trim(), out port))
Servers.Add(new Server(host: host, port: port, timeout: ConnectionTimeout.Seconds));
else
Servers.Add(new Server(host: host, timeout: ConnectionTimeout.Seconds));
}
else
- Servers.Add(new Server(host: host, timeout: ConnectionTimeout.Seconds));
+ Servers.Add(new Server(host: host, timeout: ConnectionTimeout.Seconds));
}
}
@@ -402,6 +421,11 @@ private string GetConnectionString()
public int MaxPoolSize { get; private set; }
/// <summary>
+ /// The maximum number of execution retry attempts if there is an error during the execution of an operation and the exception is a type that can be retried.
+ /// </summary>
+ public int MaxRetries { get; private set; }
+
+ /// <summary>
/// When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection Lifetime. This is useful in clustered configurations to force load balancing between a running server and a server just brought online. A value of zero (0) causes pooled connections to have the maximum connection timeout.
/// </summary>
public TimeSpan ConnectionLifetime { get; private set; }
View
2  src/Connections/ConnectionProvider.cs
@@ -42,6 +42,8 @@ public virtual IConnection Open()
return conn;
}
+ public abstract void ErrorOccurred(IConnection connection, Exception exc = null);
+
/// <summary>
///
/// </summary>
View
2  src/Connections/IConnection.cs
@@ -1,5 +1,5 @@
using System;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
namespace FluentCassandra.Connections
{
View
3  src/Connections/IConnectionBuilder.cs
@@ -1,5 +1,5 @@
using System;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
using System.Collections.Generic;
namespace FluentCassandra.Connections
@@ -12,6 +12,7 @@ public interface IConnectionBuilder
bool Pooling { get; }
int MinPoolSize { get; }
int MaxPoolSize { get; }
+ int MaxRetries { get; }
TimeSpan ConnectionTimeout { get; }
TimeSpan ConnectionLifetime { get; }
ConnectionType ConnectionType { get; }
View
3  src/Connections/IConnectionProvider.cs
@@ -9,9 +9,10 @@ public interface IConnectionProvider
IServerManager Servers { get; }
IConnection CreateConnection();
-
IConnection Open();
+ void ErrorOccurred(IConnection connection, Exception exc = null);
+
bool Close(IConnection connection);
}
}
View
1  src/Connections/IServerManager.cs
@@ -9,7 +9,6 @@ public interface IServerManager : IEnumerable<Server>
Server Next();
void ErrorOccurred(Server server, Exception exc = null);
- void BlackList(Server server);
void Add(Server server);
void Remove(Server server);
View
8 src/Connections/NormalConnectionProvider.cs
@@ -53,6 +53,12 @@ public override IConnection Open()
return conn;
}
+ public override void ErrorOccurred(IConnection connection, Exception exc = null)
+ {
+ try { Close(connection); } catch { }
+ Servers.ErrorOccurred(connection.Server, exc);
+ }
+
/// <summary>
///
/// </summary>
@@ -68,4 +74,4 @@ public override IConnection CreateConnection()
return conn;
}
}
-}
+}
View
22 src/Connections/PooledConnectionProvider.cs
@@ -9,7 +9,7 @@ public class PooledConnectionProvider : NormalConnectionProvider
private readonly object _lock = new object();
private readonly Queue<IConnection> _freeConnections = new Queue<IConnection>();
- private readonly List<IConnection> _usedConnections = new List<IConnection>();
+ private readonly HashSet<IConnection> _usedConnections = new HashSet<IConnection>();
private readonly Timer _maintenanceTimer;
/// <summary>
@@ -59,7 +59,7 @@ public override IConnection CreateConnection()
else if (_freeConnections.Count + _usedConnections.Count >= MaxPoolSize)
{
if (!Monitor.Wait(_lock, TimeSpan.FromSeconds(30)))
- throw new CassandraException("No connection could be made, timed out trying to aquire a connection from the connection pool.");
+ throw new TimeoutException("No connection could be made, timed out trying to acquirer a connection from the connection pool.");
return CreateConnection();
}
@@ -73,6 +73,22 @@ public override IConnection CreateConnection()
return conn;
}
+ public override void ErrorOccurred(IConnection connection, Exception exc = null)
+ {
+ lock (_lock)
+ {
+ _usedConnections.RemoveWhere(x => x.Server == connection.Server);
+ Servers.ErrorOccurred(connection.Server, exc);
+
+ var currentFreeConnections = _freeConnections.ToArray();
+ _freeConnections.Clear();
+
+ foreach (var conn in currentFreeConnections)
+ if (conn.Server != connection.Server)
+ _freeConnections.Enqueue(conn);
+ }
+ }
+
/// <summary>
///
/// </summary>
@@ -132,4 +148,4 @@ private void CheckFreeConnectionsAlive()
}
}
}
-}
+}
View
246 src/Connections/RoundRobinServerManager.cs
@@ -1,120 +1,140 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Threading;
namespace FluentCassandra.Connections
{
- public class RoundRobinServerManager : IServerManager
- {
- private readonly object _lock = new object();
-
- private List<Server> _servers;
- private Queue<Server> _serverQueue;
- private HashSet<Server> _blackListed;
-
- public RoundRobinServerManager(IConnectionBuilder builder)
- {
- _servers = new List<Server>(builder.Servers);
- _serverQueue = new Queue<Server>(_servers);
- _blackListed = new HashSet<Server>();
- }
-
- private bool IsBlackListed(Server server)
- {
- return _blackListed.Contains(server);
- }
-
- #region IServerManager Members
-
- public bool HasNext
- {
- get { lock (_lock) { return _serverQueue.Count > 0; } }
- }
-
- public Server Next()
- {
- Server server = null;
-
- lock (_lock)
- {
- if (_serverQueue.Count > 0)
- {
- server = _serverQueue.Dequeue();
- _serverQueue.Enqueue(server);
- }
- }
-
- return server;
- }
-
- public void Add(Server server)
- {
- lock (_lock)
- {
- _servers.Add(server);
- _serverQueue.Enqueue(server);
- }
- }
-
- public void ErrorOccurred(Server server, Exception exc = null)
- {
- Debug.WriteLineIf(exc != null, exc, "connection");
- BlackList(server);
- }
-
- public void BlackList(Server server)
- {
- Debug.WriteLine(server + " has been blacklisted", "connection");
- lock (_lock)
- {
- if (_blackListed.Add(server))
- {
- _serverQueue.Clear();
- foreach (Server srv in _servers)
- {
- if (!IsBlackListed(srv))
- {
- _serverQueue.Enqueue(srv);
- }
- }
- }
- }
- }
-
- public void Remove(Server server)
- {
- lock (_lock)
- {
- _servers.Remove(server);
- _serverQueue = new Queue<Server>();
- _blackListed.RemoveWhere(x => x == server);
-
- foreach (var s in _servers)
- {
- if (!_blackListed.Contains(s))
- _serverQueue.Enqueue(s);
- }
- }
- }
-
- #endregion
-
- #region IEnumerable<Server> Members
-
- public IEnumerator<Server> GetEnumerator()
- {
- return _servers.GetEnumerator();
- }
-
- #endregion
-
- #region IEnumerable Members
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
- }
+ public class RoundRobinServerManager : IServerManager
+ {
+ private readonly object _lock = new object();
+ private List<Server> _servers;
+ private Queue<Server> _serverQueue;
+ private HashSet<Server> _blackListed;
+ private Timer _recoveryTimer;
+
+ public RoundRobinServerManager(IConnectionBuilder builder)
+ {
+ _servers = new List<Server>(builder.Servers);
+ _serverQueue = new Queue<Server>(_servers);
+ _blackListed = new HashSet<Server>();
+
+ _recoveryTimer = new Timer(o => ServerRecover(), null, 30000L, 30000L);
+ }
+
+ private void ServerRecover()
+ {
+ if (_blackListed.Count == 0)
+ return;
+
+ var clonedBlackList = (HashSet<Server>)null;
+
+ lock (_lock)
+ clonedBlackList = new HashSet<Server>(this._blackListed);
+
+ foreach (var server in clonedBlackList)
+ {
+ var connection = new Connection(server, ConnectionType.Simple, 1024);
+
+ try
+ {
+ connection.Open();
+
+ lock (_lock)
+ _blackListed.Remove(server);
+ }
+ catch { }
+ finally
+ {
+ connection.Close();
+ }
+ }
+ }
+
+ #region IServerManager Members
+
+ public bool HasNext
+ {
+ get { lock (_lock) { return _serverQueue.Count > 0; } }
+ }
+
+ public Server Next()
+ {
+ Server server = null;
+
+ lock (_lock)
+ {
+ if (_serverQueue.Count > 0)
+ {
+ server = _serverQueue.Dequeue();
+ _serverQueue.Enqueue(server);
+ }
+ }
+
+ return server;
+ }
+
+ public void Add(Server server)
+ {
+ lock (_lock)
+ {
+ _servers.Add(server);
+ _serverQueue.Enqueue(server);
+ }
+ }
+
+ public void ErrorOccurred(Server server, Exception exc = null)
+ {
+ Debug.WriteLineIf(exc != null, exc, "connection");
+ Debug.WriteLine(server + " has been blacklisted", "connection");
+
+ lock (_lock)
+ {
+ if (_blackListed.Add(server))
+ RefreshServerQueue();
+ }
+ }
+
+ public void Remove(Server server)
+ {
+ Debug.WriteLine(server + " has been removed", "connection");
+ lock (_lock)
+ {
+ _servers.Remove(server);
+ _blackListed.RemoveWhere(x => x == server);
+
+ RefreshServerQueue();
+ }
+ }
+
+ private void RefreshServerQueue()
+ {
+ _serverQueue.Clear();
+ foreach (var s in _servers)
+ {
+ if (!_blackListed.Contains(s))
+ _serverQueue.Enqueue(s);
+ }
+ }
+
+ #endregion
+
+ #region IEnumerable<Server> Members
+
+ public IEnumerator<Server> GetEnumerator()
+ {
+ return _servers.GetEnumerator();
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ #endregion
+ }
}
View
21 src/Connections/Server.cs
@@ -2,7 +2,7 @@
namespace FluentCassandra.Connections
{
- public class Server
+ public class Server : IEquatable<Server>
{
public const int DefaultPort = 9160;
public const int DefaultTimeout = 0;
@@ -24,5 +24,24 @@ public override string ToString()
{
return String.Concat(Host, ":", Port, ",", Timeout, " secs");
}
+
+ #region IEquatable<Server> Members
+
+ public bool Equals(Server other)
+ {
+ return other != null && Host == other.Host && Port == other.Port;
+ }
+
+ #endregion
+
+ public override bool Equals(object obj)
+ {
+ return obj is Server && Equals((Server)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Host.GetHashCode() + Port.GetHashCode();
+ }
}
}
View
2  src/Operations/BatchMutate.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
namespace FluentCassandra.Operations
{
View
2  src/Operations/CassandraIndexClauseBuilder.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
-using Cassandra = Apache.Cassandra;
+using Cassandra = FluentCassandra.Apache.Cassandra;
using FluentCassandra.Types;
namespace FluentCassandra.Operations
View
14 src/Operations/CassandraOperationException.cs
@@ -1,6 +1,7 @@
using System;
using System.Linq;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
+using FluentCassandra.Thrift.Transport;
namespace FluentCassandra.Operations
{
@@ -20,5 +21,14 @@ public CassandraOperationException(UnavailableException exc)
public CassandraOperationException(TimedOutException exc)
: base("Connection to Cassandra has timed out.", exc) { }
+
+ public CassandraOperationException(TimeoutException exc)
+ : base("Connection to Cassandra has timed out.", exc) { }
+
+ public CassandraOperationException(TTransportException exc)
+ : base(exc.Message, exc) { }
+
+ public CassandraOperationException(Exception exc)
+ : base(exc.Message, exc) { }
}
-}
+}
View
2  src/Operations/GetSuperColumn.cs
@@ -1,6 +1,6 @@
using System;
using FluentCassandra.Types;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
namespace FluentCassandra.Operations
{
View
2  src/Operations/Helper.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
using FluentCassandra.Types;
using System.IO;
using System.IO.Compression;
View
43 src/Operations/Operation.cs
@@ -1,13 +1,18 @@
using System;
using System.Diagnostics;
-using Apache.Cassandra;
+using FluentCassandra.Apache.Cassandra;
+using FluentCassandra.Thrift.Transport;
namespace FluentCassandra.Operations
{
public abstract class Operation<TResult>
{
+ private int _executionCount;
+
public Operation()
{
+ _executionCount = 0;
+
HasError = false;
}
@@ -15,10 +20,18 @@ public Operation()
public CassandraSession Session { get; set; }
public bool HasError { get; protected set; }
- public CassandraException Error { get; protected set; }
+ public CassandraOperationException Error { get; protected set; }
public virtual bool TryExecute(out TResult result)
{
+ if (_executionCount > Session.ConnectionBuilder.MaxRetries)
+ {
+ result = default(TResult);
+ return !HasError;
+ }
+
+ _executionCount++;
+
try
{
result = Execute();
@@ -40,24 +53,38 @@ public virtual bool TryExecute(out TResult result)
}
catch (UnavailableException exc)
{
- ExceptionOccurred(new CassandraOperationException(exc));
- result = default(TResult);
+ ExceptionOccuredRetryExecution(new CassandraOperationException(exc), out result);
+ }
+ catch (TimeoutException exc)
+ {
+ ExceptionOccuredRetryExecution(new CassandraOperationException(exc), out result);
}
catch (TimedOutException exc)
{
- ExceptionOccurred(new CassandraOperationException(exc));
- result = default(TResult);
+ ExceptionOccuredRetryExecution(new CassandraOperationException(exc), out result);
+ }
+ catch (TTransportException exc)
+ {
+ ExceptionOccuredRetryExecution(new CassandraOperationException(exc), out result);
}
catch (Exception exc)
{
- ExceptionOccurred(new CassandraException(exc.Message, exc));
+ ExceptionOccurred(new CassandraOperationException(exc));
result = default(TResult);
}
return !HasError;
}
- private void ExceptionOccurred(CassandraException exc)
+ private void ExceptionOccuredRetryExecution(CassandraOperationException exc, out TResult result)
+ {
+ ExceptionOccurred(exc);
+ Session.MarkCurrentConnectionAsUnhealthy(exc);
+
+ TryExecute(out result);
+ }
+
+ private void ExceptionOccurred(CassandraOperationException exc)
{
Debug.WriteLine(exc);
View
2  src/Thrift/Collections/THashSet.cs
@@ -25,7 +25,7 @@
using System.Runtime.Serialization;
#endif
-namespace Thrift.Collections
+namespace FluentCassandra.Thrift.Collections
{
#if SILVERLIGHT
[DataContract]
View
2  src/Thrift/Protocol/TBase.cs
@@ -17,7 +17,7 @@
* under the License.
*/
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public interface TBase
{
View
2  src/Thrift/Protocol/TBase64Utils.cs
@@ -19,7 +19,7 @@
using System;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
internal static class TBase64Utils
{
View
4 src/Thrift/Protocol/TBinaryProtocol.cs
@@ -23,9 +23,9 @@
using System;
using System.Text;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Transport;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public class TBinaryProtocol : TProtocol
{
View
4 src/Thrift/Protocol/TCompactProtocol.cs
@@ -23,12 +23,12 @@
using System;
using System.Text;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Transport;
using System.Collections;
using System.IO;
using System.Collections.Generic;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public class TCompactProtocol : TProtocol
{
View
2  src/Thrift/Protocol/TField.cs
@@ -25,7 +25,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public struct TField
{
View
4 src/Thrift/Protocol/TJSONProtocol.cs
@@ -22,10 +22,10 @@
using System.Text;
using System.Collections.Generic;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Transport;
using System.Globalization;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
/// <summary>
/// JSON protocol implementation for thrift.
View
2  src/Thrift/Protocol/TList.cs
@@ -25,7 +25,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public struct TList
{
View
2  src/Thrift/Protocol/TMap.cs
@@ -25,7 +25,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public struct TMap
{
View
2  src/Thrift/Protocol/TMessage.cs
@@ -25,7 +25,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public struct TMessage
{
View
2  src/Thrift/Protocol/TMessageType.cs
@@ -19,7 +19,7 @@
using System;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public enum TMessageType
{
View
4 src/Thrift/Protocol/TProtocol.cs
@@ -23,9 +23,9 @@
using System;
using System.Text;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Transport;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public abstract class TProtocol
{
View
2  src/Thrift/Protocol/TProtocolException.cs
@@ -23,7 +23,7 @@
using System;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public class TProtocolException : Exception
{
View
4 src/Thrift/Protocol/TProtocolFactory.cs
@@ -22,9 +22,9 @@
*/
using System;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Transport;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public interface TProtocolFactory
{
View
2  src/Thrift/Protocol/TProtocolUtil.cs
@@ -23,7 +23,7 @@
using System;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public static class TProtocolUtil
{
View
2  src/Thrift/Protocol/TSet.cs
@@ -25,7 +25,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public struct TSet
{
View
2  src/Thrift/Protocol/TStruct.cs
@@ -25,7 +25,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public struct TStruct
{
View
2  src/Thrift/Protocol/TType.cs
@@ -23,7 +23,7 @@
using System;
-namespace Thrift.Protocol
+namespace FluentCassandra.Thrift.Protocol
{
public enum TType : byte
{
View
6 src/Thrift/Server/TServer.cs
@@ -22,11 +22,11 @@
*/
using System;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
using System.IO;
-namespace Thrift.Server
+namespace FluentCassandra.Thrift.Server
{
public abstract class TServer
{
View
6 src/Thrift/Server/TSimpleServer.cs
@@ -22,10 +22,10 @@
*/
using System;
-using Thrift.Transport;
-using Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
-namespace Thrift.Server
+namespace FluentCassandra.Thrift.Server
{
/// <summary>
/// Simple single-threaded server for testing
View
6 src/Thrift/Server/TThreadPoolServer.cs
@@ -23,10 +23,10 @@
using System;
using System.Threading;
-using Thrift.Protocol;
-using Thrift.Transport;
+using FluentCassandra.Thrift.Protocol;
+using FluentCassandra.Thrift.Transport;
-namespace Thrift.Server
+namespace FluentCassandra.Thrift.Server
{
/// <summary>