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)); }
public SafePartitionManager( AzureStorageOrchestrationService service, OrchestrationSessionManager sessionManager, AzureStorageOrchestrationServiceSettings settings, CloudStorageAccount account, AzureStorageOrchestrationServiceStats stats) { this.service = service; this.settings = settings; this.stats = stats; this.sessionManager = sessionManager; string storageAccountName = account.Credentials.AccountName; this.intentLeaseManager = new BlobLeaseManager( settings, settings.TaskHubName.ToLowerInvariant() + "-leases", string.Empty, "intent", account.CreateCloudBlobClient(), skipBlobContainerCreation: false, stats); this.intentLeaseCollectionManager = new LeaseCollectionBalancer <BlobLease>( "intent", settings, storageAccountName, this.intentLeaseManager, new LeaseCollectionBalancerOptions { AcquireInterval = settings.LeaseAcquireInterval, RenewInterval = settings.LeaseRenewInterval, LeaseInterval = settings.LeaseInterval, }); var currentlyOwnedIntentLeases = this.intentLeaseCollectionManager.GetCurrentlyOwnedLeases(); this.ownershipLeaseManager = new BlobLeaseManager( settings, settings.TaskHubName.ToLowerInvariant() + "-leases", string.Empty, "ownership", account.CreateCloudBlobClient(), skipBlobContainerCreation: false, stats); this.ownershipLeaseCollectionManager = new LeaseCollectionBalancer <BlobLease>( "ownership", this.settings, storageAccountName, 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)); }