Exemplo n.º 1
0
        CreateQueueAsync(
            string  queueName,
            int     shardIndexPadding)
        {
            if (string.IsNullOrWhiteSpace(queueName))
                throw new ArgumentNullException(nameof(queueName));

            var queueShardName = SlinqyQueueShard.GenerateFirstShardName(
                slinqyQueueName:    queueName,
                shardIndexPadding:  shardIndexPadding
            );

            // Call the function to create the first physical queue shard to establish the virtual queue.
            // No need to do anything with the returned shard...
            var shard = await this.physicalQueueService
                .CreateQueue(queueShardName)
                .ConfigureAwait(false);

            var shardMonitor = new SlinqyQueueShardMonitor(
                queueName,
                this.physicalQueueService
            );

            await shardMonitor
                .Start()
                .ConfigureAwait(false);

            var queue = new SlinqyQueue(
                shardMonitor
            );

            this.slinqyQueues.TryAdd(queueName, queue);

            return queue;
        }
Exemplo n.º 2
0
 SlinqyAgent(
     IPhysicalQueueService queueService,
     SlinqyQueueShardMonitor slinqyQueueShardMonitor,
     double storageCapacityScaleOutThreshold)
     : this(queueService, slinqyQueueShardMonitor, storageCapacityScaleOutThreshold, 1)
 {
 }
Exemplo n.º 3
0
 SlinqyAgent(
     IPhysicalQueueService   queueService,
     SlinqyQueueShardMonitor slinqyQueueShardMonitor,
     double                  storageCapacityScaleOutThreshold)
 {
     this.monitoring                         = false;
     this.queueService                       = queueService;
     this.queueShardMonitor                  = slinqyQueueShardMonitor;
     this.storageCapacityScaleOutThreshold   = storageCapacityScaleOutThreshold;
 }
Exemplo n.º 4
0
 SlinqyAgent(
     IPhysicalQueueService queueService,
     SlinqyQueueShardMonitor slinqyQueueShardMonitor,
     double storageCapacityScaleOutThreshold,
     int shardIndexPadding)
 {
     this.queueService      = queueService;
     this.queueShardMonitor = slinqyQueueShardMonitor;
     this.storageCapacityScaleOutThreshold = storageCapacityScaleOutThreshold;
     this.shardIndexPadding = shardIndexPadding;
 }
Exemplo n.º 5
0
 SlinqyAgent(
     IPhysicalQueueService   queueService,
     SlinqyQueueShardMonitor slinqyQueueShardMonitor,
     double                  storageCapacityScaleOutThreshold,
     int                     shardIndexPadding)
 {
     this.queueService                       = queueService;
     this.queueShardMonitor                  = slinqyQueueShardMonitor;
     this.storageCapacityScaleOutThreshold   = storageCapacityScaleOutThreshold;
     this.shardIndexPadding                  = shardIndexPadding;
 }
Exemplo n.º 6
0
        CreateQueueAsync(
            string queueName,
            int shardIndexPadding)
        {
            // TODO: Refactor - Much of this functionality overlaps with the Agent,
            //       let Agent create first shard too and remove this code.
            if (string.IsNullOrWhiteSpace(queueName))
            {
                throw new ArgumentNullException(nameof(queueName));
            }

            var queueShardName = SlinqyQueueShard.GenerateFirstShardName(
                slinqyQueueName:    queueName,
                shardIndexPadding:  shardIndexPadding
                );

            // Call the function to create the first physical queue shard to establish the virtual queue.
            // No need to do anything with the returned shard...
            var shard = await this.physicalQueueService
                        .CreateQueue(queueShardName)
                        .ConfigureAwait(false);

            var shardMonitor = new SlinqyQueueShardMonitor(
                queueName,
                this.physicalQueueService
                );

            await shardMonitor
            .Start()
            .ConfigureAwait(false);

            var queue = new SlinqyQueue(
                shardMonitor
                );

            this.slinqyQueues.TryAdd(queueName, queue);

            return(queue);
        }
        CreateQueue(
            CreateQueueCommandModel createQueueModel)
        {
            if (createQueueModel == null)
                throw new ArgumentNullException(nameof(createQueueModel));

            if (!this.ModelState.IsValid)
                return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, this.ModelState);

            var monitor = new SlinqyQueueShardMonitor(
                createQueueModel.QueueName,
                PhysicalQueueService
            );

            slinqyAgent = new SlinqyAgent(
                PhysicalQueueService,
                monitor,
                createQueueModel.StorageCapacityScaleOutThresholdPercentage / 100D,
                4
            );

            await slinqyAgent.Start();

            SlinqyQueues.Add(
                createQueueModel.QueueName,
                new SlinqyQueue(monitor)
            );

            var response = new HttpResponseMessage(HttpStatusCode.Created) {
                Content = new ObjectContent<QueueInformationViewModel>(
                    new QueueInformationViewModel(
                        queueName:              createQueueModel.QueueName,
                        maxQueueSizeMegabytes:  createQueueModel.MaxQueueSizeMegabytes,
                        currentQueueSizeBytes:  0
                    ),
                    new JsonMediaTypeFormatter()
                )
            };

            return response;
        }
Exemplo n.º 8
0
 SlinqyAgent(
     IPhysicalQueueService   queueService,
     SlinqyQueueShardMonitor slinqyQueueShardMonitor,
     double                  storageCapacityScaleOutThreshold)
         : this(queueService, slinqyQueueShardMonitor, storageCapacityScaleOutThreshold, 1)
 {
 }
Exemplo n.º 9
0
 SlinqyQueue(
     SlinqyQueueShardMonitor slinqyQueueShardMonitor)
 {
     this.queueShardMonitor = slinqyQueueShardMonitor;
 }
Exemplo n.º 10
0
        CreateQueue(
            CreateQueueCommandModel createQueueModel)
        {
            if (createQueueModel == null)
                throw new ArgumentNullException(nameof(createQueueModel));

            var queue = await SlinqyQueueClient.CreateQueueAsync(
                queueName:          createQueueModel.QueueName,
                shardIndexPadding:  4
            );

            var monitor = new SlinqyQueueShardMonitor(
                createQueueModel.QueueName,
                PhysicalQueueService
            );

            slinqyAgent = new SlinqyAgent(
                PhysicalQueueService,
                monitor,
                createQueueModel.StorageCapacityScaleOutThresholdPercentage / 100D
            );

            await slinqyAgent.Start();

            return new QueueInformationViewModel(
                queue.Name,
                queue.MaxQueueSizeMegabytes,
                queue.CurrentQueueSizeBytes
            );
        }
Exemplo n.º 11
0
 SlinqyQueue(
     SlinqyQueueShardMonitor slinqyQueueShardMonitor)
 {
     this.queueShardMonitor = slinqyQueueShardMonitor;
 }