Commit 6778d4dc authored by Andre Freyssinet's avatar Andre Freyssinet

Adds WorkInProgress counter to visualize the engine activity.

parent d0ad44f8
......@@ -87,6 +87,14 @@ public abstract class Agent implements AgentMBean, Serializable, Encodable {
public int getReactNb() {
return reactNb;
}
/**
* Increments the tick counter that reflects activity in server.
* @see #workInProgress
*/
public final void incWorkInProgress() {
AgentServer.getEngine().incWorkInProgress();
}
/**
* Boolean value indicating if the agent profiling is on.
......
......@@ -223,4 +223,9 @@ public interface AgentEngine extends MessageConsumer {
* @return the flag to avoid transactions
*/
boolean isNoTxIfTransient();
/**
* Increments the tick counter that reflects activity in server.
*/
void incWorkInProgress();
}
......@@ -1071,6 +1071,9 @@ class Engine implements Runnable, AgentEngine, EngineMBean {
canStop = false;
if (! isRunning) break;
// Increment workInProgress counter to indicate that the engine is working.
incWorkInProgress();
if ((msg.from == null) || (msg.to == null) || (msg.not == null)) {
// The notification is malformed.
logmon.log(BasicLevel.ERROR,
......@@ -1342,9 +1345,37 @@ class Engine implements Runnable, AgentEngine, EngineMBean {
AgentServer.getTransaction().release();
}
/** the tick counter that reflects activity in engine. */
long workInProgress = 0L;
/**
* Returns the tick counter that reflects activity in engine.
* @return the tick counter that reflects activity in engine.
*/
@Override
public final long getWorkInProgress() {
return workInProgress;
}
/**
* Increments the tick counter that reflects activity in engine.
* @see #workInProgress
*/
@Override
public final void incWorkInProgress() {
workInProgress++;
}
/** The average use of CPU by the Engine thread during last minute. */
AverageCPUTask averageCPUTask = null;
public int getAverageCPU() {
/**
* Returns the average use of CPU by the Engine thread during last minute.
*
* @return the average use of CPU by the Engine thread during last minute.
*/
@Override
public final int getAverageCPU() {
if (averageCPUTask != null)
return averageCPUTask.getAverage();
return 0;
......@@ -1352,7 +1383,7 @@ class Engine implements Runnable, AgentEngine, EngineMBean {
EngineAverageLoadTask averageLoadTask = null;
public void resetAverageLoad() {
public final void resetAverageLoad() {
if (averageLoadTask != null)
averageLoadTask.reset();
}
......@@ -1361,7 +1392,8 @@ class Engine implements Runnable, AgentEngine, EngineMBean {
* Returns the load averages for the last minute.
* @return the load averages for the last minute.
*/
public float getAverageLoad1() {
@Override
public final float getAverageLoad1() {
return averageLoadTask.getAverageLoad1();
}
......@@ -1369,7 +1401,8 @@ class Engine implements Runnable, AgentEngine, EngineMBean {
* Returns the load averages for the past 5 minutes.
* @return the load averages for the past 5 minutes.
*/
public float getAverageLoad5() {
@Override
public final float getAverageLoad5() {
return averageLoadTask.getAverageLoad5();
}
......@@ -1377,7 +1410,8 @@ class Engine implements Runnable, AgentEngine, EngineMBean {
* Returns the load averages for the past 15 minutes.
* @return the load averages for the past 15 minutes.
*/
public float getAverageLoad15() {
@Override
public final float getAverageLoad15() {
return averageLoadTask.getAverageLoad15();
}
......@@ -1430,5 +1464,4 @@ class Engine implements Runnable, AgentEngine, EngineMBean {
public boolean isEngineThread() {
return Thread.currentThread() == thread;
}
}
......@@ -144,6 +144,12 @@ public interface EngineMBean {
*/
public void resetTimer();
/**
* Returns the tick counter that reflects activity in engine.
* @return the tick counter that reflects activity in engine.
*/
public long getWorkInProgress();
/**
* Returns the average use of CPU by the Engine thread during last minute.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment