ibspan.log4jade.common
Class AgentEventsBuffer

java.lang.Object
  extended by ibspan.log4jade.common.AgentEventsBuffer
All Implemented Interfaces:
Serializable

public class AgentEventsBuffer
extends Object
implements Serializable

Events buffer implemented as FIFO queue.

Author:
Maciej Gawinecki
See Also:
Serialized Form

Constructor Summary
AgentEventsBuffer(int maxSize, AgentContext context)
          Instantiate a new AgentEventsBuffer of at most maxSize events.
 
Method Summary
 void add(LoggingEvent event)
          Add an event as the last event in the buffer.
 LoggingEvent get()
          Get the oldest (first) element in the buffer.
 LoggingEvent get(int i)
          Get the ith oldest event currently in the buffer.
 AgentContext getContext()
           
 int getMaxSize()
           
 boolean isEmpty()
           
 boolean isFull()
           
 int length()
          Get the number of elements in the buffer.
 void resize(int newSize)
          Resize the cyclic buffer to newSize.
 void setContext(AgentContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentEventsBuffer

public AgentEventsBuffer(int maxSize,
                         AgentContext context)
                  throws IllegalArgumentException
Instantiate a new AgentEventsBuffer of at most maxSize events. The maxSize argument must a positive integer.

Parameters:
maxSize - The maximum number of elements in the buffer.
Throws:
IllegalArgumentException
Method Detail

getContext

public AgentContext getContext()

setContext

public void setContext(AgentContext context)

isFull

public boolean isFull()

isEmpty

public boolean isEmpty()

add

public void add(LoggingEvent event)
Add an event as the last event in the buffer.


get

public LoggingEvent get(int i)
Get the ith oldest event currently in the buffer. If i is outside the range 0 to the number of elements currently in the buffer, then null is returned.


getMaxSize

public int getMaxSize()

get

public LoggingEvent get()
Get the oldest (first) element in the buffer. The oldest element is removed from the buffer.


length

public int length()
Get the number of elements in the buffer. This number is guaranteed to be in the range 0 to maxSize (inclusive).


resize

public void resize(int newSize)
Resize the cyclic buffer to newSize.

Throws:
IllegalArgumentException - if newSize is negative.