created separate init() and start() methods,
wrote lots of thread state getters to make this accessible from other packages.
This commit is contained in:
parent
9734e347a9
commit
ddb7ec49a4
1 changed files with 77 additions and 9 deletions
|
@ -161,9 +161,9 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IRep
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finish initializing the application and start requestors and type manager.
|
* Finish initializing the application
|
||||||
*/
|
*/
|
||||||
public void start () throws DbException {
|
public void init () throws DbException {
|
||||||
|
|
||||||
eval = new RequestEvaluator (this);
|
eval = new RequestEvaluator (this);
|
||||||
logEvent ("Starting evaluators for "+name);
|
logEvent ("Starting evaluators for "+name);
|
||||||
|
@ -197,11 +197,6 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IRep
|
||||||
|
|
||||||
nmgr = new NodeManager (this, dbDir.getAbsolutePath (), props);
|
nmgr = new NodeManager (this, dbDir.getAbsolutePath (), props);
|
||||||
|
|
||||||
// worker = new Thread (this, "Worker-"+name);
|
|
||||||
// worker.setPriority (Thread.NORM_PRIORITY+2);
|
|
||||||
// worker.start ();
|
|
||||||
// logEvent ("session cleanup and scheduler thread started");
|
|
||||||
|
|
||||||
String xmlrpcHandlerName = props.getProperty ("xmlrpcHandlerName", this.name);
|
String xmlrpcHandlerName = props.getProperty ("xmlrpcHandlerName", this.name);
|
||||||
if (xmlrpc != null)
|
if (xmlrpc != null)
|
||||||
xmlrpc.addHandler (xmlrpcHandlerName, new XmlRpcInvoker (this));
|
xmlrpc.addHandler (xmlrpcHandlerName, new XmlRpcInvoker (this));
|
||||||
|
@ -209,6 +204,15 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IRep
|
||||||
// typemgr.start ();
|
// typemgr.start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create request evaluators and start scheduler and cleanup thread
|
||||||
|
*/
|
||||||
|
public void start () {
|
||||||
|
worker = new Thread (this, "Worker-"+name);
|
||||||
|
worker.setPriority (Thread.NORM_PRIORITY+2);
|
||||||
|
worker.start ();
|
||||||
|
// logEvent ("session cleanup and scheduler thread started");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called to shut down a running application.
|
* This is called to shut down a running application.
|
||||||
|
@ -307,7 +311,8 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IRep
|
||||||
public ResponseTrans execute (RequestTrans req) {
|
public ResponseTrans execute (RequestTrans req) {
|
||||||
|
|
||||||
requestCount += 1;
|
requestCount += 1;
|
||||||
// long reqstart = System.currentTimeMillis ();
|
|
||||||
|
// get user for this request's session
|
||||||
User u = getUser (req.session);
|
User u = getUser (req.session);
|
||||||
|
|
||||||
ResponseTrans res = null;
|
ResponseTrans res = null;
|
||||||
|
@ -350,7 +355,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IRep
|
||||||
res.waitForClose ();
|
res.waitForClose ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// System.err.println ("********************** ABSOLUTE TIME: "+(System.currentTimeMillis() - reqstart));
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,6 +442,13 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IRep
|
||||||
return typemgr.getPrototype (protoname);
|
return typemgr.getPrototype (protoname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a collection containing all prototypes defined for this application
|
||||||
|
*/
|
||||||
|
public Collection getPrototypes () {
|
||||||
|
return typemgr.prototypes.values ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the user currently associated with a given Hop session ID. This may be
|
* Return the user currently associated with a given Hop session ID. This may be
|
||||||
|
@ -837,6 +849,62 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IRep
|
||||||
return props.getProperty (propname, defvalue);
|
return props.getProperty (propname, defvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int countThreads () {
|
||||||
|
return threadgroup.activeCount() -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int countEvaluators () {
|
||||||
|
return allThreads.size()-1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int countFreeEvaluators () {
|
||||||
|
return freeThreads.size ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int countActiveEvaluators () {
|
||||||
|
return allThreads.size() - freeThreads.size () -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int countMaxActiveEvaluators () {
|
||||||
|
return typemgr.countRegisteredRequestEvaluators () -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public long getRequestCount () {
|
||||||
|
return requestCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public long getXmlrpcCount () {
|
||||||
|
return xmlrpcCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public long getErrorCount () {
|
||||||
|
return errorCount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Periodically called to log thread stats for this application
|
* Periodically called to log thread stats for this application
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue