Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReliableCloudCacheStorage"/> class using the specified storage account information, custom retry policy
        /// and custom implementation of <see cref="ICloudStorageEntitySerializer"/> interface.
        /// </summary>
        /// <param name="endpointInfo">The endpoint details for Windows Azure Caching Service.</param>
        /// <param name="retryPolicy">The custom retry policy that will ensure reliable access to the Caching Service.</param>
        /// <param name="dataSerializer">An instance of the component which performs custom serialization and deserialization of cache items.</param>
        public ReliableCloudCacheStorage(CachingServiceEndpointInfo endpointInfo, RetryPolicy retryPolicy, ICloudStorageEntitySerializer dataSerializer)
        {
            Guard.ArgumentNotNull(endpointInfo, "endpointInfo");
            Guard.ArgumentNotNull(retryPolicy, "retryPolicy");
            Guard.ArgumentNotNull(dataSerializer, "dataSerializer");

            this.retryPolicy    = retryPolicy;
            this.dataSerializer = dataSerializer;

            var cacheServers = new List <DataCacheServerEndpoint>(1);

            cacheServers.Add(new DataCacheServerEndpoint(endpointInfo.ServiceHostName, endpointInfo.CachePort));

            var cacheConfig = new DataCacheFactoryConfiguration()
            {
                Servers = cacheServers,
                MaxConnectionsToServer = 1,
                IsCompressionEnabled   = false,
                SecurityProperties     = new DataCacheSecurity(endpointInfo.SecureAuthenticationToken, endpointInfo.SslEnabled),
                // As per recommendations in http://blogs.msdn.com/b/akshar/archive/2011/05/01/azure-appfabric-caching-errorcode-lt-errca0017-gt-substatus-lt-es0006-gt-what-to-do.aspx
                TransportProperties = new DataCacheTransportProperties()
                {
                    ReceiveTimeout = TimeSpan.FromSeconds(45)
                }
            };

            this.cacheFactory = new DataCacheFactory(cacheConfig);
            this.cache        = this.retryPolicy.ExecuteAction <DataCache>(() =>
            {
                return(this.cacheFactory.GetDefaultCache());
            });
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReliableHybridBlobStorage"/> class using the specified storage account information, caching service endpoint, custom retry policies
        /// and a custom implementation of <see cref="ICloudStorageEntitySerializer"/> interface.
        /// </summary>
        /// <param name="storageAccountInfo">The access credentials for Windows Azure storage account.</param>
        /// <param name="storageRetryPolicy">The custom retry policy that will ensure reliable access to the underlying blob storage.</param>
        /// <param name="cacheEndpointInfo">The endpoint details for Windows Azure Caching Service.</param>
        /// <param name="cacheRetryPolicy">The custom retry policy that will ensure reliable access to the Caching Service.</param>
        /// <param name="dataSerializer">An instance of the component which performs serialization and deserialization of storage objects.</param>
        public ReliableHybridBlobStorage(StorageAccountInfo storageAccountInfo, RetryPolicy storageRetryPolicy, CachingServiceEndpointInfo cacheEndpointInfo, RetryPolicy cacheRetryPolicy, ICloudStorageEntitySerializer dataSerializer)
        {
            Guard.ArgumentNotNull(storageAccountInfo, "storageAccountInfo");
            Guard.ArgumentNotNull(storageRetryPolicy, "storageRetryPolicy");
            Guard.ArgumentNotNull(cacheEndpointInfo, "cacheEndpointInfo");
            Guard.ArgumentNotNull(cacheRetryPolicy, "cacheRetryPolicy");
            Guard.ArgumentNotNull(dataSerializer, "dataSerializer");

            this.dataSerializer = dataSerializer;
            this.storageList    = new List <ICloudBlobStorage>(2);

            this.storageList.Add(this.cacheStorage = new ReliableCloudCacheStorage(cacheEndpointInfo, cacheRetryPolicy, dataSerializer));
            this.storageList.Add(this.blobStorage  = new ReliableCloudBlobStorage(storageAccountInfo, storageRetryPolicy, dataSerializer));
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the reliable Windows Azure Table storage layer connected to the specified storage account,
        /// initialized with the specified retry policy and custom serializer.
        /// </summary>
        /// <param name="storageAccountInfo">The access credentials for Windows Azure storage account.</param>
        /// <param name="retryPolicy">The custom retry policy that will ensure reliable access to the underlying table storage.</param>
        /// <param name="dataSerializer">An instance of the component which performs serialization and deserialization of storage objects.</param>
        public ReliableCloudTableStorage(StorageAccountInfo storageAccountInfo, RetryPolicy retryPolicy, ICloudStorageEntitySerializer dataSerializer)
        {
            Guard.ArgumentNotNull(storageAccountInfo, "storageAccountInfo");
            Guard.ArgumentNotNull(retryPolicy, "retryPolicy");
            Guard.ArgumentNotNull(dataSerializer, "dataSerializer");

            this.retryPolicy    = retryPolicy;
            this.dataSerializer = dataSerializer;

            CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(storageAccountInfo.AccountName, storageAccountInfo.AccountKey), true);

            this.tableStorage = storageAccount.CreateCloudTableClient();

            // Configure the Table storage not to enforce any retry policies since this is something that we will be dealing ourselves.
            this.tableStorage.RetryPolicy = RetryPolicies.NoRetry();
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReliableCloudBlobStorage"/> class using the specified storage account information, custom retry policy
        /// and custom implementation of <see cref="ICloudStorageEntitySerializer"/> interface.
        /// </summary>
        /// <param name="storageAccountInfo">The access credentials for Windows Azure storage account.</param>
        /// <param name="retryPolicy">The custom retry policy that will ensure reliable access to the underlying storage.</param>
        /// <param name="dataSerializer">An instance of the component which performs serialization and deserialization of storage objects.</param>
        public ReliableCloudBlobStorage(StorageAccountInfo storageAccountInfo, RetryPolicy retryPolicy, ICloudStorageEntitySerializer dataSerializer)
        {
            Guard.ArgumentNotNull(storageAccountInfo, "storageAccountInfo");
            Guard.ArgumentNotNull(retryPolicy, "retryPolicy");
            Guard.ArgumentNotNull(dataSerializer, "dataSerializer");

            this.retryPolicy    = retryPolicy;
            this.dataSerializer = dataSerializer;

            CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(storageAccountInfo.AccountName, storageAccountInfo.AccountKey), true);

            this.blobStorage = storageAccount.CreateCloudBlobClient();

            // Configure the Blob storage not to enforce any retry policies since this is something that we will be dealing ourselves.
            this.blobStorage.RetryPolicy = RetryPolicies.NoRetry();

            // Disable parallelism in blob upload operations to reduce the impact of multiple concurrent threads on parallel upload feature.
            this.blobStorage.ParallelOperationThreadCount = 1;
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReliableCloudQueueStorage"/> class using the specified storage account information, custom retry policy,
        /// custom implementation of <see cref="ICloudStorageEntitySerializer"/> interface and custom implementation of the large message overflow store.
        /// </summary>
        /// <param name="storageAccountInfo">The storage account that is projected through this component.</param>
        /// <param name="retryPolicy">The specific retry policy that will ensure reliable access to the underlying storage.</param>
        /// <param name="dataSerializer">An instance of the component which performs serialization and deserialization of storage objects.</param>
        /// <param name="overflowStorage">An instance of the component implementing overflow store that will be used for persisting large messages that cannot be accommodated in a queue due to message size constraints.</param>
        public ReliableCloudQueueStorage(StorageAccountInfo storageAccountInfo, RetryPolicy retryPolicy, ICloudStorageEntitySerializer dataSerializer, ICloudBlobStorage overflowStorage)
        {
            Guard.ArgumentNotNull(storageAccountInfo, "storageAccountInfo");
            Guard.ArgumentNotNull(retryPolicy, "retryPolicy");
            Guard.ArgumentNotNull(dataSerializer, "dataSerializer");
            Guard.ArgumentNotNull(overflowStorage, "overflowStorage");

            this.retryPolicy     = retryPolicy;
            this.dataSerializer  = dataSerializer;
            this.overflowStorage = overflowStorage;

            CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(storageAccountInfo.AccountName, storageAccountInfo.AccountKey), true);

            this.queueStorage = storageAccount.CreateCloudQueueClient();

            // Configure the Queue storage not to enforce any retry policies since this is something that we will be dealing ourselves.
            this.queueStorage.RetryPolicy = RetryPolicies.NoRetry();

            this.inflightMessages = new ConcurrentDictionary <object, InflightMessageInfo>(Environment.ProcessorCount * 4, InflightMessageQueueInitialCapacity);
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReliableHybridBlobStorage"/> class using the specified storage account information, caching service endpoint
 /// and custom implementation of <see cref="ICloudStorageEntitySerializer"/> interface. Assumes the default use of <see cref="RetryPolicy.DefaultExponential"/>
 /// retry policies when accessing storage and caching services.
 /// </summary>
 /// <param name="storageAccountInfo">The access credentials for Windows Azure storage account.</param>
 /// <param name="cacheEndpointInfo">The endpoint details for Windows Azure Caching Service.</param>
 /// <param name="dataSerializer">An instance of the component which performs serialization and deserialization of storage objects.</param>
 public ReliableHybridBlobStorage(StorageAccountInfo storageAccountInfo, CachingServiceEndpointInfo cacheEndpointInfo, ICloudStorageEntitySerializer dataSerializer)
     : this
     (
         storageAccountInfo,
         new RetryPolicy <StorageTransientErrorDetectionStrategy>(RetryPolicy.DefaultClientRetryCount, RetryPolicy.DefaultMinBackoff, RetryPolicy.DefaultMaxBackoff, RetryPolicy.DefaultClientBackoff),
         cacheEndpointInfo,
         new RetryPolicy <CacheTransientErrorDetectionStrategy>(RetryPolicy.DefaultClientRetryCount, RetryPolicy.DefaultMinBackoff, RetryPolicy.DefaultMaxBackoff, RetryPolicy.DefaultClientBackoff),
         dataSerializer
     )
 {
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReliableCloudQueueStorage"/> class using the specified storage account information, custom retry policy
 /// and custom implementation of <see cref="ICloudStorageEntitySerializer"/> interface.
 /// </summary>
 /// <param name="storageAccountInfo">The storage account that is projected through this component.</param>
 /// <param name="retryPolicy">The specific retry policy that will ensure reliable access to the underlying storage.</param>
 /// <param name="dataSerializer">An instance of the component which performs serialization and deserialization of storage objects.</param>
 public ReliableCloudQueueStorage(StorageAccountInfo storageAccountInfo, RetryPolicy retryPolicy, ICloudStorageEntitySerializer dataSerializer)
     : this(storageAccountInfo, retryPolicy, dataSerializer, new ReliableCloudBlobStorage(storageAccountInfo, retryPolicy, dataSerializer))
 {
 }