Search in sources :

Example 1 with GetJobletRequest

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);
    }
}
Also used : GetJobletRequest(io.datarouter.jobletmysql.txn.GetJobletRequest) GetJobletRequest(io.datarouter.jobletmysql.txn.GetJobletRequest) JobletRequest(io.datarouter.joblet.storage.jobletrequest.JobletRequest) JobletRequestQueueKey(io.datarouter.joblet.storage.jobletrequestqueue.JobletRequestQueueKey)

Aggregations

JobletRequest (io.datarouter.joblet.storage.jobletrequest.JobletRequest)1 JobletRequestQueueKey (io.datarouter.joblet.storage.jobletrequestqueue.JobletRequestQueueKey)1 GetJobletRequest (io.datarouter.jobletmysql.txn.GetJobletRequest)1