pero 2004/11/22 06:50:23
Modified: catalina/src/share/org/apache/catalina/session
ManagerBase.java PersistentManagerBase.java
StandardManager.java
Log:
Move processExpiresFrequency check to ManagerBase and reflect change to all
subclasses (StandardManager, PersientManagerBase, DeltaManager)
Revision Changes Path
1.37 +95 -10
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/ManagerBase.java
Index: ManagerBase.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/ManagerBase.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- ManagerBase.java 24 Sep 2004 14:55:13 -0000 1.36
+++ ManagerBase.java 22 Nov 2004 14:50:23 -0000 1.37
@@ -180,6 +180,25 @@
protected int duplicates=0;
protected boolean initialized=false;
+
+ /**
+ * Processing time during session expiration.
+ */
+ protected long processingTime = 0;
+
+ /**
+ * Iteration count for background processing.
+ */
+ private int count = 0;
+
+
+ /**
+ * Frequency of the session expiration, and related manager operations.
+ * Manager operations will be done once for the specified amount of
+ * backgrondProcess calls (ie, the lower the amount, the most often the
+ * checks will occur).
+ */
+ protected int processExpiresFrequency = 6;
/**
* The string manager for this package.
@@ -257,8 +276,6 @@
Container oldContainer = this.container;
this.container = container;
support.firePropertyChange("container", oldContainer,
this.container);
- // TODO: find a good scheme for the log names
- //log=LogFactory.getLog("tomcat.manager." + container.getName());
}
@@ -515,9 +532,11 @@
this.random = new java.util.Random();
this.random.setSeed(seed);
}
- long t2=System.currentTimeMillis();
- if( (t2-t1) > 100 )
- log.debug(sm.getString("managerBase.seeding",
randomClass) + " " + (t2-t1));
+ if(log.isDebugEnabled()) {
+ long t2=System.currentTimeMillis();
+ if( (t2-t1) > 100 )
+ log.debug(sm.getString("managerBase.seeding",
randomClass) + " " + (t2-t1));
+ }
}
}
}
@@ -571,6 +590,42 @@
this.expiredSessions = expiredSessions;
}
+ public long getProcessingTime() {
+ return processingTime;
+ }
+
+
+ public void setProcessingTime(long processingTime) {
+ this.processingTime = processingTime;
+ }
+
+ /**
+ * Return the frequency of manager checks.
+ */
+ public int getProcessExpiresFrequency() {
+
+ return (this.processExpiresFrequency);
+
+ }
+
+ /**
+ * Set the manager checks frequency.
+ *
+ * @param processExpiresFrequency the new manager checks frequency
+ */
+ public void setProcessExpiresFrequency(int processExpiresFrequency) {
+
+ if (processExpiresFrequency <= 0) {
+ return;
+ }
+
+ int oldProcessExpiresFrequency = this.processExpiresFrequency;
+ this.processExpiresFrequency = processExpiresFrequency;
+ support.firePropertyChange("processExpiresFrequency",
+ new Integer(oldProcessExpiresFrequency),
+ new
Integer(this.processExpiresFrequency));
+
+ }
// --------------------------------------------------------- Public
Methods
@@ -579,8 +634,34 @@
* Implements the Manager interface, direct call to processExpires
*/
public void backgroundProcess() {
+ count = (count + 1) % processExpiresFrequency;
+ if (count == 0)
+ processExpires();
}
+ /**
+ * Invalidate all sessions that have expired.
+ */
+ public void processExpires() {
+
+ long timeNow = System.currentTimeMillis();
+ Session sessions[] = findSessions();
+ int expireHere = 0 ;
+
+ if(log.isDebugEnabled())
+ log.debug("Start expire sessions " + getName() + " at " +
timeNow + " sessioncount " + sessions.length);
+ for (int i = 0; i < sessions.length; i++) {
+ if (!sessions[i].isValid()) {
+ expiredSessions++;
+ expireHere++;
+ }
+ }
+ long timeEnd = System.currentTimeMillis();
+ if(log.isDebugEnabled())
+ log.debug("End expire sessions " + getName() + " processingTime
" + (timeEnd - timeNow) + " expired sessions: " + expireHere);
+ processingTime += ( timeEnd - timeNow );
+
+ }
public void destroy() {
if( oname != null )
@@ -610,7 +691,8 @@
log.error("Error registering ",e);
}
}
- log.debug("Registering " + oname );
+ if(log.isDebugEnabled())
+ log.debug("Registering " + oname );
}
@@ -768,7 +850,8 @@
if( len==bytes.length ) {
return;
}
- log.debug("Got " + len + " " + bytes.length );
+ if(log.isDebugEnabled())
+ log.debug("Got " + len + " " + bytes.length );
} catch( Exception ex ) {
}
devRandomSource=null;
@@ -993,7 +1076,8 @@
public String getSessionAttribute( String sessionId, String key ) {
Session s=(Session)sessions.get(sessionId);
if( s==null ) {
- log.info("Session not found " + sessionId);
+ if(log.isInfoEnabled())
+ log.info("Session not found " + sessionId);
return null;
}
Object o=s.getSession().getAttribute(key);
@@ -1005,7 +1089,8 @@
public void expireSession( String sessionId ) {
Session s=(Session)sessions.get(sessionId);
if( s==null ) {
- log.info("Session not found " + sessionId);
+ if(log.isInfoEnabled())
+ log.info("Session not found " + sessionId);
return;
}
s.expire();
1.24 +28 -82
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java
Index: PersistentManagerBase.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- PersistentManagerBase.java 2 Nov 2004 19:07:50 -0000 1.23
+++ PersistentManagerBase.java 22 Nov 2004 14:50:23 -0000 1.24
@@ -203,69 +203,11 @@
*/
protected long processingTime = 0;
- /**
- * Frequency of the session expiration, and related manager operations.
- * Manager operations will be done once for the specified amount of
- * backgrondProcess calls (ie, the lower the amount, the most often the
- * checks will occur).
- */
- protected int processExpiresFrequency = 6;
-
-
- /**
- * Iteration count for background processing.
- */
- private int count = 0;
// -------------------------------------------------------------
Properties
- /**
- * Return the frequency of manager checks.
- */
- public int getProcessExpiresFrequency() {
-
- return (this.processExpiresFrequency);
-
- }
-
-
- /**
- * Set the manager checks frequency.
- *
- * @param processExpiresFrequency the new manager checks frequency
- */
- public void setProcessExpiresFrequency(int processExpiresFrequency) {
-
- if (processExpiresFrequency <= 0) {
- return;
- }
-
- int oldProcessExpiresFrequency = this.processExpiresFrequency;
- this.processExpiresFrequency = processExpiresFrequency;
- support.firePropertyChange("processExpiresFrequency",
- new Integer(oldProcessExpiresFrequency),
- new
Integer(this.processExpiresFrequency));
-
- }
- /**
- * Implements the Manager interface, direct call to processExpires and
processPersistenceChecks
- */
- public void backgroundProcess() {
- count = (count + 1) % processExpiresFrequency;
- if (count == 0) {
- long timeNow = System.currentTimeMillis();
-
- processExpires();
- processPersistenceChecks();
- if ((getStore() != null) && (getStore() instanceof
StoreBase)) {
- ((StoreBase) getStore()).processExpires();
- }
-
- long timeEnd = System.currentTimeMillis();
- processingTime += (timeEnd - timeNow);
- }
- }
+
/**
@@ -469,17 +411,6 @@
this.rejectedSessions = rejectedSessions;
}
-
- public long getProcessingTime() {
- return processingTime;
- }
-
-
- public void setProcessingTime(long processingTime) {
- this.processingTime = processingTime;
- }
-
-
/**
* Return the descriptive short name of this Manager implementation.
*/
@@ -601,23 +532,38 @@
/**
- * Invalidate all sessions that have expired.
- */
+ * Implements the Manager interface, direct call to processExpires and
processPersistenceChecks
+ */
public void processExpires() {
- Session sessions[] = findSessions();
-
- for (int i = 0; i < sessions.length; i++) {
- sessions[i].isValid();
- }
-
+ long timeNow = System.currentTimeMillis();
+ Session sessions[] = findSessions();
+ int expireHere = 0 ;
+ if(log.isDebugEnabled())
+ log.debug("Start expire sessions " + getName() + " at " +
timeNow + " sessioncount " + sessions.length);
+ for (int i = 0; i < sessions.length; i++) {
+ if (!sessions[i].isValid()) {
+ expiredSessions++;
+ expireHere++;
+ }
+ }
+ processPersistenceChecks();
+ if ((getStore() != null) && (getStore() instanceof StoreBase)) {
+ ((StoreBase) getStore()).processExpires();
+ }
+
+ long timeEnd = System.currentTimeMillis();
+ if(log.isDebugEnabled())
+ log.debug("End expire sessions " + getName() + " processingTime
" + (timeEnd - timeNow) + " expired sessions: " + expireHere);
+ processingTime += (timeEnd - timeNow);
+
}
/**
- * Called by the background thread after active sessions have been
checked
- * for expiration, to allow sessions to be swapped out, backed up, etc.
- */
+ * Called by the background thread after active sessions have been
checked
+ * for expiration, to allow sessions to be swapped out, backed up, etc.
+ */
public void processPersistenceChecks() {
processMaxIdleSwaps();
1.26 +1 -84
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardManager.java
Index: StandardManager.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardManager.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- StandardManager.java 5 Oct 2004 17:12:52 -0000 1.25
+++ StandardManager.java 22 Nov 2004 14:50:23 -0000 1.26
@@ -108,21 +108,6 @@
/**
- * Iteration count for background processing.
- */
- private int count = 0;
-
-
- /**
- * Frequency of the session expiration, and related manager operations.
- * Manager operations will be done once for the specified amount of
- * backgrondProcess calls (ie, the lower the amount, the most often the
- * checks will occur).
- */
- protected int processExpiresFrequency = 6;
-
-
- /**
* The maximum number of active Sessions allowed, or -1 for no limit.
*/
protected int maxActiveSessions = -1;
@@ -229,46 +214,6 @@
}
- public long getProcessingTime() {
- return processingTime;
- }
-
-
- public void setProcessingTime(long processingTime) {
- this.processingTime = processingTime;
- }
-
-
- /**
- * Return the frequency of manager checks.
- */
- public int getProcessExpiresFrequency() {
-
- return (this.processExpiresFrequency);
-
- }
-
-
- /**
- * Set the manager checks frequency.
- *
- * @param processExpiresFrequency the new manager checks frequency
- */
- public void setProcessExpiresFrequency(int processExpiresFrequency) {
-
- if (processExpiresFrequency <= 0) {
- return;
- }
-
- int oldProcessExpiresFrequency = this.processExpiresFrequency;
- this.processExpiresFrequency = processExpiresFrequency;
- support.firePropertyChange("processExpiresFrequency",
- new Integer(oldProcessExpiresFrequency),
- new
Integer(this.processExpiresFrequency));
-
- }
-
-
/**
* Set the maximum number of actives Sessions allowed, or -1 for
* no limit.
@@ -799,32 +744,4 @@
return (file);
}
-
-
- /**
- * Invalidate all sessions that have expired.
- */
- public void processExpires() {
-
- long timeNow = System.currentTimeMillis();
- Session sessions[] = findSessions();
-
- for (int i = 0; i < sessions.length; i++) {
- sessions[i].isValid();
- }
- long timeEnd = System.currentTimeMillis();
- processingTime += ( timeEnd - timeNow );
-
- }
-
- /**
- * Implements the Manager interface, direct call to processExpires
- */
- public void backgroundProcess() {
- count = (count + 1) % processExpiresFrequency;
- if (count == 0)
- processExpires();
- }
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]