@VisibleForTesting
    DeletionMeta globalLogCleanup(long size) throws Exception {
        List<Path> workerDirs = new ArrayList<>(workerLogs.getAllWorkerDirs());
        Set<Path> aliveWorkerDirs = workerLogs.getAliveWorkerDirs();

        return directoryCleaner.deleteOldestWhileTooLarge(workerDirs, size, false, aliveWorkerDirs);
    }
@Test
    public void testGlobalLogCleanup() throws Exception {
        long nowMillis = Time.currentTimeMillis();

        try (TmpPath testDir = new TmpPath()) {
            Files.createDirectories(testDir.getFile().toPath());
            Path rootDir = createDir(testDir.getFile().toPath(), "workers-artifacts");
            Path topo1Dir = createDir(rootDir, "topo1");
            Path topo2Dir = createDir(rootDir, "topo2");
            // note that port1Dir is active worker containing active logs
            Path port1Dir = createDir(topo1Dir, "port1");
            Path port2Dir = createDir(topo1Dir, "port2");
            Path port3Dir = createDir(topo2Dir, "port3");

            IntStream.range(0, 10)
                .forEach(idx -> createFile(port1Dir, "A" + idx + ".log", nowMillis + 100L * idx, 200));
            IntStream.range(0, 10)
                .forEach(idx -> createFile(port2Dir, "B" + idx, nowMillis + 100L * idx, 200));
            IntStream.range(0, 10)
                .forEach(idx -> createFile(port3Dir, "C" + idx, nowMillis + 100L * idx, 200));

            Map<String, Object> conf = Utils.readStormConfig();
            StormMetricsRegistry metricRegistry = new StormMetricsRegistry();
            WorkerLogs stubbedWorkerLogs = new WorkerLogs(conf, rootDir, metricRegistry) {
                @Override
                public SortedSet<Path> getAliveWorkerDirs() {
                    return new TreeSet<>(Collections.singletonList(port1Dir));
                }
            };

            LogCleaner logCleaner = new LogCleaner(conf, stubbedWorkerLogs, new DirectoryCleaner(metricRegistry), rootDir, metricRegistry);
            int deletedFiles = logCleaner.globalLogCleanup(2400).deletedFiles;
            assertEquals(18, deletedFiles);
        }
    }