org.ow2.jonas.lib.jmbeans.log
Class LogBuffer

java.lang.Object
  extended by org.ow2.jonas.lib.jmbeans.log.LogBuffer
All Implemented Interfaces:
MBeanRegistration, LogBufferMBean

public class LogBuffer
extends Object
implements LogBufferMBean, MBeanRegistration

THis MBean receives and treats LogRecords contained in notifications emitted by the Monolog JmxHandler. The treatement is aimed to provided structured data for JonasAdmin.

Author:
waeselyf, adriana danes

Field Summary
 
Fields inherited from interface org.ow2.jonas.lib.jmbeans.log.LogBufferMBean
INFO, SEVERE, WARNING
 
Constructor Summary
LogBuffer(String name)
          The MBean constructor.
 
Method Summary
protected  void addToLogRecordsQueue(LogRecord record)
          Add a LogRecord to the queue
protected  void addToRecentLog(LogRecord record)
          Add a LogRecord to the recent recors list
 StringBuffer fetchRecords()
          Fetch records
 StringBuffer fetchRecords(Long from, Long to)
           
 StringBuffer fetchRecords(Long from, Long to, int level)
           
 int getCapacity()
           
 long getInfoCount()
           
 long getLatestDate()
           
 int getLevel()
          Not used currently.
 long getOldestDate()
           
 long getOtherCount()
           
 String getRecent()
           
 int getRecentCapacity()
           
 long getRecordCount()
           
 long getSevereCount()
           
 long getWarningCount()
           
protected  void incInfoCount()
          Increment counter of received LogRecords having INFO level
protected  void incOtherCount()
          Increment counter of received LogRecords having level different of INFO, WARNING, SEVERE
protected  void incRecordCount()
          Increment counter of received LogRecors
protected  void incSevereCount()
          Increment counter of received LogRecords having SEVERE level
protected  void incWarningCount()
          Increment counter of received LogRecords having WARNING level
 void postDeregister()
          Nothing to do after deregisteing
 void postRegister(Boolean arg0)
          After registering, add LogNotificationListener as listener for notifications emitted by the LogManagement MBean
 void preDeregister()
          Before deregistering, remove LogNotificationListener listener
 ObjectName preRegister(MBeanServer mbs, ObjectName on)
          Allows getting a refernce to the MBean server, getting the domain name, and if necessary, constructing an ObjectName
 void setCapacity(int records)
          Max number of records to hold (max records of the feeder)
protected  void setLatestDate(long latestDate)
           
 void setLevel(int level)
           
 void setOldestDate(long oldestDate)
           
 void setRecentCapacity(int recentCapacity)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogBuffer

public LogBuffer(String name)
The MBean constructor.

Parameters:
name - the name used to construct the ObjectName
Method Detail

fetchRecords

public StringBuffer fetchRecords()
Description copied from interface: LogBufferMBean
Fetch records

Specified by:
fetchRecords in interface LogBufferMBean
Returns:
a StringBuffer containing all the LogRecords in the recordSet (isn't too big ?)

fetchRecords

public StringBuffer fetchRecords(Long from,
                                 Long to)
Specified by:
fetchRecords in interface LogBufferMBean
Parameters:
from - the LogRecord inferior time limit
to - the LogRecord upper time limit
Returns:
a StringBuffer containing the LogRecords from the recordSet from, to : fetch records between from and to. 0, to : fetch records anterior to to from, 0 : fetch records posterior to from 0, 0 : fetch all records

fetchRecords

public StringBuffer fetchRecords(Long from,
                                 Long to,
                                 int level)
Specified by:
fetchRecords in interface LogBufferMBean
Parameters:
from - the LogRecord inferior time limit
to - the LogRecord upper time limit
level - ...
Returns:
a StringBuffer containing the LogRecords from the recordSet from, to : fetch records between from and to. 0, to : fetch records anterior to to from, 0 : fetch records posterior to from 0, 0 : fetch all records

getCapacity

public int getCapacity()
Specified by:
getCapacity in interface LogBufferMBean
Returns:
the capacity of the recordSet

getInfoCount

public long getInfoCount()
Specified by:
getInfoCount in interface LogBufferMBean
Returns:
number of received LogRecords having INFO level

incInfoCount

protected void incInfoCount()
Increment counter of received LogRecords having INFO level


getLevel

public int getLevel()
Not used currently. It could be used to filter out LogRecord notifications having their level inferior to this level.

Specified by:
getLevel in interface LogBufferMBean
Returns:
the minimum level which is treated by the LogBuffer

getRecordCount

public long getRecordCount()
Specified by:
getRecordCount in interface LogBufferMBean
Returns:
the counter of received LogRecors

incRecordCount

protected void incRecordCount()
Increment counter of received LogRecors


getSevereCount

public long getSevereCount()
Specified by:
getSevereCount in interface LogBufferMBean
Returns:
the number of received LogRecords having SEVERE level

incSevereCount

protected void incSevereCount()
Increment counter of received LogRecords having SEVERE level


getWarningCount

public long getWarningCount()
Specified by:
getWarningCount in interface LogBufferMBean
Returns:
the number of received LogRecords having WARNING level

incWarningCount

protected void incWarningCount()
Increment counter of received LogRecords having WARNING level


getOtherCount

public long getOtherCount()
Specified by:
getOtherCount in interface LogBufferMBean
Returns:
the number of received LogRecords having level different of INFO, WARNING, SEVERE

incOtherCount

protected void incOtherCount()
Increment counter of received LogRecords having level different of INFO, WARNING, SEVERE


getLatestDate

public long getLatestDate()
Specified by:
getLatestDate in interface LogBufferMBean
Returns:
the date in millis of the most recently received LogRecord

setCapacity

public void setCapacity(int records)
Description copied from interface: LogBufferMBean
Max number of records to hold (max records of the feeder)

Specified by:
setCapacity in interface LogBufferMBean
Parameters:
records - the capacity of the recordSet

setLevel

public void setLevel(int level)
Specified by:
setLevel in interface LogBufferMBean

getRecent

public String getRecent()
Specified by:
getRecent in interface LogBufferMBean
Returns:
recent LogRecord appended into a String

postRegister

public void postRegister(Boolean arg0)
After registering, add LogNotificationListener as listener for notifications emitted by the LogManagement MBean

Specified by:
postRegister in interface MBeanRegistration
Parameters:
arg0 - Indicates whether or not the MBean has been successfully registered

preRegister

public ObjectName preRegister(MBeanServer mbs,
                              ObjectName on)
                       throws MalformedObjectNameException
Allows getting a refernce to the MBean server, getting the domain name, and if necessary, constructing an ObjectName

Specified by:
preRegister in interface MBeanRegistration
Parameters:
mbs - refernce to the MBean
on - ObjectName provided by the creator of the MBean
Returns:
this MBean's ObjectName
Throws:
MalformedObjectNameException - could not create ObjectName

preDeregister

public void preDeregister()
                   throws Exception
Before deregistering, remove LogNotificationListener listener

Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception - pb. when deregistering

postDeregister

public void postDeregister()
Nothing to do after deregisteing

Specified by:
postDeregister in interface MBeanRegistration

addToRecentLog

protected void addToRecentLog(LogRecord record)
Add a LogRecord to the recent recors list

Parameters:
record - LogRecord to be add

addToLogRecordsQueue

protected void addToLogRecordsQueue(LogRecord record)
Add a LogRecord to the queue

Parameters:
record - LogRecord to be add

getRecentCapacity

public int getRecentCapacity()
Specified by:
getRecentCapacity in interface LogBufferMBean
Returns:
current capacity of the recent LogRecord list

setRecentCapacity

public void setRecentCapacity(int recentCapacity)
Specified by:
setRecentCapacity in interface LogBufferMBean
Parameters:
recentCapacity - capacity of the recent LogRecord list

setLatestDate

protected void setLatestDate(long latestDate)

getOldestDate

public long getOldestDate()
Specified by:
getOldestDate in interface LogBufferMBean

setOldestDate

public void setOldestDate(long oldestDate)


Copyright © 2010 OW2 Consortium. All Rights Reserved.