public static void repair(final Path path) throws IOException {
        if (!path.toFile().isDirectory()) {
            throw new IllegalArgumentException(
                String.format("Given PQ path %s is not a directory.", path)
            );
        }

        LOGGER.info("Start repairing queue dir: {}", path.toString());

        deleteTempCheckpoint(path);

        final Map<Integer, Path> pageFiles = new HashMap<>();
        try (final DirectoryStream<Path> pfs = Files.newDirectoryStream(path, "page.*")) {
            pfs.forEach(p -> pageFiles.put(
                Integer.parseInt(p.getFileName().toString().substring("page.".length())), p)
            );
        }
        final Map<Integer, Path> checkpointFiles = new HashMap<>();
        try (final DirectoryStream<Path> cpfs = Files.newDirectoryStream(path, "checkpoint.*")) {
            cpfs.forEach(
                c -> {
                    final String cpFilename = c.getFileName().toString();
                    if (!"checkpoint.head".equals(cpFilename)) {
                        checkpointFiles.put(
                            Integer.parseInt(cpFilename.substring("checkpoint.".length())), c
                        );
                    }
                }
            );
        }
        deleteFullyAcked(path, pageFiles, checkpointFiles);
        fixMissingPages(pageFiles, checkpointFiles);
        fixZeroSizePages(pageFiles, checkpointFiles);
        fixMissingCheckpoints(pageFiles, checkpointFiles);

        LOGGER.info("Repair is done");
    }
@Test
    public void testRemoveBrokenPage() throws Exception {
        Files.write(dataPath.resolve("page.1"), new byte[0], StandardOpenOption.TRUNCATE_EXISTING);
        PqRepair.repair(dataPath);
        verifyQueue(0, 1, 4, 5);
    }