コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DocumentDB.ChangeFeedProcessor.ChangeFeedEventHost"/> class.
        /// </summary>
        /// <param name="hostName">Unique name for this host.</param>
        /// <param name="documentCollectionLocation">Specifies location of the DocumentDB collection to monitor changes for.</param>
        /// <param name="auxCollectionLocation">Specifies location of auxiliary data for load-balancing instances of <see cref="DocumentDB.ChangeFeedProcessor.ChangeFeedEventHost" />.</param>
        /// <param name="changeFeedOptions">Options to pass to the Microsoft.AzureDocuments.DocumentClient.CreateChangeFeedQuery API.</param>
        /// <param name="hostOptions">Additional options to control load-balancing of <see cref="DocumentDB.ChangeFeedProcessor.ChangeFeedEventHost" /> instances.</param>
        public ChangeFeedEventHost(
            string hostName,
            DocumentCollectionInfo documentCollectionLocation,
            DocumentCollectionInfo auxCollectionLocation,
            ChangeFeedOptions changeFeedOptions,
            ChangeFeedHostOptions hostOptions)
        {
            if (documentCollectionLocation == null)
            {
                throw new ArgumentException("documentCollectionLocation");
            }
            if (documentCollectionLocation.Uri == null)
            {
                throw new ArgumentException("documentCollectionLocation.Uri");
            }
            if (string.IsNullOrWhiteSpace(documentCollectionLocation.DatabaseName))
            {
                throw new ArgumentException("documentCollectionLocation.DatabaseName");
            }
            if (string.IsNullOrWhiteSpace(documentCollectionLocation.CollectionName))
            {
                throw new ArgumentException("documentCollectionLocation.CollectionName");
            }
            if (hostOptions.MinPartitionCount > hostOptions.MaxPartitionCount)
            {
                throw new ArgumentException("hostOptions.MinPartitionCount cannot be greater than hostOptions.MaxPartitionCount");
            }

            this.collectionLocation             = CanoninicalizeCollectionInfo(documentCollectionLocation);
            this.changeFeedOptions              = changeFeedOptions;
            this.options                        = hostOptions;
            this.HostName                       = hostName;
            this.auxCollectionLocation          = CanoninicalizeCollectionInfo(auxCollectionLocation);
            this.partitionKeyRangeIdToWorkerMap = new ConcurrentDictionary <string, WorkerData>();
        }
コード例 #2
0
        public PartitionManager(string workerName, ILeaseManager <T> leaseManager, ChangeFeedHostOptions options)
        {
            this.workerName   = workerName;
            this.leaseManager = leaseManager;
            this.options      = options;

            this.currentlyOwnedPartitions = new ConcurrentDictionary <string, T>();
            this.keepRenewingDuringClose  = new ConcurrentDictionary <string, T>();
            this.partitionObserverManager = new PartitionObserverManager(this);
        }