Search in sources :

Example 6 with TransactionInfo

use of com.linkedin.databus.monitoring.mbean.GGParserStatistics.TransactionInfo in project databus by linkedin.

the class TransactionState method onEndElement.

@Override
public void onEndElement(StateMachine stateMachine, XMLStreamReader xmlStreamReader) throws Exception {
    _currentStateType = STATETYPE.ENDELEMENT;
    if (LOG.isDebugEnabled())
        LOG.debug("The current transaction has " + stateMachine.dbUpdateState.getSourceDbUpdatesMap().size() + " DbUpdates");
    if (_transactionSuccessCallBack == null) {
        throw new DatabusException("No callback specified for the transaction state! Cannot proceed without a callback");
    }
    long endTransactionLocation = xmlStreamReader.getLocation().getCharacterOffset();
    _transactionSize = endTransactionLocation - _startTransLocation;
    // collect stats
    long trTime = System.nanoTime() - _startTransProcessingTimeNs;
    long scn = stateMachine.dbUpdateState.getScn();
    TransactionInfo trInfo = new TransactionInfo(_transactionSize, trTime, _currentTimeStamp, scn);
    if (stateMachine.dbUpdateState.getSourceDbUpdatesMap().size() == 0) {
        if (LOG.isDebugEnabled())
            LOG.debug("The current transaction contains no dbUpdates, giving empty callback");
        _transactionSuccessCallBack.onTransactionEnd(null, trInfo);
    } else {
        List<PerSourceTransactionalUpdate> dbUpdates = sortDbUpdates(stateMachine.dbUpdateState.getSourceDbUpdatesMap());
        _transactionSuccessCallBack.onTransactionEnd(dbUpdates, trInfo);
    }
    stateMachine.dbUpdateState.cleanUpState(stateMachine, xmlStreamReader);
    cleanUpState(stateMachine, xmlStreamReader);
    xmlStreamReader.nextTag();
    setNextStateProcessor(stateMachine, xmlStreamReader);
}
Also used : DatabusException(com.linkedin.databus2.core.DatabusException) TransactionInfo(com.linkedin.databus.monitoring.mbean.GGParserStatistics.TransactionInfo)

Aggregations

TransactionInfo (com.linkedin.databus.monitoring.mbean.GGParserStatistics.TransactionInfo)6 PhysicalSourceStaticConfig (com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig)5 ArrayList (java.util.ArrayList)5 DbusEventBufferAppendable (com.linkedin.databus.core.DbusEventBufferAppendable)4 Test (org.testng.annotations.Test)4 Method (java.lang.reflect.Method)3 ColumnsState (com.linkedin.databus2.ggParser.XmlStateMachine.ColumnsState)2 DBUpdateImage (com.linkedin.databus2.ggParser.XmlStateMachine.DbUpdateState.DBUpdateImage)2 TransactionState (com.linkedin.databus2.ggParser.XmlStateMachine.TransactionState)2 VersionedSchema (com.linkedin.databus2.schemas.VersionedSchema)2 HashSet (java.util.HashSet)2 Schema (org.apache.avro.Schema)2 GenericRecord (org.apache.avro.generic.GenericRecord)2 DbusEvent (com.linkedin.databus.core.DbusEvent)1 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)1 DbusEventIterator (com.linkedin.databus.core.DbusEventBuffer.DbusEventIterator)1 EventSourceStatistics (com.linkedin.databus.monitoring.mbean.EventSourceStatistics)1 GGParserStatistics (com.linkedin.databus.monitoring.mbean.GGParserStatistics)1 DatabusException (com.linkedin.databus2.core.DatabusException)1 EventSourceStatisticsIface (com.linkedin.databus2.producers.db.EventSourceStatisticsIface)1