Search in sources :

Example 1 with ECacheTicket

use of com.accenture.trac.common.exception.ECacheTicket in project tracdap by finos.

the class LocalJobCache method deleteJob.

@Override
public void deleteJob(String jobKey, Ticket ticket) {
    var operationTime = Instant.now();
    var cacheEntry = cache.computeIfPresent(jobKey, (key, priorEntry) -> {
        if (priorEntry.ticket != ticket)
            return priorEntry;
        if (priorEntry.jobState == null)
            throw new EUnexpected();
        var newEntry = priorEntry.clone();
        newEntry.jobState = null;
        newEntry.lastActivity = operationTime;
        newEntry.revision = priorEntry.revision + 1;
        return newEntry;
    });
    if (cacheEntry != null && cacheEntry.ticket != ticket)
        // TODO: Error
        throw new ECacheTicket("");
}
Also used : EUnexpected(com.accenture.trac.common.exception.EUnexpected) ECacheTicket(com.accenture.trac.common.exception.ECacheTicket)

Example 2 with ECacheTicket

use of com.accenture.trac.common.exception.ECacheTicket in project tracdap by finos.

the class LocalJobCache method updateJob.

@Override
public void updateJob(String jobKey, JobState jobState, Ticket ticket) {
    var operationTime = Instant.now();
    var cacheEntry = cache.computeIfPresent(jobKey, (key, priorEntry) -> {
        if (priorEntry.ticket != ticket)
            return priorEntry;
        if (priorEntry.jobState == null)
            // TODO: error
            throw new ECacheNotFound("");
        var newEntry = priorEntry.clone();
        newEntry.jobState = jobState;
        newEntry.lastActivity = operationTime;
        newEntry.revision = priorEntry.revision + 1;
        return newEntry;
    });
    if (cacheEntry == null || cacheEntry.ticket != ticket)
        // TODO: Error
        throw new ECacheTicket("");
}
Also used : ECacheNotFound(com.accenture.trac.common.exception.ECacheNotFound) ECacheTicket(com.accenture.trac.common.exception.ECacheTicket)

Example 3 with ECacheTicket

use of com.accenture.trac.common.exception.ECacheTicket in project tracdap by finos.

the class LocalJobCache method createJob.

@Override
public void createJob(String jobKey, JobState jobState, Ticket ticket) {
    var operationTime = Instant.now();
    var cacheEntry = cache.computeIfPresent(jobKey, (key, priorEntry) -> {
        if (priorEntry.ticket != ticket)
            return priorEntry;
        // Same job created twice, this is an unexpected logic error
        if (priorEntry.jobState != null)
            throw new EUnexpected();
        var newEntry = priorEntry.clone();
        newEntry.jobState = jobState;
        newEntry.lastActivity = operationTime;
        newEntry.revision = priorEntry.revision + 1;
        return newEntry;
    });
    if (cacheEntry == null || cacheEntry.ticket != ticket)
        // TODO: Error
        throw new ECacheTicket("");
}
Also used : EUnexpected(com.accenture.trac.common.exception.EUnexpected) ECacheTicket(com.accenture.trac.common.exception.ECacheTicket)

Aggregations

ECacheTicket (com.accenture.trac.common.exception.ECacheTicket)3 EUnexpected (com.accenture.trac.common.exception.EUnexpected)2 ECacheNotFound (com.accenture.trac.common.exception.ECacheNotFound)1