Пример #1
0
        public LegacyPartitionManager(
            AzureStorageOrchestrationService service,
            AzureStorageOrchestrationServiceSettings settings,
            CloudStorageAccount account,
            AzureStorageOrchestrationServiceStats stats)
        {
            this.service      = service;
            this.settings     = settings;
            this.stats        = stats;
            this.leaseManager = new BlobLeaseManager(
                settings,
                settings.TaskHubName.ToLowerInvariant() + "-leases",
                string.Empty,
                "default",
                account.CreateCloudBlobClient(),
                skipBlobContainerCreation: false,
                stats);

            this.leaseCollectionManager = new LeaseCollectionBalancer <BlobLease>(
                "default",
                settings,
                account.Credentials.AccountName,
                leaseManager,
                new LeaseCollectionBalancerOptions
            {
                AcquireInterval   = settings.LeaseAcquireInterval,
                RenewInterval     = settings.LeaseRenewInterval,
                LeaseInterval     = settings.LeaseInterval,
                ShouldStealLeases = true,
            });
        }
Пример #2
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));
        }
Пример #3
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,
            });
        }
Пример #4
0
 public LeaseObserverManager(LeaseCollectionBalancer <T> partitionManager)
 {
     this.partitionManager = partitionManager;
     this.observers        = new List <LeaseObserver <T> >();
 }
Пример #5
0
        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));
        }