Permalink
Browse files

Modify various bit after review by robey.

  • Loading branch information...
1 parent 7841145 commit 52c5fac2c6438eaf826647d6cae3b884d6fd9e57 @gphat gphat committed Feb 16, 2012
View
@@ -151,12 +151,10 @@ useful as a throttling mechanism when using a queue as a way to delay work.
Queue expiration
----------------
-Queues can be configure to expire whole queues as well. When a queue is
-created the time is noted. It is periodically (see the aforementioned
-`expirationTimerFrequency`) checked against the current time and the
-`maxQueueAge` configuration option. If the queue is *empty* and the current time
-is greater than create time + `maxQueueAge` then the queue is ready to be
-expired and will be deleted.
+Whole queues can be configured to expire as well. If `maxQueueAge` is set
+`expirationTimerFrequency` is used to check the queue age. If the queue is
+empty, and it has been longer than `maxQueueAge` since it was created then
+the queue will be deleted.
A `maxQueueAge` of zero, which is usually the default, means a queue never
expires.
@@ -180,7 +178,6 @@ is created, and it will start receiving new items written to the parent queue.
Existing items are not copied over. A fanout queue can be deleted to stop it
from receiving new items.
-
Memcache commands
-----------------
@@ -154,6 +154,8 @@ class Kestrel(defaultQueueConfig: QueueConfig, builders: List[QueueBuilder],
if (expired > 0) {
log.info("Expired %d item(s) from queues automatically.", expired)
}
+ // Now that we've cleaned out the queue, lets see if any of them are
+ // ready to be expired.
Kestrel.this.queueCollection.deleteExpiredQueues()
}
}.start()
@@ -148,14 +148,10 @@ class PersistentQueue(val name: String, persistencePath: String, @volatile var c
*/
def isReadyForExpiration: Boolean = {
// Don't even bother if the maxQueueAge is None
- if(config.maxQueueAge.isDefined && config.maxQueueAge.get == None) {
- false
+ if(config.maxQueueAge.isDefined && queue.isEmpty && Time.now > _createTime + config.maxQueueAge.get) {
+ true
} else {
- if(queue.isEmpty && config.maxQueueAge.isDefined && Time.now > _createTime + config.maxQueueAge.get) {
- true
- } else {
- false
- }
+ false
}
}
@@ -198,10 +198,9 @@ class QueueCollection(queueFolder: String, timer: Timer, journalSyncScheduler: S
}
def expireQueue(name: String): Unit = {
-
- if(!shuttingDown) {
+ if (!shuttingDown) {
queues.get(name) map { q =>
- if(q.isReadyForExpiration) {
+ if (q.isReadyForExpiration) {
delete(name)
Stats.incr("queue_expires")
log.info("Expired queue %s", name)
@@ -217,8 +216,6 @@ class QueueCollection(queueFolder: String, timer: Timer, journalSyncScheduler: S
def deleteExpiredQueues(): Unit = {
- // Now that we've cleaned out the queue, lets see if any of them are
- // ready to be expired.
queueNames.map { qName => expireQueue(qName) }
}

0 comments on commit 52c5fac

Please sign in to comment.