Server-start wait seems to be computed wrong

John Mazzitelli mazz at redhat.com
Fri Dec 17 13:20:32 UTC 2010


On 12/17/2010 04:44 AM, Heiko W.Rupp wrote:
 > Just saw this after my server was down for>  45mins
 >
 > 10:43:37,695 INFO  [[/]] initializer: Forcing the server to wait 
[39540]ms to ensure agents know we went down
 >
 > There must be some issue with computing that delay.
 >

Its pretty simple - there isn't much going on with that code - see below.

What must have happened is that your RHQ Server restarted (or its 
"jboss.system:type=Server" MBean reset its "StartDate" attribute) and 
your portal war redeployed (i.e. retriggered StartupServlet).

===

// under a rare case, if the server starts up really fast as soon as it 
dies, any connected
// agents will not realize the server has bounced and will not know to 
re-connect. When this
// happens the server's caches will not be refreshed and bad things will 
happen (e.g. alerts not firing).
// make sure we are down for a certain amount of time to ensure the 
agent's know the server was down.
long ensureDownTimeSecs = 70;
ensureDownTimeSecs = 
Long.parseLong(System.getProperty("rhq.server.ensure-down-time-secs", 
"70"));
long elapsed = getElapsedTimeSinceStartup();
long sleepTime = (ensureDownTimeSecs * 1000L) - elapsed;
if (sleepTime > 0) {
     log("Forcing the server to wait [" + sleepTime + "]ms to ensure 
agents know we went down");
     Thread.sleep(sleepTime);


....


/**
  * Gets the number of milliseconds since the time when the server was 
started.
  * @return elapsed time since server started, 0 if not known
  */
  private long getElapsedTimeSinceStartup() throws ServletException {
      long elapsed;
      ObjectName jbossServerName = new 
ObjectName("jboss.system:type=Server");
      MBeanServer jbossServer = MBeanServerLocator.locateJBoss();
      Date startTime = (Date) jbossServer.getAttribute(jbossServerName, 
"StartDate");
      long currentTime = System.currentTimeMillis();
      elapsed = currentTime - startTime.getTime();
      return elapsed;




More information about the rhq-devel mailing list