public FirebirdConnection( FbConnection connection, PersistentJobQueueProviderCollection queueProviders, FirebirdStorageOptions options) : this(connection, queueProviders, options, true) { }
public FirebirdFetchedJob( IDbConnection connection, FirebirdStorageOptions options, int id, string jobId, string queue) { if (connection == null) { throw new ArgumentNullException("connection"); } if (jobId == null) { throw new ArgumentNullException("jobId"); } if (queue == null) { throw new ArgumentNullException("queue"); } if (options == null) { throw new ArgumentNullException("options"); } _connection = connection; _options = options; Id = id; JobId = jobId; Queue = queue; }
public FirebirdJobQueueMonitoringApi(IDbConnection connection, FirebirdStorageOptions options) { if (connection == null) throw new ArgumentNullException("connection"); if (options == null) throw new ArgumentNullException("options"); _connection = connection; _options = options; }
public ExpirationManager(FirebirdStorage storage, FirebirdStorageOptions options, TimeSpan checkInterval) { if (storage == null) throw new ArgumentNullException("storage"); if (options == null) throw new ArgumentNullException("options"); _options = options; _storage = storage; _checkInterval = checkInterval; }
public FirebirdJobQueueProvider(FirebirdStorageOptions options) { if (options == null) { throw new ArgumentNullException("options"); } _options = options; }
private void Init(string resource, TimeSpan timeout, IDbConnection connection, FirebirdStorageOptions options) { Stopwatch lockAcquiringTime = new Stopwatch(); lockAcquiringTime.Start(); bool tryAcquireLock = true; while (tryAcquireLock) { try { int rowsAffected = -1; using (var trx = _connection.BeginTransaction(IsolationLevel.RepeatableRead)) { rowsAffected = _connection.Execute(string.Format(@" INSERT INTO ""{0}.LOCK"" (resource) SELECT @resource FROM rdb$database WHERE NOT EXISTS ( SELECT 1 FROM ""{0}.LOCK"" WHERE resource = @resource ); ", _options.Prefix), new { resource = resource }, trx); trx.Commit(); } if (rowsAffected > 0) return; } catch (Exception) { } if (lockAcquiringTime.ElapsedMilliseconds > timeout.TotalMilliseconds) tryAcquireLock = false; else { int sleepDuration = (int)(timeout.TotalMilliseconds - lockAcquiringTime.ElapsedMilliseconds); if (sleepDuration > 1000) sleepDuration = 1000; if (sleepDuration > 0) Thread.Sleep(sleepDuration); else tryAcquireLock = false; } } throw new FirebirdDistributedLockException( string.Format( "Could not place a lock on the resource '{0}': {1}.", _resource, "Lock timeout")); }
public static FirebirdStorage UseFirebirdStorage( this IBootstrapperConfiguration configuration, string nameOrConnectionString, FirebirdStorageOptions options) { var storage = new FirebirdStorage(nameOrConnectionString, options); configuration.UseStorage(storage); return(storage); }
public FirebirdDistributedLock(string resource, TimeSpan timeout, IDbConnection connection, FirebirdStorageOptions options) { if (String.IsNullOrEmpty(resource)) throw new ArgumentNullException("resource"); if (connection == null) throw new ArgumentNullException("connection"); if (options == null) throw new ArgumentNullException("options"); _resource = resource; _connection = connection; _options = options; Init(resource, timeout, connection, options); }
public FirebirdWriteOnlyTransaction( FbConnection connection, FirebirdStorageOptions options, PersistentJobQueueProviderCollection queueProviders) { if (connection == null) throw new ArgumentNullException("connection"); if (queueProviders == null) throw new ArgumentNullException("queueProviders"); if (options == null) throw new ArgumentNullException("options"); _connection = connection; _options = options; _queueProviders = queueProviders; }
public FirebirdMonitoringApi( string connectionString, FirebirdStorageOptions options, PersistentJobQueueProviderCollection queueProviders) { if (options == null) { throw new ArgumentNullException("options"); } _connectionString = connectionString; _queueProviders = queueProviders; _options = options; }
public FirebirdJobQueueMonitoringApi(IDbConnection connection, FirebirdStorageOptions options) { if (connection == null) { throw new ArgumentNullException("connection"); } if (options == null) { throw new ArgumentNullException("options"); } _connection = connection; _options = options; }
public FirebirdConnection( FbConnection connection, PersistentJobQueueProviderCollection queueProviders, FirebirdStorageOptions options, bool ownsConnection) { if (connection == null) throw new ArgumentNullException("connection"); if (queueProviders == null) throw new ArgumentNullException("queueProviders"); if (options == null) throw new ArgumentNullException("options"); _connection = connection; _queueProviders = queueProviders; _options = options; OwnsConnection = ownsConnection; }
public ExpirationManager(FirebirdStorage storage, FirebirdStorageOptions options, TimeSpan checkInterval) { if (storage == null) { throw new ArgumentNullException("storage"); } if (options == null) { throw new ArgumentNullException("options"); } _options = options; _storage = storage; _checkInterval = checkInterval; }
/// <summary> /// Initializes a new instance of the <see cref="FirebirdStorage"/> class with /// explicit instance of the <see cref="FbConnection"/> class that will be used /// to query the data. /// </summary> /// <param name="existingConnection">Existing connection</param> /// <param name="options">FirebirdStorageOptions</param> public FirebirdStorage(FbConnection existingConnection, FirebirdStorageOptions options) { if (existingConnection == null) { throw new ArgumentNullException("existingConnection"); } if (options == null) { throw new ArgumentNullException("options"); } //var connectionStringBuilder = new FbConnectionStringBuilder(existingConnection.ConnectionString); //if (connectionStringBuilder.Enlist) throw new ArgumentException("FirebirdSql is not fully compatible with TransactionScope yet, only connections without Enlist = true are accepted."); _existingConnection = existingConnection; _options = new FirebirdStorageOptions(); InitializeQueueProviders(); }
/// <summary> /// Initializes FirebirdStorage from the provided FirebirdStorageOptions and either the provided connection /// string or the connection string with provided name pulled from the application config file. /// </summary> /// <param name="nameOrConnectionString">Either a Firebird connection string or the name of /// a Firebird connection string located in the connectionStrings node in the application config</param> /// <param name="options"></param> /// <exception cref="ArgumentNullException"><paramref name="nameOrConnectionString"/> argument is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="options"/> argument is null.</exception> /// <exception cref="ArgumentException"><paramref name="nameOrConnectionString"/> argument is neither /// a valid Firebird connection string nor the name of a connection string in the application /// config file.</exception> public FirebirdStorage(string nameOrConnectionString, FirebirdStorageOptions options) { if (nameOrConnectionString == null) { throw new ArgumentNullException("nameOrConnectionString"); } if (options == null) { throw new ArgumentNullException("options"); } _options = options; if (IsConnectionString(nameOrConnectionString)) { _connectionString = nameOrConnectionString; } else if (IsConnectionStringInConfiguration(nameOrConnectionString)) { _connectionString = ConfigurationManager.ConnectionStrings[nameOrConnectionString].ConnectionString; } else { throw new ArgumentException( string.Format("Could not find connection string with name '{0}' in application config file", nameOrConnectionString)); } if (options.PrepareSchemaIfNecessary) { var connectionStringBuilder = new FbConnectionStringBuilder(_connectionString); if (!File.Exists(connectionStringBuilder.Database)) { FbConnection.CreateDatabase(_connectionString, 16384, true, false); } using (var connection = CreateAndOpenConnection()) { FirebirdObjectsInstaller.Install(connection); } } InitializeQueueProviders(); }
public FirebirdFetchedJob( IDbConnection connection, FirebirdStorageOptions options, int id, string jobId, string queue) { if (connection == null) throw new ArgumentNullException("connection"); if (jobId == null) throw new ArgumentNullException("jobId"); if (queue == null) throw new ArgumentNullException("queue"); if (options == null) throw new ArgumentNullException("options"); _connection = connection; _options = options; Id = id; JobId = jobId; Queue = queue; }
public FirebirdWriteOnlyTransaction( FbConnection connection, FirebirdStorageOptions options, PersistentJobQueueProviderCollection queueProviders) { if (connection == null) { throw new ArgumentNullException("connection"); } if (queueProviders == null) { throw new ArgumentNullException("queueProviders"); } if (options == null) { throw new ArgumentNullException("options"); } _connection = connection; _options = options; _queueProviders = queueProviders; }
public FirebirdDistributedLock(string resource, TimeSpan timeout, IDbConnection connection, FirebirdStorageOptions options) { if (String.IsNullOrEmpty(resource)) { throw new ArgumentNullException("resource"); } if (connection == null) { throw new ArgumentNullException("connection"); } if (options == null) { throw new ArgumentNullException("options"); } _resource = resource; _connection = connection; _options = options; Init(resource, timeout, connection, options); }
public static IGlobalConfiguration <FirebirdStorage> UseFirebirdStorage( [NotNull] this IGlobalConfiguration configuration, [NotNull] string nameOrConnectionString, [NotNull] FirebirdStorageOptions options) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (nameOrConnectionString == null) { throw new ArgumentNullException("nameOrConnectionString"); } if (options == null) { throw new ArgumentNullException("options"); } var storage = new FirebirdStorage(nameOrConnectionString, options); return(configuration.UseStorage(storage)); }
public FirebirdConnection( FbConnection connection, PersistentJobQueueProviderCollection queueProviders, FirebirdStorageOptions options, bool ownsConnection) { if (connection == null) { throw new ArgumentNullException("connection"); } if (queueProviders == null) { throw new ArgumentNullException("queueProviders"); } if (options == null) { throw new ArgumentNullException("options"); } _connection = connection; _queueProviders = queueProviders; _options = options; OwnsConnection = ownsConnection; }
/// <summary> /// Initializes FirebirdStorage from the provided FirebirdStorageOptions and either the provided connection /// string or the connection string with provided name pulled from the application config file. /// </summary> /// <param name="nameOrConnectionString">Either a Firebird connection string or the name of /// a Firebird connection string located in the connectionStrings node in the application config</param> /// <param name="options"></param> /// <exception cref="ArgumentNullException"><paramref name="nameOrConnectionString"/> argument is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="options"/> argument is null.</exception> /// <exception cref="ArgumentException"><paramref name="nameOrConnectionString"/> argument is neither /// a valid Firebird connection string nor the name of a connection string in the application /// config file.</exception> public FirebirdStorage(string nameOrConnectionString, FirebirdStorageOptions options) { if (nameOrConnectionString == null) throw new ArgumentNullException("nameOrConnectionString"); if (options == null) throw new ArgumentNullException("options"); _options = options; if (IsConnectionString(nameOrConnectionString)) { _connectionString = nameOrConnectionString; } else if (IsConnectionStringInConfiguration(nameOrConnectionString)) { _connectionString = ConfigurationManager.ConnectionStrings[nameOrConnectionString].ConnectionString; } else { throw new ArgumentException( string.Format("Could not find connection string with name '{0}' in application config file", nameOrConnectionString)); } if (options.PrepareSchemaIfNecessary) { var connectionStringBuilder = new FbConnectionStringBuilder(_connectionString); if (!File.Exists(connectionStringBuilder.Database)) FbConnection.CreateDatabase(_connectionString, 16384, true, false); using (var connection = CreateAndOpenConnection()) { FirebirdObjectsInstaller.Install(connection); } } InitializeQueueProviders(); }
public FirebirdJobQueueProvider(FirebirdStorageOptions options) { if (options == null) throw new ArgumentNullException("options"); _options = options; }
/// <summary> /// Initializes a new instance of the <see cref="FirebirdStorage"/> class with /// explicit instance of the <see cref="FbConnection"/> class that will be used /// to query the data. /// </summary> /// <param name="existingConnection">Existing connection</param> /// <param name="options">FirebirdStorageOptions</param> public FirebirdStorage(FbConnection existingConnection, FirebirdStorageOptions options) { if (existingConnection == null) throw new ArgumentNullException("existingConnection"); if (options == null) throw new ArgumentNullException("options"); //var connectionStringBuilder = new FbConnectionStringBuilder(existingConnection.ConnectionString); //if (connectionStringBuilder.Enlist) throw new ArgumentException("FirebirdSql is not fully compatible with TransactionScope yet, only connections without Enlist = true are accepted."); _existingConnection = existingConnection; _options = new FirebirdStorageOptions(); InitializeQueueProviders(); }
public ExpirationManager(FirebirdStorage storage, FirebirdStorageOptions options) : this(storage, options, TimeSpan.FromHours(1)) { }
private void Init(string resource, TimeSpan timeout, IDbConnection connection, FirebirdStorageOptions options) { Stopwatch lockAcquiringTime = new Stopwatch(); lockAcquiringTime.Start(); bool tryAcquireLock = true; while (tryAcquireLock) { try { int rowsAffected = -1; using (var trx = _connection.BeginTransaction(IsolationLevel.RepeatableRead)) { rowsAffected = _connection.Execute(string.Format(@" INSERT INTO ""{0}.LOCK"" (resource) SELECT @resource FROM rdb$database WHERE NOT EXISTS ( SELECT 1 FROM ""{0}.LOCK"" WHERE resource = @resource ); ", _options.Prefix), new { resource = resource }, trx); trx.Commit(); } if (rowsAffected > 0) { return; } } catch (Exception) { } if (lockAcquiringTime.ElapsedMilliseconds > timeout.TotalMilliseconds) { tryAcquireLock = false; } else { int sleepDuration = (int)(timeout.TotalMilliseconds - lockAcquiringTime.ElapsedMilliseconds); if (sleepDuration > 1000) { sleepDuration = 1000; } if (sleepDuration > 0) { Thread.Sleep(sleepDuration); } else { tryAcquireLock = false; } } } throw new FirebirdDistributedLockException( string.Format( "Could not place a lock on the resource '{0}': {1}.", _resource, "Lock timeout")); }