private void output2file(int readIndex) {
        WritableUnit selectedUnit =
                switchableUnits[getIndex(readIndex)];
        if (selectedUnit == null) {
            return;
        }
        // Wait for the data update operation to complete
        long startTime = System.currentTimeMillis();
        do {
            if (System.currentTimeMillis() - startTime >= MAX_WRITING_WAIT_DLT) {
                break;
            }
            try {
                Thread.sleep(2);
            } catch (InterruptedException e) {
                break;
            }
        } while (selectedUnit.refCnt.getValue() > 0);
        // Output data to file
        Map<String, TrafficStatsUnit> statsMap = selectedUnit.statsUnitMap;
        for (Entry<String, TrafficStatsUnit> entry : statsMap.entrySet()) {
            logger.info("{}#{}#{}#{}", statsCat, entry.getKey(),
                    entry.getValue().msgCnt.getValue(),
                    entry.getValue().msgSize.getValue());
        }
        statsMap.clear();
    }
Print statistics data to file

@param readIndex   the readable index
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/broker/stats/TrafficStatsService.java