use explicit flag for stopped app and throw exception to
the servlet so it really knows whats going on.
This commit is contained in:
parent
bbf1122ddb
commit
b78f45ddaf
1 changed files with 11 additions and 1 deletions
|
@ -42,6 +42,8 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
protected Stack freeThreads;
|
protected Stack freeThreads;
|
||||||
protected Vector allThreads;
|
protected Vector allThreads;
|
||||||
|
|
||||||
|
boolean stopped = false;
|
||||||
|
|
||||||
Hashtable sessions;
|
Hashtable sessions;
|
||||||
Hashtable activeUsers;
|
Hashtable activeUsers;
|
||||||
Hashtable dbMappings;
|
Hashtable dbMappings;
|
||||||
|
@ -150,6 +152,9 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
|
|
||||||
|
|
||||||
public void stop () {
|
public void stop () {
|
||||||
|
|
||||||
|
stopped = true;
|
||||||
|
|
||||||
// stop all threads, this app is going down
|
// stop all threads, this app is going down
|
||||||
if (worker != null)
|
if (worker != null)
|
||||||
worker.interrupt ();
|
worker.interrupt ();
|
||||||
|
@ -174,7 +179,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RequestEvaluator getEvaluator () {
|
protected RequestEvaluator getEvaluator () {
|
||||||
if (freeThreads == null)
|
if (stopped)
|
||||||
throw new ApplicationStoppedException ();
|
throw new ApplicationStoppedException ();
|
||||||
try {
|
try {
|
||||||
return (RequestEvaluator) freeThreads.pop ();
|
return (RequestEvaluator) freeThreads.pop ();
|
||||||
|
@ -228,6 +233,9 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
try {
|
try {
|
||||||
ev = getEvaluator ();
|
ev = getEvaluator ();
|
||||||
res = ev.invoke (req, u);
|
res = ev.invoke (req, u);
|
||||||
|
} catch (ApplicationStoppedException stopped) {
|
||||||
|
// let the servlet know that this application has gone to heaven
|
||||||
|
throw stopped;
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
errorCount += 1;
|
errorCount += 1;
|
||||||
res = new ResponseTrans ();
|
res = new ResponseTrans ();
|
||||||
|
@ -418,6 +426,8 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
worker.sleep (cleanupSleep);
|
worker.sleep (cleanupSleep);
|
||||||
} catch (InterruptedException x) {
|
} catch (InterruptedException x) {
|
||||||
IServer.getLogger().log ("Scheduler for "+name+" interrupted");
|
IServer.getLogger().log ("Scheduler for "+name+" interrupted");
|
||||||
|
worker = null;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
IServer.getLogger().log ("Cleaning up "+name+": " + sessions.size () + " sessions active");
|
IServer.getLogger().log ("Cleaning up "+name+": " + sessions.size () + " sessions active");
|
||||||
|
|
Loading…
Add table
Reference in a new issue