You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2010/10/30 01:08:59 UTC
svn commit: r1028939 - in /tomcat/trunk/java/org/apache/jasper:
compiler/JspRuntimeContext.java servlet/JspServletWrapper.java
Author: rjung
Date: Fri Oct 29 23:08:59 2010
New Revision: 1028939
URL: http://svn.apache.org/viewvc?rev=1028939&view=rev
Log:
We will no longer continuously update the jspQueue
order. Instead only update each JSP once between
background task runs.
Changes to JspRuntimeContext:
- Rename "ticket" to "unloadHandle"
- Rename "lastCheck" to "lastCompileCheck" to clarify purpose
- Add lastJspQueueUpdate which contains the time of
the last run of checkUnload()
- Add getter for lastJspQueueUpdate
- Background task checkUnload() now only tracks the time
of its last execution.
Changes to JspServletWrapper:
- Rename "ticket" to "unloadHandle"
- Replace options.getMaxLoadedJsps() with final field "unloadByCount"
- Do no longer move wrapper in jspQueue on each access.
Only move once after each run of the background task checkUnload().
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java
tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java?rev=1028939&r1=1028938&r2=1028939&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java Fri Oct 29 23:08:59 2010
@@ -153,7 +153,7 @@ public final class JspRuntimeContext {
if (!options.getDevelopment()
&& appBase != null
&& options.getCheckInterval() > 0) {
- lastCheck = System.currentTimeMillis();
+ lastCompileCheck = System.currentTimeMillis();
}
if (options.getMaxLoadedJsps() > 0) {
@@ -173,7 +173,8 @@ public final class JspRuntimeContext {
private final PermissionCollection permissionCollection;
private final CodeSource codeSource;
private final String classpath;
- private volatile long lastCheck = -1L;
+ private volatile long lastCompileCheck = -1L;
+ private volatile long lastJspQueueUpdate = System.currentTimeMillis();
/**
* Maps JSP pages to their JspServletWrapper's
@@ -221,7 +222,7 @@ public final class JspRuntimeContext {
* execution of jsp. Destroy any JSP the has been replaced in the queue.
*
* @param jsw Servlet wrapper for jsp.
- * @return a ticket that can be pushed to front of queue at later execution times.
+ * @return an unloadHandle that can be pushed to front of queue at later execution times.
* */
public FastRemovalDequeue<JspServletWrapper>.Entry push(JspServletWrapper jsw) {
FastRemovalDequeue<JspServletWrapper>.Entry entry = jspQueue.push(jsw);
@@ -233,12 +234,12 @@ public final class JspRuntimeContext {
}
/**
- * Push ticket for JspServletWrapper to front of the queue.
+ * Push unloadHandle for JspServletWrapper to front of the queue.
*
- * @param ticket the ticket for the jsp.
+ * @param unloadHandle the unloadHandle for the jsp.
* */
- public void makeYoungest(FastRemovalDequeue<JspServletWrapper>.Entry ticket) {
- jspQueue.moveFirst(ticket);
+ public void makeYoungest(FastRemovalDequeue<JspServletWrapper>.Entry unloadHandle) {
+ jspQueue.moveFirst(unloadHandle);
}
/**
@@ -322,13 +323,13 @@ public final class JspRuntimeContext {
*/
public void checkCompile() {
- if (lastCheck < 0) {
+ if (lastCompileCheck < 0) {
// Checking was disabled
return;
}
long now = System.currentTimeMillis();
- if (now > (lastCheck + (options.getCheckInterval() * 1000L))) {
- lastCheck = now;
+ if (now > (lastCompileCheck + (options.getCheckInterval() * 1000L))) {
+ lastCompileCheck = now;
} else {
return;
}
@@ -361,6 +362,13 @@ public final class JspRuntimeContext {
return classpath;
}
+ /**
+ * Last time the update background task has run
+ */
+ public long getLastJspQueueUpdate() {
+ return lastJspQueueUpdate;
+ }
+
// -------------------------------------------------------- Private Methods
@@ -513,31 +521,12 @@ public final class JspRuntimeContext {
}
}
+
/**
- * Method used by background thread to check if any JSP's should be destroyed.
- * If JSP's to be unloaded are found, they will be destroyed.
- * Uses the lastCheck time from background compiler to determine if it is time to unload JSP's.
+ * Method used by background thread to check if any JSP's should be unloaded.
*/
public void checkUnload() {
- if (options.getMaxLoadedJsps() > 0) {
- while (unloadJsp()) {}
- }
- }
-
- /**
- * Checks whether there is a jsp to unload, if one is found, it is destroyed.
- * */
- public boolean unloadJsp() {
- JspServletWrapper jsw = null;
- synchronized(jspQueue) {
- if(jspQueue.getSize() > options.getMaxLoadedJsps()) {
- jsw = jspQueue.pop();
- }
- }
- if (jsw != null) {
- unloadJspServletWrapper(jsw);
- return true;
- }
- return false;
+
+ lastJspQueueUpdate = System.currentTimeMillis();
}
}
Modified: tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java?rev=1028939&r1=1028938&r2=1028939&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java (original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java Fri Oct 29 23:08:59 2010
@@ -87,7 +87,9 @@ public class JspServletWrapper {
/** Timestamp of last time servlet resource was modified */
private volatile long servletClassLastModifiedTime;
private long lastModificationTest = 0L;
- private FastRemovalDequeue<JspServletWrapper>.Entry ticket;
+ private long lastUsageTime = System.currentTimeMillis();
+ private FastRemovalDequeue<JspServletWrapper>.Entry unloadHandle;
+ private final boolean unloadByCount;
/*
* JspServletWrapper for JSP pages.
@@ -99,6 +101,7 @@ public class JspServletWrapper {
this.config = config;
this.options = options;
this.jspUri = jspUri;
+ unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
ctxt = new JspCompilationContext(jspUri, isErrorPage, options,
config.getServletContext(),
this, rctxt);
@@ -119,6 +122,7 @@ public class JspServletWrapper {
this.options = options;
this.jspUri = tagFilePath;
this.tripCount = 0;
+ unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
ctxt = new JspCompilationContext(jspUri, tagInfo, options,
servletContext, this, rctxt,
tagJarResource);
@@ -373,12 +377,13 @@ public class JspServletWrapper {
/*
* (3) Handle limitation of number of loaded Jsps
*/
- if (options.getMaxLoadedJsps() > 0) {
+ if (unloadByCount) {
synchronized(this) {
- if (ticket == null) {
- ticket = ctxt.getRuntimeContext().push(this);
- } else {
- ctxt.getRuntimeContext().makeYoungest(ticket);
+ if (unloadHandle == null) {
+ unloadHandle = ctxt.getRuntimeContext().push(this);
+ } else if (lastUsageTime < ctxt.getRuntimeContext().getLastJspQueueUpdate()) {
+ ctxt.getRuntimeContext().makeYoungest(unloadHandle);
+ lastUsageTime = System.currentTimeMillis();
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org