예제 #1
0
        public SafePartitionManager(
            AzureStorageOrchestrationService service,
            AzureStorageClient azureStorageClient,
            OrchestrationSessionManager sessionManager)
        {
            this.service            = service;
            this.azureStorageClient = azureStorageClient;
            this.settings           = this.azureStorageClient.Settings;
            this.sessionManager     = sessionManager;

            this.intentLeaseManager = AzureStorageOrchestrationService.GetBlobLeaseManager(
                this.azureStorageClient,
                "intent");

            this.intentLeaseCollectionManager = new LeaseCollectionBalancer <BlobLease>(
                "intent",
                settings,
                this.azureStorageClient.BlobAccountName,
                this.intentLeaseManager,
                new LeaseCollectionBalancerOptions
            {
                AcquireInterval = settings.LeaseAcquireInterval,
                RenewInterval   = settings.LeaseRenewInterval,
                LeaseInterval   = settings.LeaseInterval,
            });

            var currentlyOwnedIntentLeases = this.intentLeaseCollectionManager.GetCurrentlyOwnedLeases();

            this.ownershipLeaseManager = AzureStorageOrchestrationService.GetBlobLeaseManager(
                this.azureStorageClient,
                "ownership");

            this.ownershipLeaseCollectionManager = new LeaseCollectionBalancer <BlobLease>(
                "ownership",
                this.settings,
                this.azureStorageClient.BlobAccountName,
                this.ownershipLeaseManager,
                new LeaseCollectionBalancerOptions
            {
                AcquireInterval   = TimeSpan.FromSeconds(5),
                RenewInterval     = TimeSpan.FromSeconds(10),
                LeaseInterval     = TimeSpan.FromSeconds(15),
                ShouldStealLeases = false
            },
                shouldAquireLeaseDelegate: leaseKey => currentlyOwnedIntentLeases.ContainsKey(leaseKey),
                shouldRenewLeaseDelegate: leaseKey => currentlyOwnedIntentLeases.ContainsKey(leaseKey) ||
                this.sessionManager.IsControlQueueReceivingMessages(leaseKey) ||
                this.sessionManager.IsControlQueueProcessingMessages(leaseKey));
        }
예제 #2
0
        public LegacyPartitionManager(
            AzureStorageOrchestrationService service,
            AzureStorageClient azureStorageClient)
        {
            this.service            = service;
            this.azureStorageClient = azureStorageClient;
            this.settings           = this.azureStorageClient.Settings;
            this.leaseManager       = AzureStorageOrchestrationService.GetBlobLeaseManager(
                this.azureStorageClient,
                "default");

            this.leaseCollectionManager = new LeaseCollectionBalancer <BlobLease>(
                "default",
                settings,
                this.azureStorageClient.BlobAccountName,
                leaseManager,
                new LeaseCollectionBalancerOptions
            {
                AcquireInterval   = settings.LeaseAcquireInterval,
                RenewInterval     = settings.LeaseRenewInterval,
                LeaseInterval     = settings.LeaseInterval,
                ShouldStealLeases = true,
            });
        }