Package com.linkedin.databus.core.util

Examples of com.linkedin.databus.core.util.UncaughtExceptionTrackingThread


    @Override
    public void start()
    {
      super.start();

      _relayPullerThread = new UncaughtExceptionTrackingThread(
          _relayPuller, _relayPuller.getName());
      _relayPullerThread.setDaemon(true);
      _relayPullerThread.start();

      _relayDispatcherThread = new UncaughtExceptionTrackingThread(
          _relayDispatcher, _relayDispatcher.getName());
      _relayDispatcherThread.setDaemon(true);
      _relayDispatcherThread.start();

      if (_isBootstrapEnabled) {
        _bootstrapPullerThread = new UncaughtExceptionTrackingThread(
            _bootstrapPuller, _bootstrapPuller.getName());
        _bootstrapPullerThread.setDaemon(true);
        _bootstrapPullerThread.start();

        _bootstrapDispatcherThread = new UncaughtExceptionTrackingThread(
            _bootstrapDispatcher, _bootstrapDispatcher.getName());
        _bootstrapDispatcherThread.setDaemon(true);
        _bootstrapDispatcherThread.start();
      }
    }
View Full Code Here


    consList.add(consumer);
    //Event readers - Clients in the real world
    DbusEventBufferReader reader = new DbusEventBufferReader(consEventBuffer, readerStream,
                                                             consList, clientStats);

    UncaughtExceptionTrackingThread tEmitter = new UncaughtExceptionTrackingThread(eventProducer,"EventProducer");
    UncaughtExceptionTrackingThread tWriter = new UncaughtExceptionTrackingThread(writer,"Writer");
    UncaughtExceptionTrackingThread tReader = new UncaughtExceptionTrackingThread(reader,"Reader");
    UncaughtExceptionTrackingThread tConsumer = new UncaughtExceptionTrackingThread(consumer,"Consumer");

    long emitterWaitms = 20000;
    long writerWaitms = 10000;
    long readerWaitms = 10000;
    long consumerWaitms = readerWaitms;

    //start emitter;
    tEmitter.start();

    //tarnish events written to buffer;
    int [] corruptIndexList = input.getCorruptIndexList();
    if (corruptIndexList.length > 0)
    {
      tEmitter.join(emitterWaitms);
      EventCorruptionType corruptionType = input.getCorruptionType();
      eventProducer.tarnishEventsInBuffer(corruptIndexList, corruptionType);
    }

    //start  consumer / reader /writer
    tConsumer.start();
    tWriter.start();
    tReader.start();

    //wait until all events have been written;
    dumpEmitterWriterReaderConsumerState(eventProducer, writer, reader, consumer, emitterStats, streamStats, clientStats, dstTestEvents, prodEventBuffer, consEventBuffer);
    LOG.info("runConstEventsReaderWriter(): waiting up to " + (emitterWaitms/1000) + " sec for appender/producer/emitter thread to terminate");
    tEmitter.join(emitterWaitms);
    //try and set a finish for writer
    long eventsEmitted = eventProducer.eventsEmitted();
    writer.setExpectedEvents(eventsEmitted);

    //wait for writer to finish;
    dumpEmitterWriterReaderConsumerState(eventProducer, writer, reader, consumer, emitterStats, streamStats, clientStats, dstTestEvents, prodEventBuffer, consEventBuffer);
    LOG.info("runConstEventsReaderWriter(): waiting up to " + (writerWaitms/1000) + " sec for writer thread to terminate");
    tWriter.join(writerWaitms);
    //close the writer Stream;
    dumpEmitterWriterReaderConsumerState(eventProducer, writer, reader, consumer, emitterStats, streamStats, clientStats, dstTestEvents, prodEventBuffer, consEventBuffer);
    LOG.info("runConstEventsReaderWriter(): signalling writer to stop");
    writer.stop();

    if (!tReader.isAlive())
    {
      LOG.error("runConstEventsReaderWriter(): reader thread died unexpectedly");
    }

    dumpEmitterWriterReaderConsumerState(eventProducer, writer, reader, consumer, emitterStats, streamStats, clientStats, dstTestEvents, prodEventBuffer, consEventBuffer);
    LOG.info("runConstEventsReaderWriter(): waiting up to " + (consumerWaitms/1000) + " sec for consumer thread to terminate");
    tConsumer.join(consumerWaitms);
    //stop the consumer thread; may or may not have got all events;
    dumpEmitterWriterReaderConsumerState(eventProducer, writer, reader, consumer, emitterStats, streamStats, clientStats, dstTestEvents, prodEventBuffer, consEventBuffer);
    LOG.info("runConstEventsReaderWriter(): signalling consumer to stop");
    consumer.stop();
    dumpEmitterWriterReaderConsumerState(eventProducer, writer, reader, consumer, emitterStats, streamStats, clientStats, dstTestEvents, prodEventBuffer, consEventBuffer);
View Full Code Here

      //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 both windows");
        StreamEventsResult streamRes = srcEventsBuf.streamEvents(cp, writerStream, new StreamEventsArgs(win1Size));
        Assert.assertEquals("num events streamed should equal total number of events plus 2", // EOP events, presumably?
View Full Code Here

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

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final WritableByteChannel ochannel = Channels.newChannel(baos);
    final AtomicBoolean hasError = new AtomicBoolean(false);
    final AtomicInteger num = new AtomicInteger(0);
    final AtomicBoolean genComplete = new AtomicBoolean(false);
    UncaughtExceptionTrackingThread streamThread = new UncaughtExceptionTrackingThread(new Runnable()
    {
      @Override
      public void run()
      {
        try
        {
          while (!genComplete.get() && 0 >= num.get())
          {
            StreamEventsArgs args = new StreamEventsArgs(10000);
            num.set(dbusBuf.streamEvents(cp, ochannel, args).getNumEventsStreamed());
          }
        }
        catch (ScnNotFoundException e)
        {
          hasError.set(true);
        }
        catch (OffsetNotFoundException e)
        {
          hasError.set(true);
        }
      }
    }, "testGetLargeScn.streamThread");
    streamThread.setDaemon(true);
    streamThread.start();

    log.info("append initial events");
    DbusEventGenerator generator = new DbusEventGenerator();
    Vector<DbusEvent> events = new Vector<DbusEvent>();
    generator.generateEvents(70000, 1, 120, 39, events);

    // Add events to the EventBuffer. Now the buffer is full
    DbusEventAppender appender = new DbusEventAppender(events, dbusBuf, null);
    appender.run(); // running in the same thread
    genComplete.set(true);

    streamThread.join(10000);

    Assert.assertFalse(streamThread.isAlive());
    Assert.assertNull(streamThread.getLastException());
    Assert.assertFalse(hasError.get());
    Assert.assertTrue(num.get() > 0);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.databus.core.util.UncaughtExceptionTrackingThread

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.