Пример #1
0
        public async Task <bool> InsertRow(MembershipEntry entry, TableVersion tableVersion)
        {
            try
            {
                if (logger.IsVerbose)
                {
                    logger.Verbose("InsertRow entry = {0}, table version = {1}", entry.ToFullString(), tableVersion);
                }
                var tableEntry   = Convert(entry, tableManager.DeploymentId);
                var versionEntry = tableManager.CreateTableVersionEntry(tableVersion.Version);

                bool result = await tableManager.InsertSiloEntryConditionally(
                    tableEntry, versionEntry, tableVersion.VersionEtag);

                if (result == false)
                {
                    logger.Warn(ErrorCode.AzureTable_22, String.Format("Insert failed due to contention on the table. Will retry. Entry {0}, table version = {1}", entry.ToFullString(), tableVersion));
                }
                return(result);
            }
            catch (Exception exc)
            {
                logger.Warn(ErrorCode.AzureTable_23, String.Format("Intermediate error inserting entry {0} tableVersion {1} to the table {2}.",
                                                                   entry.ToFullString(), (tableVersion == null ? "null" : tableVersion.ToString()), tableManager.TableName), exc);
                throw;
            }
        }
        public async Task <bool> InsertRow(MembershipEntry entry, TableVersion tableVersion)
        {
            try
            {
                if (logger.IsEnabled(LogLevel.Debug))
                {
                    logger.Debug("InsertRow entry = {0}, table version = {1}", entry.ToFullString(), tableVersion);
                }
                var tableEntry   = Convert(entry, tableManager.DeploymentId);
                var versionEntry = tableManager.CreateTableVersionEntry(tableVersion.Version);

                bool result = await tableManager.InsertSiloEntryConditionally(
                    tableEntry, versionEntry, tableVersion.VersionEtag);

                if (result == false)
                {
                    logger.Warn((int)TableStorageErrorCode.AzureTable_22,
                                $"Insert failed due to contention on the table. Will retry. Entry {entry.ToFullString()}, table version = {tableVersion}");
                }
                return(result);
            }
            catch (Exception exc)
            {
                logger.Warn((int)TableStorageErrorCode.AzureTable_23,
                            $"Intermediate error inserting entry {entry.ToFullString()} tableVersion {(tableVersion == null ? "null" : tableVersion.ToString())} to the table {tableManager.TableName}.", exc);
                throw;
            }
        }
Пример #3
0
        public async Task SiloInstanceTable_Op_InsertSiloEntryConditionally()
        {
            SiloInstanceTableEntry newEntry = manager.CreateTableVersionEntry(0);

            bool didInsert = await manager.InsertSiloEntryConditionally(newEntry, null, null, false)
                             .WithTimeout(AzureTableDefaultPolicies.TableOperationTimeout);

            Assert.IsTrue(didInsert, "Did insert");
        }