biz.hammurapi.metrics
Class BatchingSliceConsumer

java.lang.Object
  extended by biz.hammurapi.metrics.BatchingSliceConsumer
All Implemented Interfaces:
biz.hammurapi.config.Component, biz.hammurapi.metrics.SliceConsumer
Direct Known Subclasses:
DestinationSliceConsumer, QueueSliceConsumer, SocketSliceConsumer, TopicSliceConsumer

public abstract class BatchingSliceConsumer
extends java.lang.Object
implements biz.hammurapi.metrics.SliceConsumer, biz.hammurapi.config.Component

Collects slices for a period of time and processes them in batches.

Author:
Pavel Vlasov

Nested Class Summary
static class BatchingSliceConsumer.SliceEntry
          Helper class to serialize accumulated slices.
 
Constructor Summary
BatchingSliceConsumer()
           
 
Method Summary
 boolean consumeSlice(java.lang.String category, biz.hammurapi.metrics.Slice slice)
           
protected abstract  boolean processSlices(java.util.List slices)
          Subclasses shall implement this method.
 void setInterval(long interval)
          Sets batching interval.
 void setMaxSlices(int maxSlices)
          Sets maximum number of slices to be retained if processing fails.
 void setOwner(java.lang.Object owner)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatchingSliceConsumer

public BatchingSliceConsumer()
Method Detail

setMaxSlices

public void setMaxSlices(int maxSlices)
Sets maximum number of slices to be retained if processing fails.

Parameters:
maxSlices -

setInterval

public void setInterval(long interval)
Sets batching interval. Default interval is one minute.

Parameters:
interval -

consumeSlice

public boolean consumeSlice(java.lang.String category,
                            biz.hammurapi.metrics.Slice slice)
Specified by:
consumeSlice in interface biz.hammurapi.metrics.SliceConsumer

setOwner

public void setOwner(java.lang.Object owner)
Specified by:
setOwner in interface biz.hammurapi.config.Component

start

public void start()
           throws biz.hammurapi.config.ConfigurationException
Specified by:
start in interface biz.hammurapi.config.Component
Throws:
biz.hammurapi.config.ConfigurationException

stop

public void stop()
          throws biz.hammurapi.config.ConfigurationException
Specified by:
stop in interface biz.hammurapi.config.Component
Throws:
biz.hammurapi.config.ConfigurationException

processSlices

protected abstract boolean processSlices(java.util.List slices)
Subclasses shall implement this method.

Parameters:
slices -
Returns:
true if slices was successfully processed.


Copyright © 2006 Hammurapi Group. All Rights Reserved.