Examples of DbusEventsStatisticsCollector


Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

    cp100.setWindowOffset(-1);
    cpMult1.addCheckpoint(pp100, cp100);

    String[] pnames = {"multBufferTest1:100","multBufferTest2:101"};
    StatsCollectors<DbusEventsStatisticsCollector> statsColls1 = createStats(pnames);
    DbusEventsStatisticsCollector statsCol1 = statsColls1.getStatsCollector("multBufferTest1:100");
    DbusEventsStatisticsCollector statsCol2 = statsColls1.getStatsCollector("multBufferTest2:101");

    //read an entire buffer
    DbusEventBufferBatchReadable reader1 =
        t._eventBuffer.getDbusEventBufferBatchReadable(cpMult1, Arrays.asList(pk1), statsColls1);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    // Try a call with 20 bytes of fetch size, we should see the event size in the first return with 0 events read.
    StreamEventsResult result = reader1.streamEvents(false, 20, Channels.newChannel(baos),
                                                     Encoding.BINARY, filter1);
    assertEquals(0, result.getNumEventsStreamed());
    assertEquals(161, result.getSizeOfPendingEvent());

    result = reader1.streamEvents(false, 1000000, Channels.newChannel(baos),
                                          Encoding.BINARY, filter1);
    int eventsRead = result.getNumEventsStreamed();
    assertEquals(eventsRead, 8); //4 events + 1 eop + 2 events + 1 eop
    assertEquals(statsColls1.getStatsCollector("multBufferTest1:100").getTotalStats().getNumSysEvents(), 2);
    assertEquals(statsColls1.getStatsCollector("multBufferTest1:100").getTotalStats().getNumDataEvents(), 6);
    assertEquals(result.getSizeOfPendingEvent(), 0, "Size of pending event not zero");

    // Now that we have read all the events, we should not see a pending event even if we offer a small fetch size.

    result = reader1.streamEvents(false, 20, Channels.newChannel(baos),
                                                     Encoding.BINARY, filter1);

    assertEquals(0, result.getNumEventsStreamed(), "There should be no more events in the buffer now");
    assertEquals(0, result.getSizeOfPendingEvent(), "We should not see pending event size since there are no events in buffer");
    baos.reset();
    statsCol1.reset(); statsCol2.reset();

    //read from two buffers, filtering out one
    cpMult1 = new CheckpointMult();
    cp100.init();
    cp100.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
    cp100.setWindowScn(10L);
    cp100.setWindowOffset(-1);
    cpMult1.addCheckpoint(pp100, cp100);
    reader1 = t._eventBuffer.getDbusEventBufferBatchReadable(cpMult1, Arrays.asList(pk1, pk2),
                                                             statsColls1);

    eventsRead = reader1.streamEvents(false, 1000000, Channels.newChannel(baos),
                                      Encoding.BINARY, filter1).getNumEventsStreamed();
    assertEquals(eventsRead, 10); //4 events + 1 eop + 1 eop from the other buffer + 2 events +
                                  //1 eop + 1 eop from the other buffer
    assertEquals(statsColls1.getStatsCollector("multBufferTest1:100").getTotalStats().getNumSysEvents(), 2);
    assertEquals(statsColls1.getStatsCollector("multBufferTest1:100").getTotalStats().getNumDataEvents(), 6);

    baos.reset();
    statsCol1.reset();

    //read from one buffer and one source partition
    DatabusSubscription sub2 =
        new DatabusSubscription(PhysicalSource.MASTER_PHISYCAL_SOURCE,
                                new PhysicalPartition(101, "multBufferTest2"),
                                new LogicalSourceId(new LogicalSource(2, "srcName2"), (short)2)
                                );

    DbusFilter filter2 = t._eventBuffer.constructFilters(Arrays.asList(sub2));
    assertNotNull(filter2);

    CheckpointMult cpMult2 = new CheckpointMult();
    Checkpoint cp101 = new Checkpoint();
    cp101.init();
    cp101.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
    cp101.setWindowScn(10L);
    cp101.setWindowOffset(-1);
    cpMult2.addCheckpoint(pp101, cp101);
    DbusEventBufferBatchReadable reader2 =
        t._eventBuffer.getDbusEventBufferBatchReadable(cpMult2, Arrays.asList(pk2), statsColls1);

    eventsRead = reader2.streamEvents(false, 1000000, Channels.newChannel(baos),
                                      Encoding.BINARY, filter2).getNumEventsStreamed();
    assertEquals(eventsRead, 6); //1 events + 1 eop + 3events + 1 eop

    baos.reset();
    statsCol1.reset();statsCol2.reset();

    //read all partitions for a source
    DatabusSubscription sub3 =
        new DatabusSubscription(PhysicalSource.MASTER_PHISYCAL_SOURCE,
                                PhysicalPartition.ANY_PHYSICAL_PARTITION,
                                LogicalSourceId.createAllPartitionsWildcard(new LogicalSource(2, "srcName2"))
                                );

    DbusFilter filter3 = t._eventBuffer.constructFilters(Arrays.asList(sub3));
    assertNotNull(filter3);


    CheckpointMult cpMult3 = new CheckpointMult();
    cp100.init();
    cp100.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
    cp100.setWindowScn(10L);
    cp100.setWindowOffset(-1);
    cpMult1.addCheckpoint(pp100, cp100);
    cp101.init();
    cp101.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
    cp101.setWindowScn(10L);
    cp101.setWindowOffset(-1);
    cpMult2.addCheckpoint(pp101, cp101);
    DbusEventBufferBatchReadable reader3 =
        t._eventBuffer.getDbusEventBufferBatchReadable(cpMult3, Arrays.asList(pk1, pk2), statsColls1);
    eventsRead = reader3.streamEvents(false, 1000000, Channels.newChannel(baos),
                                      Encoding.BINARY, filter3).getNumEventsStreamed();
    assertEquals(eventsRead, 11); //1 events + 1 eop + 1 events + 1 eop + 2 events + 1 eop + 3 events + 1 eop
    assertEquals(statsColls1.getStatsCollector("multBufferTest1:100").getTotalStats().getNumSysEvents(), 2);
    assertEquals(statsColls1.getStatsCollector("multBufferTest2:101").getTotalStats().getNumSysEvents(), 2);
    assertEquals(statsColls1.getStatsCollector("multBufferTest1:100").getTotalStats().getNumDataEventsFiltered(), 3);
    assertEquals(statsColls1.getStatsCollector("multBufferTest2:101").getTotalStats().getNumDataEventsFiltered(), 4);

    baos.reset();
    statsCol1.reset(); statsCol2.reset();

    log.info("end");
  }
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

      {
        synchronized (_inBoundStatsCollectors)
        {
          if (null == _inBoundStatsCollectors.getStatsCollector(statsCollectorName))
          {
            DbusEventsStatisticsCollector collector = new DbusEventsStatisticsCollector(getContainerStaticConfig().getId(),
                                              statsCollectorName+".inbound",
                                              true,
                                              false,
                                              getMbeanServer());
            _inBoundStatsCollectors.addStatsCollector(statsCollectorName, collector);
            _dbInboundStatsCollectors.addStatsCollector(pPartition, collector);
          }
        }
      }

      if (null != _outBoundStatsCollectors)
      {
        synchronized (_outBoundStatsCollectors)
        {
          if (null == _outBoundStatsCollectors.getStatsCollector(statsCollectorName))
          {
            DbusEventsStatisticsCollector collector = new DbusEventsStatisticsCollector(getContainerStaticConfig().getId(),
                                                                                        statsCollectorName+".outbound",
                                                                                        true,
                                                                                        false,
                                                                                        getMbeanServer());
            _outBoundStatsCollectors.addStatsCollector(statsCollectorName, collector);
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

    collector.registerStatsCallback(callback);

    // Add 2 collectors for DB1
    PhysicalPartition p1 = new PhysicalPartition(1, "db1");
    PhysicalPartition p2 = new PhysicalPartition(2, "db1");
    DbusEventsStatisticsCollector c1 =
        new DbusEventsStatisticsCollector(1, "db1:1", true, false, null);
    DbusEventsStatisticsCollector c2 =
        new DbusEventsStatisticsCollector(1, "db1:2", true, false, null);
    collector.addStatsCollector(p1, c1);
    collector.addStatsCollector(p2, c2);

    StatsWriter w1 = new StatsWriter(c1);
    StatsWriter w2 = new StatsWriter(c2);
    w1.addEvents(2, 2, 100);
    w2.addEvents(2, 2, 200);
    StatsCollectors<DbusEventsStatisticsCollector> col =
        collector.getDBStatsCollector("db1");
    Assert.assertNotNull(col);
    col.mergeStatsCollectors();
    LOG.info("Merged Stats : " + col.getStatsCollector().getTotalStats());
    LOG.info("C1 Stats : " + c1.getTotalStats());
    LOG.info("C2 Stats : " + c2.getTotalStats());
    DbusEventsTotalStats s = col.getStatsCollector().getTotalStats();
    Assert.assertEquals("Total Events", 8, s.getNumDataEvents());
    Assert.assertEquals("Sys Events", 4, s.getNumSysEvents());
    Assert.assertEquals("Min Scn", 101, s.getMinScn());
    Assert.assertEquals("Max Scn", 205, s.getMaxScn());
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

    collector.registerStatsCallback(callback);

    // Add 2 collectors for DB1
    PhysicalPartition p1 = new PhysicalPartition(1, "db1");
    PhysicalPartition p2 = new PhysicalPartition(2, "db1");
    DbusEventsStatisticsCollector c1 =
        new DbusEventsStatisticsCollector(1, "db1:1", true, false, null);
    DbusEventsStatisticsCollector c2 =
        new DbusEventsStatisticsCollector(1, "db1:2", true, false, null);
    collector.addStatsCollector(p1, c1);
    collector.addStatsCollector(p2, c2);

    // Add 2 collectors for DB2
    PhysicalPartition p3 = new PhysicalPartition(1, "db2");
    PhysicalPartition p4 = new PhysicalPartition(2, "db2");
    DbusEventsStatisticsCollector c3 =
        new DbusEventsStatisticsCollector(1, "db2:1", true, false, null);
    DbusEventsStatisticsCollector c4 =
        new DbusEventsStatisticsCollector(1, "db2:2", true, false, null);
    collector.addStatsCollector(p3, c3);
    collector.addStatsCollector(p4, c4);

    // Add 2 collectors for DB3
    PhysicalPartition p5 = new PhysicalPartition(3, "db3");
    PhysicalPartition p6 = new PhysicalPartition(4, "db3");
    DbusEventsStatisticsCollector c5 =
        new DbusEventsStatisticsCollector(1, "db3:3", true, false, null);
    DbusEventsStatisticsCollector c6 =
        new DbusEventsStatisticsCollector(1, "db3:4", true, false, null);
    collector.addStatsCollector(p5, c5);
    collector.addStatsCollector(p6, c6);

    StatsWriter w1 = new StatsWriter(c1);
    StatsWriter w2 = new StatsWriter(c2);
    StatsWriter w3 = new StatsWriter(c3);
    StatsWriter w4 = new StatsWriter(c4);
    StatsWriter w5 = new StatsWriter(c5);
    StatsWriter w6 = new StatsWriter(c6);
    w1.addEvents(2, 2, 100);
    w2.addEvents(2, 2, 200);
    w3.addEvents(3, 2, 300);
    w4.addEvents(3, 2, 400);
    w5.addEvents(4, 2, 500);
    w6.addEvents(4, 2, 600);

    // Verify DB1 collector
    StatsCollectors<DbusEventsStatisticsCollector> col =
        collector.getDBStatsCollector("db1");
    Assert.assertNotNull(col);
    col.mergeStatsCollectors();
    LOG.info("Merged Stats : " + col.getStatsCollector().getTotalStats());
    LOG.info("C1 Stats : " + c1.getTotalStats());
    LOG.info("C2 Stats : " + c2.getTotalStats());
    DbusEventsTotalStats s = col.getStatsCollector().getTotalStats();
    Assert.assertEquals("Total Events", 8, s.getNumDataEvents());
    Assert.assertEquals("Sys Events", 4, s.getNumSysEvents());
    Assert.assertEquals("Min Scn", 101, s.getMinScn());
    Assert.assertEquals("Max Scn", 205, s.getMaxScn());

    // Verify DB2 collector
    col = collector.getDBStatsCollector("db2");
    Assert.assertNotNull(col);
    col.mergeStatsCollectors();
    LOG.info("Merged Stats : " + col.getStatsCollector().getTotalStats());
    LOG.info("C3 Stats : " + c3.getTotalStats());
    LOG.info("C4 Stats : " + c4.getTotalStats());
    s = col.getStatsCollector().getTotalStats();
    Assert.assertEquals("Total Events", 12, s.getNumDataEvents());
    Assert.assertEquals("Sys Events", 4, s.getNumSysEvents());
    Assert.assertEquals("Min Scn", 301, s.getMinScn());
    Assert.assertEquals("Max Scn", 407, s.getMaxScn());

    // Verify DB3 collector
    col = collector.getDBStatsCollector("db3");
    Assert.assertNotNull(col);
    col.mergeStatsCollectors();
    LOG.info("Merged Stats : " + col.getStatsCollector().getTotalStats());
    LOG.info("C3 Stats : " + c5.getTotalStats());
    LOG.info("C4 Stats : " + c6.getTotalStats());
    s = col.getStatsCollector().getTotalStats();
    Assert.assertEquals("Total Events", 16, s.getNumDataEvents());
    Assert.assertEquals("Sys Events", 4, s.getNumSysEvents());
    Assert.assertEquals("Min Scn", 501, s.getMinScn());
    Assert.assertEquals("Max Scn", 609, s.getMaxScn());
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

    _executorService = executorService;
    _relay = relay;
    _producer = eventProducer;
    //currently generateDataEvents does not support generation across multiple partitions
    //for statistics, we'll make up a "virtual" partition
    _relayStatsCollector = new DbusEventsStatisticsCollector(
       _relay.getContainerStaticConfig().getId(),
       _producer.toString(),
       true,
       false,
       _relay.getMbeanServer());
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

      if ((buf.getMinScn() < 0) && (buf.getPrevScn() < 0)) buf.start(0);

      try
      {
        DbusEventsStatisticsCollector statsCollector = _relay.getInBoundStatsCollectors().getStatsCollector(pPartition.toSimpleString());

        int eventsAppended = 0;
        if (!((eventsAppended = DbusEventSerializable.appendToEventBuffer(in, buf, statsCollector, startWin))>0))
        {
          throw new RequestProcessingException("event loading failed");
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

    if (reqPathSuffix.contains(":"))
    {
      // This is a request for a specific partition
      if (null != globalStatsCollector)
      {
        DbusEventsStatisticsCollector s =
            globalStatsCollector.getStatsCollector(reqPathSuffix);
        sourceStats = (s == null) ? null : s.getTotalStats();
      }
    }
    else
    {
      // This is a request at DB aggregate level
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

    Vector<EventBufferTestInput> tests = new Vector<EventBufferTestInput>();
    tests.add(blockingCapacityTest);
    tests.add(block2);
    tests.add(block3);

    DbusEventsStatisticsCollector emitterStats = new DbusEventsStatisticsCollector(1,"appenderStats",true,true,null);
    DbusEventsStatisticsCollector streamStats = new DbusEventsStatisticsCollector(1,"streamStats",true,true,null);
    DbusEventsStatisticsCollector clientStats = new DbusEventsStatisticsCollector(1,"clientStats",true,true,null);

    int testId = 0;
    for (Iterator<EventBufferTestInput> it=tests.iterator(); it.hasNext(); )
    {
      EventBufferTestInput testInput = it.next();

      srcTestEvents.clear();
      dstTestEvents.clear();
      emitterStats.reset();
      streamStats.reset();
      clientStats.reset();

      assertEquals(0, dstTestEvents.size());
      boolean result = runConstEventsReaderWriter(srcTestEvents, dstTestEvents, testInput, emitterStats,
                                                  streamStats, clientStats, invokeStartOnBuffer);
      LOG.info(String.format("TestId=%d Test=%s  result=%b size of dst events=%d \n",
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

  }

  @Test
  public void testAppendEventStats() throws Exception
  {
    DbusEventsStatisticsCollector collector = new DbusEventsStatisticsCollector(1,"appenderStats",true,true,null);
    DbusEventBuffer dbuf = new DbusEventBuffer(getConfig(10000000,
                                                         DbusEventBuffer.Config.DEFAULT_INDIVIDUAL_BUFFER_SIZE,
                                                         100000, 1000000, AllocationPolicy.HEAP_MEMORY,
                                                         QueuePolicy.OVERWRITE_ON_WRITE, AssertLevel.ALL));

    assertTrue(dbuf.getScnIndex().getUpdateOnNext()); // DDSDBUS-1109
    dbuf.startEvents();
    long now = System.currentTimeMillis();
    final int sleepTime = 100;
    Thread.sleep(sleepTime);
    assertTrue(dbuf.appendEvent(new DbusEventKey(key),
                                pPartitionId,
                                lPartitionId,
                                now * 1000000,
                                srcId,
                                schemaId,
                                value.getBytes(Charset.defaultCharset()),
                                false));
    dbuf.endEvents(true, 0x100000001L, false, false, collector);
    assertTrue(collector.getTotalStats().getTimeLag() + "," + sleepTime, collector.getTotalStats().getTimeLag() >= sleepTime);
    assertTrue(collector.getTotalStats().getMinTimeLag() + "," + sleepTime,collector.getTotalStats().getMinTimeLag() >= sleepTime);
    assertTrue(collector.getTotalStats().getMaxTimeLag() + "," + sleepTime, collector.getTotalStats().getMaxTimeLag() >= sleepTime);
  }
View Full Code Here

Examples of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector

      WritableByteChannel writeChannel = Channels.newChannel(baos);
      //File directory = new File(".");
      //File writeFile = File.createTempFile("test", ".dbus", directory);
      int streamedEvents = 0;

      final DbusEventsStatisticsCollector streamStats =
          new DbusEventsStatisticsCollector(1, "stream", true, false, null);
      //writeChannel = Utils.openChannel(writeFile, true);
      StreamEventsArgs args = new StreamEventsArgs(batchFetchSize).setStatsCollector(streamStats);
      streamedEvents = dbuf.streamEvents(cp, writeChannel, args).getNumEventsStreamed();

      writeChannel.close();
      final byte[] eventBytes = baos.toByteArray();
      Assert.assertTrue(eventBytes.length > 0);
      Assert.assertTrue(streamedEvents > 0);

      final DbusEventsStatisticsCollector inputStats =
          new DbusEventsStatisticsCollector(1, "input", true, false, null);

      ByteArrayInputStream bais = new ByteArrayInputStream(eventBytes);
      ReadableByteChannel readChannel = Channels.newChannel(bais);
      DbusEventBuffer checkDbusEventBuffer =
          new DbusEventBuffer(getConfig(5000000, DbusEventBuffer.
                                        Config.DEFAULT_INDIVIDUAL_BUFFER_SIZE, 100000, 4000,
                                        AllocationPolicy.HEAP_MEMORY,
                                        QueuePolicy.OVERWRITE_ON_WRITE,
                                        AssertLevel.ALL));
      int messageSize = 0;
      int numEvents =0;
      checkDbusEventBuffer.clear();
      numEvents = checkDbusEventBuffer.readEvents(readChannel, inputStats);
      long ts= 0;
      for (DbusEventInternalWritable e : checkDbusEventBuffer)
      {
        ts = Math.max(e.timestampInNanos(),ts);
        messageSize += e.size();
        if (e.isEndOfPeriodMarker())
        {
          //check if of eop has timestamp of most recent data event in the window
          assertEquals(ts, e.timestampInNanos());
          LOG.debug("EOP:"+e.sequence() + " ts=" + e.timestampInNanos());
          ts=0;
        }
        else
        {
          LOG.debug("DAT:"+ e.sequence() + " ts=" + e.timestampInNanos());
        }
      }
      assertEquals("Events Count Check", streamedEvents, numEvents );
      assertTrue(messageSize <= batchFetchSize);
      assertEquals(streamStats.getTotalStats().getNumDataEvents(),
                   inputStats.getTotalStats().getNumDataEvents());
      assertEquals(streamStats.getTotalStats().getNumSysEvents(),
                   inputStats.getTotalStats().getNumSysEvents());

      LOG.debug("BatchFetchSize = " + batchFetchSize + " messagesSize = " + messageSize + " numEvents = " + numEvents);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.