use of io.datarouter.jobletmysql.txn.GetJobletRequest in project datarouter by hotpads.
the class MysqlLockForUpdateJobletRequestSelector method getJobletRequestForProcessing.
@Override
public Optional<JobletRequest> getJobletRequestForProcessing(PhaseTimer timer, JobletType<?> type, String reservedBy) {
while (true) {
var mysqlOp = new GetJobletRequest(reservedBy, type, datarouter, jobletRequestDao, mysqlFieldCodecFactory, mysqlSqlFactory, jobletRequestSqlBuilder, jobletService);
JobletRequest jobletRequest = sessionExecutor.runWithoutRetries(mysqlOp);
timer.add("GetJobletRequest");
if (jobletRequest == null) {
// for back-off
jobletRequestQueueManager.onJobletRequestMissForAllPriorities(type);
return Optional.empty();
}
if (!jobletRequest.getStatus().isRunning()) {
// weird flow. it was probably just marked as timedOut, so skip it
continue;
}
var queueKey = new JobletRequestQueueKey(type, jobletRequest.getKey().getPriority());
datarouterJobletCounters.incQueueHit(queueKey.getQueueName());
return Optional.of(jobletRequest);
}
}
Aggregations