Skip to content

Commit

Permalink
[FIXED JENKINS-19691] - Added the hudson.model.Queue.cacheRefreshPeri…
Browse files Browse the repository at this point in the history
…od option

The option allows to manage the refresh period of the internal queue cache.

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
(cherry picked from commit 0d82598)
(cherry picked from commit 05cb8b2ec6b7e7ca688cfbcf4711bb2d14950eff)
  • Loading branch information
oleg-nenashev authored and olivergondza committed Nov 13, 2014
1 parent 0e6f09c commit 227b73e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/src/main/java/hudson/model/Queue.java
Expand Up @@ -148,6 +148,14 @@
*/
@ExportedBean
public class Queue extends ResourceController implements Saveable {

/**
* Defines the refresh period for of the internal cache ({@link #itemsView}).
* Data should be defined in milliseconds, default value - 1000;
* @since TODO: define the version
*/
private static int CACHE_REFRESH_PERIOD = Integer.getInteger(Queue.class.getName() + ".cacheRefreshPeriod", 1000);

/**
* Items that are waiting for its quiet period to pass.
*
Expand Down Expand Up @@ -208,7 +216,7 @@ List<Item> get() {
long t = System.currentTimeMillis();
long d = expires.get();
if (t>d) {// need to refresh the cache
long next = t+1000;
long next = t+CACHE_REFRESH_PERIOD;
if (expires.compareAndSet(d,next)) {
// avoid concurrent cache update via CAS.
// if the getItems() lock is contended,
Expand Down

0 comments on commit 227b73e

Please sign in to comment.