User: pra
Date: 01/03/02 06:59:31
Modified: src/main/org/jboss/jms/asf StdServerSession.java
StdServerSessionPool.java
StdServerSessionPoolFactory.java ThreadPool.java
Log:
Added clean up stuff so that sessions are closed, threads are stoped and pools are
cleared. Was necesarry to stop failover to leak threads
Revision Changes Path
1.4 +19 -1 jboss/src/main/org/jboss/jms/asf/StdServerSession.java
Index: StdServerSession.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/StdServerSession.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StdServerSession.java 2001/02/28 09:25:43 1.3
+++ StdServerSession.java 2001/03/02 14:59:30 1.4
@@ -45,7 +45,7 @@
private StdServerSessionPool serverSessionPool = null;
private Session session = null;
private XASession xaSession = null;
- private TransactionManager tm;
+ private TransactionManager tm;
StdServerSession(StdServerSessionPool pool, Session session, XASession
xaSession) throws JMSException{
@@ -192,5 +192,23 @@
void recycle()
{
serverSessionPool.recycle(this);
+ }
+
+ /**
+ * Called by the ServerSessionPool when the sessions should be closed.
+ */
+ void close() {
+ if (session != null) {
+ try {
+ session.close();
+ }catch(Exception ex) {}
+ session = null;
+ }
+ if (xaSession != null) {
+ try {
+ xaSession.close();
+ }catch(Exception ex) {}
+ xaSession = null;
+ }
}
} // StdServerSession
1.4 +23 -0 jboss/src/main/org/jboss/jms/asf/StdServerSessionPool.java
Index: StdServerSessionPool.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/StdServerSessionPool.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StdServerSessionPool.java 2001/02/28 09:25:44 1.3
+++ StdServerSessionPool.java 2001/03/02 14:59:30 1.4
@@ -18,6 +18,7 @@
package org.jboss.jms.asf;
import java.util.Vector;
+import java.util.Enumeration;
import javax.jms.Connection;
import javax.jms.JMSException;
@@ -119,6 +120,28 @@
return threadPool;
}
+ /**
+ * Clear the pool, clear out both threads and ServerSessions,
+ * connection.stop() should be run before this method.
+ */
+ public void clear() {
+ synchronized (sessionPool){
+ // FIXME - is there a runaway condition here. What if a
+ // ServerSession are taken by a ConnecionConsumer? Should we set
+ // a flag somehow so that no
+ // ServerSessions are recycled and the ThreadPool don't leve any
+ // more threads out.
+ Logger.debug("Clearing " + sessionPool.size() + " from ServerSessionPool");
+ for(Enumeration e = sessionPool.elements() ; e.hasMoreElements() ; ){
+ StdServerSession ses = (StdServerSession)e.nextElement();
+ // Should we do any thing to the server session?
+ ses.close();
+ }
+ sessionPool.clear();
+ threadPool.clear();
+ sessionPool.notifyAll();
+ }
+ }
// --- Private methods used internally
1.3 +0 -1
jboss/src/main/org/jboss/jms/asf/StdServerSessionPoolFactory.java
Index: StdServerSessionPoolFactory.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/StdServerSessionPoolFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StdServerSessionPoolFactory.java 2001/02/28 09:25:44 1.2
+++ StdServerSessionPoolFactory.java 2001/03/02 14:59:30 1.3
@@ -46,6 +46,5 @@
public ServerSessionPool getServerSessionPool(Connection con, int maxSession,
boolean isTransacted, int ack, MessageListener listener) throws JMSException {
ServerSessionPool pool = (ServerSessionPool)new StdServerSessionPool(con,
isTransacted, ack, listener,maxSession);
return pool;
- //}
}
} // StdServerSessionPoolFactory
1.3 +2 -2 jboss/src/main/org/jboss/jms/asf/ThreadPool.java
Index: ThreadPool.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/ThreadPool.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ThreadPool.java 2001/01/03 08:28:36 1.2
+++ ThreadPool.java 2001/03/02 14:59:31 1.3
@@ -21,7 +21,7 @@
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
* @author Peter Antman ([EMAIL PROTECTED])
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class ThreadPool
{
@@ -41,7 +41,7 @@
// Public --------------------------------------------------------
- public synchronized void clear()
+ public synchronized void clear()
{
for (int i = 0; i < pool.size(); i++)
{