Examples of ConditionCheck


Examples of com.linkedin.databus2.test.ConditionCheck

    ConcurrentAppendableSingleFileInputStream i = ConcurrentAppendableSingleFileInputStream.createAppendingFileInputStream(srcFile.getAbsolutePath(),0,100);
    BufferedReader r = new BufferedReader(new InputStreamReader(i));
    WriterThread w2 = new WriterThread("Writer2",destFile, 0,  r);
    w2.start();

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return w1.getNumNullsInserted() >= 1;
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

    w2.start();

    for ( int j = 1; j <= 3; j++)
    {
      final int nullInsertTimes = j;
      TestUtil.assertWithBackoff(new ConditionCheck()
      {
        @Override
        public boolean check()
        {
          return w1.getNumNullsInserted() == nullInsertTimes;
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

      LOG.info("starting event producer");
      gg.start(-2); // -2 here does nothing. actual setting happens thru the mock of
                    // MaxSCNReadWriter
      // let it parse first files

      TestUtil.assertWithBackoff(new ConditionCheck()
      {
        @Override
        public boolean check()
        {
          return ggParserStats.getNumFilesParsed() == 2
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

    iter0 = null;
    iter1 = null;
    iter2 = null;
    iter3 = null;

    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        System.gc();
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

      buf.endEvents(100L, null);
      r1.start();
      log.info("Relay started");

      // wait until relay comes up
      TestUtil.assertWithBackoff(new ConditionCheck() {
        @Override
        public boolean check() {
          return relay1.isRunningStatus();
        }
      },"Relay hasn't come up completely ", 7000, LOG);

      // now create client:
      String srcSubscriptionString = TestUtil.join(srcs, ",");
      String serverName = "localhost:" + relayPort;
      final EventsCountingConsumer countingConsumer = new EventsCountingConsumer();

      int id = (RngUtils.randomPositiveInt() % 10000) + 1;
      DatabusSourcesConnection clientConn = RelayEventProducer
      .createDatabusSourcesConnection("testProducer", id, serverName,
          srcSubscriptionString, countingConsumer,
          1 * 1024 * 1024, 50000, 30 * 1000, 100, 15 * 1000,
          1, true, DatabusClientNettyThreadPools.createNettyThreadPools(id),
          0, DbusEventFactory.DBUS_EVENT_V1,0);

      cr = new ClientRunner(clientConn);

      cr.start();
      log.info("Consumer started");
      // wait till client gets the event
      TestUtil.assertWithBackoff(new ConditionCheck() {
        @Override
        public boolean check() {
          return countingConsumer.getNumDataEvents() == 1;
        }
      },"Consumer didn't get any events ", 64 * 1024, LOG);
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

      log.info("starting relay on port " + relayPort);
      r1.start();
      //TestUtil.sleep(10*1000);

      // wait until relay comes up
      TestUtil.assertWithBackoff(new ConditionCheck() {
        @Override
        public boolean check() {
          return relay1.isRunningStatus();
        }
      },"Relay hasn't come up completely ", 30000, LOG);

      log.info("now create client");
      String srcSubscriptionString = TestUtil.join(srcs, ",");
      String serverName = "localhost:" + relayPort;
      final EventsCountingConsumer countingConsumer = new EventsCountingConsumer();

      int id = (RngUtils.randomPositiveInt() % 10000) + 1;
      DatabusSourcesConnection clientConn = RelayEventProducer
      .createDatabusSourcesConnection("testProducer", id, serverName,
          srcSubscriptionString, countingConsumer,
          1 * 1024 * 1024, 50000, 30 * 1000, 100, 15 * 1000,
          1, true, DatabusClientNettyThreadPools.createNettyThreadPools(id),
          0, DbusEventFactory.DBUS_EVENT_V1,0);

      cr = new ClientRunner(clientConn);

      log.info("starting client");
      cr.start();
      // wait till client gets the event
      TestUtil.assertWithBackoff(new ConditionCheck() {
        @Override
        public boolean check() {
          int events = countingConsumer.getNumDataEvents();
          LOG.info("client got " + events + " events");
          return events == 2;
        }
      },"Consumer didn't get 2 events ", 64 * 1024, LOG);

      // asserts
      Assert.assertEquals(countingConsumer.getNumDataEvents(), 2);
      Assert.assertEquals(countingConsumer.getNumWindows(), 2);
      Assert.assertEquals(countingConsumer.getNumDataEvents(DbusEventFactory.DBUS_EVENT_V1),2);
      log.info("shutdown first client");
      clientConn.stop();
      cr.shutdown();
      TestUtil.sleep(1000);
      cr = null;


      log.info("start another client who understands V2");
      final EventsCountingConsumer countingConsumer1 = new EventsCountingConsumer();

      clientConn = RelayEventProducer
      .createDatabusSourcesConnection("testProducer", id, serverName,
          srcSubscriptionString, countingConsumer1,
          1 * 1024 * 1024, 50000, 30 * 1000, 100, 15 * 1000,
          1, true, DatabusClientNettyThreadPools.createNettyThreadPools(id),
          0, DbusEventFactory.DBUS_EVENT_V2,0);

      cr = new ClientRunner(clientConn);

      cr.start();
      log.info("wait till client gets the event");
      TestUtil.assertWithBackoff(new ConditionCheck() {
        @Override
        public boolean check() {
          int events = countingConsumer1.getNumDataEvents();
          LOG.debug("client got " + events + " events");
          return events == 2;
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

    }
  }

    public void assertRelayRunning(final HttpRelay relay, long timeoutMs, Logger log)
    {
      TestUtil.assertWithBackoff(new ConditionCheck()
      {
        @Override
        public boolean check()
        {
          return relay.isRunningStatus();
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

      log.info("Sending pause to relay!");
      log.info("numDataEvents=" + stats.getNumDataEvents()
          + " numWindows=" + stats.getNumSysEvents() + " size="
          + stats.getSizeDataEvents());

      TestUtil.assertWithBackoff(new ConditionCheck()
            {
              @Override
              public boolean check()
              {
                boolean success = true;
                for (EventProducer p: relay1.getProducers())
                {
                    if (!(success = success && p.isPaused())) break;
                }
                return success;
              }
            }, "waiting for producers to pause", 4000, log);

      TestUtil.assertWithBackoff(new ConditionCheck()
            {
              @Override
              public boolean check()
              {
                log.debug("countingConsumer.getNumWindows()=" + countingConsumer.getNumWindows());
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

      // wait for r2 to catchup with r1
      final DbusEventsTotalStats stats = relay1
          .getInboundEventStatisticsCollector().getTotalStats();
      final DbusEventsTotalStats stats2 = relay2
          .getInboundEventStatisticsCollector().getTotalStats();
      TestUtil.assertWithBackoff(new ConditionCheck()
      {

        @Override
        public boolean check()
        {
          log.debug("stats2.getNumSysEvents()=" + stats2.getNumSysEvents());
          return stats2.getNumSysEvents() == stats.getNumSysEvents();
        }
      }, "wait for chained relay to catchup", 60000, log);

      log.info("start the client");
      cr.start();

      // wait until client got all events or for maxTimeout;
      TestUtil.assertWithBackoff(new ConditionCheck()
      {

        @Override
        public boolean check()
        {
View Full Code Here

Examples of com.linkedin.databus2.test.ConditionCheck

      log.info("start the client");
      cr.start();

      // wait until client got all events or for maxTimeout;
      TestUtil.assertWithBackoff(new ConditionCheck()
      {

        @Override
        public boolean check()
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.