Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #214 from mintsoft/master

Queue: Implementing a maximum size restriction per queue
  • Loading branch information...
commit 0ced9ffb9f651474dd09a38e756064c8ebd5e220 2 parents 98b1adf + a7a65c5
@RubenWillems RubenWillems authored
View
13 project/core/Config/DefaultQueueConfiguration.cs
@@ -92,6 +92,7 @@ public class DefaultQueueConfiguration
private string name;
private QueueDuplicateHandlingMode handlingMode = QueueDuplicateHandlingMode.UseFirst;
private string lockQueueNames;
+ private int maxSize = int.MaxValue;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultQueueConfiguration"/> class.
@@ -143,6 +144,18 @@ public virtual string LockQueueNames
get { return lockQueueNames; }
set { lockQueueNames = value; }
}
+
+ /// <summary>
+ /// The maximum number of items that can be exist in the queue.
+ /// </summary>
+ /// <default>none</default>
+ /// <version>1.4.2</version>
+ [ReflectorProperty("maxsize", Required = false)]
+ public virtual int MaxSize
+ {
+ get { return maxSize; }
+ set { maxSize = value; }
+ }
/// <summary>
/// The list of projects for the queue.
View
5 project/core/Config/IQueueConfiguration.cs
@@ -21,6 +21,11 @@ public interface IQueueConfiguration
/// A list of the names of any other queues which should be locked when a project in this queue is building.
/// </summary>
string LockQueueNames { get; set; }
+
+ /// <summary>
+ /// The maximum size of the the queue
+ /// </summary>
+ int MaxSize { get; set; }
/// <summary>
/// Gets or sets the projects.
View
4 project/core/Queues/IntegrationQueue.cs
@@ -90,6 +90,10 @@ public void Enqueue(IIntegrationQueueItem integrationQueueItem)
// We can start integration straight away as first in first served
AddToQueue(integrationQueueItem);
}
+ else if ( Count >= configuration.MaxSize )
+ {
+ throw new ConfigurationException(string.Format("Project '{0}' cannot be added to queue '{1}' as the queue is full", integrationQueueItem.Project.Name, Name));
+ }
else
{
// We need to see if we already have a integration request for this project on the queue
Please sign in to comment.
Something went wrong with that request. Please try again.