You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by fl...@apache.org on 2017/09/14 10:37:06 UTC
[1/4] tinkerpop git commit: Add handling for closed connections
Repository: tinkerpop
Updated Branches:
refs/heads/tp32 736cb261c -> 9402e4e43
Add handling for closed connections
Closed connections are not returned to the ConnectionPool as the client cannot send any further requests with them. Additionally, the host is considered to be unavailable when a connection was closed and all other connections are closed and removed from the ConnectionPool. This is in line with the handling for closed connection in gremlin-driver.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/98e4e1b8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/98e4e1b8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/98e4e1b8
Branch: refs/heads/tp32
Commit: 98e4e1b8201f50e1f34458a82c20f2737aa6ae53
Parents: 397158a
Author: florianhockmann <fl...@apache.org>
Authored: Sat Sep 2 17:54:39 2017 +0200
Committer: florianhockmann <fl...@apache.org>
Committed: Sat Sep 2 17:54:39 2017 +0200
----------------------------------------------------------------------
.../src/Gremlin.Net/Driver/Connection.cs | 2 +
.../src/Gremlin.Net/Driver/ConnectionPool.cs | 62 ++++++++++++++------
.../Gremlin.Net/Driver/WebSocketConnection.cs | 2 +
3 files changed, 47 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98e4e1b8/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
index 126b461..dbbd375 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
@@ -68,6 +68,8 @@ namespace Gremlin.Net.Driver
await _webSocketConnection.CloseAsync().ConfigureAwait(false);
}
+ public bool IsOpen => _webSocketConnection.IsOpen;
+
private async Task SendAsync(RequestMessage message)
{
var graphsonMsg = _graphSONWriter.WriteObject(message);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98e4e1b8/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
index 945e5e4..779815a 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
@@ -55,7 +55,7 @@ namespace Gremlin.Net.Driver
if (connection == null)
connection = await CreateNewConnectionAsync().ConfigureAwait(false);
- return new ProxyConnection(connection, AddConnection);
+ return new ProxyConnection(connection, AddConnectionIfOpen);
}
private async Task<Connection> CreateNewConnectionAsync()
@@ -66,6 +66,17 @@ namespace Gremlin.Net.Driver
return newConnection;
}
+ private void AddConnectionIfOpen(Connection connection)
+ {
+ if (!connection.IsOpen)
+ {
+ ConsiderUnavailable();
+ connection.Dispose();
+ return;
+ }
+ AddConnection(connection);
+ }
+
private void AddConnection(Connection connection)
{
lock (_connectionsLock)
@@ -74,6 +85,36 @@ namespace Gremlin.Net.Driver
}
}
+ private void ConsiderUnavailable()
+ {
+ CloseAndRemoveAllConnections();
+ }
+
+ private void CloseAndRemoveAllConnections()
+ {
+ lock (_connectionsLock)
+ {
+ TeardownAsync().WaitUnwrap();
+ RemoveAllConnections();
+ }
+ }
+
+ private void RemoveAllConnections()
+ {
+ while (!_connections.IsEmpty)
+ {
+ _connections.TryTake(out var connection);
+ connection.Dispose();
+ }
+ }
+
+ private async Task TeardownAsync()
+ {
+ var closeTasks = new List<Task>(_connections.Count);
+ closeTasks.AddRange(_connections.Select(conn => conn.CloseAsync()));
+ await Task.WhenAll(closeTasks).ConfigureAwait(false);
+ }
+
#region IDisposable Support
private bool _disposed;
@@ -89,27 +130,10 @@ namespace Gremlin.Net.Driver
if (!_disposed)
{
if (disposing)
- lock (_connectionsLock)
- {
- if (_connections != null && !_connections.IsEmpty)
- {
- TeardownAsync().WaitUnwrap();
-
- foreach (var conn in _connections)
- conn.Dispose();
- }
- }
+ CloseAndRemoveAllConnections();
_disposed = true;
}
}
-
- private async Task TeardownAsync()
- {
- var closeTasks = new List<Task>(_connections.Count);
- closeTasks.AddRange(_connections.Select(conn => conn.CloseAsync()));
- await Task.WhenAll(closeTasks).ConfigureAwait(false);
- }
-
#endregion
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98e4e1b8/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs
index 5a20759..9672606 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs
@@ -71,6 +71,8 @@ namespace Gremlin.Net.Driver
}
}
+ public bool IsOpen => _client.State == WebSocketState.Open;
+
#region IDisposable Support
private bool _disposed;
[2/4] tinkerpop git commit: Update NuGet packages of test projects
Posted by fl...@apache.org.
Update NuGet packages of test projects
One of the dependencies (Castle.Core) produced a warning because one of its dependencies couldn't be found in the specified version. This doesn't occur anymore for the updated version.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d9a4f79f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d9a4f79f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d9a4f79f
Branch: refs/heads/tp32
Commit: d9a4f79f7c568761461dc11d22fbf907578f7d14
Parents: 98e4e1b
Author: florianhockmann <fl...@apache.org>
Authored: Sat Sep 2 18:00:52 2017 +0200
Committer: florianhockmann <fl...@apache.org>
Committed: Sat Sep 2 18:00:52 2017 +0200
----------------------------------------------------------------------
.../Gremlin.Net.IntegrationTest.csproj | 2 +-
.../test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d9a4f79f/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj
index fed1c49..9d00a5a 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj
@@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.1" />
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d9a4f79f/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
index db36085..41617be 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
@@ -13,8 +13,8 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
- <PackageReference Include="Moq" Version="4.7.1" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
+ <PackageReference Include="Moq" Version="4.7.99" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="OpenCover" Version="4.6.519" />
[3/4] tinkerpop git commit: Improve closing and removing of
connections in ConnectionPool
Posted by fl...@apache.org.
Improve closing and removing of connections in ConnectionPool
This resolves a possible race condition.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ef658752
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ef658752
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ef658752
Branch: refs/heads/tp32
Commit: ef658752099e127fa1f4e3e6737a0b6f81270622
Parents: d9a4f79
Author: florianhockmann <fl...@apache.org>
Authored: Wed Sep 6 20:53:11 2017 +0200
Committer: florianhockmann <fl...@apache.org>
Committed: Wed Sep 6 20:53:11 2017 +0200
----------------------------------------------------------------------
gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ef658752/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
index 779815a..9501686 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
@@ -101,18 +101,15 @@ namespace Gremlin.Net.Driver
private void RemoveAllConnections()
{
- while (!_connections.IsEmpty)
+ while (_connections.TryTake(out var connection))
{
- _connections.TryTake(out var connection);
connection.Dispose();
}
}
private async Task TeardownAsync()
{
- var closeTasks = new List<Task>(_connections.Count);
- closeTasks.AddRange(_connections.Select(conn => conn.CloseAsync()));
- await Task.WhenAll(closeTasks).ConfigureAwait(false);
+ await Task.WhenAll(_connections.Select(c => c.CloseAsync())).ConfigureAwait(false);
}
#region IDisposable Support
[4/4] tinkerpop git commit: Merge branch 'TINKERPOP-1766' into tp32
Posted by fl...@apache.org.
Merge branch 'TINKERPOP-1766' into tp32
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9402e4e4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9402e4e4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9402e4e4
Branch: refs/heads/tp32
Commit: 9402e4e4384d7062f87f143a6ffbfddaa13781df
Parents: 736cb26 ef65875
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Thu Sep 14 12:35:59 2017 +0200
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Thu Sep 14 12:35:59 2017 +0200
----------------------------------------------------------------------
.../src/Gremlin.Net/Driver/Connection.cs | 2 +
.../src/Gremlin.Net/Driver/ConnectionPool.cs | 59 +++++++++++++-------
.../Gremlin.Net/Driver/WebSocketConnection.cs | 2 +
.../Gremlin.Net.IntegrationTest.csproj | 2 +-
.../Gremlin.Net.UnitTest.csproj | 4 +-
5 files changed, 47 insertions(+), 22 deletions(-)
----------------------------------------------------------------------