/// <summary> /// Returns the blob for the main primary site of the current configuration. /// </summary> /// <returns>the primary blob (or null if unable to renew the lease on the configuration)</returns> public ICloudBlob MainPrimary() { ICloudBlob primary = null; if (configuration.IsInFastMode(renew: true)) { string server = configuration.PrimaryServers.First(); primary = ClientRegistry.GetCloudBlob(server, configuration.Name, blobName); } return(primary); }
//public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginUploadFromStream(System.IO.Stream source, AsyncCallback callback, object state) //{ // return strongBlob.BeginUploadFromStream(source, callback, state); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginUploadFromStream(System.IO.Stream source, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext, AsyncCallback callback, object state) //{ // return strongBlob.BeginUploadFromStream(source, accessCondition, options, operationContext, callback, state); //} //public void EndUploadFromStream(IAsyncResult asyncResult) //{ // strongBlob.EndUploadFromStream(asyncResult); // slaEngine.SessionState.RecordObjectWritten(strongBlob.Name, Timestamp(strongBlob), primaryServer); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginDownloadToStream(System.IO.Stream target, AsyncCallback callback, object state) //{ // // TODO: Use SLA to decide from which server to download. // return strongBlob.BeginDownloadToStream(target, callback, state); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginDownloadToStream(System.IO.Stream target, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext, AsyncCallback callback, object state) //{ // return strongBlob.BeginDownloadToStream(target, accessCondition, options, operationContext, callback, state); //} //public void EndDownloadToStream(IAsyncResult asyncResult) //{ // strongBlob.EndDownloadToStream(asyncResult); // slaEngine.SessionState.RecordObjectRead(strongBlob.Name, Timestamp(strongBlob), primaryServer); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginDownloadRangeToStream(System.IO.Stream target, long? offset, long? length, AsyncCallback callback, object state) //{ // return strongBlob.BeginDownloadRangeToStream(target, offset, length, callback, state); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginDownloadRangeToStream(System.IO.Stream target, long? offset, long? length, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext, AsyncCallback callback, object state) //{ // return strongBlob.BeginDownloadRangeToStream(target, offset, length, accessCondition, options, operationContext, callback, state); //} //public void EndDownloadRangeToStream(IAsyncResult asyncResult) //{ // strongBlob.EndDownloadRangeToStream(asyncResult); // slaEngine.SessionState.RecordObjectRead(strongBlob.Name, Timestamp(strongBlob), primaryServer); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginExists(AsyncCallback callback, object state) //{ // return strongBlob.BeginExists(callback, state); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginExists(Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext, AsyncCallback callback, object state) //{ // return strongBlob.BeginExists(options, operationContext, callback, state); //} //public bool EndExists(IAsyncResult asyncResult) //{ // bool result = strongBlob.EndExists(asyncResult); // slaEngine.SessionState.RecordObjectRead(strongBlob.Name, Timestamp(strongBlob), primaryServer); // return result; //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginFetchAttributes(AsyncCallback callback, object state) //{ // return strongBlob.BeginFetchAttributes(callback, state); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginFetchAttributes(Microsoft.WindowsAzure.Storage.AccessCondition accessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext, AsyncCallback callback, object state) //{ // return strongBlob.BeginFetchAttributes(accessCondition, options, operationContext, callback, state); //} //public void EndFetchAttributes(IAsyncResult asyncResult) //{ // strongBlob.EndFetchAttributes(asyncResult); // slaEngine.SessionState.RecordObjectRead(strongBlob.Name, Timestamp(strongBlob), primaryServer); //} //public void SetMetadata(Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null) //{ // watch.Start(); // strongBlob.SetMetadata(accessCondition, options, operationContext); // primaryServer.AddRtt(watch.ElapsedMilliseconds); // slaEngine.SessionState.RecordObjectWritten(strongBlob.Name, Timestamp(strongBlob), primaryServer); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginSetMetadata(AsyncCallback callback, object state) //{ // return strongBlob.BeginSetMetadata(callback, state); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginSetMetadata(Microsoft.WindowsAzure.Storage.AccessCondition accessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext, AsyncCallback callback, object state) //{ // return strongBlob.BeginSetMetadata(accessCondition, options, operationContext, callback, state); //} //public void EndSetMetadata(IAsyncResult asyncResult) //{ // strongBlob.EndSetMetadata(asyncResult); // slaEngine.SessionState.RecordObjectWritten(strongBlob.Name, Timestamp(strongBlob), primaryServer); //} //public void SetProperties(Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null) //{ // watch.Start(); // strongBlob.SetProperties(accessCondition, options, operationContext); // primaryServer.AddRtt(watch.ElapsedMilliseconds); // slaEngine.SessionState.RecordObjectWritten(strongBlob.Name, Timestamp(strongBlob), primaryServer); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginSetProperties(AsyncCallback callback, object state) //{ // return strongBlob.BeginSetProperties(callback, state); //} //public Microsoft.WindowsAzure.Storage.ICancellableAsyncResult BeginSetProperties(Microsoft.WindowsAzure.Storage.AccessCondition accessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext, AsyncCallback callback, object state) //{ // return strongBlob.BeginSetProperties(accessCondition, options, operationContext, callback, state); //} //public void EndSetProperties(IAsyncResult asyncResult) //{ // strongBlob.EndSetProperties(asyncResult); // slaEngine.SessionState.RecordObjectWritten(strongBlob.Name, Timestamp(strongBlob), primaryServer); //} public void Delete(Microsoft.WindowsAzure.Storage.Blob.DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null) { bool isDone = false; do { try { if (configuration.IsInFastMode()) { DoDelete(deleteSnapshotsOption, accessCondition, options, operationContext); isDone = true; } else { //We are not sure if reconfiguration is happening or not. We execute put in slow mode. using (CloudBlobLease lease = new CloudBlobLease(configuration.Name, LeaseTakingPolicy.TryOnce)) { if (lease.HasLease) { configuration.SyncWithCloud(ClientRegistry.GetConfigurationAccount()); DoDelete(deleteSnapshotsOption, accessCondition, options, operationContext); isDone = true; } } } } catch (StorageException ex) { throw ex; } catch (Exception ex) { throw ex; } } while (!isDone); }