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

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


                                      true,
                                      false,
                                      null,
                                      ManagementFactory.getPlatformMBeanServer());

        UnifiedClientStats unifiedClientStats =
            new UnifiedClientStats(id,
                                   producerName + ".inbound.unified.cons",
                                   producerName + ".inbound.unified.cons",
                                   true,
                                   false,
                                   UnifiedClientStats.DEFAULT_DEADNESS_THRESHOLD_MS,
View Full Code Here


  private void processUnifiedTotalStats(StatsCollectors<UnifiedClientStats> statsCollectors,
                                       DatabusRequest request) throws IOException
  {
    if (null == statsCollectors) return;

    UnifiedClientStats unifiedTotalStats = statsCollectors.getStatsCollector();
    if (null == unifiedTotalStats) return;

    writeJsonObjectToResponse(unifiedTotalStats, request);

    if (request.getRequestType() == HttpMethod.PUT || request.getRequestType() == HttpMethod.POST)
View Full Code Here

                                      null,
                                      getMbeanServer()));

        _unifiedClientStatsCollectors.addStatsCollector(
            statsCollectorName,
            new UnifiedClientStats(ownerId,
                                   statsCollectorName + ".inbound.unified.cons",
                                   statsCollectorName + ".inbound.unified.cons",
                                   true,
                                   false,
                                   _clientStaticConfig.getPullerThreadDeadnessThresholdMs(),
View Full Code Here

            }

            long consumerTimeBudgetMs = 60*1000;
            DatabusV2ConsumerRegistration consumerReg = new DatabusV2ConsumerRegistration(tConsumer, sources, null);
            List<DatabusV2ConsumerRegistration> allRegistrations =  Arrays.asList(consumerReg);
            final UnifiedClientStats unifiedStats = new UnifiedClientStats(0, "test", "test.unified");
            // single-threaded execution of consumer
            MultiConsumerCallback mConsumer =
                new MultiConsumerCallback(allRegistrations,
                                          Executors.newFixedThreadPool(1),
                                          consumerTimeBudgetMs,
                                          new StreamConsumerCallbackFactory(null, unifiedStats),
                                          null,
                                          unifiedStats,
                                          null,
                                          null);

            /* Generate events */
            Vector<DbusEvent> srcTestEvents = new Vector<DbusEvent>();
            Vector<Short> srcIdList = new Vector<Short> ();
            srcIdList.add(srcId);

            DbusEventGenerator evGen = new DbusEventGenerator(0,srcIdList);
            Assert.assertTrue(evGen.generateEvents(numEvents, maxWindowSize, 512, payloadSize, srcTestEvents) > 0);

            int totalSize=0;
            int maxSize=0;
            for (DbusEvent e : srcTestEvents)
            {
                totalSize += e.size();
                maxSize = (e.size() > maxSize) ? e.size():maxSize;
            }

            /* Source configuration */
            double thresholdChkptPct = thresholdPct;
            DatabusSourcesConnection.Config conf = new DatabusSourcesConnection.Config();
            conf.setCheckpointThresholdPct(thresholdChkptPct);
            conf.getDispatcherRetries().setMaxRetryNum(10);
            conf.setFreeBufferThreshold(maxSize);
            conf.setConsumerTimeBudgetMs(consumerTimeBudgetMs);
            int freeBufferThreshold = conf.getFreeBufferThreshold();
            DatabusSourcesConnection.StaticConfig connConfig = conf.build();

            // make buffer large enough to hold data; the control events are large that contain checkpoints
            int producerBufferSize = wrapAround ? totalSize : totalSize*2 + numCheckpoints*10*maxSize*5 + freeBufferThreshold;
            int individualBufferSize = producerBufferSize;
            int indexSize = producerBufferSize / 10;
            int stagingBufferSize = producerBufferSize;

            /* Event Buffer creation */
            TestGenericDispatcherEventBuffer dataEventsBuffer=
                new TestGenericDispatcherEventBuffer(
                    getConfig(producerBufferSize, individualBufferSize, indexSize ,
                              stagingBufferSize, AllocationPolicy.HEAP_MEMORY,
                              QueuePolicy.BLOCK_ON_WRITE));

            List<DatabusSubscription> subs = DatabusSubscription.createSubscriptionList(sources);
            /* Generic Dispatcher creation */
            TestDispatcher<DatabusCombinedConsumer> dispatcher =
                new TestDispatcher<DatabusCombinedConsumer>("rollBackcheck",
                                                            connConfig,
                                                            subs,
                                                            new InMemoryPersistenceProvider(),
                                                            dataEventsBuffer,
                                                            mConsumer,
                                                            bootstrapCheckpointsPerWindow == 0);

            /* Launch writer */
            DbusEventAppender eventProducer =
                new DbusEventAppender(srcTestEvents, dataEventsBuffer,bootstrapCheckpointsPerWindow ,null);
            Thread tEmitter = new Thread(eventProducer);
            tEmitter.start();

            /* Launch dispatcher */
            Thread tDispatcher = new Thread(dispatcher);
            tDispatcher.start();

            /* Now initialize this state machine */
            dispatcher.enqueueMessage(SourcesMessage.createSetSourcesIdsMessage(sourcesMap.values()));
            dispatcher.enqueueMessage(SourcesMessage.createSetSourcesSchemasMessage(schemaMap));

            // be generous; use worst case for num control events
            long waitTimeMs  = (numEvents*timeTakenForDataEventInMs + numEvents*timeTakenForControlEventInMs) * 4;
            tEmitter.join(waitTimeMs);
            // wait for dispatcher to finish reading the events
            tDispatcher.join(waitTimeMs);
            Assert.assertFalse(tEmitter.isAlive());
            System.out.println("tConsumer: " + tConsumer);

            int windowBeforeDataFail=(numFailDataEvent/maxWindowSize);
            int expectedDataFaults = numFailDataEvent == 0 ? 0:numFailures;

            int expectedCheckPointFaults =
                (numFailCheckpointEvent==0 || (expectedDataFaults!=0 && numFailCheckpointEvent==windowBeforeDataFail)) ?
                0 : numFailures;

            // Dispatcher/Library perspective
            // check if all windows were logged by dispatcher; in online case;
            if (bootstrapCheckpointsPerWindow == 0)
            {
                Assert.assertTrue(dispatcher.getNumCheckPoints() >= (numCheckpoints-expectedCheckPointFaults));
            }

            // Consumer prespective
            // 1 or 0 faults  injected in data callbacks; success (store) differs callback by 1
            Assert.assertEquals("Mismatch between callbacks and stored data on consumer.",
                                expectedDataFaults, tConsumer.getDataCallbackCount()-tConsumer.getStoredDataCount());
            Assert.assertTrue(tConsumer.getStoredDataCount() >= tConsumer.getNumUniqStoredEvents());
            Assert.assertEquals("Consumer failed to store expected number of checkpoints.",
                                dispatcher.getNumCheckPoints(), tConsumer.getStoredCheckpointCount());

            // Equality would be nice, but each "real" error (as seen by MultiConsumerCallback) triggers a non-
            // deterministic number of cancelled callbacks, each of which is treated as another consumer error
            // (as seen by StreamConsumerCallbackFactory or BootstrapConsumerCallbackFactory).  So an inequality
            // is the best we can do at the moment, barring a change in how numConsumerErrors is accounted.
            // Special case:  non-zero numFailCheckpointEvent doesn't actually trigger a callback error; instead
            // it's converted to ConsumerCallbackResult.SKIP_CHECKPOINT and therefore not seen by client metrics.
            if (expectedCheckPointFaults == 0 || expectedDataFaults > 0 || negativeTest)
            {
              Assert.assertTrue("Unexpected error count in consumer metrics (" + unifiedStats.getNumConsumerErrors() +
                                "); should be greater than or equal to numFailures (" + numFailures + ").",
                                unifiedStats.getNumConsumerErrors() >= numFailures);
            }
            else
            {
              Assert.assertEquals("Unexpected error count in consumer metrics; checkpoint errors shouldn't count. ",
                                  // unless negativeTest ...
                                  0, unifiedStats.getNumConsumerErrors());
            }

            // rollback behaviour; were all events re-sent?
            if (!negativeTest)
            {
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
                                    new StreamConsumerCallbackFactory(callbackStats, unifiedStats),
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),
View Full Code Here

                                  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(),
                               new UnifiedClientStatsEvent());
  }
View Full Code Here

        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,
                               new UnifiedClientStatsEvent());
    _relayCallbackStatsMerger = new StatsCollectors<ConsumerCallbackStats>(relayConsumerStats);
    _bootstrapCallbackStatsMerger = new StatsCollectors<ConsumerCallbackStats>(bootstrapConsumerStats);
View Full Code Here

      cpEvent.getRawBytes().get(cpEventBytes);
      ByteArrayInputStream cpIs = new ByteArrayInputStream(cpEventBytes);
      ReadableByteChannel cpRbc = Channels.newChannel(cpIs);

      UnifiedClientStats unifiedClientStats = _sourcesConn.getUnifiedClientStats();
      sendHeartbeat(unifiedClientStats);
      int ecnt = eventBuffer.readEvents(cpRbc);

      success = (ecnt > 0);
View Full Code Here

               " startScn=" + cp.getBootstrapStartScn() +
               " targetScn=" + cp.getBootstrapTargetScn() +
               " sinceScn=" + cp.getBootstrapSinceScn() +
               " windowScn=" + cp.getWindowScn());

      UnifiedClientStats unifiedClientStats = _sourcesConn.getUnifiedClientStats();
      if (unifiedClientStats != null)
      {
        // should always be false, but just in case of weird edge cases:
        boolean isBootstrapping = (consumptionMode == DbusClientMode.BOOTSTRAP_SNAPSHOT ||
                                   consumptionMode == DbusClientMode.BOOTSTRAP_CATCHUP);
        unifiedClientStats.setBootstrappingState(isBootstrapping);
      }

      cp.resetBootstrap(); // clear Bootstrap scns for future bootstraps

      if ( toTearConnAfterHandlingResponse())
View Full Code Here

TOP

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

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.