public UsageReport parseAccountingDataFromStdOut()

in src/main/java/com/epam/grid/engine/provider/utils/sge/usage/SgeSummaryAccountingDataParser.java [52:79]


    public UsageReport parseAccountingDataFromStdOut(final List<String> stdOut) {
        final SgeUsageRawOutput sgeUsageRawOutput = parseSgeAccountingOutput(stdOut);

        final EnumMap<SgeAccountingHeaders, Double> accountingMap = new EnumMap<>(SgeAccountingHeaders.class);
        final String valuesLine = Optional.ofNullable(sgeUsageRawOutput.getAccountingData()).orElse(EMPTY_STRING);

        final List<String> headers = getHeaders(sgeUsageRawOutput);
        try {
            final Double[] acctValues = parseResultValues(headers, valuesLine);
            for (int i = 0; i < headers.size(); i++) {
                accountingMap.put(SgeAccountingHeaders.valueOfName(headers.get(i))
                        .orElseThrow(IllegalArgumentException::new), acctValues[i]
                );
            }
        } catch (ArrayIndexOutOfBoundsException | IllegalArgumentException e) {
            throw new GridEngineException(HttpStatus.NOT_FOUND, "Cannot parse SGE output", e);
        }

        return UsageReport.builder()
                .wallClock(accountingMap.get(SgeAccountingHeaders.WALL_CLOCK).intValue())
                .userTime(accountingMap.get(SgeAccountingHeaders.USER_TIME))
                .systemTime(accountingMap.get(SgeAccountingHeaders.SYSTEM_TIME))
                .cpuTime(accountingMap.get(SgeAccountingHeaders.CPU_TIME))
                .memory(accountingMap.get(SgeAccountingHeaders.MEMORY))
                .ioData(accountingMap.get(SgeAccountingHeaders.IO_DATA))
                .ioWaiting(accountingMap.get(SgeAccountingHeaders.IO_WAITING))
                .build();
    }