Source:
<code>public void run() { long startTimestamp = System.nanoTime(); IteratorSetting slow = new IteratorSetting(30, "slow", SlowIterator.class); SlowIterator.setSleepTime(slow, 100); List<IteratorSetting> compactIterators = new ArrayList<>(); compactIterators.add(slow); log.trace("Slow iterator {}", slow.toString()); try { Connector connector = getConnector(); log.trace("Start compaction"); connector.tableOperations().compact(tableName, new Text("0"), new Text("z"), compactIterators, true, true); log.trace("Compaction wait is complete"); log.trace("Slow compaction of rows took ms", NUM_ROWS, TimeUnit.MILLISECONDS.convert((System.nanoTime() - startTimestamp), TimeUnit.NANOSECONDS)); startTimestamp = System.nanoTime(); Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY); int count = 0; for (Map.Entry<Key,Value> elt : scanner) { String expected = String.format("%05d", count); assert (elt.getKey().getRow().toString().equals(expected)); count++; } log.trace("After compaction, scan time for rows ms", NUM_ROWS, TimeUnit.MILLISECONDS.convert((System.nanoTime() - startTimestamp), TimeUnit.NANOSECONDS)); if (count != NUM_ROWS) { throw new IllegalStateException(String.format("After compaction, number of rows %1$d does not match expected %2$d", count, NUM_ROWS)); } } catch (TableNotFoundException ex) { throw new IllegalStateException("test failed, table " + tableName + " does not exist", ex); } catch (AccumuloSecurityException ex) { throw new IllegalStateException("test failed, could not add iterator due to security exception", ex); } catch (AccumuloException ex) { <START> if (!ex.getMessage().contains("Compaction canceled")) { <END> throw new IllegalStateException("test failed with an Accumulo exception", ex); } } }</code><technical_language>Do get a named exception compaction is cancelled</technical_language>

Target:
public void run() { long startTimestamp = System.nanoTime(); IteratorSetting slow = new IteratorSetting(30, "slow", SlowIterator.class); SlowIterator.setSleepTime(slow, SLOW_SCAN_SLEEP_MS); List<IteratorSetting> compactIterators = new ArrayList<>(); compactIterators.add(slow); log.trace("Slow iterator {}", slow.toString()); try { log.trace("Start compaction"); connector.tableOperations().compact(tableName, new Text("0"), new Text("z"), compactIterators, true, true); log.trace("Compaction wait is complete"); log.trace("Slow compaction of rows took ms", NUM_ROWS, TimeUnit.MILLISECONDS.convert((System.nanoTime() - startTimestamp), TimeUnit.NANOSECONDS)); startTimestamp = System.nanoTime(); Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY); int count = 0; for (Map.Entry<Key,Value> elt : scanner) { String expected = String.format("%05d", count); assert (elt.getKey().getRow().toString().equals(expected)); count++; } log.trace("After compaction, scan time for rows ms", NUM_ROWS, TimeUnit.MILLISECONDS.convert((System.nanoTime() - startTimestamp), TimeUnit.NANOSECONDS)); if (count != NUM_ROWS) { throw new IllegalStateException(String.format("After compaction, number of rows %1$d does not match expected %2$d", count, NUM_ROWS)); } } catch (TableNotFoundException ex) { throw new IllegalStateException("test failed, table " + tableName + " does not exist", ex); } catch (AccumuloSecurityException ex) { throw new IllegalStateException("test failed, could not add iterator due to security exception", ex); } catch (AccumuloException ex) { if (!ex.getMessage().contains("Compaction canceled")) { throw new IllegalStateException("test failed with an Accumulo exception", ex); } } }