private void updateLock()

in spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java [164:195]


    private void updateLock(final LockModel updateLock, ActionListener<LockModel> listener) {
        try {
            UpdateRequest updateRequest = new UpdateRequest()
                .index(LOCK_INDEX_NAME)
                .id(updateLock.getLockId())
                .setIfSeqNo(updateLock.getSeqNo())
                .setIfPrimaryTerm(updateLock.getPrimaryTerm())
                .doc(updateLock.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS))
                .fetchSource(true);

            client.update(updateRequest, ActionListener.wrap(
                    response -> listener.onResponse(new LockModel(updateLock, response.getSeqNo(),
                            response.getPrimaryTerm())),
                    exception -> {
                        if (exception instanceof VersionConflictEngineException) {
                            logger.debug("could not acquire lock {}", exception.getMessage());
                        }
                        if (exception instanceof DocumentMissingException) {
                            logger.debug("Document is deleted. This happens if the job is already removed and" +
                                    " this is the last run." +
                                    "{}", exception.getMessage());
                        }
                        if (exception instanceof IOException) {
                            logger.error("IOException occurred updating lock.", exception);
                        }
                        listener.onResponse(null);
                    }));
        } catch (IOException e) {
            logger.error("IOException occurred updating lock.", e);
            listener.onResponse(null);
        }
    }