use of com.linkedin.databus.client.pub.mbean.UnifiedClientStats in project databus by linkedin.
the class TestMultiConsumerCallback method testPerf.
@Test
public void testPerf() throws Exception {
LOG.info("\n\nstarting testPerf()");
List<String> sources = new ArrayList<String>();
Map<Long, IdNamePair> sourcesMap = new HashMap<Long, IdNamePair>();
for (int i = 1; i <= 3; ++i) {
IdNamePair sourcePair = new IdNamePair((long) i, "source" + i);
sources.add(sourcePair.getName());
sourcesMap.put(sourcePair.getId(), sourcePair);
}
Hashtable<Long, AtomicInteger> keyCounts = new Hashtable<Long, AtomicInteger>();
DbusEventBuffer eventsBuf = new DbusEventBuffer(_generic100KBufferStaticConfig);
eventsBuf.start(0);
eventsBuf.startEvents();
initBufferWithEvents(eventsBuf, 1, 1, (short) 1, keyCounts);
initBufferWithEvents(eventsBuf, 2, 2, (short) 3, keyCounts);
eventsBuf.endEvents(100L);
DbusEventBuffer.DbusEventIterator iter = eventsBuf.acquireIterator("myIter1");
assert iter.hasNext() : "unable to read event";
iter.next();
DbusEvent event1 = iter.next();
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);
}
Aggregations