class RateControl {

  public long incrementEventCount() throws DatabusException
  {
    // If throttle is not enabled, this is a no-op ( rate metrics need not be maintained )
    if (! isEnabled())
    {
      return Long.MIN_VALUE;
    }

    // Enabled, but has expired, this is a no-op ( rate metrics need not be maintained )
    if ( checkExpired())
    {
      if (LOG.isDebugEnabled())
      {
        LOG.debug("Throttle duration has expired. Accepting events without rate control");
      }

      return Long.MIN_VALUE;
    }

    // Enabled, not expired; add the event and compute if we need to throttle
    _ra.tick();
    if (! checkRateExceeded())
    {
      // This event can be accepted without sleeping. Return number of events received so far
      return _ra.getNumTicks();
    }

    try
    {
      // Compute how long we need to sleep
      long duration = computeSleepDuration();
      sleepToMaintainRate(duration);
    }
    catch (InterruptedException ie){}
    return _ra.getNumTicks();
  }

  public  RateControl(long numEventsPerSec, long throttleDurationInSecs);

}