Package com.linkedin.databus.core

Examples of com.linkedin.databus.core.DbusEventBuffer


        MockServerChannelHandler.LOG.setLevel(debugLevel);
        final int eventsNum = 20;
        DbusEventInfo[] eventInfos = createSampleSchema1Events(eventsNum);

        //simulate relay buffers
        DbusEventBuffer relayBuffer = new DbusEventBuffer(_bufCfg);
        relayBuffer.start(0);
        writeEventsToBuffer(relayBuffer, eventInfos, 4);

        //prepare stream response ??????????????//
        Checkpoint cp = Checkpoint.createFlexibleCheckpoint();
        final DbusEventsStatisticsCollector stats =
View Full Code Here


        //log.setLevel(Level.);
        final int eventsNum = 20;
        DbusEventInfo[] eventInfos = createSampleSchema1Events(eventsNum);

        //simulate relay buffers
        DbusEventBuffer relayBuffer = new DbusEventBuffer(_bufCfg);
        relayBuffer.start(0);
        writeEventsToBuffer(relayBuffer, eventInfos, 4);

        //prepare stream response
        Checkpoint cp = Checkpoint.createFlexibleCheckpoint();
        final DbusEventsStatisticsCollector stats =
View Full Code Here

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

  {
    LOG.info("\n\nstarting test1StreamConsumerHappyPath()");

    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);

    DatabusStreamConsumer mockConsumer = EasyMock.createStrictMock(DatabusStreamConsumer.class);
    SelectingDatabusCombinedConsumer sdccMockConsumer = new SelectingDatabusCombinedConsumer(mockConsumer);

    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);
    }

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

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

    DbusEventBuffer.DbusEventIterator iter = eventsBuf.acquireIterator("myIter1");
    assert iter.hasNext() : "unable to read event";
    DbusEvent event1 = iter.next();
    assert iter.hasNext() : "unable to read event";
    DbusEvent event2 = iter.next();
    assert iter.hasNext() : "unable to read event";
View Full Code Here

  {
    LOG.info("\n\nstarting test1StreamConsumerCallFailure()");

    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);

    DatabusStreamConsumer mockConsumer = EasyMock.createStrictMock(DatabusStreamConsumer.class);
    SelectingDatabusCombinedConsumer sdccMockConsumer = new SelectingDatabusCombinedConsumer(mockConsumer);

    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);
    }

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

    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg);
    MultiConsumerCallback callback =
        new MultiConsumerCallback(
            allRegistrations,
            Executors.newCachedThreadPool(),
            1000,
            new StreamConsumerCallbackFactory(null, null),
            null,
            null,
            null,
            null);
    callback.setSourceMap(sourcesMap);

    DbusEventBuffer.DbusEventIterator iter = eventsBuf.acquireIterator("myIter1");
    assert iter.hasNext() : "unable to read event";
    DbusEvent event1 = iter.next();
    assert iter.hasNext() : "unable to read event";
    DbusEvent event2 = iter.next();
    assert iter.hasNext() : "unable to read event";
View Full Code Here

  private void testConsumersWithException(Throwable exception)
  {
    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);

    DatabusStreamConsumer mockConsumer = EasyMock.createStrictMock(DatabusStreamConsumer.class);
    SelectingDatabusCombinedConsumer sdccMockConsumer = new SelectingDatabusCombinedConsumer(mockConsumer);

    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);
    }

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

    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg);
    MultiConsumerCallback callback =
        new MultiConsumerCallback(
            allRegistrations,
            Executors.newCachedThreadPool(),
            1000,
            new StreamConsumerCallbackFactory(null, null),
            null,
            null,
            null,
            null);
    callback.setSourceMap(sourcesMap);

    DbusEventBuffer.DbusEventIterator iter = eventsBuf.acquireIterator("myIter1");
    assert iter.hasNext() : "unable to read event";
    DbusEvent event1 = iter.next();
    assert iter.hasNext() : "unable to read event";
    DbusEvent event2 = iter.next();
    assert iter.hasNext() : "unable to read event";
View Full Code Here

  {
    LOG.info("\n\nstarting test3IndependentStreamConsumersHappyPath()");

    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);

    DatabusStreamConsumer mockConsumer1 = EasyMock.createStrictMock("consumer1",
                                                                    DatabusStreamConsumer.class);
    SelectingDatabusCombinedConsumer sdccMockConsumer1 = new SelectingDatabusCombinedConsumer(mockConsumer1);
    EasyMock.makeThreadSafe(mockConsumer1, true);

    DatabusStreamConsumer mockConsumer2 = EasyMock.createStrictMock("consumer2",
                                                                    DatabusStreamConsumer.class);
    SelectingDatabusCombinedConsumer sdccMockConsumer2 = new SelectingDatabusCombinedConsumer(mockConsumer2);
    EasyMock.makeThreadSafe(mockConsumer2, true);

    DatabusStreamConsumer mockConsumer3 = EasyMock.createStrictMock("consumer3",
                                                                    DatabusStreamConsumer.class);
    SelectingDatabusCombinedConsumer sdccMockConsumer3 = new SelectingDatabusCombinedConsumer(mockConsumer3);
    EasyMock.makeThreadSafe(mockConsumer3, true);

    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);
    }

    DatabusV2ConsumerRegistration consumerReg1 =
        new DatabusV2ConsumerRegistration(sdccMockConsumer1, sources, null);
    DatabusV2ConsumerRegistration consumerReg2 =
      new DatabusV2ConsumerRegistration(sdccMockConsumer2, sources, null);
    DatabusV2ConsumerRegistration consumerReg3 =
      new DatabusV2ConsumerRegistration(sdccMockConsumer3, sources, null);

    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg1, consumerReg2, consumerReg3);
    MultiConsumerCallback callback =
        new MultiConsumerCallback(
            allRegistrations,
            Executors.newCachedThreadPool(),
            1000,
            new StreamConsumerCallbackFactory(null, null),
            null,
            null,
            null,
            null);
    callback.setSourceMap(sourcesMap);

    DbusEventBuffer.DbusEventIterator iter = eventsBuf.acquireIterator("myIter1");
    assert iter.hasNext() : "unable to read event";
    DbusEvent event1 = iter.next();
    assert iter.hasNext() : "unable to read event";
    DbusEvent event2 = iter.next();
    assert iter.hasNext() : "unable to read event";
View Full Code Here

  {
    LOG.info("\n\nstarting test3IndependentStreamConsumersWithFailure()");

    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);

    DatabusStreamConsumer mockConsumer1 = EasyMock.createStrictMock("consumer1",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer1, true);
    DatabusStreamConsumer mockConsumer2 = EasyMock.createStrictMock("consumer2",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer2, true);
    DatabusStreamConsumer mockConsumer3 = EasyMock.createStrictMock("consumer3",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer3, true);

    SelectingDatabusCombinedConsumer sdccMockConsumer1 = new SelectingDatabusCombinedConsumer(mockConsumer1);
    SelectingDatabusCombinedConsumer sdccMockConsumer2 = new SelectingDatabusCombinedConsumer(mockConsumer2);
    SelectingDatabusCombinedConsumer sdccMockConsumer3 = new SelectingDatabusCombinedConsumer(mockConsumer3);

    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);
    }

    DatabusV2ConsumerRegistration consumerReg1 =
        new DatabusV2ConsumerRegistration(sdccMockConsumer1, sources, null);
    DatabusV2ConsumerRegistration consumerReg2 =
      new DatabusV2ConsumerRegistration(sdccMockConsumer2, sources, null);
    DatabusV2ConsumerRegistration consumerReg3 =
      new DatabusV2ConsumerRegistration(sdccMockConsumer3, sources, null);

    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg1, consumerReg2, consumerReg3);
    MultiConsumerCallback callback =
        new MultiConsumerCallback(
            allRegistrations,
            Executors.newCachedThreadPool(),
            1000,
            new StreamConsumerCallbackFactory(null, null),
            null,
            null,
            null,
            null);
    callback.setSourceMap(sourcesMap);

    DbusEventBuffer.DbusEventIterator iter = eventsBuf.acquireIterator("myIter1");
    assert iter.hasNext() : "unable to read event";
    DbusEvent event1 = iter.next();
    assert iter.hasNext() : "unable to read event";
    DbusEvent event2 = iter.next();
    assert iter.hasNext() : "unable to read event";
View Full Code Here

  {
    LOG.info("\n\nstarting test3GroupedStreamConsumersHappyPath()");

    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);

    DatabusStreamConsumer mockConsumer1 = EasyMock.createStrictMock("consumer1",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer1, true);
    DatabusStreamConsumer mockConsumer2 = EasyMock.createStrictMock("consumer2",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer2, true);
    DatabusStreamConsumer mockConsumer3 = EasyMock.createStrictMock("consumer3",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer3, true);

    DatabusCombinedConsumer sdccMockConsumer1 = new SelectingDatabusCombinedConsumer(mockConsumer1);
    DatabusCombinedConsumer sdccMockConsumer2 = new SelectingDatabusCombinedConsumer(mockConsumer2);
    DatabusCombinedConsumer sdccMockConsumer3 = new SelectingDatabusCombinedConsumer(mockConsumer3);

    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);
    }

    DatabusV2ConsumerRegistration consumerReg1 =
        new DatabusV2ConsumerRegistration(
            Arrays.asList(sdccMockConsumer1, sdccMockConsumer2, sdccMockConsumer3), sources, null);

    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg1);
    MultiConsumerCallback callback =
        new MultiConsumerCallback(
            allRegistrations,
            Executors.newCachedThreadPool(),
            1000,
            new StreamConsumerCallbackFactory(null, null),
            null,
            null,
            null,
            null);
    callback.setSourceMap(sourcesMap);

    DbusEventBuffer.DbusEventIterator iter = eventsBuf.acquireIterator("myIter1");
    assert iter.hasNext() : "unable to read event";
    DbusEvent event1 = iter.next();
    assert iter.hasNext() : "unable to read event";
    DbusEvent event2 = iter.next();
    assert iter.hasNext() : "unable to read event";
View Full Code Here

  {
    LOG.info("\n\nstarting test3GroupedStreamConsumersWithFailure()");

    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);

    DatabusStreamConsumer mockConsumer1 = EasyMock.createStrictMock("consumer1",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer1, true);
    DatabusStreamConsumer mockConsumer2 = EasyMock.createStrictMock("consumer2",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer2, true);
    DatabusStreamConsumer mockConsumer3 = EasyMock.createStrictMock("consumer3",
                                                                    DatabusStreamConsumer.class);
    EasyMock.makeThreadSafe(mockConsumer3, true);

    DatabusCombinedConsumer sdccMockConsumer1 = new SelectingDatabusCombinedConsumer(mockConsumer1);
    DatabusCombinedConsumer sdccMockConsumer2 = new SelectingDatabusCombinedConsumer(mockConsumer2);
    DatabusCombinedConsumer sdccMockConsumer3 = new SelectingDatabusCombinedConsumer(mockConsumer3);

    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);
    }

    DatabusV2ConsumerRegistration consumerReg1 =
        new DatabusV2ConsumerRegistration(
            Arrays.asList(sdccMockConsumer1, sdccMockConsumer2, sdccMockConsumer3), sources, null);

    List<DatabusV2ConsumerRegistration> allRegistrations =
        Arrays.asList(consumerReg1);
    MultiConsumerCallback callback =
        new MultiConsumerCallback(
            allRegistrations,
            Executors.newCachedThreadPool(),
            1000,
            new StreamConsumerCallbackFactory(null, null),
            null,
            null,
            null,
            null);
    callback.setSourceMap(sourcesMap);

    DbusEventBuffer.DbusEventIterator iter = eventsBuf.acquireIterator("myIter1");
    assert iter.hasNext() : "unable to read event";
    DbusEvent event1 = iter.next();
    assert iter.hasNext() : "unable to read event";
    DbusEvent event2 = iter.next();
    assert iter.hasNext() : "unable to read event";
View Full Code Here

TOP

Related Classes of com.linkedin.databus.core.DbusEventBuffer

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.