use of org.candlepin.cache.StatusCache in project candlepin by candlepin.
the class StatusResource method status.
/**
* Retrieves the Status of the System
* <p>
* <pre>
* {
* "result" : true,
* "version" : "0.9.10",
* "rulesVersion" : "5.8",
* "release" : "1",
* "standalone" : true,
* "timeUTC" : [date],
* "managerCapabilities" : [ "cores", "ram", "instance_multiplier" ],
* "rulesSource" : "DEFAULT"
* }
* </pre>
* <p>
* Status to see if a server is up and running
*
* @return a Status object
* @httpcode 200
*/
@GET
@ApiOperation(value = "Status", notes = "Returns status of the server", authorizations = {})
@Produces({ MediaType.APPLICATION_JSON })
@SecurityHole(noAuth = true, anon = true)
public Status status() {
StatusCache statusCache = candlepinCache.getStatusCache();
Status cached = statusCache.getStatus();
if (cached != null) {
return cached;
}
/*
* Originally this was used to indicate database connectivity being good/bad.
* In reality it could never be false, the request would fail. This check has
* been moved to GET /status/db.
*/
boolean good = true;
try {
rulesCurator.getUpdatedFromDB();
} catch (Exception e) {
log.error("Error checking database connection", e);
good = false;
}
CandlepinModeChange modeChange = modeManager.getLastCandlepinModeChange();
if (modeChange.getMode() != Mode.NORMAL) {
good = false;
}
Status status = new Status(good, version, release, standalone, jsProvider.getRulesVersion(), jsProvider.getRulesSource(), modeChange.getMode(), modeChange.getReason(), modeChange.getChangeTime());
statusCache.setStatus(status);
return status;
}
Aggregations