Package com.linkedin.databus.monitoring.mbean.GGParserStatistics

Examples of com.linkedin.databus.monitoring.mbean.GGParserStatistics.TransactionInfo


    // SCN = 10
    long timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC;
    List<TransactionState.PerSourceTransactionalUpdate> dbUpdates1 =
        generateUpdates(sourceIds, keys, 10);
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
        new TransactionInfo(0, 0, timestamp, 10) });
    timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC + 1;
    Assert.assertEquals("NumSCNRegressions", 0, ggParserStats.getNumSCNRegressions());
    Assert.assertEquals("NumSCNRegressions", -1, ggParserStats.getLastRegressedScn());
    Assert.assertEquals("MaxScn", 10, ggParserStats.getMaxScn());

    // SCN = 5 Regression
    List<TransactionState.PerSourceTransactionalUpdate> dbUpdates2 =
        generateUpdates(sourceIds, keys, 5); // SCN Regression here
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
        new TransactionInfo(0, 0, timestamp + 1, 5) });

    Assert.assertEquals("NumSCNRegressions", 1, ggParserStats.getNumSCNRegressions());
    Assert.assertEquals("NumSCNRegressions", 5, ggParserStats.getLastRegressedScn());
    Assert.assertEquals("MaxScn", 10, ggParserStats.getMaxScn());

    // SCN = 6 No Regression here
    dbUpdates2 = generateUpdates(sourceIds, keys, 6);
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
        new TransactionInfo(0, 0, timestamp + 1, 6) });

    Assert.assertEquals("NumSCNRegressions", 1, ggParserStats.getNumSCNRegressions());
    Assert.assertEquals("NumSCNRegressions", 5, ggParserStats.getLastRegressedScn());
    Assert.assertEquals("MaxScn", 10, ggParserStats.getMaxScn());

    // SCN = 3 : SCN regression again
    dbUpdates2 = generateUpdates(sourceIds, keys, 3);
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
        new TransactionInfo(0, 0, timestamp + 1, 3) });

    Assert.assertEquals("NumSCNRegressions", 2, ggParserStats.getNumSCNRegressions());
    Assert.assertEquals("NumSCNRegressions", 3, ggParserStats.getLastRegressedScn());
    Assert.assertEquals("MaxScn", 10, ggParserStats.getMaxScn());

    // SCN = 11: No regression here
    dbUpdates2 = generateUpdates(sourceIds, keys, 11);
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
        new TransactionInfo(0, 0, timestamp + 1, 11) });

    Assert.assertEquals("NumSCNRegressions", 2, ggParserStats.getNumSCNRegressions());
    Assert.assertEquals("NumSCNRegressions", 3, ggParserStats.getLastRegressedScn());
    Assert.assertEquals("MaxScn", 11, ggParserStats.getMaxScn());
  }
View Full Code Here


    long scn = 10;
    long timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC;
    List<TransactionState.PerSourceTransactionalUpdate> dbUpdates1 =
        generateUpdates(sourceIds, keys, scn);
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
        new TransactionInfo(0, 0, timestamp, scn) });
    timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC + 1;
    List<TransactionState.PerSourceTransactionalUpdate> dbUpdates2 =
        generateUpdates(sourceIds, keys, scn); // Same SCN as before
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
        new TransactionInfo(0, 0, timestamp + 1, scn) });

    // Expect no events as events are not yet appended to buffer.
    testStats(gg,
              new EventStatsValues(sourceIds[0], 0, 0, 0, 0, 0),
              new EventStatsValues(sourceIds[1], 0, 0, 0, 0, 0),
              new EventStatsValues(GoldenGateEventProducer.GLOBAL_SOURCE_ID,
                                   0,
                                   0,
                                   0,
                                   0,
                                   0));

    // SCN = 11 - Case where both transactions having same SCNs : same set of sources but
    // different keys
    {
      scn = 11;
      timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC + 1;
      dbUpdates1 = generateUpdates(sourceIds, keys, scn);
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
          new TransactionInfo(0, 0, timestamp, scn) });
      timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC + 1;
      keys.clear();
      keys.add("key2");
      dbUpdates2 = generateUpdates(sourceIds, keys, scn); // Same SCN as before
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
          new TransactionInfo(0, 0, timestamp, scn) });

      // Testing for SCN = 10 case
      testStats(gg,
                new EventStatsValues(sourceIds[0], 5, 0, 1, 0, 10),
                new EventStatsValues(sourceIds[1], 5, 0, 1, 0, 10),
                new EventStatsValues(GoldenGateEventProducer.GLOBAL_SOURCE_ID,
                                     5,
                                     0,
                                     2,
                                     0,
                                     10));
    }

    // SCN = 12 - Case where both transactions having same SCNs but different set of
    // sources
    {
      scn = 12;
      keys.clear();
      keys.add("key2");
      timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC + 2;
      dbUpdates1 = generateUpdates(new short[] { sourceIds[1] }, keys, scn);
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
          new TransactionInfo(0, 0, timestamp, scn) });
      dbUpdates2 = generateUpdates(new short[] { sourceIds[0] }, keys, scn); // Same SCN
                                                                             // as before
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
          new TransactionInfo(0, 0, timestamp, scn) });

      // Testing for SCN = 11 case
      testStats(gg,
                new EventStatsValues(sourceIds[0], 5, 0, 3, 0, 11),
                new EventStatsValues(sourceIds[1], 5, 0, 3, 0, 11),
                new EventStatsValues(GoldenGateEventProducer.GLOBAL_SOURCE_ID,
                                     5,
                                     0,
                                     6,
                                     0,
                                     11));
    }

    // SCN = 13 - Case where more than 2 transactions having same SCNs and keys. The keys
    // will be merged.
    {
      scn = 13;
      timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC + 3;
      dbUpdates1 = generateUpdates(sourceIds, keys, scn);
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
          new TransactionInfo(0, 0, timestamp, scn) });
      dbUpdates2 = generateUpdates(sourceIds, keys, scn); // Same SCN as before
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
          new TransactionInfo(0, 0, timestamp, scn) });
      dbUpdates1 = generateUpdates(sourceIds, keys, scn);
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
          new TransactionInfo(0, 0, timestamp, scn) });
      dbUpdates2 = generateUpdates(sourceIds, keys, scn); // Same SCN as before
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
          new TransactionInfo(0, 0, timestamp, scn) });

      // Testing for SCN = 12 case
      testStats(gg,
                new EventStatsValues(sourceIds[0], 5, 0, 4, 0, 12),
                new EventStatsValues(sourceIds[1], 5, 0, 4, 0, 12),
                new EventStatsValues(GoldenGateEventProducer.GLOBAL_SOURCE_ID,
                                     5,
                                     0,
                                     8,
                                     0,
                                     12));
    }

    // SCN = 14 - Case where more than 2 transactions having same SCNs but different keys.
    {
      scn = 14;
      timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC + 3;
      dbUpdates1 = generateUpdates(sourceIds, keys, scn);
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
          new TransactionInfo(0, 0, timestamp, scn) });
      dbUpdates2 = generateUpdates(sourceIds, keys, scn); // Same SCN as before
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
          new TransactionInfo(0, 0, timestamp, scn) });
      keys.clear();
      keys.add("key5");
      dbUpdates1 = generateUpdates(sourceIds, keys, scn);
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
          new TransactionInfo(0, 0, timestamp, scn) });
      dbUpdates2 = generateUpdates(sourceIds, keys, scn); // Same SCN as before
      method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
          new TransactionInfo(0, 0, timestamp, scn) });

      // Testing for SCN = 13 case
      testStats(gg,
                new EventStatsValues(sourceIds[0], 5, 0, 5, 0, 13),
                new EventStatsValues(sourceIds[1], 5, 0, 5, 0, 13),
                new EventStatsValues(GoldenGateEventProducer.GLOBAL_SOURCE_ID,
                                     5,
                                     0,
                                     10,
                                     0,
                                     13));
    }

    // THis is an extra-call but the corresponding events will not be added to EVB.
    // This is needed to flush the events in the above call to EVB
    scn = 15;
    timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC + 4;
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
        new TransactionInfo(0, 0, timestamp, scn) });
    // Testing for SCN = 12 case
    testStats(gg,
              new EventStatsValues(sourceIds[0], 5, 0, 7, 0, 14),
              new EventStatsValues(sourceIds[1], 5, 0, 7, 0, 14),
              new EventStatsValues(GoldenGateEventProducer.GLOBAL_SOURCE_ID,
View Full Code Here

    TransactionState.PerSourceTransactionalUpdate dbUpdate = new TransactionState.PerSourceTransactionalUpdate(
        sourceId, db);
    dbUpdates.add(dbUpdate);

    long timestamp = System.nanoTime();
    gg.addEventToBuffer(dbUpdates, new TransactionInfo(0, 0, timestamp, scn));
    Assert.assertEquals(gg.getRateControl().getNumSleeps(), 0);
    DbusEventIterator iter  = mb.acquireIterator("test");
    int count = 0;
    long eventTs = 0;
    while(iter.hasNext()) {
View Full Code Here

    long timestamp = System.currentTimeMillis() * DbusConstants.NUM_NSECS_IN_MSEC;

    // gg.addEventToBuffer(dbUpdates, new TransactionInfo(0, 0, timestamp, scn));
    // gg.addEventToBuffer(dbUpdates1, new TransactionInfo(0, 0, timestamp+1, scn+1));
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates,
        new TransactionInfo(0, 0, timestamp, scn) });
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates1,
        new TransactionInfo(0, 0, timestamp + 1, scn + 1) });

    // THis is an extra-call but the corresponding events will not be added to EVB.
    // This is needed to flush the events in the above call to EVB
    method.invoke(handleXmlCallbackObject, new Object[] { dbUpdates2,
        new TransactionInfo(0, 0, timestamp + 1, scn + 2) });

    for (EventSourceStatisticsIface si : gg.getSources())
    {
      EventSourceStatistics ss = si.getStatisticsBean();
      LOG.info(si.getSourceName() + ": scn=" + ss.getMaxScn() + ",averageSize="
View Full Code Here

      TransactionState.PerSourceTransactionalUpdate dbUpdate = new TransactionState.PerSourceTransactionalUpdate(
          sourceId, db);
      dbUpdates.add(dbUpdate);

      long timestamp = 60;
      gg.addEventToBuffer(dbUpdates, new TransactionInfo(0, 0, timestamp, scn));
      scn++;
    }

    // It may not sleep the very first time as 1 second may have elapsed from when the rate control got started to when event in
    // getting inserted. Subsequently, expect rate control to kick in
View Full Code Here

           * We will guarantee that the last seen event (in the trail file order =  commit order) is buffered and intermediate images are discarded
           */
          _pendingDbUpdatesBuffer = DBUpdatesMergeUtils.mergeTransactionData(dbUpdates,_pendingDbUpdatesBuffer);

          // New TransactionInfo will have new Txn's SCN and Timestamp
          _pendingTxnInfo = new TransactionInfo(_pendingTxnInfo.getTransactionSize() + txnInfo.getTransactionSize(),
                                                _pendingTxnInfo.getTransactionTimeRead() + txnInfo.getTransactionTimeRead(),
                                                txnInfo.getTransactionTimeStampNs(),
                                                txnInfo.getScn());
          // We will update the parser stats for this txn though as it had already read the transaction.
          result = MergeDbResult.createDoNotAppendResult(txnInfo, getNumEventsInTxn(dbUpdates));
View Full Code Here

        if(!isReadyToRun())
          return;

        MergeDbResult result = mergeTransactions(newDbUpdates,newTxnInfo);
        List<TransactionState.PerSourceTransactionalUpdate> dbUpdates = result.getMergedDbUpdates();
        TransactionInfo txnInfo = result.getMergedTxnInfo();

        if (! result.isDoAppendToBuffer())
        {
          _ggParserStats.addTransactionInfo(result.getLastParsedTxnInfo(), result.getNumEventsInLastParsedTxn());
          return;
        }

        //SCN of the txn that we are going to write.
        scn = txnInfo.getScn();

        try
        {
          if((dbUpdates == null) || (dbUpdates.isEmpty())) {
            checkAndInsertEOP(scn);
View Full Code Here

    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())
View Full Code Here

TOP

Related Classes of com.linkedin.databus.monitoring.mbean.GGParserStatistics.TransactionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.