Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions VoltDB.Data.Client/Connections/ConnectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ public ConnectionSettings[] ClusterConnectionSettings
// the endpoint for each IP address found in the original connection string.
// - Build and return the array
return this.HostAddresses.Select(a => new ConnectionSettings(connectionString)
{
HostList = a.ToString()
}
{
HostList = a.ToString()
}
).ToArray();
}
}
Expand Down Expand Up @@ -516,6 +516,12 @@ public bool AllowAdhocQueries
}
static readonly string CS_DisplayName_AllowAdhocQueries = Resources.CS_DisplayName_AllowAdhocQueries;

/// <summary>Gets or sets the use pooling.</summary>
public bool? UsePooling { get; set; }

/// <summary>Gets or sets the maximum connections in pool.</summary>
public int MaxConnectionsInPool { get; set; }

/// <summary>
/// Gets or sets a value indicating how many requests may be queued up in "pending" state before blocking
/// execution on all calls (to prevent degradation of performance through server 'fire-hosing').
Expand Down
653 changes: 651 additions & 2 deletions VoltDB.Data.Client/Connections/ProcedureAccess.cs

Large diffs are not rendered by default.

396 changes: 396 additions & 0 deletions VoltDB.Data.Client/Connections/ProcedureWrapper[TResult,T1,...,T36].cs

Large diffs are not rendered by default.

402 changes: 402 additions & 0 deletions VoltDB.Data.Client/Connections/ProcedureWrapper[TResult,T1,...,T37].cs

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions VoltDB.Data.Client/Connections/SnapshotRestoreOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Newtonsoft.Json;

namespace VoltDB.Data.Client.Connections
{
/// <summary>
/// Describes the possible options when restoring a snapshot
/// </summary>
public struct SnapshotRestoreOptions
{
/// <summary>
/// Path of the directory containing the snapshot.
/// </summary>
[JsonProperty("path")]
public string DirectoryPath { get; set; }

/// <summary>
/// Specifies the unique identifier for the snapshot.
/// </summary>
[JsonProperty("nonce")]
public string UniqueId { get; set; }

/// <summary>
/// Specifies tables to include in the snapshot.
/// </summary>
[JsonProperty("tables")]
public string[] Tables { get; set; }

/// <summary>
/// Specifies tables to leave out of the snapshot.
/// </summary>
[JsonProperty("skiptables")]
public string[] Skiptables { get; set; }
}
}
45 changes: 45 additions & 0 deletions VoltDB.Data.Client/Connections/SnapshotSaveOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Newtonsoft.Json;

namespace VoltDB.Data.Client.Connections
{
/// <summary>
/// Describes all possible options when creating a snapshot
/// </summary>
public struct SnapshotSaveOptions
{
private string _directoryPath;
/// <summary>
/// Path of the directory containing the snapshot.
/// </summary>
[JsonProperty("uripath")]
public string DirectoryPath
{
get => _directoryPath;
set => _directoryPath = $"file://{value}";
}

/// <summary>
/// Specifies the unique identifier for the snapshot.
/// </summary>
[JsonProperty("nonce")]
public string UniqueId { get; set; }

/// <summary>
/// Specifies whether the snapshot should be synchronous (true) and block other transactions or asynchronous (false).
/// </summary>
[JsonProperty("block")]
public bool Block { get; set; }

/// <summary>
/// Specifies tables to include in the snapshot.
/// </summary>
[JsonProperty("tables")]
public string[] Tables { get; set; }

/// <summary>
/// Specifies tables to leave out of the snapshot.
/// </summary>
[JsonProperty("skiptables")]
public string[] Skiptables { get; set; }
}
}
69 changes: 52 additions & 17 deletions VoltDB.Data.Client/Connections/SystemAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

using System;

using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Xml.Linq;
using Newtonsoft.Json;
using VoltDB.Data.Client.Connections;

// ReSharper disable CheckNamespace
namespace VoltDB.Data.Client
{
/// <summary>
Expand Down Expand Up @@ -68,7 +70,6 @@ public void Shutdown()
this.Executor.Execute<long>(Timeout.Infinite, "@Shutdown");
}
catch (VoltConnectionException) { }
catch (Exception) { throw; }
}

/// <summary>
Expand All @@ -78,14 +79,18 @@ public void Shutdown()
/// <returns>Status of the delete operations.</returns>
public Response<Table> SnapshotDelete(IEnumerable<SnapshotReference> snapshotReferences)
{
var references = snapshotReferences as SnapshotReference[] ?? snapshotReferences.ToArray();

return this.Executor.Execute<Table>(
Timeout.Infinite
, "@SnapshotDelete"
, snapshotReferences.Select(i => i.DirectoryPath).ToArray()
, snapshotReferences.Select(i => i.UniqueId).ToArray()
, references.Select(i => i.DirectoryPath).ToArray()
, references.Select(i => i.UniqueId).ToArray()
);
}



/// <summary>
/// Restores a database from disk.
/// </summary>
Expand All @@ -95,11 +100,26 @@ public Response<Table> SnapshotDelete(IEnumerable<SnapshotReference> snapshotRef
public Response<Table[]> SnapshotRestore(SnapshotReference snapshotReference)
{
return this.Executor.Execute<Table[]>(
Timeout.Infinite
, "@SnapshotRestore"
, snapshotReference.DirectoryPath
, snapshotReference.UniqueId
);
Timeout.Infinite
, "@SnapshotRestore"
, snapshotReference.DirectoryPath
, snapshotReference.UniqueId
);
}

/// <summary>
/// Restores a database from disk.
/// </summary>
/// <param name="options">Key <see cref="SnapshotSaveOptions"/>
/// Describes all possible options when creating a snapshot </param>
/// <returns>Detailed status information on the initiated restore operation.</returns>
public Response<Table> SnapshotRestore(SnapshotRestoreOptions options)
{
var jsonString = JsonConvert.SerializeObject(options);
return this.Executor.Execute<Table>(
Timeout.Infinite
, "@SnapshotRestore"
, jsonString);
}

/// <summary>
Expand All @@ -113,12 +133,27 @@ public Response<Table[]> SnapshotRestore(SnapshotReference snapshotReference)
public Response<Table> SnapshotSave(SnapshotReference snapshotReference, bool blocking)
{
return this.Executor.Execute<Table>(
Timeout.Infinite
, "@SnapshotSave"
, snapshotReference.DirectoryPath
, snapshotReference.UniqueId
, blocking ? 1 : 0
);
Timeout.Infinite
, "@SnapshotSave"
, snapshotReference.DirectoryPath
, snapshotReference.UniqueId
, blocking ? 1 : 0
);
}

/// <summary>
/// Saves the current database contents to disk.
/// </summary>
/// <param name="options">Key <see cref="SnapshotSaveOptions"/>
/// Describes all possible options when creating a snapshot </param>
/// <returns>Detailed status information on the initiated save operation.</returns>
public Response<Table> SnapshotSave(SnapshotSaveOptions options)
{
var jsonString = JsonConvert.SerializeObject(options);
return this.Executor.Execute<Table>(
Timeout.Infinite
, "@SnapshotSave"
, jsonString);
}

/// <summary>
Expand Down Expand Up @@ -255,7 +290,7 @@ public void Resume()
{
this.Executor.Execute<long>(Timeout.Infinite, "@Resume");
}

/// <summary>
/// Promotes the cluster from a replica to a master
/// The cluster will start accepting write transactions
Expand Down
25 changes: 25 additions & 0 deletions VoltDB.Data.Client/DB/IVoltConnection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

namespace VoltDB.Data.Client
{
///<summary>
///The volt connection
///</summary>
public interface IVoltConnection : IDisposable
{
/// <summary>Gets the adhoc.</summary>
AdhocAccess Adhoc { get; }

/// <summary>Gets a value indicating whether this instance is healthy.</summary>
bool IsHealthy { get; }

/// <summary>Gets the procedures.</summary>
ProcedureAccess Procedures { get; }

/// <summary>Gets the system access.</summary>
SystemAccess SystemAccess { get; }

/// <summary>Opens this instance.</summary>
IVoltConnection Open();
}
}
58 changes: 58 additions & 0 deletions VoltDB.Data.Client/DB/VoltConnectionFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;

namespace VoltDB.Data.Client
{
/// <summary>Volt connection factory</summary>
public static class VoltConnectionFactory
{
private static readonly object syncRoot = new object();
private static VoltDBConnectionPool pool;
private static VoltConnectionProxy singleConnectionInstance;

/// <summary>Gets the open connection.</summary>
/// <param name="connectionString">The connection string.</param>
/// <param name="useSingleConnection">if set to <c>true</c> [use single connection].</param>
/// <returns></returns>
public static IVoltConnection GetOpenConnection(
string connectionString,
bool useSingleConnection = false)
{
if (!useSingleConnection)
return GetPool(new ConnectionSettings(connectionString)).GetConnection().Open();
if (singleConnectionInstance == null)
{
lock (syncRoot)
{
if (singleConnectionInstance == null)
singleConnectionInstance = new VoltConnectionProxy(new ConnectionSettings(connectionString), true);
}
}
try
{
singleConnectionInstance.Open();
}
catch (Exception)
{
try
{
if (singleConnectionInstance != null)
singleConnectionInstance.Open();
}
catch (Exception)
{
singleConnectionInstance = (VoltConnectionProxy)null;
throw;
}
}
return (IVoltConnection)singleConnectionInstance;
}

private static VoltDBConnectionPool GetPool(
ConnectionSettings connectionSettings)
{
if (pool == null)
pool = VoltDBConnectionPool.GetInstance(connectionSettings);
return pool;
}
}
}
Loading