class TarContainerPacker implements ContainerPacker<KeyValueContainerData> {

  @Override
  public void pack(Container<KeyValueContainerData> container,
      OutputStream output)
      throws IOException {

    KeyValueContainerData containerData = container.getContainerData();

    try (OutputStream compressed = compress(output);
         ArchiveOutputStream archiveOutput = tar(compressed)) {

      includePath(containerData.getDbFile().toPath(), DB_DIR_NAME,
          archiveOutput);

      includePath(Paths.get(containerData.getChunksPath()), CHUNKS_DIR_NAME,
          archiveOutput);

      includeFile(container.getContainerFile(), CONTAINER_FILE_NAME,
          archiveOutput);
    } catch (CompressorException e) {
      throw new IOException(
          "Can't compress the container: " + containerData.getContainerID(),
          e);
    }
  }

}