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);
}
Aggregations