cgl.narada.service.buffering
Class BufferingServiceImpl

java.lang.Object
  extended by cgl.narada.service.buffering.BufferingServiceImpl
All Implemented Interfaces:
BufferingService

public class BufferingServiceImpl
extends Object
implements BufferingService

This is the implementation of the BufferingService interface.


Constructor Summary
BufferingServiceImpl(QosServiceImpl qosServiceImpl)
          Generates a new BufferingServiceImpl object.
 
Method Summary
 long getBufferEntryMaximumDuration()
          Retrieves the maximum duration after which the oldest element in the buffer is released
 boolean getEnforceTimeOrderingConsistency(Object contentSynopsis)
          Indicates if the buffering service enforces time ordering conistency
 int getMaximumBufferSize()
          Returns maximum buffer size.This corresponds to the total size of all the payloads associated with events in the buffer.
 int getMaximumNumberOfEntries()
          Returns the maximum number of entries
 double getReleaseFactor()
          Returns the release factor of the buffer
 String getSortingScheme()
          Returns the current sorting scheme
 int getTotalBufferSize()
          Returns the total size of the buffer.
 int getTotalNumberOfEntries()
          Returns the total number of entries currently present within the buffer.
 void loadDefaults()
          Reads default values from DefaultParams class.
 void loadProperties()
          Reads required params from a properties class.
 int releaseAllEntries()
          Releases all the entries currently present in the buffer.
 int releaseAllEntries(double releaseFactor)
          .
 int releaseAllEntries(long timestamp)
          Releases all entries that occured before the specified timestamp.
 int releaseAllEntries(Object contentSynopsis)
          Releases all the entries with the specified content synopsis.
 void setBufferEntryMaximumDuration(long entryAge)
          Sets the maximum duration after which the oldest element in the buffer is released
 void setEnforceTimeOrderingConsistency(Object contentSynopsis, boolean enforce)
          Ensures that events are ordered while enforcing timing consistencies.
 void setMaximumBufferSize(int maxBufferSize)
          Sets the maximum buffer size.
 void setMaximumNumberOfEntries(int maxEntries)
          Sets the maximum number of entries in the buffering service.
 void setReleaseFactor(double factor)
          Release facotr is a double number between 0 - 1.
 void setSortingScheme(String sortAlgo)
          Sets the scheme for sorting events in the buffers
 void startBufferingService()
          Starts buffering service
 void stopBufferingService()
          Stops buffering service
 void terminateService()
           
 void timeOrderEvent(QosEvent qosEvent)
          Takes QosEvent and puts it into the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferingServiceImpl

public BufferingServiceImpl(QosServiceImpl qosServiceImpl)
Generates a new BufferingServiceImpl object.

Parameters:
qosServiceImpl - QosServiceImpl
Method Detail

setBufferEntryMaximumDuration

public void setBufferEntryMaximumDuration(long entryAge)
Sets the maximum duration after which the oldest element in the buffer is released

Specified by:
setBufferEntryMaximumDuration in interface BufferingService
Parameters:
entryAge - long - maximum buffer entry duration

getBufferEntryMaximumDuration

public long getBufferEntryMaximumDuration()
Retrieves the maximum duration after which the oldest element in the buffer is released


setEnforceTimeOrderingConsistency

public void setEnforceTimeOrderingConsistency(Object contentSynopsis,
                                              boolean enforce)
Ensures that events are ordered while enforcing timing consistencies. The consistencies are enforced based on the timestamp of the last event that was released. This has to be EXPLICTLY set.

Specified by:
setEnforceTimeOrderingConsistency in interface BufferingService
Parameters:
contentSynopsis - Object - content synopsis
enforce - boolean - strict consistency enforcement

getEnforceTimeOrderingConsistency

public boolean getEnforceTimeOrderingConsistency(Object contentSynopsis)
Indicates if the buffering service enforces time ordering conistency

Specified by:
getEnforceTimeOrderingConsistency in interface BufferingService
Parameters:
contentSynopsis - Object - content synopsis
Returns:
boolean - enforcement value for the content synopsis

setMaximumBufferSize

public void setMaximumBufferSize(int maxBufferSize)
                          throws ServiceException
Sets the maximum buffer size. This corresponds to the total size of all the payloads associated with events in the buffer. This method throws an exception if the specified value is an invalid one

Specified by:
setMaximumBufferSize in interface BufferingService
Parameters:
maxBufferSize - int - maximum buffer size in bytes
Throws:
ServiceException

getMaximumBufferSize

public int getMaximumBufferSize()
Returns maximum buffer size.This corresponds to the total size of all the payloads associated with events in the buffer.

Specified by:
getMaximumBufferSize in interface BufferingService
Returns:
int - maximum buffer size

setMaximumNumberOfEntries

public void setMaximumNumberOfEntries(int maxEntries)
                               throws ServiceException
Sets the maximum number of entries in the buffering service. This method throws an exception if the specified value is an invalid one (0 or negative).

Specified by:
setMaximumNumberOfEntries in interface BufferingService
Parameters:
maxEntries - int - maximum number of entries
Throws:
ServiceException

getMaximumNumberOfEntries

public int getMaximumNumberOfEntries()
Returns the maximum number of entries

Specified by:
getMaximumNumberOfEntries in interface BufferingService
Returns:
int - maximum number of entries

setReleaseFactor

public void setReleaseFactor(double factor)
Release facotr is a double number between 0 - 1. It should not be less than 0.5. the default value is 1.0. Setting this factor to another value causes BufferHandler to release (factor * number of buffer entries)

Specified by:
setReleaseFactor in interface BufferingService
Parameters:
factor - double - release factor

getReleaseFactor

public double getReleaseFactor()
Returns the release factor of the buffer

Specified by:
getReleaseFactor in interface BufferingService
Returns:
double - release factor

setSortingScheme

public void setSortingScheme(String sortAlgo)
                      throws ServiceException
Sets the scheme for sorting events in the buffers

Specified by:
setSortingScheme in interface BufferingService
Parameters:
sortAlgo - String - String representation of the sorting algorithm. MergeSort, QuickSort, etc.
Throws:
ServiceException

getSortingScheme

public String getSortingScheme()
Returns the current sorting scheme

Specified by:
getSortingScheme in interface BufferingService
Returns:
String - sorting algorithm

getTotalBufferSize

public int getTotalBufferSize()
Returns the total size of the buffer. This corresponds to the total size of the content payloads of all the events within the buffer.

Specified by:
getTotalBufferSize in interface BufferingService
Returns:
int - total buffer size

getTotalNumberOfEntries

public int getTotalNumberOfEntries()
Returns the total number of entries currently present within the buffer.

Specified by:
getTotalNumberOfEntries in interface BufferingService
Returns:
int - total number of entries in the buffer

loadDefaults

public void loadDefaults()
Reads default values from DefaultParams class.


loadProperties

public void loadProperties()
Reads required params from a properties class.


releaseAllEntries

public int releaseAllEntries()
Releases all the entries currently present in the buffer. Returns the total number of entries that were released.

Specified by:
releaseAllEntries in interface BufferingService
Returns:
int - the total number of entries that were released

releaseAllEntries

public int releaseAllEntries(Object contentSynopsis)
Releases all the entries with the specified content synopsis.

Specified by:
releaseAllEntries in interface BufferingService
Parameters:
contentSynopsis - Object - content synopsis
Returns:
int - the total number of entries that were released

releaseAllEntries

public int releaseAllEntries(long timestamp)
Releases all entries that occured before the specified timestamp.

Specified by:
releaseAllEntries in interface BufferingService
Parameters:
timestamp - long - upper limit timestamp value of the entries to be released
Returns:
int - the total number of entries that were released

releaseAllEntries

public int releaseAllEntries(double releaseFactor)
. Returns the total number of entries that were released.


startBufferingService

public void startBufferingService()
Starts buffering service


stopBufferingService

public void stopBufferingService()
Stops buffering service


terminateService

public void terminateService()
Specified by:
terminateService in interface BufferingService

timeOrderEvent

public void timeOrderEvent(QosEvent qosEvent)
Takes QosEvent and puts it into the buffer. If maximum number of entries and/or maximum buffer size is/are reached, it notifies the BufferHandler thread.

Specified by:
timeOrderEvent in interface BufferingService
Parameters:
qosEvent - - QosEvent


For comments and suggestions please send e-mail to The NaradaBrokering Project