提交 0d825984 编写于 作者: O Oleg Nenashev

[FIXED JENKINS-19691] - Added the hudson.model.Queue.cacheRefreshPeriod option

The option allows to manage the refresh period of the internal queue cache.
Signed-off-by: NOleg Nenashev <o.v.nenashev@gmail.com>
上级 1568a8bc
...@@ -148,6 +148,14 @@ import org.kohsuke.stapler.interceptor.RequirePOST; ...@@ -148,6 +148,14 @@ import org.kohsuke.stapler.interceptor.RequirePOST;
*/ */
@ExportedBean @ExportedBean
public class Queue extends ResourceController implements Saveable { 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. * Items that are waiting for its quiet period to pass.
* *
...@@ -208,7 +216,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -208,7 +216,7 @@ public class Queue extends ResourceController implements Saveable {
long t = System.currentTimeMillis(); long t = System.currentTimeMillis();
long d = expires.get(); long d = expires.get();
if (t>d) {// need to refresh the cache if (t>d) {// need to refresh the cache
long next = t+1000; long next = t+CACHE_REFRESH_PERIOD;
if (expires.compareAndSet(d,next)) { if (expires.compareAndSet(d,next)) {
// avoid concurrent cache update via CAS. // avoid concurrent cache update via CAS.
// if the getItems() lock is contended, // if the getItems() lock is contended,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册