Permalink
Browse files

Merge branch 'master' of https://github.com/managedfusion/fluentcassa…

  • Loading branch information...
2 parents 1c2099e + ab76730 commit 793a0aa29e68f96cefbdae343f2060f203cce9fd Mike Williams committed May 11, 2012
Showing with 1,182 additions and 134 deletions.
  1. +67 −0 .gitattributes
  2. +2 −1 .gitignore
  3. +18 −1 src/CassandraColumnFamily.cs
  4. +8 −0 src/CassandraColumnFamilySchema.cs
  5. +42 −14 src/Connections/Connection.cs
  6. +47 −23 src/Connections/ConnectionBuilder.cs
  7. +5 −5 src/Connections/ConnectionProviderFactory.cs
  8. +7 −0 src/FluentCassandra.csproj
  9. +1 −1 src/FluentCassandra.nuspec
  10. +1 −1 src/FluentColumnFamily.cs
  11. +1 −2 src/GuidGenerator.cs
  12. +6 −1 src/Linq/CassandraColumnFamily+QueryProvider.cs
  13. +120 −0 src/Linq/CqlObjectQuery.cs
  14. +126 −0 src/Linq/CqlObjectQueryProvider.cs
  15. +63 −38 src/Linq/CqlQueryEvaluator.cs
  16. +10 −0 src/Linq/ICassandraColumnFamilyInfo.cs
  17. +15 −0 src/ObjectSerializer/IObjectSerializer.cs
  18. +18 −0 src/ObjectSerializer/ObjectSerializerConventions.cs
  19. +33 −0 src/ObjectSerializer/ObjectSerializerFactory.cs
  20. +96 −0 src/ObjectSerializer/ReflectionObjectSerializer.cs
  21. +6 −16 src/Operations/ExecuteCqlNonQuery.cs
  22. +8 −18 src/Operations/ExecuteCqlQuery.cs
  23. +50 −1 src/Operations/Helper.cs
  24. +27 −1 src/Types/BytesTypeConverter.cs
  25. +1 −6 src/Types/DateTypeConverter.cs
  26. +17 −0 test/FluentCassandra.Sandbox/Program.cs
  27. +36 −0 test/FluentCassandra.Tests/Bugs/Issue25JavaBigDecimalBinaryConversion.cs
  28. +7 −2 test/FluentCassandra.Tests/FluentCassandra.Tests.csproj
  29. +1 −2 test/FluentCassandra.Tests/Linq/{LinqToCassandraTests.cs → LinqToCqlCassandraTests.cs}
  30. +144 −0 test/FluentCassandra.Tests/Linq/LinqToCqlObjectsCassandraTests.cs
  31. +147 −0 test/FluentCassandra.Tests/Linq/LinqToCqlObjectsTests.cs
  32. +1 −1 test/FluentCassandra.Tests/Linq/{LinqTests.cs → LinqToCqlTests.cs}
  33. +51 −0 test/FluentCassandra.Tests/Operations/CqlTest.cs
View
@@ -0,0 +1,67 @@
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
+
+*.jpg binary
+*.png binary
+*.gif binary
+*.bmp binary
+
+*.aspx text=auto
+*.ascx text=auto
+*.cs text=auto diff=csharp
+*.vb text=auto
+*.c text=auto
+*.cpp text=auto
+*.cxx text=auto
+*.cmd text=auto
+*.h text=auto
+*.hxx text=auto
+*.py text=auto
+*.rb text=auto
+*.java text=auto
+*.html text=auto
+*.htm text=auto
+*.cshtml text=auto
+*.vbhtml text=auto
+*.css text=auto
+*.config text=auto
+*.scss text=auto
+*.sass text=auto
+*.less text=auto
+*.js text=auto
+*.lisp text=auto
+*.clj text=auto
+*.sql text=auto
+*.php text=auto
+*.lua text=auto
+*.m text=auto
+*.asm text=auto
+*.erl text=auto
+*.fs text=auto
+*.fsx text=auto
+*.hs text=auto
+*.msbuild text=auto
+*.xml text=auto
+*.xunit text=auto
+*.targets text
+*.tt text
+*.txt text
+*.coffee text
+*.ruleset text
+*.stylecop text
+*.resx text merge=union
+
+
+*.csproj text=auto merge=union
+*.vbproj text=auto merge=union
+*.fsproj text=auto merge=union
+*.dbproj text=auto merge=union
+*.sln text=auto eol=crlf merge=union
View
@@ -44,8 +44,9 @@ ipch/
*.psess
*.vsp
-# ReSharper is a .NET coding add-in
+# .NET coding add-in
_ReSharper*
+.JustCode*
# Installshield output folder
[Ee]xpress
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using FluentCassandra.ObjectSerializer;
using FluentCassandra.Types;
namespace FluentCassandra
@@ -21,9 +22,13 @@ public CassandraColumnFamily(CassandraContext context, string columnFamily)
public partial class CassandraColumnFamily : BaseCassandraColumnFamily
{
private CassandraColumnFamilySchema _cachedSchema;
+ private ObjectSerializerConventions _conventions;
public CassandraColumnFamily(CassandraContext context, string columnFamily)
- : base(context, columnFamily) { }
+ : base(context, columnFamily)
+ {
+ _conventions = new ObjectSerializerConventions();
+ }
public FluentColumnFamily CreateRecord(CassandraObject key)
{
@@ -33,6 +38,18 @@ public FluentColumnFamily CreateRecord(CassandraObject key)
return new FluentColumnFamily(key, FamilyName, GetSchema());
}
+ public ObjectSerializerConventions ObjectConventions
+ {
+ get { return _conventions; }
+ set
+ {
+ if (value == null)
+ throw new ArgumentNullException("value");
+
+ _conventions = value;
+ }
+ }
+
public override CassandraColumnFamilySchema GetSchema()
{
var schema = Context.Keyspace.GetColumnFamilySchema(FamilyName);
@@ -10,8 +10,16 @@ public class CassandraColumnFamilySchema
{
public static readonly AsciiType DefaultKeyName = "KEY";
+#if DEBUG
+ private CfDef _def;
+#endif
+
public CassandraColumnFamilySchema(CfDef def)
{
+#if DEBUG
+ _def = def;
+#endif
+
var familyType = ColumnType.Standard;
Enum.TryParse<ColumnType>(def.Column_type, out familyType);
@@ -12,31 +12,35 @@ namespace FluentCassandra.Connections
/// <see href="http://github.com/robconery/NoRM/tree/master/NoRM/Connections/"/>
public class Connection : IConnection, IDisposable
{
- private bool _disposed;
+ private readonly ConnectionType _connectionType;
+ private readonly int _bufferSize;
- private TTransport _transport;
- private TProtocol _protocol;
- private Cassandra.Client _client;
+ private readonly TTransport _transport;
+ private readonly TProtocol _protocol;
+ private readonly Cassandra.Client _client;
/// <summary>
///
/// </summary>
/// <param name="builder"></param>
internal Connection(Server server, ConnectionBuilder builder)
{
+ _connectionType = builder.ConnectionType;
+ _bufferSize = builder.BufferSize;
+
Created = DateTime.Now;
Server = server;
var socket = new TSocket(server.Host, server.Port, server.Timeout * 1000);
- switch(builder.ConnectionType)
+ switch (_connectionType)
{
case ConnectionType.Simple:
_transport = socket;
break;
case ConnectionType.Buffered:
- _transport = new TBufferedTransport(socket, builder.BufferSize);
+ _transport = new TBufferedTransport(socket, _bufferSize);
break;
case ConnectionType.Framed:
@@ -71,7 +75,17 @@ public Server Server
/// </summary>
public bool IsOpen
{
- get { return _transport.IsOpen; }
+ get
+ {
+ lock (_transport)
+ {
+ if (_transport == null)
+ return false;
+
+ try { return _transport.IsOpen; }
+ catch { return false; }
+ }
+ }
}
/// <summary>
@@ -82,7 +96,8 @@ public void Open()
if (IsOpen)
return;
- _transport.Open();
+ lock (_transport)
+ _transport.Open();
}
/// <summary>
@@ -93,10 +108,11 @@ public void Close()
if (!IsOpen)
return;
- _transport.Close();
+ lock (_transport)
+ _transport.Close();
}
- public void SetKeyspace(string keyspace)
+ public void SetKeyspace(string keyspace)
{
Client.set_keyspace(keyspace);
}
@@ -117,6 +133,17 @@ public override string ToString()
return String.Format("{0}/{1}", Server, Created);
}
+ #region IDisposable Members
+
+ /// <summary>
+ ///
+ /// </summary>
+ public bool WasDisposed
+ {
+ get;
+ private set;
+ }
+
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
@@ -132,12 +159,11 @@ public void Dispose()
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
- if (_disposed) {
+ if (WasDisposed)
return;
- }
Close();
- _disposed = true;
+ WasDisposed = true;
}
/// <summary>
@@ -148,5 +174,7 @@ protected virtual void Dispose(bool disposing)
{
Dispose(false);
}
+
+ #endregion
}
-}
+}
@@ -34,6 +34,26 @@ 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, bool compressCqlQueries = false, string username = null, string password = null)
+ {
+ Keyspace = keyspace;
+ Servers = new List<Server>() { server };
+ ConnectionTimeout = TimeSpan.FromSeconds(server.Timeout);
+ Pooling = pooling;
+ MinPoolSize = minPoolSize;
+ MaxPoolSize = maxPoolSize;
+ ConnectionLifetime = TimeSpan.FromSeconds(connectionLifetime);
+ ConnectionType = connectionType;
+ BufferSize = bufferSize;
+ ReadConsistency = read;
+ WriteConsistency = write;
+ CompressCqlQueries = compressCqlQueries;
+ Username = username;
+ Password = password;
+
+ ConnectionString = GetConnectionString();
+ }
+
/// <summary>
///
/// </summary>
@@ -72,27 +92,6 @@ private void InitializeConnectionString(string connectionString)
#endregion
- #region ConnectionTimeout
-
- if (!pairs.ContainsKey("Connection Timeout"))
- {
- ConnectionTimeout = TimeSpan.Zero;
- }
- else
- {
- int connectionTimeout;
-
- if (!Int32.TryParse(pairs["Connection Timeout"], out connectionTimeout))
- throw new CassandraException("Connection Timeout is not valid.");
-
- if (connectionTimeout < 0)
- connectionTimeout = 0;
-
- ConnectionTimeout = TimeSpan.FromSeconds(connectionTimeout);
- }
-
- #endregion
-
#region Server
Servers = new List<Server>();
@@ -184,6 +183,27 @@ private void InitializeConnectionString(string connectionString)
#endregion
+ #region ConnectionTimeout
+
+ if (!pairs.ContainsKey("Connection Timeout"))
+ {
+ ConnectionTimeout = TimeSpan.Zero;
+ }
+ else
+ {
+ int connectionTimeout;
+
+ if (!Int32.TryParse(pairs["Connection Timeout"], out connectionTimeout))
+ throw new CassandraException("Connection Timeout is not valid.");
+
+ if (connectionTimeout < 0)
+ connectionTimeout = 0;
+
+ ConnectionTimeout = TimeSpan.FromSeconds(connectionTimeout);
+ }
+
+ #endregion
+
#region ConnectionLifetime
if (!pairs.ContainsKey("Connection Lifetime"))
@@ -281,7 +301,7 @@ private void InitializeConnectionString(string connectionString)
if (!pairs.ContainsKey("Compress CQL Queries"))
{
- CompressCqlQueries = true;
+ CompressCqlQueries = false;
}
else
{
@@ -319,16 +339,20 @@ private string GetConnectionString()
b.AppendFormat(format, "Keyspace", Keyspace);
b.AppendFormat(format, "Server", String.Join(",", Servers));
- b.AppendFormat(format, "Connection Timeout", Convert.ToInt32(ConnectionTimeout.TotalSeconds));
+
b.AppendFormat(format, "Pooling", Pooling);
b.AppendFormat(format, "Min Pool Size", MinPoolSize);
b.AppendFormat(format, "Max Pool Size", MaxPoolSize);
+ b.AppendFormat(format, "Connection Timeout", Convert.ToInt32(ConnectionTimeout.TotalSeconds));
b.AppendFormat(format, "Connection Lifetime", Convert.ToInt32(ConnectionLifetime.TotalSeconds));
b.AppendFormat(format, "Connection Type", ConnectionType);
b.AppendFormat(format, "Buffer Size", BufferSize);
b.AppendFormat(format, "Read", ReadConsistency);
b.AppendFormat(format, "Write", WriteConsistency);
+
+ b.AppendFormat(format, "Compress CQL Queries", CompressCqlQueries);
+
b.AppendFormat(format, "Username", Username);
b.AppendFormat(format, "Password", Password);
Oops, something went wrong.

0 comments on commit 793a0aa

Please sign in to comment.