private IEnumerator <IAsyncResult> CreateQueueContainerImpl(string containerName, DateTime?expiryTime, byte[] serviceMetadata, byte[] applicationMetadata, AsyncIteratorContext <IQueueContainer> context) { IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug; object[] objArray = new object[] { containerName, expiryTime, serviceMetadata, applicationMetadata, this.Timeout }; verboseDebug.Log("CreateQueueContainerImpl({0},{1},{2},{3},{4})", objArray); IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <DbQueueContainer>((TimeSpan param0) => { Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer queueContainer = new Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer() { AccountName = this._account.Name, QueueName = containerName, ServiceMetadata = serviceMetadata, Metadata = applicationMetadata }; DbQueueContainer dbQueueContainer = new DbQueueContainer(this, queueContainer); using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { dbContext.QueueContainers.InsertOnSubmit(queueContainer); dbContext.SubmitChanges(); } return(dbQueueContainer); }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageAccount.CreateQueueContainer")); yield return(asyncResult); context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <DbQueueContainer>(asyncResult); }
private IEnumerator <IAsyncResult> DeleteQueueContainerImpl(string containerName, IContainerCondition conditions, AsyncIteratorContext <NoResults> context) { IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug; object[] objArray = new object[] { containerName, this.Timeout }; verboseDebug.Log("DeleteQueueContainerImpl({0},{1})", objArray); IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer queueContainer = new Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer() { AccountName = this._account.Name, QueueName = containerName }; queueContainer = DbQueueContainer.LoadQueueContainer(dbContext, queueContainer); DbQueueContainer.CheckQueueContainerCondition(queueContainer, conditions); dbContext.QueueContainers.DeleteOnSubmit(queueContainer); dbContext.SubmitChanges(); } }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageAccount.DeleteBlobContainerImpl")); yield return(asyncResult); this.StorageManager.AsyncProcessor.EndExecute(asyncResult); }
private IEnumerator <IAsyncResult> DeleteMessageImpl(IQueueMessageReceipt queueMessageReceipt, AsyncIteratorContext <bool> context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <bool>((TimeSpan remaining) => { bool flag; using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer queueContainer = this.LoadQueueContainer(dbContext); context.ResultData = false; Receipt receipt = (Receipt)queueMessageReceipt; Guid messageId = receipt.MessageId; DateTime visibilityStart = receipt.VisibilityStart; QueueMessage queueMessage = ( from m in dbContext.QueueMessages where (m.AccountName == this._queue.AccountName) && (m.QueueName == this._queue.QueueName) && (m.VisibilityStartTime == visibilityStart) && (m.MessageId == messageId) select m).FirstOrDefault <QueueMessage>(); if (queueMessage == null) { throw new MessageNotFoundException(); } dbContext.QueueMessages.DeleteOnSubmit(queueMessage); dbContext.SubmitChanges(); this._queue = queueContainer; flag = true; } return(flag); }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.DeleteMessageImpl")); yield return(asyncResult); context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <bool>(asyncResult); }
private IEnumerator <IAsyncResult> ReleaseLeaseImpl(Guid leaseId, IContainerCondition condition, bool updateLastModificationTime, AsyncIteratorContext <NoResults> context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer nullable = this.LoadBlobContainer(dbContext); DbBlobContainer.CheckBlobContainerConditionWithoutLeaseCondition(nullable, condition); DateTime utcNow = DateTime.UtcNow; ContainerLeaseInfo containerLeaseInfo = new ContainerLeaseInfo(nullable, utcNow); if (containerLeaseInfo.Id.HasValue && containerLeaseInfo.Id.Value != leaseId) { throw new LeaseLostException(); } if (containerLeaseInfo.State.Value == LeaseState.Available) { throw new LeaseLostException(); } nullable.LeaseEndTime = new DateTime?(utcNow); nullable.LeaseState = 0; nullable.IsLeaseOp = !updateLastModificationTime; dbContext.SubmitChanges(); containerLeaseInfo.SetBlobContainer(nullable, utcNow); this._container = nullable; this.LeaseInfo = containerLeaseInfo; } }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbBlobContainer.ReleaseLease")); yield return(asyncResult); this.StorageManager.AsyncProcessor.EndExecute(asyncResult); }
private IEnumerator <IAsyncResult> SetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncIteratorContext <NoResults> context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer>((TimeSpan param0) => { Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer blobContainer; using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer serviceMetadata = this.LoadBlobContainer(dbContext); ContainerLeaseInfo containerLeaseInfo = new ContainerLeaseInfo(serviceMetadata, DateTime.UtcNow); DbBlobContainer.CheckBlobContainerCondition(serviceMetadata, condition, containerLeaseInfo); if ((propertyNames & ContainerPropertyNames.ServiceMetadata) != ContainerPropertyNames.None) { serviceMetadata.ServiceMetadata = ((IContainer)this).ServiceMetadata; } if ((propertyNames & ContainerPropertyNames.ApplicationMetadata) != ContainerPropertyNames.None) { serviceMetadata.Metadata = this.ApplicationMetadata; } dbContext.SubmitChanges(); this.LeaseInfo = containerLeaseInfo; blobContainer = serviceMetadata; } return(blobContainer); }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbBlobContainer.SetProperties")); yield return(asyncResult); this._container = this.StorageManager.AsyncProcessor.EndExecute <Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer>(asyncResult); }
private bool PutBlockList() { bool flag; bool flag1 = false; try { for (int i = 0; i < this._maxNumberOfRetries; i++) { try { using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew)) { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { this.GetContainer(dbContext); BlockBlob blob = this.GetBlob(dbContext, true) as BlockBlob; BlobServiceMetaData instance = BlobServiceMetaData.GetInstance(blob.ServiceMetadata); instance.CopyStatus = "success"; instance.CopyProgressOffset = this._contentLength.ToString(); instance.CopyProgressTotal = this._contentLength.ToString(); instance.CopyCompletionTime = new long?(DateTime.UtcNow.ToFileTimeUtc()); blob.HasBlock = new bool?((this._blockIds.Count > 1 ? true : this._contentLength < (long)4194304)); blob.ContentLength = this._contentLength; blob.ServiceMetadata = instance.GetMetadata(); blob.IsCommitted = new bool?(false); blob.UncommittedBlockIdLength = null; dbContext.SubmitChanges(); dbContext.CommitBlockList(this._accountName, this._containerName, this._blobName, DbListBlobObject.SerializeCommitBlockListEntryFromUncommitted(this._blockIds).ToString(), ref this._lastModifiedTime); transactionScope.Complete(); } } IStringDataEventStream info = Logger <IRestProtocolHeadLogger> .Instance.Info; object[] objArray = new object[] { this._accountName, this._containerName, this._blobName, this._contentLength }; info.Log("Commited Blocks for: {0}/{1}/{2}, Length:{3}", objArray); break; } catch (SqlException sqlException) { if (this.ShouldRethrowException(i, sqlException, out flag1)) { throw; } } } return(true); } catch (Exception exception1) { Exception exception = exception1; Logger <IRestProtocolHeadLogger> .Instance.Error.Log("CopyBlob: PutBlockList exception {0}", new object[] { exception }); this.SetCopyFailed(exception, flag1, null); flag = false; } return(flag); }
private IEnumerator <IAsyncResult> ChangeLeaseImpl(Guid leaseId, Guid proposedLeaseId, IContainerCondition condition, bool updateLastModificationTime, AsyncIteratorContext <NoResults> context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer nullable = this.LoadBlobContainer(dbContext); DbBlobContainer.CheckBlobContainerConditionWithoutLeaseCondition(nullable, condition); DateTime utcNow = DateTime.UtcNow; ContainerLeaseInfo containerLeaseInfo = new ContainerLeaseInfo(nullable, utcNow); switch (containerLeaseInfo.State.Value) { case LeaseState.Available: { throw new LeaseNotPresentException(); } case LeaseState.Leased: { if (!(leaseId != containerLeaseInfo.Id.Value) || !(proposedLeaseId != containerLeaseInfo.Id.Value)) { break; } throw new LeaseHeldException(); } case LeaseState.Expired: { throw new LeaseHeldException(); } case LeaseState.Breaking: { if (!containerLeaseInfo.Id.HasValue || !(leaseId != containerLeaseInfo.Id.Value) || !(proposedLeaseId != containerLeaseInfo.Id.Value)) { throw new LeaseBrokenException(); } throw new LeaseHeldException(); } case LeaseState.Broken: { throw new LeaseNotPresentException(); } } nullable.LeaseId = new Guid?(proposedLeaseId); nullable.IsLeaseOp = !updateLastModificationTime; dbContext.SubmitChanges(); containerLeaseInfo.SetBlobContainer(nullable, utcNow); this._container = nullable; this.LeaseInfo = containerLeaseInfo; } }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbBlobContainer.ChangeLease")); yield return(asyncResult); this.StorageManager.AsyncProcessor.EndExecute(asyncResult); }
public static void SetCopyStatusToFailedAfterRestart() { while (true) { IEnumerable <Blob> blobs = null; try { using (TransactionScope transactionScope = new TransactionScope()) { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { IQueryable <Blob> blobs1 = from b in dbContext.Blobs select b; blobs = blobs1.Take <Blob>(100); if (blobs == null || blobs.Count <Blob>() == 0) { break; } else { foreach (Blob blob in blobs) { BlobServiceMetaData instance = BlobServiceMetaData.GetInstance(blob.ServiceMetadata); if (!"pending".Equals(instance.CopyStatus)) { continue; } instance.CopyStatus = "failed"; instance.CopyStatusDescription = "500 InternalError \"Reset to failed during restart.\""; Blob blob1 = DbBlobObject.ClearBlob(blob, instance.GetMetadata()); dbContext.Blobs.DeleteOnSubmit(blob); dbContext.SubmitChanges(); using (DevelopmentStorageDbDataContext developmentStorageDbDataContext = DevelopmentStorageDbDataContext.GetDbContext()) { developmentStorageDbDataContext.Blobs.InsertOnSubmit(blob1); developmentStorageDbDataContext.SubmitChanges(); } } } } transactionScope.Complete(); } } catch (Exception exception1) { Exception exception = exception1; Logger <IRestProtocolHeadLogger> .Instance.Error.Log("SetCopyStatusToFailedAfterRestart: Failed to change copy status! Exception {0}", new object[] { exception }); } } }
private IEnumerator <IAsyncResult> PutMessageImpl(List <PushedMessage> messagesList, bool usePutMessageRowCommand, AsyncIteratorContext <List <IMessageData> > context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <List <IMessageData> >((TimeSpan remaining) => { List <IMessageData> messageDatas; using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { DateTime utcNow = DateTime.UtcNow; this.LoadQueueContainer(dbContext); List <QueueMessage> queueMessages = new List <QueueMessage>(); List <IMessageData> messageDatas1 = new List <IMessageData>(); object obj = messagesList; if (obj == null) { obj = Enumerable.Empty <PushedMessage>(); } foreach (PushedMessage pushedMessage in (IEnumerable <PushedMessage>)obj) { QueueMessage queueMessage = new QueueMessage() { AccountName = this._queue.AccountName, QueueName = this._queue.QueueName, VisibilityStartTime = utcNow.Add(pushedMessage.VisibilityTimeout), MessageId = Guid.NewGuid() }; QueueMessage queueMessage1 = queueMessage; TimeSpan?messageTTL = pushedMessage.MessageTTL; queueMessage1.ExpiryTime = utcNow.Add((messageTTL.HasValue ? messageTTL.GetValueOrDefault() : new TimeSpan((long)0))); queueMessage.InsertionTime = utcNow; queueMessage.DequeueCount = 0; queueMessage.Data = pushedMessage.MessageText; QueueMessage queueMessage2 = queueMessage; queueMessages.Add(queueMessage2); messageDatas1.Add(new DbMessageData(queueMessage2, false)); } dbContext.QueueMessages.InsertAllOnSubmit <QueueMessage>(queueMessages); dbContext.SubmitChanges(); messageDatas = messageDatas1; } return(messageDatas); }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.PutMessage")); yield return(asyncResult); context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <List <IMessageData> >(asyncResult); }
private IEnumerator <IAsyncResult> UpdateMessageImpl(IQueueMessageReceipt queueMessageReceipt, byte[] body, TimeSpan visibilityTimeout, TimeSpan?timeToLive, AsyncIteratorContext <IQueueMessageReceipt> context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <IQueueMessageReceipt>((TimeSpan remaining) => { IQueueMessageReceipt receipt; using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer queueContainer = this.LoadQueueContainer(dbContext); this._queue = queueContainer; QueueMessage queueMessage = ( from m in dbContext.QueueMessages where (m.AccountName == this._queue.AccountName) && (m.QueueName == this._queue.QueueName) && (m.MessageId == ((Receipt)queueMessageReceipt).MessageId) && (m.VisibilityStartTime == ((Receipt)queueMessageReceipt).VisibilityStart) select m).FirstOrDefault <QueueMessage>(); if (queueMessage == null) { throw new MessageNotFoundException(); } DateTime utcNow = DateTime.UtcNow; QueueMessage queueMessage1 = new QueueMessage() { AccountName = queueMessage.AccountName, QueueName = queueMessage.QueueName, VisibilityStartTime = utcNow.Add(visibilityTimeout), MessageId = queueMessage.MessageId, ExpiryTime = queueMessage.ExpiryTime, InsertionTime = queueMessage.InsertionTime, DequeueCount = queueMessage.DequeueCount, Data = body ?? queueMessage.Data }; dbContext.QueueMessages.DeleteOnSubmit(queueMessage); dbContext.QueueMessages.InsertOnSubmit(queueMessage1); dbContext.SubmitChanges(); receipt = new Receipt() { MessageId = ((Receipt)queueMessageReceipt).MessageId, VisibilityStart = queueMessage1.VisibilityStartTime, DequeueCount = queueMessage1.DequeueCount }; } return(receipt); }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.UpdateMessage")); yield return(asyncResult); context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <IQueueMessageReceipt>(asyncResult); }
public void SetCopyCompleted() { for (int i = 0; i < this._maxNumberOfRetries; i++) { try { using (TransactionScope transactionScope = new TransactionScope()) { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { this.GetContainer(dbContext); Blob blob = this.GetBlob(dbContext, false); BlobServiceMetaData instance = BlobServiceMetaData.GetInstance(blob.ServiceMetadata); if (!string.Equals(this._copyId, instance.CopyId, StringComparison.OrdinalIgnoreCase)) { Logger <IRestProtocolHeadLogger> .Instance.Info.Log("CopyBlob: SetCopyCompleted not updating status as the copyId has changed."); } else { instance.CopyStatus = "success"; instance.CopyProgressOffset = this._contentLength.ToString(); instance.CopyProgressTotal = this._contentLength.ToString(); instance.CopyCompletionTime = new long?(DateTime.UtcNow.ToFileTimeUtc()); blob.ServiceMetadata = instance.GetMetadata(); dbContext.SubmitChanges(); transactionScope.Complete(); } } } break; } catch (Exception exception1) { Exception exception = exception1; if (i != this._maxNumberOfRetries - 1) { IStringDataEventStream critical = Logger <IRestProtocolHeadLogger> .Instance.Critical; object[] objArray = new object[] { exception, i + 1 }; critical.Log("Could not set copyStatus of blob. Exception {0}!Retrying attempt {1}...", objArray); } } } }
private IEnumerator <IAsyncResult> CreateContainerImpl(DateTime?expiryTime, byte[] serviceMetadata, byte[] applicationMetadata, AsyncIteratorContext <NoResults> context) { IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug; object[] objArray = new object[] { expiryTime, serviceMetadata, applicationMetadata, this.Timeout }; verboseDebug.Log("CreateContainerImpl({0},{1},{2},{3})", objArray); IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { StorageStampHelpers.CheckContainerName(this._container.ContainerName, Microsoft.Cis.Services.Nephos.Common.Storage.ContainerType.BlobContainer, false); using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { this._container.ServiceMetadata = serviceMetadata; this._container.Metadata = applicationMetadata; dbContext.BlobContainers.InsertOnSubmit(this._container); dbContext.SubmitChanges(); } }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbBlobContainer.CreateContainerImpl")); yield return(asyncResult); this.StorageManager.AsyncProcessor.EndExecute(asyncResult); }
private IEnumerator <IAsyncResult> SetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncIteratorContext <NoResults> context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan remaining) => { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer applicationMetadata = this.LoadQueueContainer(dbContext); if ((propertyNames & ContainerPropertyNames.ApplicationMetadata) != ContainerPropertyNames.None) { StorageStampHelpers.ValidateApplicationMetadata(this.ApplicationMetadata); applicationMetadata.Metadata = this.ApplicationMetadata; } if ((propertyNames & ContainerPropertyNames.ServiceMetadata) != ContainerPropertyNames.None) { applicationMetadata.ServiceMetadata = ((IContainer)this).ServiceMetadata; } dbContext.SubmitChanges(); this._queue = applicationMetadata; } }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.SetProperties")); yield return(asyncResult); this.StorageManager.AsyncProcessor.EndExecute(asyncResult); }
private IEnumerator <IAsyncResult> DeleteContainerImpl(IContainerCondition conditions, Guid?leaseId, AsyncIteratorContext <NoResults> context) { object obj; IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug; object[] timeout = new object[2]; object[] objArray = timeout; obj = (leaseId.HasValue ? leaseId.Value.ToString() : "NULL"); objArray[0] = obj; timeout[1] = this.Timeout; verboseDebug.Log("DeleteContainerImpl({0},{1})", timeout); IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer blobContainer = this.LoadBlobContainer(dbContext); ContainerLeaseInfo containerLeaseInfo = new ContainerLeaseInfo(blobContainer, DateTime.UtcNow); DbBlobContainer.CheckBlobContainerCondition(blobContainer, conditions, containerLeaseInfo); LeaseState?state = containerLeaseInfo.State; LeaseState valueOrDefault = state.GetValueOrDefault(); if (state.HasValue) { switch (valueOrDefault) { case LeaseState.Available: case LeaseState.Broken: { if (!leaseId.HasValue) { break; } if (!containerLeaseInfo.Id.HasValue) { throw new LeaseNotPresentException(); } throw new LeaseLostException(); } case LeaseState.Leased: case LeaseState.Breaking: { if (leaseId.HasValue && !(leaseId.Value != containerLeaseInfo.Id.Value)) { break; } throw new LeaseHeldException(); } case LeaseState.Expired: { if (!leaseId.HasValue) { break; } throw new LeaseLostException(); } } } dbContext.BlobContainers.DeleteOnSubmit(blobContainer); dbContext.SubmitChanges(); } }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbBlobContainer.DeleteContainerImpl")); yield return(asyncResult); this.StorageManager.AsyncProcessor.EndExecute(asyncResult); }
private static void DoDefragmentBlobWork(object info) { string str; bool flag; long num; string str1; while (true) { BlockBlobMetaInfo blockBlobMetaInfo = null; lock (BlockBlobGarbageCollector.defragLock) { if (BlockBlobGarbageCollector.defragWorkItems.Count == 0) { Monitor.Wait(BlockBlobGarbageCollector.defragLock); } blockBlobMetaInfo = BlockBlobGarbageCollector.defragWorkItems.Dequeue(); } IStringDataEventStream infoDebug = Logger <INormalAndDebugLogger> .Instance.InfoDebug; object[] objArray = new object[] { blockBlobMetaInfo.ToString() }; infoDebug.Log("BlockBlob: DoDefragmentBlobWork WorkItem! {0}", objArray); try { BlockBlobDataManager.GetDataFiles(blockBlobMetaInfo, out str1, out str); Logger <INormalAndDebugLogger> .Instance.InfoDebug.Log("BlockBlob: DoDefragmentBlobWork readOnlyFile {0}, readWriteFile {1}", new object[] { str1, str }); if (string.IsNullOrEmpty(str1)) { BlockBlobDataManager.SealCurrentWriteFile(blockBlobMetaInfo, -1); } BlockBlobDataManager.GetDataFiles(blockBlobMetaInfo, out str1, out str); Logger <INormalAndDebugLogger> .Instance.InfoDebug.Log("BlockBlob: DoDefragmentBlobWork NEW readOnlyFile {0}, readWriteFile {1}", new object[] { str1, str }); } catch (Exception exception1) { Exception exception = exception1; Logger <INormalAndDebugLogger> .Instance.Error.Log("BlockBlob: DoDefragmentBlobWork Exception {0}", new object[] { exception.StackTrace }); BlockBlobGarbageCollector.RemoveWorkFromProcessingDictionary(blockBlobMetaInfo); continue; } int num1 = 0; do { Label0: if (num1 >= 5) { break; } flag = true; int maxItemsToSync = BlockBlobGarbageCollector.GetMaxItemsToSync(); try { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { IQueryable <BlockData> blockDatas = ( from b in dbContext.BlocksData where (b.ContainerName == blockBlobMetaInfo.ContainerName) && (b.BlobName == blockBlobMetaInfo.BlobName) && (b.FilePath == str1) select b).Take <BlockData>(maxItemsToSync); foreach (BlockData nullable in blockDatas) { flag = false; byte[] numArray = null; using (FileStream fileStream = new FileStream(str1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { fileStream.Seek(nullable.StartOffset.Value, SeekOrigin.Begin); numArray = new byte[checked ((IntPtr)nullable.Length.Value)]; fileStream.Read(numArray, 0, (int)numArray.Length); } string file = BlockBlobDataManager.WriteBytesToFile(blockBlobMetaInfo, numArray, out num); nullable.FilePath = file; nullable.StartOffset = new long?(num); } dbContext.SubmitChanges(ConflictMode.ContinueOnConflict); } } catch (Exception exception3) { Exception exception2 = exception3; num1++; IStringDataEventStream error = Logger <INormalAndDebugLogger> .Instance.Error; object[] stackTrace = new object[] { exception2.StackTrace, num1 }; error.Log("BlockBlob: DoDefragmentBlobWork Exception {0}, Attempt {1}", stackTrace); goto Label0; } }while (!flag); if (num1 < 5) { try { BlockBlobDataManager.ResetReadOnlyFileToNull(blockBlobMetaInfo); } catch (Exception exception5) { Exception exception4 = exception5; Logger <INormalAndDebugLogger> .Instance.Error.Log("BlockBlob: DoDefragmentBlobWork Exception while setting up rofile to null {0} ", new object[] { exception4.StackTrace }); } } BlockBlobGarbageCollector.RemoveWorkFromProcessingDictionary(blockBlobMetaInfo); } }
private IEnumerator <IAsyncResult> SetPropertiesImpl(AccountPropertyNames propertyNames, IAccountCondition conditions, AsyncIteratorContext <NoResults> context) { IStringDataEventStream infoDebug = Logger <INormalAndDebugLogger> .Instance.InfoDebug; object[] objArray = new object[] { propertyNames, conditions, this.Timeout }; infoDebug.Log("SetPropertiesImpl({0},{1},{2})", objArray); IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { StorageStampHelpers.CheckAccountName(this._account.Name); Account value = this.LoadAccount(dbContext); this._account = value; AnalyticsSettings analyticsSetting = null; AnalyticsSettings blobAnalyticsSettings = null; AccountServiceMetadataPropertyNames serviceMetadataPropertyNames = propertyNames.ServiceMetadataPropertyNames; if (serviceMetadataPropertyNames <= AccountServiceMetadataPropertyNames.QueueAnalyticsSettings) { if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.BlobAnalyticsSettings) { blobAnalyticsSettings = this.ServiceMetadata.BlobAnalyticsSettings; if (blobAnalyticsSettings != null) { if (value.BlobServiceSettings != null) { analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.BlobServiceSettings); this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting); } value.BlobServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings); dbContext.SubmitChanges(); } } else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.QueueAnalyticsSettings) { blobAnalyticsSettings = this.ServiceMetadata.QueueAnalyticsSettings; if (blobAnalyticsSettings != null) { if (value.QueueServiceSettings != null) { analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.QueueServiceSettings); this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting); } value.QueueServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings); dbContext.SubmitChanges(); } } } else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.TableAnalyticsSettings) { blobAnalyticsSettings = this.ServiceMetadata.TableAnalyticsSettings; if (blobAnalyticsSettings != null) { if (value.TableServiceSettings != null) { analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.TableServiceSettings); this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting); } value.TableServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings); dbContext.SubmitChanges(); } } else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.SecondaryReadEnabled) { bool?secondaryReadEnabled = this.ServiceMetadata.SecondaryReadEnabled; if (secondaryReadEnabled.HasValue) { value.SecondaryReadEnabled = secondaryReadEnabled.Value; dbContext.SubmitChanges(); } } } }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageAccount.SetPropertiesImpl")); yield return(asyncResult); this.StorageManager.AsyncProcessor.EndExecute(asyncResult); }
public void SetCopyFailed(Exception exception, bool isRetryFailure, string description) { bool flag; bool flag1 = true; for (int i = 0; i < this._maxNumberOfRetries; i++) { try { using (TransactionScope transactionScope = new TransactionScope()) { Blob blob = null; using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { this.GetContainer(dbContext); Blob metadata = this.GetBlob(dbContext, false); DateTime?lastModificationTime = metadata.LastModificationTime; DateTime?nullable = this._lastModifiedTime; if (lastModificationTime.HasValue != nullable.HasValue) { flag = true; } else { flag = (!lastModificationTime.HasValue ? false : lastModificationTime.GetValueOrDefault() != nullable.GetValueOrDefault()); } if (flag) { flag1 = false; } BlobServiceMetaData instance = BlobServiceMetaData.GetInstance(metadata.ServiceMetadata); if (!string.Equals(this._copyId, instance.CopyId, StringComparison.OrdinalIgnoreCase)) { Logger <IRestProtocolHeadLogger> .Instance.Info.Log("CopyBlob: SetCopyFailed not updating status as the copyId is changed."); break; } else { instance.CopyStatus = "failed"; instance.CopyStatusDescription = (description == null ? string.Format("Internal Error. HasRetriedOnFailure={0}", isRetryFailure) : description); instance.CopyCompletionTime = new long?(DateTime.UtcNow.ToFileTimeUtc()); if (!flag1) { metadata.ServiceMetadata = instance.GetMetadata(); metadata.ContentLength = (long)0; } else { blob = DbBlobObject.ClearBlob(metadata, instance.GetMetadata()); dbContext.Blobs.DeleteOnSubmit(metadata); } dbContext.SubmitChanges(); } } if (flag1) { using (DevelopmentStorageDbDataContext developmentStorageDbDataContext = DevelopmentStorageDbDataContext.GetDbContext()) { developmentStorageDbDataContext.Blobs.InsertOnSubmit(blob); developmentStorageDbDataContext.SubmitChanges(); } } transactionScope.Complete(); } break; } catch (Exception exception2) { Exception exception1 = exception2; if (i != this._maxNumberOfRetries - 1) { IStringDataEventStream critical = Logger <IRestProtocolHeadLogger> .Instance.Critical; object[] objArray = new object[] { exception1, i + 1 }; critical.Log("Could not set copyStatus of blob. Exception {0}!Retrying attempt {1}...", objArray); } } } }
public bool PutPage(long startIndex, byte[] data) { bool flag; bool flag1 = false; this._currentLength += data.LongLength; bool flag2 = false; DateTime?nullable = this._lastModifiedTime; try { for (int i = 0; i < this._maxNumberOfRetries; i++) { this._lastModifiedTime = nullable; try { using (TransactionScope transactionScope = new TransactionScope()) { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { this.GetContainer(dbContext); PageBlob blob = this.GetBlob(dbContext, true) as PageBlob; CurrentPage currentPage = new CurrentPage() { AccountName = blob.AccountName, ContainerName = blob.ContainerName, BlobName = blob.BlobName, VersionTimestamp = blob.VersionTimestamp, StartOffset = startIndex, EndOffset = startIndex + data.LongLength, SnapshotCount = blob.SnapshotCount }; dbContext.CurrentPages.InsertOnSubmit(currentPage); lock (DbPageBlobObject.m_writeFileLock) { if (!flag2) { using (FileStream fileStream = new FileStream(DbPageBlobObject.GetFilePath(blob.FileName), FileMode.OpenOrCreate, FileAccess.Write)) { fileStream.Seek(startIndex, SeekOrigin.Begin); fileStream.Write(data, 0, (int)data.Length); } flag2 = true; } dbContext.SubmitChanges(); dbContext.Refresh(RefreshMode.OverwriteCurrentValues, blob); this.SetCopyStatus(blob); dbContext.SubmitChanges(); dbContext.Refresh(RefreshMode.OverwriteCurrentValues, blob); transactionScope.Complete(); this._lastModifiedTime = blob.LastModificationTime; } IStringDataEventStream info = Logger <IRestProtocolHeadLogger> .Instance.Info; object[] objArray = new object[] { startIndex, startIndex + data.LongLength - (long)1 }; info.Log("Uploaded Page: {0}-{1}", objArray); } } break; } catch (SqlException sqlException) { if (this.ShouldRethrowException(i, sqlException, out flag1)) { throw; } } } return(true); } catch (Exception exception1) { Exception exception = exception1; Logger <IRestProtocolHeadLogger> .Instance.Error.Log("CopyBlob: PutPage exception {0}", new object[] { exception }); this.SetCopyFailed(exception, flag1, null); flag = false; } return(flag); }
public bool PutBlock(string blockId, byte[] data) { bool flag; bool flag1 = false; DateTime?nullable = this._lastModifiedTime; bool flag2 = false; long num = (long)0; string file = null; this._currentLength += data.LongLength; this._blockIds.Add(blockId); try { for (int i = 0; i < this._maxNumberOfRetries; i++) { this._lastModifiedTime = nullable; try { using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew)) { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { this.GetContainer(dbContext); BlockBlob blob = this.GetBlob(dbContext, true) as BlockBlob; if (!flag2) { file = BlockBlobDataManager.WriteBytesToFile(new BlockBlobMetaInfo(blob.AccountName, blob.ContainerName, blob.BlobName, blob.DirectoryPath), data, out num); flag2 = true; } BlockData blockDatum = new BlockData() { AccountName = blob.AccountName, ContainerName = blob.ContainerName, BlobName = blob.BlobName, VersionTimestamp = blob.VersionTimestamp, IsCommitted = false, BlockId = blockId, Length = new long?(data.LongLength), FilePath = file, StartOffset = new long?(num) }; dbContext.BlocksData.InsertOnSubmit(blockDatum); this.SetCopyStatus(blob); dbContext.SubmitChanges(); dbContext.Refresh(RefreshMode.OverwriteCurrentValues, blob); transactionScope.Complete(); this._lastModifiedTime = blob.LastModificationTime; } } Logger <IRestProtocolHeadLogger> .Instance.Info.Log("Uploaded Block: {0}", new object[] { blockId }); break; } catch (SqlException sqlException) { if (this.ShouldRethrowException(i, sqlException, out flag1)) { throw; } } } if (this._currentLength < this._contentLength) { return(true); } return(this.PutBlockList()); } catch (Exception exception1) { Exception exception = exception1; Logger <IRestProtocolHeadLogger> .Instance.Error.Log("CopyBlob: PutBlock exception {0}", new object[] { exception }); this.SetCopyFailed(exception, flag1, null); flag = false; } return(flag); }
private IEnumerator <IAsyncResult> PutBlockImpl(byte[] blockIdentifier, long contentLength, Stream inputStream, byte[] contentMD5, bool isLargeBlockBlobRequest, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context) { Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer blobContainer = null; BlockBlob blockBlob = null; IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { long num; long num1; StorageStampHelpers.ValidatePutBlockArguments(this, blockIdentifier, contentLength, contentMD5, condition, true); string str = null; using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { blobContainer = base.LoadContainer(dbContext); blockBlob = base.TryLoadBlockBlob(dbContext, out str); if (blockBlob == null) { lock (DbListBlobObject.SynchronizePutBlock) { blockBlob = base.TryLoadBlockBlob(dbContext, out str); if (blockBlob == null) { if (string.IsNullOrEmpty(str)) { str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced(); } using (DevelopmentStorageDbDataContext developmentStorageDbDataContext = DevelopmentStorageDbDataContext.GetDbContext()) { Logger <INormalAndDebugLogger> .Instance.VerboseDebug.Log("PutBlockImpl: Creating record for ({0};{1};{2})", new object[] { this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName }); StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName); blockBlob = new BlockBlob() { AccountName = this._blob.AccountName, ContainerName = this._blob.ContainerName, BlobName = this._blob.BlobName, VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc), ContentLength = (long)0, IsCommitted = new bool?(false), HasBlock = new bool?(true), DirectoryPath = str, GenerationId = Guid.NewGuid().ToString(), SnapshotCount = 0 }; developmentStorageDbDataContext.Blobs.InsertOnSubmit(blockBlob); developmentStorageDbDataContext.SubmitChanges(); } } } } bool flag = false; BlobLeaseInfo blobLeaseInfo = new BlobLeaseInfo(blockBlob, DateTime.UtcNow); DbBlobObject.CheckCopyState(blockBlob); flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, blobLeaseInfo, condition, null, true); byte[] byteArrayFromStream = DbStorageHelper.GetByteArrayFromStream(inputStream, out num, true, isLargeBlockBlobRequest); string file = BlockBlobDataManager.WriteBytesToFile(new BlockBlobMetaInfo(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, str), byteArrayFromStream, out num1); string hexString = DbListBlobObject.ToHexString(blockIdentifier); BlockData blockDatum = this.TryLoadUncommittedBlock(dbContext, hexString); if (blockDatum == null) { blockDatum = new BlockData() { AccountName = this._blob.AccountName, ContainerName = this._blob.ContainerName, BlobName = this._blob.BlobName, VersionTimestamp = this._blob.VersionTimestamp, IsCommitted = false, BlockId = hexString }; dbContext.BlocksData.InsertOnSubmit(blockDatum); } blockDatum.Length = new long?(num); blockDatum.FilePath = file; blockDatum.StartOffset = new long?(num1); base.ResetBlobLeaseToAvailable(blockBlob, flag); dbContext.SubmitChanges(); blobLeaseInfo.SetBlob(blockBlob, blobLeaseInfo.LeaseInfoValidAt); this.LeaseInfo = blobLeaseInfo; } }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlock")); yield return(asyncResult); this._storageManager.AsyncProcessor.EndExecute(asyncResult); }
private IEnumerator <IAsyncResult> PutBlobImpl(string contentType, long contentLength, byte[] serviceMetadata, byte[] applicationMetadata, byte[][] blockList, BlockSource[] blockSourceList, byte[] contentMD5, OverwriteOption overwriteOption, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context) { IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug; object[] objArray = new object[] { contentType, this.ContentLength, serviceMetadata, applicationMetadata, blockList, overwriteOption, condition, base.Timeout }; verboseDebug.Log("PutBlobImpl.PutBlobImpl({0};{1};{2};{3};{4};{5};{6};{7})", objArray); IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { using (TransactionScope transactionScope = new TransactionScope()) { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { base.LoadContainer(dbContext); string str = null; BlockBlob blockBlob = base.TryLoadBlockBlob(dbContext, out str); DateTime utcNow = DateTime.UtcNow; bool flag = false; if (blockBlob != null) { DbBlobObject.CheckCopyState(blockBlob); flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, new BlobLeaseInfo(blockBlob, utcNow), condition, null, true); if (blockBlob.IsCommitted.Value) { if (overwriteOption == OverwriteOption.CreateNewOnly) { throw new BlobAlreadyExistsException(); } } else if (overwriteOption == OverwriteOption.UpdateExistingOnly && condition != null && !condition.IsIncludingUncommittedBlobs) { throw new ConditionNotMetException(); } } else { if (overwriteOption == OverwriteOption.UpdateExistingOnly) { if (condition == null || !condition.LeaseId.HasValue) { throw new ConditionNotMetException(); } throw new LeaseNotPresentException(); } StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName); if (string.IsNullOrEmpty(str)) { str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced(); } blockBlob = new BlockBlob() { AccountName = this._blob.AccountName, ContainerName = this._blob.ContainerName, BlobName = this._blob.BlobName, VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc), IsCommitted = new bool?(false), DirectoryPath = str }; dbContext.Blobs.InsertOnSubmit(blockBlob); } StorageStampHelpers.ValidatePutBlockListArguments(this, contentLength, applicationMetadata, blockList, blockSourceList, contentMD5, condition, this._blobServiceVersion); blockBlob.ContentType = contentType ?? "application/octet-stream"; blockBlob.ContentMD5 = contentMD5; blockBlob.ServiceMetadata = serviceMetadata; blockBlob.Metadata = applicationMetadata; blockBlob.HasBlock = new bool?(true); blockBlob.GenerationId = Guid.NewGuid().ToString(); blockBlob.SnapshotCount = 0; base.ResetBlobLeaseToAvailable(blockBlob, flag); dbContext.SubmitChanges(); DateTime?nullable = null; StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < (int)blockList.Length; i++) { DbListBlobObject.SerializeCommitBlockListEntry(stringBuilder, blockList[i], (blockSourceList != null ? blockSourceList[i] : BlockSource.Uncommitted)); } dbContext.CommitBlockList(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, stringBuilder.ToString(), ref nullable); transactionScope.Complete(); blockBlob.LastModificationTime = nullable; this._blob = blockBlob; this.LeaseInfo = new BlobLeaseInfo(blockBlob, utcNow); } } }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlob")); yield return(asyncResult); this._storageManager.AsyncProcessor.EndExecute(asyncResult); }
private IEnumerator <IAsyncResult> PutBlobImpl(string contentType, long contentLength, byte[] serviceMetadata, byte[] applicationMetadata, Stream inputStream, byte[] contentMD5, bool invokeGeneratePutBlobServiceMetadata, GeneratePutBlobServiceMetadata generatePutBlobServiceMetadata, bool isLargeBlockBlobRequest, ISequenceNumberUpdate sequenceNumberUpdate, OverwriteOption overwriteOption, IBlobObjectCondition condition, AsyncIteratorContext <NoResults> context) { IAsyncResult asyncResult = this._storageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => { long num; long num1; using (TransactionScope transactionScope = new TransactionScope()) { using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { base.LoadContainer(dbContext); string str = null; BlockBlob blockBlob = base.TryLoadBlockBlob(dbContext, out str); DateTime utcNow = DateTime.UtcNow; bool flag = false; if (blockBlob != null) { if (blockBlob.IsCommitted.Value && overwriteOption == OverwriteOption.CreateNewOnly) { throw new BlobAlreadyExistsException(); } DbBlobObject.CheckCopyState(blockBlob); flag = DbBlobObject.CheckConditionsAndReturnResetRequired(blockBlob, new BlobLeaseInfo(blockBlob, utcNow), condition, null, true); dbContext.ClearUncommittedBlocks(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName); dbContext.Refresh(RefreshMode.KeepChanges, blockBlob); } else { if (overwriteOption == OverwriteOption.UpdateExistingOnly) { if (condition == null || !condition.LeaseId.HasValue) { throw new ConditionNotMetException(); } throw new LeaseNotPresentException(); } StorageStampHelpers.CheckBlobName(this._blob.BlobName, this._blob.ContainerName); if (string.IsNullOrEmpty(str)) { str = BlockBlobDataManager.CreateUniqueDirectoryLoadBalanced(); } blockBlob = new BlockBlob() { AccountName = this._blob.AccountName, ContainerName = this._blob.ContainerName, BlobName = this._blob.BlobName, VersionTimestamp = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc), DirectoryPath = str }; dbContext.Blobs.InsertOnSubmit(blockBlob); } StorageStampHelpers.ValidatePutBlobArguments(this, contentLength, null, applicationMetadata, contentMD5, sequenceNumberUpdate, overwriteOption, condition, true, false); byte[] byteArrayFromStream = DbStorageHelper.GetByteArrayFromStream(inputStream, out num, false, isLargeBlockBlobRequest); string file = BlockBlobDataManager.WriteBytesToFile(new BlockBlobMetaInfo(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, str), byteArrayFromStream, out num1); Guid guid = Guid.NewGuid(); BlockData blockDatum = new BlockData() { AccountName = this._blob.AccountName, ContainerName = this._blob.ContainerName, BlobName = this._blob.BlobName, VersionTimestamp = this._blob.VersionTimestamp, IsCommitted = false, BlockId = DbListBlobObject.ToHexString(guid.ToByteArray()), FilePath = file, StartOffset = new long?(num1) }; dbContext.BlocksData.InsertOnSubmit(blockDatum); if (invokeGeneratePutBlobServiceMetadata && generatePutBlobServiceMetadata != null) { serviceMetadata = generatePutBlobServiceMetadata(); } blockBlob.ContentType = contentType ?? "application/octet-stream"; blockBlob.ContentMD5 = contentMD5; blockBlob.ServiceMetadata = serviceMetadata; blockBlob.Metadata = applicationMetadata; blockBlob.IsCommitted = new bool?(false); blockBlob.HasBlock = new bool?(false); blockBlob.UncommittedBlockIdLength = null; blockBlob.GenerationId = Guid.NewGuid().ToString(); blockBlob.SnapshotCount = 0; blockDatum.Length = new long?(num); blockBlob.ContentLength = num; base.ResetBlobLeaseToAvailable(blockBlob, flag); dbContext.SubmitChanges(); StringBuilder stringBuilder = new StringBuilder(); DbListBlobObject.SerializeCommitBlockListEntry(stringBuilder, guid.ToByteArray(), BlockSource.Uncommitted); DateTime?nullable = null; dbContext.CommitBlockList(this._blob.AccountName, this._blob.ContainerName, this._blob.BlobName, stringBuilder.ToString(), ref nullable); transactionScope.Complete(); blockBlob.LastModificationTime = nullable; this._blob = blockBlob; this.LeaseInfo = new BlobLeaseInfo(blockBlob, utcNow); } } }, base.Timeout, context.GetResumeCallback(), context.GetResumeState("DbListBlobObject.PutBlobImpl")); yield return(asyncResult); this._storageManager.AsyncProcessor.EndExecute(asyncResult); }