in spi/src/main/java/org/opensearch/jobscheduler/spi/LockModel.java [95:136]
public static LockModel parse(final XContentParser parser, long seqNo, long primaryTerm) throws IOException {
String jobIndexName = null;
String jobId = null;
Instant lockTime = null;
Long lockDurationSecond = null;
Boolean released = null;
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser);
while (!XContentParser.Token.END_OBJECT.equals(parser.nextToken())) {
String fieldName = parser.currentName();
parser.nextToken();
switch (fieldName) {
case JOB_INDEX_NAME:
jobIndexName = parser.text();
break;
case JOB_ID:
jobId = parser.text();
break;
case LOCK_TIME:
lockTime = Instant.ofEpochSecond(parser.longValue());
break;
case LOCK_DURATION:
lockDurationSecond = parser.longValue();
break;
case RELEASED:
released = parser.booleanValue();
break;
default:
throw new IllegalArgumentException("Unknown field " + fieldName);
}
}
return new LockModel(
requireNonNull(jobIndexName, "JobIndexName cannot be null"),
requireNonNull(jobId, "JobId cannot be null"),
requireNonNull(lockTime, "lockTime cannot be null"),
requireNonNull(lockDurationSecond, "lockDurationSeconds cannot be null"),
requireNonNull(released, "released cannot be null"),
seqNo,
primaryTerm
);
}