@Override
  public void perform() throws IOException {
    // Possible compression algorithms. If an algorithm is not supported,
    // modifyTable will fail, so there is no harm.
    Algorithm[] possibleAlgos = Algorithm.values();
    // Since not every compression algorithm is supported,
    // let's use the same algorithm for all column families.
    Random rand = ThreadLocalRandom.current();
    // If an unsupported compression algorithm is chosen, pick a different one.
    // This is to work around the issue that modifyTable() does not throw remote
    // exception.
    Algorithm algo;
    do {
      algo = possibleAlgos[rand.nextInt(possibleAlgos.length)];

      try {
        Compressor c = algo.getCompressor();

        // call returnCompressor() to release the Compressor
        algo.returnCompressor(c);
        break;
      } catch (Throwable t) {
        getLogger().info("Performing action: Changing compression algorithms to " + algo
          + " is not supported, pick another one");
      }
    } while (true);

    final Algorithm chosenAlgo = algo; // for use in lambda
    getLogger().debug("Performing action: Changing compression algorithms on "
      + tableName.getNameAsString() + " to " + chosenAlgo);
    modifyAllTableColumns(tableName, columnFamilyDescriptorBuilder -> {
      if (rand.nextBoolean()) {
        columnFamilyDescriptorBuilder.setCompactionCompressionType(chosenAlgo);
      } else {
        columnFamilyDescriptorBuilder.setCompressionType(chosenAlgo);
      }
    });
  }
Action that changes the compression algorithm on a column family from a list of tables.
hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/ChangeCompressionAction.java