Esempio n. 1
0
 public void ReadEntity(IDictionary <string, EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
 {
     foreach (var item in properties)
     {
         SetProperProperty(item.Key, item.Value.PropertyAsObject);
     }
 }
Esempio n. 2
0
        public override IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var dict = base.WriteEntity(operationContext);

            WriteTimestamp(dict, "Created_At", Created_At);
            return(dict);
        }
Esempio n. 3
0
        public override void ReadEntity(IDictionary <string, EntityProperty> properties,
                                        Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            base.ReadEntity(properties, operationContext);

            EntityId = ReadString(properties, "EntityId");
        }
Esempio n. 4
0
        void ReadEntity(IDictionary <string, EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            // This can occasionally fail because someone didn't finish creating the entity yet.

            EntityProperty value;

            if (properties.TryGetValue("SerializedError", out value))
            {
                Error = ErrorXml.DecodeString(value.StringValue);
            }
            else
            {
                Error = new Error
                {
                    ApplicationName = "TableErrorLog",
                    StatusCode      = 999,
                    HostName        = Environment.MachineName,
                    Time            = DateTime.UtcNow,
                    Type            = typeof(Exception).FullName,
                    Detail          = "Error Log Entry is Corrupted/Missing in Table Store"
                };

                return;
            }

            if (properties.TryGetValue("Detail", out value))
            {
                Error.Detail = value.StringValue;
            }

            if (properties.TryGetValue("WebHostHtmlMessage", out value))
            {
                Error.WebHostHtmlMessage = value.StringValue;
            }
        }
Esempio n. 5
0
        public override IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var dict = MergeDicts(base.WriteEntity(operationContext));

            WriteString(dict, "EntityId", EntityId);
            return(dict);
        }
Esempio n. 6
0
        public virtual IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var dict = MergeDicts(null);

            Timestamp = DateTimeOffset.Now;
            WriteTimestamp(dict, "Timestamp", Timestamp);

            return(dict);
        }
Esempio n. 7
0
 public void ReadEntity(IDictionary <string, EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
 {
     a = properties["a"].Int32Value.Value;
     b = properties["b"].Int32Value.Value;
     c = properties["c"].Int32Value.Value;
     d = properties["d"].StringValue;
     e = properties["e"].BooleanValue.Value;
     f = properties["f"].DoubleValue.Value;
 }
Esempio n. 8
0
        public override void ReadEntity(IDictionary <string, EntityProperty> properties,
                                        Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            base.ReadEntity(properties, operationContext);

            ReviewId       = ReadString(properties, "ReviewId");
            ReviewerName   = ReadString(properties, "ReviewerName");
            Review         = ReadString(properties, "Review");
            ReviewerRating = ReadInt(properties, "ReviewerRating");
            SystemRating   = ReadInt(properties, "SystemRating");
        }
Esempio n. 9
0
        public override IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var dict = MergeDicts(base.WriteEntity(operationContext));

            WriteString(dict, "ReviewId", ReviewId);
            WriteString(dict, "ReviewerName", ReviewerName);
            WriteString(dict, "Review", Review);
            WriteInt(dict, "ReviewerRating", ReviewerRating);
            WriteInt(dict, "SystemRating", SystemRating);

            return(dict);
        }
Esempio n. 10
0
        public IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var _entities = new Dictionary <string, EntityProperty>(StringComparer.InvariantCultureIgnoreCase);

            // Add all of the properties from the property bag
            foreach (var item in EventProperties)
            {
                _entities.Add(item.Key, new EntityProperty(item.Value));
            }

            return(_entities);
        }
Esempio n. 11
0
        public IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var res = new Dictionary <string, EntityProperty>();

            res.Add("a", new EntityProperty(a));
            res.Add("b", new EntityProperty(b));
            res.Add("c", new EntityProperty(c));
            res.Add("d", new EntityProperty(d));
            res.Add("e", new EntityProperty(e));
            res.Add("f", new EntityProperty(f));

            return(res);
        }
        public override IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var entityProperties = base.WriteEntity(operationContext);
            var objectProperties = GetType().GetProperties();

            foreach (var property in from property in objectProperties
                     let nonSerializedAttributes = property.GetCustomAttributes(typeof(NonSerializedTableStoreAttribute), false)
                                                   where nonSerializedAttributes.Length > 0
                                                   select property)
            {
                entityProperties.Remove(property.Name);
            }

            return(entityProperties);
        }
Esempio n. 13
0
        public override void ReadEntity(IDictionary <string, EntityProperty> properties,
                                        Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            base.ReadEntity(properties, operationContext);

            MovieId         = ReadString(properties, "MovieId");
            Name            = ReadString(properties, "Name");
            AltNames        = ReadString(properties, "AltNames");
            Actors          = ReadString(properties, "Actors");
            Directors       = ReadString(properties, "Directors");
            Producers       = ReadString(properties, "Producers");
            MusicDirectors  = ReadString(properties, "MusicDirectors");
            ReviewIds       = ReadString(properties, "ReviewIds");
            AggregateRating = ReadString(properties, "AggregateRating");
            HotOrNot        = ReadBool(properties, "HotOrNot");
            Synopsis        = ReadString(properties, "Synopsis");
        }
Esempio n. 14
0
        public override IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var dict = MergeDicts(base.WriteEntity(operationContext));

            WriteString(dict, "MovieId", MovieId);
            WriteString(dict, "Name", Name);
            WriteString(dict, "AltNames", AltNames);
            WriteString(dict, "Actors", Actors);
            WriteString(dict, "Directors", Directors);
            WriteString(dict, "Producers", Producers);
            WriteString(dict, "MusicDirectors", MusicDirectors);
            WriteString(dict, "ReviewIds", ReviewIds);
            WriteString(dict, "AggregateRating", AggregateRating);
            WriteBool(dict, "HotOrNot", HotOrNot);
            WriteString(dict, "Synopsis", Synopsis);

            return(dict);
        }
Esempio n. 15
0
        public override void ReadEntity(IDictionary <string, EntityProperty> properties,
                                        Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            base.ReadEntity(properties, operationContext);

            MovieId  = ReadString(properties, "MovieId");
            Name     = ReadString(properties, "Name");
            AltNames = ReadString(properties, "AltNames");
            Posters  = ReadString(properties, "Posters");
            Ratings  = ReadString(properties, "Rating");
            Synopsis = ReadString(properties, "Synopsis");
            Casts    = ReadString(properties, "Cast");
            Stats    = ReadString(properties, "Stats");
            Songs    = ReadString(properties, "Songs");
            Trailers = ReadString(properties, "Trailers");
            Pictures = ReadString(properties, "Pictures");
            Genre    = ReadString(properties, "Genre");
            Month    = ReadString(properties, "Month");
            Year     = ReadString(properties, "Year");
        }
Esempio n. 16
0
        public override IDictionary <string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var dict = MergeDicts(base.WriteEntity(operationContext));

            WriteString(dict, "MovieId", MovieId);
            WriteString(dict, "Name", Name);
            WriteString(dict, "AltNames", AltNames);
            WriteString(dict, "Posters", Posters);
            WriteString(dict, "Rating", Ratings);
            WriteString(dict, "Synopsis", Synopsis);
            WriteString(dict, "Cast", Casts);
            WriteString(dict, "Stats", Stats);
            WriteString(dict, "Songs", Songs);
            WriteString(dict, "Trailers", Trailers);
            WriteString(dict, "Pictures", Pictures);
            WriteString(dict, "Month", Month);
            WriteString(dict, "Year", Year);
            WriteString(dict, "Genre", Genre);

            return(dict);
        }
Esempio n. 17
0
        public static IEnumerable <IListBlobItem> ListBlobs(this CloudBlobContainer container, string prefix, bool useFlatBlobListing = false, BlobListingDetails blobListingDetails = BlobListingDetails.None, BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null)
        {
            BlobContinuationToken token   = new BlobContinuationToken();
            BlobResultSegment     segment = container.ListBlobsSegmentedAsync(prefix, useFlatBlobListing, blobListingDetails, int.MaxValue, token, options, operationContext).Result;

            while (segment.ContinuationToken != null)
            {
                foreach (var t in segment.Results)
                {
                    yield return(t);
                }

                segment = container.ListBlobsSegmentedAsync(prefix, useFlatBlobListing, blobListingDetails, int.MaxValue, token, options, operationContext).Result;
            }
        }
Esempio n. 18
0
 public override void ReadEntity(IDictionary <string, EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
 {
     base.ReadEntity(properties, operationContext);
     this.Id = Guid.Parse(this.RowKey);
 }
Esempio n. 19
0
        // TODO: implement this
        //public void DownloadRangeToStream(System.IO.Stream target, long? offset, long? length, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null)
        //{
        //    ServerState ss = slaEngine.FindServerToRead(name);
        //    ICloudBlob blob = configuration.GetCloudBlobContainerDetail(ss.Name).GetCloudBlob(name);

        //    watch.Start();
        //    blob.DownloadRangeToStream(target, offset, length, accessCondition, options, operationContext);
        //    ss.AddRtt(watch.ElapsedMilliseconds);
        //    slaEngine.SessionState.RecordObjectRead(blob.Name, Timestamp(blob), ss);
        //}

        public bool Exists(Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null)
        {
            // Note sure that it's a good idea to ask a secondary site if a blob exists...
            bool result = false;

            protocol.Read(blob => result = blob.Exists(options, operationContext));

            /*
             * ServerState ss = slaEngine.FindServerToRead(Name);
             * ICloudBlob blob = ClientRegistry.GetCloudBlob(ss.Name, configuration.Name, Name);
             *
             * watch.Start();
             * bool result = blob.Exists(options, operationContext);
             * ss.AddRtt(watch.ElapsedMilliseconds);
             * // slaEngine.SessionState.RecordObjectRead(blob.Name, Timestamp(blob), ss);
             * slaEngine.Session.RecordObjectRead(blob.Name, Timestamp(blob), ss, "");
             */
            return(result);
        }
Esempio n. 20
0
        //public int StreamWriteSizeInBytes
        //{
        //    get
        //    {
        //        return strongBlob.StreamWriteSizeInBytes;
        //    }
        //    set
        //    {
        //        strongBlob.StreamWriteSizeInBytes = value;
        //        eventualBlob.StreamWriteSizeInBytes = value;
        //    }
        //}

        //public int StreamMinimumReadSizeInBytes
        //{
        //    get
        //    {
        //        return strongBlob.StreamMinimumReadSizeInBytes;
        //    }
        //    set
        //    {
        //        strongBlob.StreamMinimumReadSizeInBytes = value;
        //        eventualBlob.StreamMinimumReadSizeInBytes = value;
        //    }
        //}

        //public Microsoft.WindowsAzure.Storage.Blob.BlobProperties Properties
        //{
        //    get { return strongBlob.Properties; }
        //}

        //public IDictionary<string, string> Metadata
        //{
        //    get { return strongBlob.Metadata; }
        //}

        //public DateTimeOffset? SnapshotTime
        //{
        //    get { return strongBlob.SnapshotTime; }
        //}

        //public Microsoft.WindowsAzure.Storage.Blob.CopyState CopyState
        //{
        //    get { return strongBlob.CopyState; }
        //}

        //public Microsoft.WindowsAzure.Storage.Blob.BlobType BlobType
        //{
        //    get { return strongBlob.BlobType; }
        //}

        /// <summary>
        /// Upload to primary blobs from the provided stream.
        ///
        /// Our put is using an optimization where it does not take lease on blobs if there is only one primary container.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="accessCondition"></param>
        /// <param name="options"></param>
        /// <param name="operationContext"></param>
        public void UploadFromStream(System.IO.Stream source, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null)
        {
            source.Position = 0;
            protocol.Write(blob => blob.UploadFromStream(source, /*lease.getAccessConditionWithLeaseId(accessCondition)*/ accessCondition, options, operationContext), accessCondition);

            /*
             * bool isDone = false;
             *
             * do
             * {
             *  try
             *  {
             *
             *      if (configuration.IsInFastMode())
             *      {
             *          DoUploadFromStream(source, 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());
             *                  DoUploadFromStream(source, accessCondition, options, operationContext);
             *                  isDone = true;
             *              }
             *              else
             *              {
             *                  continue;
             *              }
             *          }
             *      }
             *  }
             *  catch (StorageException ex)
             *  {
             *      throw ex;
             *  }
             *  catch (Exception ex)
             *  {
             *      Console.WriteLine(ex.StackTrace.ToString());
             *      throw ex;
             *  }
             * }
             * while (!isDone);
             */
        }
Esempio n. 21
0
        public void FetchAttributes(Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null)
        {
            // TODO: use protocol
            ServerState ss   = slaEngine.FindServerToRead(Name);
            ICloudBlob  blob = ClientRegistry.GetCloudBlob(ss.Name, configuration.Name, Name);

            watch.Start();
            blob.FetchAttributes(accessCondition, options, operationContext);
            ss.AddRtt(watch.ElapsedMilliseconds);
            // slaEngine.SessionState.RecordObjectRead(blob.Name, Timestamp(blob), ss);
            slaEngine.Session.RecordObjectRead(blob.Name, Timestamp(blob), ss, "");
        }
Esempio n. 22
0
        //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);
        }
Esempio n. 23
0
        private void DoUploadFromStream(System.IO.Stream source, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition = null, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null)
        {
            try
            {
                bool done = false;
                while (!done)
                {
                    using (PrimaryCloudBlobLease lease = new PrimaryCloudBlobLease(Name, configuration, true))
                    {
                        if (lease.HasLease)
                        {
                            foreach (string server in configuration.PrimaryServers)
                            {
                                watch.Start();

                                ICloudBlob blob = ClientRegistry.GetCloudBlob(server, configuration.Name, Name, false);

                                source.Position = 0;
                                blob.UploadFromStream(source, lease.getAccessConditionWithLeaseId(accessCondition), options, operationContext);

                                watch.Stop();

                                ServerState ss = slaEngine.Monitor.GetServerState(server);
                                ss.AddRtt(watch.ElapsedMilliseconds);
                                slaEngine.Session.RecordObjectWritten(Name, Timestamp(blob), ss);
                            }

                            done = true;
                        }
                    }
                }
            }
            catch (StorageException se)
            {
                throw se;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 24
0
 public void ReadEntity(IDictionary <string, Microsoft.WindowsAzure.Storage.Table.EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
 {
     Microsoft.WindowsAzure.Storage.Table.TableEntity.ReadUserObject(this, properties, operationContext);
 }
Esempio n. 25
0
        private void DoDelete(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 done = false;

            while (!done)
            {
                using (PrimaryCloudBlobLease lease = new PrimaryCloudBlobLease(this.Name, configuration, true))
                {
                    if (lease.HasLease)
                    {
                        Dictionary <ICloudBlob, IAsyncResult> results = new Dictionary <ICloudBlob, IAsyncResult>();
                        foreach (string serverName in configuration.PrimaryServers)
                        {
                            watch.Start();
                            ICloudBlob blob = ClientRegistry.GetCloudBlob(serverName, configuration.Name, Name);
                            results[blob] = blob.BeginDelete(deleteSnapshotsOption, lease.getAccessConditionWithLeaseId(accessCondition), options, operationContext, null, null);
                            ServerState ss = slaEngine.Monitor.GetServerState(serverName);
                            ss.AddRtt(watch.ElapsedMilliseconds);
                            slaEngine.Session.RecordObjectWritten(Name, Timestamp(blob), ss);
                        }

                        foreach (ICloudBlob blob in results.Keys)
                        {
                            blob.EndDelete(results[blob]);
                        }
                        done = true;
                    }
                }
            }
        }
Esempio n. 26
0
 public virtual void ReadEntity(IDictionary <string, EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
 {
     ETag      = ReadString(properties, "ETag");
     Timestamp = ReadTimestamp(properties, "Timestamp");
 }
Esempio n. 27
0
 public IDictionary <string, Microsoft.WindowsAzure.Storage.Table.EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
 {
     return(Microsoft.WindowsAzure.Storage.Table.TableEntity.WriteUserObject(this, operationContext));
 }
Esempio n. 28
0
 public override void ReadEntity(IDictionary <string, EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
 {
     base.ReadEntity(properties, operationContext);
     Created_At = ReadTimestamp(properties, "Created_At");
 }
Esempio n. 29
0
        public override void ReadEntity(IDictionary <string, EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            base.ReadEntity(properties, operationContext);

            ReviewId       = ReadString(properties, "ReviewId");
            ReviewerName   = ReadString(properties, "ReviewerName");
            Review         = ReadString(properties, "Review");
            ReviewerRating = ReadInt(properties, "ReviewerRating");
            SystemRating   = ReadInt(properties, "SystemRating");
            MovieId        = ReadString(properties, "MovieId");
            Hot            = ReadBool(properties, "Hot");
            OutLink        = ReadString(properties, "OutLink");
            Affiliation    = ReadString(properties, "Affiliation");
        }
Esempio n. 30
0
 public static IEnumerable <IListBlobItem> ListBlobs(this CloudBlobContainer container, bool useFlatBlobListing = false, BlobListingDetails blobListingDetails = BlobListingDetails.None, BlobRequestOptions options = null, Microsoft.WindowsAzure.Storage.OperationContext operationContext = null)
 {
     return(container.ListBlobs(String.Empty, useFlatBlobListing, blobListingDetails, options, operationContext));
 }