@Test
  public void testCoolOffWithoutQueueFlush() throws Exception {
    final List<Callable<Put>> flushList = Lists.newArrayList();

    final SpillController spillController = new SpillController("test", HBASE_WRITER_CONFIG);
    final HBaseWriter dummyWriter =
        new HBaseWriter(HBASE_WRITER_CONFIG, conf, spillController) {
          @Override
          protected void flushToHBase(final List<Callable<Put>> dbObjects) {
            flushList.addAll(dbObjects);
          }
        };

    int count = 0;

    while (dummyWriter.write(CALLABLE)) {
      count++;
    }

    // Make sure that the queue is full.
    Assert.assertEquals(HBASE_WRITER_CONFIG.getQueueLength(), count);

    // Wait until "past cooloff time".
    Thread.sleep(1100L);

    // Writing should still fail, but it should log only every second..
    for (int i = 0; i < 30; i++) {
      Assert.assertFalse(dummyWriter.write(CALLABLE));
      Thread.sleep(100L);
    }
  }
  protected AbstractHBaseSupport(
      @Nonnull final HBaseWriterConfig hbaseWriterConfig,
      @Nonnull final Configuration hadoopConfig) {
    Preconditions.checkNotNull(hbaseWriterConfig, "writer config must not be null!");
    Preconditions.checkNotNull(hadoopConfig, "hadoop config must not be null!");

    this.hadoopConfig = hadoopConfig;

    this.tableName = hbaseWriterConfig.getTableName();
  }
  @Test
  public void testCoolOffWithQueueFlush() throws Exception {
    final List<Callable<Put>> flushList = Lists.newArrayList();

    final SpillController spillController = new SpillController("test", HBASE_WRITER_CONFIG);
    final HBaseWriter dummyWriter =
        new HBaseWriter(HBASE_WRITER_CONFIG, conf, spillController) {
          @Override
          protected void flushToHBase(final List<Callable<Put>> dbObjects) {
            flushList.addAll(dbObjects);
          }
        };

    int count = 0;

    while (dummyWriter.write(CALLABLE)) {
      count++;
    }

    // Make sure that the queue is full.
    Assert.assertEquals(HBASE_WRITER_CONFIG.getQueueLength(), count);

    Assert.assertEquals(0, flushList.size());

    // Run a single loop of the thread to flush the queue.
    dummyWriter.runLoop();
    Assert.assertEquals(HBASE_WRITER_CONFIG.getQueueLength(), flushList.size());

    // But writing should still fail.
    Assert.assertFalse(dummyWriter.write(CALLABLE));

    Thread.sleep(500L);

    // But writing should still fail.
    Assert.assertFalse(dummyWriter.write(CALLABLE));

    Thread.sleep(1000L);

    // Now it should work again.
    Assert.assertTrue(dummyWriter.write(CALLABLE));
  }