use of org.xipki.common.HealthCheckResult in project xipki by xipki.
the class OcspServerImpl method healthCheck.
@Override
public HealthCheckResult healthCheck(Responder responder2) {
ResponderImpl responder = (ResponderImpl) responder2;
HealthCheckResult result = new HealthCheckResult("OCSPResponder");
boolean healthy = true;
for (OcspStore store : responder.getStores()) {
boolean storeHealthy = store.isHealthy();
healthy &= storeHealthy;
HealthCheckResult storeHealth = new HealthCheckResult("CertStatusStore." + store.getName());
storeHealth.setHealthy(storeHealthy);
result.addChildCheck(storeHealth);
}
boolean signerHealthy = responder.getSigner().isHealthy();
healthy &= signerHealthy;
HealthCheckResult signerHealth = new HealthCheckResult("Signer");
signerHealth.setHealthy(signerHealthy);
result.addChildCheck(signerHealth);
result.setHealthy(healthy);
return result;
}
use of org.xipki.common.HealthCheckResult in project xipki by xipki.
the class HealthCheckResultTest method test1.
@Test
public void test1() {
String encoded = "{\"healthy\":true}";
HealthCheckResult result = HealthCheckResult.getInstanceFromJsonMessage("default", encoded);
String noPrettyJson = "{\"healthy\":true}";
String prettyJson = "{\n" + " \"healthy\":true\n" + "}";
check(result, noPrettyJson, prettyJson);
}
use of org.xipki.common.HealthCheckResult in project xipki by xipki.
the class HealthCheckResultTest method test3.
@Test
public void test3() {
HealthCheckResult result = new HealthCheckResult("mycheck-negative");
result.setHealthy(false);
String noPrettyJson = "{\"healthy\":false}";
String prettyJson = "{\n" + " \"healthy\":false\n" + "}";
check(result, noPrettyJson, prettyJson);
}
use of org.xipki.common.HealthCheckResult in project xipki by xipki.
the class HealthCheckResultTest method test4.
@Test
public void test4() {
HealthCheckResult result = new HealthCheckResult("mycheck-positive");
result.setHealthy(true);
String noPrettyJson = "{\"healthy\":true}";
String prettyJson = "{\n" + " \"healthy\":true\n" + "}";
check(result, noPrettyJson, prettyJson);
}
use of org.xipki.common.HealthCheckResult in project xipki by xipki.
the class HealthCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (caName != null) {
caName = caName.toLowerCase();
}
Set<String> caNames = caClient.getCaNames();
if (isEmpty(caNames)) {
throw new IllegalCmdParamException("no CA is configured");
}
if (caName != null && !caNames.contains(caName)) {
throw new IllegalCmdParamException("CA " + caName + " is not within the configured CAs " + caNames);
}
if (caName == null) {
if (caNames.size() == 1) {
caName = caNames.iterator().next();
} else {
throw new IllegalCmdParamException("no CA is specified, one of " + caNames + " is required");
}
}
HealthCheckResult healthResult = caClient.getHealthCheckResult(caName);
String str = StringUtil.concat("healthy status for CA ", caName, ": ", (healthResult.isHealthy() ? "healthy" : "not healthy"));
if (verbose) {
str = StringUtil.concat(str, "\n", healthResult.toJsonMessage(true));
}
System.out.println(str);
return null;
}
Aggregations