@org.junit.Ignore
  @Test // Flakey. Diasabled by HBASE-24079. Renable with Fails with HBASE-24083.
  // Caused by: java.util.concurrent.RejectedExecutionException:
  // Task org.apache.hadoop.hbase.client.ResultBoundedCompletionService$QueueingFuture@e385431
  // rejected from java.util.concurrent.ThreadPoolExecutor@ 52b027d[Terminated, pool size = 0,
  // active threads = 0, queued tasks = 0, completed tasks = 1]
  // at org.apache.hadoop.hbase.thrift2.TestThriftHBaseServiceHandler.
  // testLongLivedScan(TestThriftHBaseServiceHandler.java:804)
  public void testLongLivedScan() throws Exception {
    int numTrials = 6;
    int trialPause = 1000;
    int cleanUpInterval = 100;
    Configuration conf = new Configuration(UTIL.getConfiguration());
    // Set the ConnectionCache timeout to trigger halfway through the trials
    conf.setInt(MAX_IDLETIME, (numTrials / 2) * trialPause);
    conf.setInt(CLEANUP_INTERVAL, cleanUpInterval);
    ThriftHBaseServiceHandler handler =
      new ThriftHBaseServiceHandler(conf, UserProvider.instantiate(conf));

    ByteBuffer table = wrap(tableAname);
    // insert data
    TColumnValue columnValue =
      new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname));
    List<TColumnValue> columnValues = new ArrayList<>(1);
    columnValues.add(columnValue);
    for (int i = 0; i < numTrials; i++) {
      TPut put = new TPut(wrap(Bytes.toBytes("testScan" + i)), columnValues);
      handler.put(table, put);
    }

    // create scan instance
    TScan scan = new TScan();
    List<TColumn> columns = new ArrayList<>(1);
    TColumn column = new TColumn();
    column.setFamily(familyAname);
    column.setQualifier(qualifierAname);
    columns.add(column);
    scan.setColumns(columns);
    scan.setStartRow(Bytes.toBytes("testScan"));
    scan.setStopRow(Bytes.toBytes("testScan\uffff"));
    // Prevent the scanner from caching results
    scan.setCaching(1);

    // get scanner and rows
    int scanId = handler.openScanner(table, scan);
    for (int i = 0; i < numTrials; i++) {
      // Make sure that the Scanner doesn't throw an exception after the ConnectionCache timeout
      List<TResult> results = handler.getScannerRows(scanId, 1);
      assertArrayEquals(Bytes.toBytes("testScan" + i), results.get(0).getRow());
      Thread.sleep(trialPause);
    }
  }
Tests keeping a HBase scanner alive for long periods of time. Each call to getScannerRow()
should reset the ConnectionCache timeout for the scanner's connection.
hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java