use of io.narayana.lra.coordinator.domain.model.Transaction in project narayana by jbosstm.
the class LRAService method startLRA.
public synchronized URL startLRA(String baseUri, URL parentLRA, String clientId, Long timelimit) {
Transaction lra;
try {
lra = new Transaction(this, baseUri, parentLRA, clientId);
} catch (MalformedURLException e) {
throw new InvalidLRAIdException(baseUri, "Invalid base uri", e);
}
if (lra.currentLRA() != null)
if (LRALogger.logger.isInfoEnabled())
LRALogger.logger.infof("LRAServicve.startLRA LRA %s is already associated%n", lra.currentLRA().get_uid().fileStringForm());
int status = lra.begin(timelimit);
if (status != ActionStatus.RUNNING) {
lraTrace(lra.getId(), "failed to start LRA");
lra.abort();
throw new InternalServerErrorException("Could not start LRA: " + ActionStatus.stringForm(status));
} else {
try {
addTransaction(lra);
lraTrace(lra.getId(), "started LRA");
return lra.getId();
} finally {
AtomicAction.suspend();
}
}
}
use of io.narayana.lra.coordinator.domain.model.Transaction in project narayana by jbosstm.
the class LRAService method updateRecoveryURL.
public void updateRecoveryURL(URL lraId, String compensatorUrl, String recoveryURL, boolean persist) {
assert recoveryURL != null;
assert compensatorUrl != null;
participants.put(recoveryURL, compensatorUrl);
if (persist && lraId != null) {
Transaction transaction = getTransaction(lraId);
transaction.updateRecoveryURL(compensatorUrl, recoveryURL);
}
}
use of io.narayana.lra.coordinator.domain.model.Transaction in project narayana by jbosstm.
the class Coordinator method getNestedLRAStatus.
@GET
@Path("{NestedLraId}/status")
public Response getNestedLRAStatus(@PathParam("NestedLraId") String nestedLraId) {
if (!lraService.hasTransaction(nestedLraId)) {
// it must have compensated TODO maybe it's better to keep nested LRAs in separate collection
return Response.ok(CompensatorStatus.Compensated.name()).build();
}
Transaction lra = lraService.getTransaction(toURL(nestedLraId));
CompensatorStatus status = lra.getLRAStatus();
if (status == null || lra.getLRAStatus() == null) {
LRALogger.i18NLogger.error_cannotGetStatusOfNestedLra(nestedLraId, lra.getId());
throw new IllegalLRAStateException(nestedLraId, "The LRA is still active", "getNestedLRAStatus");
}
return Response.ok(lra.getLRAStatus().name()).build();
}
Aggregations