Ejemplo n.º 1
0
        public SqlDynamicStorage(string tableName, string connectionString, IConcurrencyControl concurrency, IKeyConverter <TKey> keyConverter)
        {
            SqlMapper.AddTypeMap(typeof(DateTime), DbType.DateTime2);

            _tableName        = tableName;
            _connectionString = connectionString;
            _cc               = concurrency;
            _keyConverter     = keyConverter;
            _defaultSelection = new[] { new StorageSelection <TKey, TEntry, IDynamicStorage <TKey, TEntry> >(this) };
        }
 internal ConcurrencyControlToken(SynchronizationContext context, Thread granteeThread, IConcurrencyControl control, Int32 identifier, TimeSpan expirationThreshold, Stopwatch expirationStopwatch)
 {
     AttachedTasks       = new List <Task>();
     Context             = context;
     Control             = control;
     ExpirationThreshold = expirationThreshold;
     ExpirationStopwatch = expirationStopwatch;
     GranteeThread       = granteeThread;
     Identifier          = identifier;
 }
Ejemplo n.º 3
0
        public AtsVolumeStorage(string tableName, string connectionString, IConcurrencyControl concurrency, IPartitionProvider <TKey> provider, IKeyConverter <TKey> keyConverter)
        {
            _cc                   = concurrency;
            _tableName            = tableName;
            _account              = CloudStorageAccount.Parse(connectionString);
            _client               = _account.CreateCloudTableClient();
            _partitioningProvider = provider;
            _keyConverter         = keyConverter;
            _defaultSelection     = new[] { new StorageSelection <TKey, TEntry, IStorage <TKey, TEntry> >(this) };

            _client.DefaultRequestOptions.PayloadFormat = TablePayloadFormat.JsonNoMetadata;
        }
Ejemplo n.º 4
0
        public InfluxStorage(Uri endpoint, string database, string username, string password, IConcurrencyControl concurrency, IKeyConverter <TKey> keyConverter)
        {
            _client   = new InfluxClient(endpoint, username, password);
            _database = database;

            _client.DefaultQueryOptions.Precision = TimestampPrecision.Nanosecond;
            _client.DefaultWriteOptions.Precision = TimestampPrecision.Nanosecond;

            _keyConverter = keyConverter;
            _cc           = concurrency;

            _defaultSelection = new[] { new StorageSelection <TKey, TEntry, IStorage <TKey, TEntry> >(this) };
        }
        public void Test_NotLockedIfLockDurationExceeded()
        {
            //---------------Set up test pack-------------------
            ContactPersonPessimisticLockingDB cp = CreateSavedContactPersonPessimisticLocking();
            IConcurrencyControl concurrCntrl     = cp.ConcurrencyControl();

            //Create Lock
            concurrCntrl.CheckConcurrencyBeforeBeginEditing();
            int lockDuration = 15;

            UpdateDatabaseLockAsExpired(lockDuration);
            //---------------Execute Test ----------------------

            concurrCntrl.CheckConcurrencyBeforeBeginEditing();

            //---------------Test Result -----------------------
            //Should not raise an error since the lock duration has been exceeded.
        }
        public void Test_ThrowErrorIfCheckConcurrencyBeforeEditingTwice()
        {
            //---------------Set up test pack-------------------
            ContactPersonPessimisticLockingDB cp = CreateSavedContactPersonPessimisticLocking();
            //---------------Execute Test ----------------------
            IConcurrencyControl concurrCntrl = cp.ConcurrencyControl();

            concurrCntrl.CheckConcurrencyBeforeBeginEditing();
            try
            {
                concurrCntrl.CheckConcurrencyBeforeBeginEditing();
                Assert.Fail();
            }
            //---------------Test Result -----------------------
            catch (BusObjPessimisticConcurrencyControlException ex)
            {
                Assert.IsTrue(
                    ex.Message.Contains(
                        "You cannot begin edits on the 'ContactPersonPessimisticLockingDB', as another user has started edits and therefore locked to this record."));
            }
        }
        public void Test_ThrowErrorIfObjectDeletedPriorToBeginEdits()
        {
            //---------------Set up test pack-------------------
            ContactPersonPessimisticLockingDB cp = CreateSavedContactPersonPessimisticLocking();

            //---------------Execute Test ----------------------
            ContactPerson.DeleteAllContactPeople();
            try
            {
                IConcurrencyControl concurrCntrl = cp.ConcurrencyControl();
                concurrCntrl.CheckConcurrencyBeforeBeginEditing();
                Assert.Fail();
            }
            //---------------Test Result -----------------------
            catch (BusObjDeleteConcurrencyControlException ex)
            {
                Assert.IsTrue(
                    ex.Message.Contains(
                        "You cannot save the changes to 'ContactPersonPessimisticLockingDB', as another user has deleted the record"));
            }
        }
Ejemplo n.º 8
0
        public CosmosTablesStorage(string tableName, string connectionString, int throughputUnits, IConcurrencyControl concurrency, IPartitionProvider <TKey> partitioningProvider, ITableProvider tableProvider, IKeyConverter <TKey> keyConverter)
        {
            _cc        = concurrency;
            _tableName = tableName;
            _account   = CloudStorageAccount.Parse(connectionString);
            var policy = new TableConnectionPolicy
            {
                EnableEndpointDiscovery             = true,
                MaxConnectionLimit                  = 1000,
                MaxRetryAttemptsOnThrottledRequests = 5,
                MaxRetryWaitTimeInSeconds           = 10,
                UseDirectMode  = false,
                UseTcpProtocol = false
            };

            _client = _account.CreateCloudTableClient(policy, ConsistencyLevel.Eventual);
            _partitioningProvider = partitioningProvider;
            _tableProvider        = tableProvider;
            _keyConverter         = keyConverter;
            _defaultSelection     = new[] { new StorageSelection <TKey, TEntry, IStorage <TKey, TEntry> >(this) };
            _tables = new Dictionary <string, CloudTable>();
            _client.DefaultRequestOptions.PayloadFormat = TablePayloadFormat.JsonNoMetadata;
            _throughputUnits = throughputUnits;
        }
Ejemplo n.º 9
0
 public AtsVolumeStorage(string tableName, string connectionString, IConcurrencyControl concurrency, IPartitionProvider <TKey> provider)
     : this(tableName, connectionString, concurrency, provider, DefaultKeyConverter <TKey> .Current)
 {
 }
Ejemplo n.º 10
0
 public CosmosTablesStorage(string tableName, string connectionString, IConcurrencyControl concurrency)
     : this(tableName, connectionString, DefaultThroughputUnits, concurrency, new YearlyPartitioningProvider <TKey>(), new YearlyTableProvider())
 {
 }
Ejemplo n.º 11
0
 public CosmosTablesStorage(string tableName, string connectionString, int throughputUnits, IConcurrencyControl concurrency, IPartitionProvider <TKey> partitioningProvider, ITableProvider tableProvider)
     : this(tableName, connectionString, throughputUnits, concurrency, partitioningProvider, tableProvider, DefaultKeyConverter <TKey> .Current)
 {
 }
Ejemplo n.º 12
0
 public InfluxStorage(Uri endpoint, string database, IConcurrencyControl concurrency)
     : this(endpoint, database, null, null, concurrency, DefaultKeyConverter <TKey> .Current)
 {
 }
Ejemplo n.º 13
0
 public InfluxStorage(Uri endpoint, string database, string username, string password, IConcurrencyControl concurrency)
     : this(endpoint, database, username, password, concurrency, DefaultKeyConverter <TKey> .Current)
 {
 }
Ejemplo n.º 14
0
 public SqlDynamicStorage(string tableName, string connectionString, IConcurrencyControl concurrency)
     : this(tableName, connectionString, concurrency, DefaultKeyConverter <TKey> .Current)
 {
 }
Ejemplo n.º 15
0
 public AtsDynamicStorage(string tableName, string connectionString, IConcurrencyControl concurrency, IPartitionProvider <TKey> partitioningProvider, ITableProvider tableProvider)
     : this(tableName, connectionString, concurrency, partitioningProvider, tableProvider, DefaultKeyConverter <TKey> .Current)
 {
 }
Ejemplo n.º 16
0
 public AtsDynamicStorage(string tableName, string connectionString, IConcurrencyControl concurrency)
     : this(tableName, connectionString, concurrency, new YearlyPartitioningProvider <TKey>(), new YearlyTableProvider())
 {
 }
Ejemplo n.º 17
0
 public InfluxTypedStorage(Uri endpoint, string database, IConcurrencyControl concurrency, ITypedKeyStorage <TKey, TMeasureType> typeStorage)
     : this(endpoint, database, null, null, concurrency, DefaultKeyConverter <TKey> .Current, typeStorage)
 {
 }