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; }
SlinqyAgent( IPhysicalQueueService queueService, SlinqyQueueShardMonitor slinqyQueueShardMonitor, double storageCapacityScaleOutThreshold) : this(queueService, slinqyQueueShardMonitor, storageCapacityScaleOutThreshold, 1) { }
SlinqyAgent( IPhysicalQueueService queueService, SlinqyQueueShardMonitor slinqyQueueShardMonitor, double storageCapacityScaleOutThreshold) { this.monitoring = false; this.queueService = queueService; this.queueShardMonitor = slinqyQueueShardMonitor; this.storageCapacityScaleOutThreshold = storageCapacityScaleOutThreshold; }
SlinqyAgent( IPhysicalQueueService queueService, SlinqyQueueShardMonitor slinqyQueueShardMonitor, double storageCapacityScaleOutThreshold, int shardIndexPadding) { this.queueService = queueService; this.queueShardMonitor = slinqyQueueShardMonitor; this.storageCapacityScaleOutThreshold = storageCapacityScaleOutThreshold; this.shardIndexPadding = shardIndexPadding; }
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; }
SlinqyQueue( SlinqyQueueShardMonitor slinqyQueueShardMonitor) { this.queueShardMonitor = slinqyQueueShardMonitor; }
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 ); }