Esempio n. 1
0
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentials.</param>
 /// <param name="keyMaker"></param>
 /// <param name="keyDeserializer"></param>
 /// <param name="storageIdMaker"></param>
 /// <param name="keySerializer"></param>
 /// <param name="entityName">The options entity name. If this is not presented then the entity name will be used.</param>
 /// <param name="versionPolicy">The versioning policy.</param>
 /// <param name="defaultTimeout">The default timeout for async requests.</param>
 /// <param name="accessType">The azure access type. BlobContainerPublicAccessType.Off is the default.</param>
 /// <param name="options">The optional blob request options.</param>
 /// <param name="context">The optional operation context.</param>
 /// <param name="persistenceRetryPolicy">Persistence retry policy</param>
 /// <param name="resourceProfile"></param>
 /// <param name="cacheManager"></param>
 /// <param name="referenceMaker"></param>
 /// <param name="encryption"></param>
 public PersistenceMessageHandlerAzureBlobStorageBase(StorageCredentials credentials
                                                      , Func <E, K> keyMaker
                                                      , Func <string, K> keyDeserializer
                                                      , Func <K, string> storageIdMaker = null
                                                      , Func <K, string> keySerializer  = null
                                                      , string entityName = null
                                                      , VersionPolicy <E> versionPolicy               = null
                                                      , TimeSpan?defaultTimeout                       = null
                                                      , BlobContainerPublicAccessType accessType      = BlobContainerPublicAccessType.Off
                                                      , BlobRequestOptions options                    = null
                                                      , OperationContext context                      = null
                                                      , PersistenceRetryPolicy persistenceRetryPolicy = null
                                                      , ResourceProfile resourceProfile               = null
                                                      , ICacheManager <K, E> cacheManager             = null
                                                      , Func <E, IEnumerable <Tuple <string, string> > > referenceMaker = null
                                                      , IServiceHandlerEncryption encryption = null
                                                      )
     : base(keyMaker, keyDeserializer
            , entityName: entityName
            , versionPolicy: versionPolicy
            , defaultTimeout: defaultTimeout
            , persistenceRetryPolicy: persistenceRetryPolicy
            , resourceProfile: resourceProfile
            , cacheManager: cacheManager
            , referenceMaker: referenceMaker
            , keySerializer: keySerializer
            )
 {
     mDirectory      = entityName ?? typeof(E).Name;
     mStorage        = new StorageServiceBase(credentials, "persistence", accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mStorageIdMaker = storageIdMaker ?? mTransform.KeySerializer;
 }
Esempio n. 2
0
        /// <summary>
        /// This method initializes the blob client and container.
        /// </summary>
        public override void Initialize()
        {
            Client = StorageAccount.CreateCloudBlobClient();

            if (RequestOptionsDefault == null)
            {
                RequestOptionsDefault = new BlobRequestOptions()
                {
                    RetryPolicy     = new LinearRetry(TimeSpan.FromMilliseconds(200), 5)
                    , ServerTimeout = DefaultTimeout ?? TimeSpan.FromSeconds(1)
                                      //, ParallelOperationThreadCount = 64
                }
            }
            ;

            Client.DefaultRequestOptions = RequestOptionsDefault;

            if (ContainerId == null)
            {
                ContainerId = AzureStorageHelper.GetEnum <DataCollectionSupport>(Support).StringValue;
            }

            ContainerId = StorageServiceBase.ValidateAzureContainerName(ContainerId);

            Container = Client.GetContainerReference(ContainerId);

            Container.CreateIfNotExistsAsync(BlobAccessType, RequestOptionsDefault, Context).Wait();
        }
Esempio n. 3
0
        /// <summary>
        /// This method initiialises the table storage connector.
        /// </summary>
        public override void Initialize()
        {
            Client = StorageAccount.CreateCloudTableClient();

            if (RequestOptionsDefault != null)
            {
                Client.DefaultRequestOptions = RequestOptionsDefault ??
                                               new TableRequestOptions()
                {
                    RetryPolicy     = new LinearRetry(TimeSpan.FromMilliseconds(200), 5)
                    , ServerTimeout = DefaultTimeout ?? TimeSpan.FromSeconds(1)
                                      //, ParallelOperationThreadCount = 64
                }
            }
            ;

            if (ContainerId == null)
            {
                ContainerId = AzureStorageHelper.GetEnum <DataCollectionSupport>(Support).StringValue;
            }

            ContainerId = StorageServiceBase.ValidateAzureContainerName(ContainerId);

            // Retrieve a reference to the table.
            Table = Client.GetTableReference(ContainerId);

            // Create the table if it doesn't exist.
            Table.CreateIfNotExists();
        }
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentails.</param>
 /// <param name="serviceName">The service name to log under.</param>
 /// <param name="defaultTimeout">The default timeout for each message.</param>
 /// <param name="accessType">The blog storage access type. By default this is set to private.</param>
 /// <param name="options">The blod request options.</param>
 /// <param name="context">The options context.</param>
 /// <param name="encryption">Encryption to be used when logging dead letters</param>
 public DeadLetterLoggerMessageHandler(StorageCredentials credentials, string serviceName
                                       , TimeSpan?defaultTimeout = null
                                       , BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off
                                       , BlobRequestOptions options           = null
                                       , OperationContext context             = null
                                       , IServiceHandlerEncryption encryption = null)
 {
     mStorage     = new StorageServiceBase(credentials, "DeadLetter", accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mServiceName = serviceName;
 }
Esempio n. 5
0
        /// <summary>
        /// This method initializes the connector.
        /// </summary>
        public override void Initialize()
        {
            Client = StorageAccount.CreateCloudQueueClient();
            if (RequestOptionsDefault != null)
            {
                Client.DefaultRequestOptions = RequestOptionsDefault;
            }

            if (ContainerId == null)
            {
                ContainerId = AzureStorageHelper.GetEnum <DataCollectionSupport>(Support).StringValue;
            }

            ContainerId = StorageServiceBase.ValidateAzureContainerName(ContainerId);

            Queue = Client.GetQueueReference(ContainerId);
            Queue.CreateIfNotExistsAsync().Wait();
        }
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentials.</param>
 /// <param name="directoryMaker"></param>
 /// <param name="defaultTimeout">The default timeout for async requests.</param>
 /// <param name="accessType">The azure access type. BlobContainerPublicAccessType.Off is the default.</param>
 /// <param name="options">The optional blob request options.</param>
 /// <param name="context">The optional operation context.</param>
 /// <param name="containerName"></param>
 /// <param name="serviceName"></param>
 /// <param name="idMaker"></param>
 /// <param name="resourceProfile"></param>
 /// <param name="encryption"></param>
 protected AzureStorageLoggingBase(StorageCredentials credentials
                                   , string containerName
                                   , string serviceName
                                   , Func <E, string> idMaker                 = null
                                   , Func <E, string> directoryMaker          = null
                                   , TimeSpan?defaultTimeout                  = null
                                   , BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off
                                   , BlobRequestOptions options               = null
                                   , OperationContext context                 = null
                                   , ResourceProfile resourceProfile          = null
                                   , IServiceHandlerEncryption encryption     = null)
 {
     mStorage         = new StorageServiceBase(credentials, containerName, accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mIdMaker         = idMaker ?? IdMaker;
     mDirectoryMaker  = directoryMaker ?? DirectoryMaker;
     mServiceName     = serviceName;
     mResourceProfile = resourceProfile;
 }
Esempio n. 7
0
        public override void Initialize()
        {
            Client = StorageAccount.CreateCloudTableClient();

            if (RequestOptionsDefault != null)
            {
                Client.DefaultRequestOptions = RequestOptionsDefault;
            }

            if (ContainerId == null)
            {
                ContainerId = AzureStorageHelper.GetEnum <DataCollectionSupport>(Support).StringValue;
            }

            ContainerId = StorageServiceBase.ValidateAzureContainerName(ContainerId);

            // Retrieve a reference to the table.
            Table = Client.GetTableReference(ContainerId);

            // Create the table if it doesn't exist.
            Table.CreateIfNotExists();
        }