public Queue updateQueue()

in src/main/java/com/epam/grid/engine/provider/queue/slurm/SlurmQueueProvider.java [119:167]


    public Queue updateQueue(final QueueVO updateRequest) {
        checkRegistrationRequest(updateRequest);

        final String updateName = updateRequest.getName();
        final List<String> updateHostList = updateRequest.getHostList();
        final List<String> updateUserGroups = ListUtils.emptyIfNull(updateRequest.getAllowedUserGroups()).stream()
                .sorted()
                .collect(Collectors.toList());
        if (!StringUtils.hasText(updateName) || CollectionUtils.isEmpty(updateHostList)
                || CollectionUtils.isEmpty(updateUserGroups)) {
            throw new GridEngineException(HttpStatus.BAD_REQUEST, "Name, hostList and allowedUserGroups should be "
                    + "specified for successful partition update");
        }

        final Context context = createContextWithUpdatePartitionName(updateName);
        final CommandResult sinfoResult = simpleCmdExecutor.execute(commandCompiler.compileCommand(getProviderType(),
                SINFO_COMMAND, context));
        checkIfExecutionResultIsEmpty(sinfoResult);

        final SlurmQueue partitionData = parseResultToSlurmQueues(sinfoResult.getStdOut())
                .stream()
                .findFirst()
                .orElseThrow(
                        () -> new GridEngineException(HttpStatus.INTERNAL_SERVER_ERROR, "Can't load slurm queue.")
                );

        final List<String> currentNodesParsed = partitionData.getNodelist().stream()
                .map(SlurmHost::getNodeName).collect(Collectors.toList());
        final List<String> userGroups = partitionData.getGroups();

        final List<String> updateHostListParsed = parseGroupOfNodes(updateHostList);

        if (updateHostListParsed.equals(currentNodesParsed) && updateUserGroups.equals(userGroups)) {
            throw new GridEngineException(HttpStatus.BAD_REQUEST, "New partition properties and the current one are "
                    + "equal");
        }
        fillContextWithDataToUpdate(context, updateUserGroups, updateHostListParsed);

        final CommandResult result = simpleCmdExecutor.execute(commandCompiler.compileCommand(getProviderType(),
                SCONTROL_COMMAND, context));
        checkIsResultIsCorrect(result);

        return listQueues(
                QueueFilter.builder().queues(Collections.singletonList(updateName)).build()
        ).stream()
        .findFirst()
        .orElseThrow(() -> new GridEngineException(
                HttpStatus.INTERNAL_SERVER_ERROR, "Can't load a queue that was just registered"));
    }