Package com.linkedin.databus.client.pub.mbean

Examples of com.linkedin.databus.client.pub.mbean.ConsumerCallbackStats


    int maxThreadsNum = 1;
    int keepAliveMs = 1000;
    ThreadPoolExecutor defaultExecutorService = new OrderedMemoryAwareThreadPoolExecutor(
        maxThreadsNum, 0, 0, keepAliveMs, TimeUnit.MILLISECONDS);

        ConsumerCallbackStats relayConsumerStats =
            new ConsumerCallbackStats(id,
                                      producerName + ".inbound.cons",
                                      producerName + ".inbound.cons",
                                      true,
                                      false,
                                      null,
                                      ManagementFactory.getPlatformMBeanServer());

        ConsumerCallbackStats bootstrapConsumerStats =
            new ConsumerCallbackStats(id,
                                      producerName + ".inbound.bs.cons" ,
                                      producerName + ".inbound.bs.cons",
                                      true,
                                      false,
                                      null,
View Full Code Here


                                              false,
                                              getMbeanServer()));

        _consumerStatsCollectors.addStatsCollector(
            statsCollectorName,
            new ConsumerCallbackStats(ownerId,
                                      statsCollectorName + ".inbound.cons",
                                      statsCollectorName + ".inbound.cons",
                                      true,
                                      false,
                                      null,
                                      getMbeanServer()));

        _bsConsumerStatsCollectors.addStatsCollector(
            statsCollectorName,
            new ConsumerCallbackStats(ownerId,
                                      statsCollectorName + ".inbound.bs.cons" ,
                                      statsCollectorName + ".inbound.bs.cons",
                                      true,
                                      false,
                                      null,
View Full Code Here

      DatabusV2ConsumerRegistration consumerReg =
          new DatabusV2ConsumerRegistration(sdccMockConsumer, sources, null);

      List<DatabusV2ConsumerRegistration> allRegistrations = Arrays.asList(consumerReg);
      final ConsumerCallbackStats callbackStats = new ConsumerCallbackStats(0, "test", "test", true, false, null);
      final UnifiedClientStats unifiedStats = new UnifiedClientStats(0, "test", "test.unified");
      MultiConsumerCallback callback =
          new MultiConsumerCallback(allRegistrations,
                                    Executors.newFixedThreadPool(2),
                                    100, // 100 ms budget
View Full Code Here

      DatabusV2ConsumerRegistration consumerReg =
              new DatabusV2ConsumerRegistration(sdccMockConsumer, sources, null);

      List<DatabusV2ConsumerRegistration> allRegistrations = Arrays.asList(consumerReg);
      final ConsumerCallbackStats callbackStats = new ConsumerCallbackStats(0, "test", "test", true, false, null);
      final UnifiedClientStats unifiedStats = new UnifiedClientStats(0, "test", "test.unified");
      MultiConsumerCallback callback =
          new MultiConsumerCallback(allRegistrations,
                                    Executors.newFixedThreadPool(2),
                                    1000,
                                    new StreamConsumerCallbackFactory(callbackStats, unifiedStats),
                                    callbackStats,
                                    unifiedStats,
                                    null,
                                    null);
      callback.setSourceMap(sourcesMap);


      List<DatabusSubscription> subs = DatabusSubscription.createSubscriptionList(sources);
      final RelayDispatcher dispatcher =
              new RelayDispatcher("dispatcher", _genericRelayConnStaticConfig, subs,
                      new InMemoryPersistenceProvider(),
                      destEventsBuf, callback, null,null,null,null,null);
      dispatcher.setSchemaIdCheck(false);

      Thread dispatcherThread = new Thread(dispatcher);
      dispatcherThread.setDaemon(true);
      log.info("starting dispatcher thread");
      dispatcherThread.start();

      HashMap<Long, List<RegisterResponseEntry>> schemaMap =
              new HashMap<Long, List<RegisterResponseEntry>>();

      List<RegisterResponseEntry> l1 = new ArrayList<RegisterResponseEntry>();
      List<RegisterResponseEntry> l2 = new ArrayList<RegisterResponseEntry>();
      List<RegisterResponseEntry> l3 = new ArrayList<RegisterResponseEntry>();

      l1.add(new RegisterResponseEntry(1L, (short)1,SOURCE1_SCHEMA_STR));
      l2.add(new RegisterResponseEntry(2L, (short)1,SOURCE2_SCHEMA_STR));
      l3.add(new RegisterResponseEntry(3L, (short)1,SOURCE3_SCHEMA_STR));

      schemaMap.put(1L, l1);
      schemaMap.put(2L, l2);
      schemaMap.put(3L, l3);

      dispatcher.enqueueMessage(SourcesMessage.createSetSourcesIdsMessage(sourcesMap.values()));
      dispatcher.enqueueMessage(SourcesMessage.createSetSourcesSchemasMessage(schemaMap));

      log.info("starting event dispatch");

      //stream the events from the source buffer without the EOW

      //comm channels between reader and writer
      Pipe pipe = Pipe.open();
      Pipe.SinkChannel writerStream = pipe.sink();
      Pipe.SourceChannel readerStream = pipe.source();
      writerStream.configureBlocking(true);
      readerStream.configureBlocking(false);

      //Event writer - Relay in the real world
      Checkpoint cp = Checkpoint.createFlexibleCheckpoint();

      //Event readers - Clients in the real world
      //Checkpoint pullerCheckpoint = Checkpoint.createFlexibleCheckpoint();
      DbusEventsStatisticsCollector clientStats = new DbusEventsStatisticsCollector(0, "client", true, false, null);
      DbusEventBufferReader reader = new DbusEventBufferReader(destEventsBuf, readerStream, null, clientStats);
      UncaughtExceptionTrackingThread tReader = new UncaughtExceptionTrackingThread(reader,"Reader");
      tReader.setDaemon(true);
      tReader.start();

      try
      {
        log.info("send first window -- that one should be OK");
        StreamEventsResult streamRes = srcEventsBuf.streamEvents(cp, writerStream, new StreamEventsArgs(win1Size));
        Assert.assertEquals(numEventsPerWindow + 1, streamRes.getNumEventsStreamed());

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 1 == callbackStats.getNumSysEventsProcessed();
          }
        }, "first window processed", 5000, log);

        log.info("send the second partial window -- that one should cause an error");
        streamRes = srcEventsBuf.streamEvents(cp, writerStream, new StreamEventsArgs(win2Size));
        Assert.assertEquals(numOfFailureEvent - numEventsPerWindow, streamRes.getNumEventsStreamed());

        log.info("wait for dispatcher to finish");
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            log.info("events received: " + callbackStats.getNumDataEventsReceived());
            return numOfFailureEvent <= callbackStats.getNumDataEventsProcessed();
          }
        }, "all events until the error processed", 5000, log);

        log.info("all data events have been received but no EOW");
        Assert.assertEquals(numOfFailureEvent, clientStats.getTotalStats().getNumDataEvents());
        Assert.assertEquals(1, clientStats.getTotalStats().getNumSysEvents());
        //at least one failing event therefore < numOfFailureEvent events can be processed
        Assert.assertTrue(numOfFailureEvent <= callbackStats.getNumDataEventsProcessed());
        //onDataEvent callbacks for e2_1 and e2_2 get cancelled
        Assert.assertEquals(2, callbackStats.getNumDataErrorsProcessed());
        //only one EOW
        Assert.assertEquals(1, callbackStats.getNumSysEventsProcessed());

        log.info("Send the remainder of the window");
        streamRes = srcEventsBuf.streamEvents(cp, writerStream, new StreamEventsArgs(100000));
        //remaining events + EOWs
        Assert.assertEquals(srcTestEvents.size() + numWindows - (numOfFailureEvent + 1),
                            streamRes.getNumEventsStreamed());

        log.info("wait for the rollback");
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 1 == mockConsumer.getNumRollbacks();
          }
        }, "rollback seen", 5000, log);

        log.info("wait for dispatcher to finish after the rollback");
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            log.info("num windows processed: " + callbackStats.getNumSysEventsProcessed());
            return numWindows == callbackStats.getNumSysEventsProcessed();
          }
        }, "all events processed", 5000, log);
      }
      finally
      {
View Full Code Here

                                          regId + BOOTSTRAP_EVENT_STATS_SUFFIX_NAME,
                                          true,
                                          false,
                                          mbeanServer);
    _relayConsumerStats =
        new ConsumerCallbackStats(ownerId, regId + RELAY_CONSUMER_STATS_SUFFIX_NAME,
                                  regId, true, false, new ConsumerCallbackStatsEvent());
    _bootstrapConsumerStats =
        new ConsumerCallbackStats(ownerId, regId + BOOTSTRAP_CONSUMER_STATS_SUFFIX_NAME,
                                  regId, true, false, new ConsumerCallbackStatsEvent());
    _unifiedClientStats =
        new UnifiedClientStats(ownerId, regId + UNIFIED_CLIENT_STATS_SUFFIX_NAME,
                               regId, true, false,
                               _client.getClientStaticConfig().getPullerThreadDeadnessThresholdMs(),
View Full Code Here

      pullerThreadDeadnessThresholdMs = _client.getClientStaticConfig().getPullerThreadDeadnessThresholdMs();
    }

    String regId = null != _id ? _id.getId() : "unknownReg";

    ConsumerCallbackStats relayConsumerStats =
        new ConsumerCallbackStats(ownerId, regId + ".callback.relay",
                                  regId, true, false, new ConsumerCallbackStatsEvent());
    ConsumerCallbackStats bootstrapConsumerStats =
        new ConsumerCallbackStats(ownerId, regId + ".callback.bootstrap",
                                  regId, true, false, new ConsumerCallbackStatsEvent());
    UnifiedClientStats unifiedClientStats =
        new UnifiedClientStats(ownerId, regId + ".callback.unified",
                               regId, true, false,
                               pullerThreadDeadnessThresholdMs,
View Full Code Here

    DatabusStreamConsumer logConsumer = new LoggingConsumer();
    SelectingDatabusCombinedConsumer sdccLogConsumer = new SelectingDatabusCombinedConsumer(logConsumer);

    DatabusV2ConsumerRegistration consumerReg =
        new DatabusV2ConsumerRegistration(sdccLogConsumer, sources, null);
    ConsumerCallbackStats consumerStatsCollector = new ConsumerCallbackStats(1, "test","test", true,false, null);
    UnifiedClientStats unifiedStatsCollector = new UnifiedClientStats(1, "test","test.unified");

    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg);
    ThreadPoolExecutor executor = (ThreadPoolExecutor)Executors.newCachedThreadPool();
    MultiConsumerCallback callback =
        new MultiConsumerCallback(
            allRegistrations,
            executor,
            60000,
            new StreamConsumerCallbackFactory(consumerStatsCollector, unifiedStatsCollector),
            consumerStatsCollector,
            unifiedStatsCollector,
            null,
            null);
    callback.setSourceMap(sourcesMap);

    callback.onStartConsumption();
    callback.onStartDataEventSequence(new SingleSourceSCN(1, 1));
    for (int i = 0; i < 10000; ++i)
    {
      callback.onDataEvent(event1, null);
    }
    callback.onEndDataEventSequence(new SingleSourceSCN(1, 1));
    callback.onStopConsumption();

    System.out.println("max threads=" + executor.getLargestPoolSize() + " task count=" + executor.getTaskCount());
    System.out.println("dataEventsReceived=" + consumerStatsCollector.getNumDataEventsReceived() +
                       " sysEventsReceived=" + consumerStatsCollector.getNumSysEventsReceived()  +
                       " dataEventsProcessed=" + consumerStatsCollector.getNumDataEventsProcessed() +
                       " latencyEventsProcessed=" + consumerStatsCollector.getLatencyEventsProcessed());
    long dataEvents = consumerStatsCollector.getNumDataEventsReceived();
    assert(consumerStatsCollector.getNumDataEventsProcessed()==dataEvents);

  }
View Full Code Here

        new SleepingAnswer<ConsumerCallbackResult>(
            new LoggedAnswer<ConsumerCallbackResult>(ConsumerCallbackResult.SUCCESS, LOG, Level.DEBUG,
                                                     "onStartSource() called"),
            50));
    EasyMock.replay(mockConsumer1);
    ConsumerCallbackStats consumerStatsCollector = new ConsumerCallbackStats(1, "test","test", true,false, null);
    UnifiedClientStats unifiedStatsCollector = new UnifiedClientStats(1, "test","test.unified");

    //Create and fire up callbacks
    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg);
    MultiConsumerCallback callback =
        new MultiConsumerCallback(
            allRegistrations,
            Executors.newCachedThreadPool(),
            100,
            new StreamConsumerCallbackFactory(consumerStatsCollector, unifiedStatsCollector),
            consumerStatsCollector,
            unifiedStatsCollector,
            null,
            null);
    callback.setSourceMap(sourcesMap);

    ConsumerCallbackResult startConsumptionRes = callback.onStartConsumption();
    Assert.assertTrue(ConsumerCallbackResult.isFailure(startConsumptionRes),
                      "startConsumption() failed");
    ConsumerCallbackResult startWindowRes = callback.onStartDataEventSequence(null);
    Assert.assertTrue(ConsumerCallbackResult.isFailure(startWindowRes),
                      "startDataEventSequence() failed");
    ConsumerCallbackResult startSourceRes = callback.onStartSource("source1", null);
    Assert.assertTrue(ConsumerCallbackResult.isSuccess(startSourceRes),
                      "startSources(source1) succeeded");
    ConsumerCallbackResult event1Res = callback.onDataEvent(event1, null);
    Assert.assertTrue(ConsumerCallbackResult.isSuccess(event1Res),
                      "onDataEvent(1) succeeded");
    ConsumerCallbackResult event2Res = callback.onDataEvent(event2, null);
    Assert.assertTrue(ConsumerCallbackResult.isSuccess(event2Res),
                       "onDataEvent(2) queued up");
    ConsumerCallbackResult event3Res = callback.onDataEvent(event1, null);
    Assert.assertTrue(ConsumerCallbackResult.isSuccess(event3Res),
                      "onDataEvent(1) queued up");
    ConsumerCallbackResult endSourceRes = callback.onEndSource("source1", null);
    Assert.assertTrue(ConsumerCallbackResult.isFailure(endSourceRes),
                       "onEndSource fails because of timeout in onDataEvent(2)");

    EasyMock.reset(mockConsumer1);
    EasyMock.makeThreadSafe(mockConsumer1, true);
    EasyMock.expect(mockConsumer1.onStartSource("source2", null)).andAnswer(
        new SleepingAnswer<ConsumerCallbackResult>(
            new LoggedAnswer<ConsumerCallbackResult>(ConsumerCallbackResult.SUCCESS, LOG, Level.DEBUG,
                                                     "onStartSource() called"),
            150)).times(0, 1);
    EasyMock.expect(mockConsumer1.onDataEvent(event3, null)).andAnswer(
        new SleepingAnswer<ConsumerCallbackResult>(
            new LoggedAnswer<ConsumerCallbackResult>(ConsumerCallbackResult.SUCCESS, LOG, Level.DEBUG,
                                                     "onDataEvet(3) called"),
        40));
    EasyMock.expect(mockConsumer1.onEndSource("source2", null)).andAnswer(
        new SleepingAnswer<ConsumerCallbackResult>(
            new LoggedAnswer<ConsumerCallbackResult>(ConsumerCallbackResult.SUCCESS, LOG, Level.DEBUG,
                                                     "onStartSource() called"),
        60));
    EasyMock.replay(mockConsumer1);


    startSourceRes = callback.onStartSource("source2", null);
    Assert.assertTrue(ConsumerCallbackResult.isFailure(startSourceRes),
        "startSources(source2) fails");

    event1Res = callback.onDataEvent(event3, null);
    Assert.assertTrue(ConsumerCallbackResult.isSuccess(event1Res),
                      "onDataEvent(3) succeeded");
    endSourceRes = callback.onEndSource("source2", null);
    Assert.assertTrue(ConsumerCallbackResult.isSuccess(endSourceRes),
                       "onEndSource succeeds");

    long eventsErrProcessed = consumerStatsCollector.getNumErrorsProcessed();
    long totalEvents  = consumerStatsCollector.getNumEventsReceived();
    long totalEventsProcessed = consumerStatsCollector.getNumEventsProcessed();

    System.out.println("eventsReceived = " + consumerStatsCollector.getNumEventsReceived() + " eventsProcessed=" + consumerStatsCollector.getNumEventsProcessed());
    System.out.println("eventsErrProcessed =" + consumerStatsCollector.getNumErrorsProcessed() + " eventsErrReceived=" + consumerStatsCollector.getNumErrorsReceived()
                       + " totalEvents=" + consumerStatsCollector.getNumEventsReceived() + " totalEventsProcessed=" + totalEventsProcessed);

    //FIXME
    Assert.assertTrue(totalEvents >= totalEventsProcessed+eventsErrProcessed);
    Assert.assertTrue(eventsErrProcessed > 0);
    Assert.assertTrue(totalEventsProcessed < totalEvents);
View Full Code Here

        new SleepingAnswer<ConsumerCallbackResult>(
            new LoggedAnswer<ConsumerCallbackResult>(ConsumerCallbackResult.SUCCESS, LOG, Level.DEBUG,
                                                     "onStartSource() called"),
            1));
    EasyMock.replay(mockConsumer1);
    ConsumerCallbackStats consumerStatsCollector = new ConsumerCallbackStats(1, "test","test", true,false, null);
    UnifiedClientStats unifiedStatsCollector = new UnifiedClientStats(1, "test","test.unified");

    log.info("Create and fire up callbacks");
    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg);
View Full Code Here

TOP

Related Classes of com.linkedin.databus.client.pub.mbean.ConsumerCallbackStats

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.