use of com.alipay.sofa.runtime.spi.health.HealthResult in project sofa-boot by alipay.
the class JvmBinding method healthCheck.
@Override
public HealthResult healthCheck() {
HealthResult healthResult = new HealthResult(getName());
healthResult.setHealthy(isHealthy);
return healthResult;
}
use of com.alipay.sofa.runtime.spi.health.HealthResult in project sofa-boot by alipay.
the class ComponentHealthChecker method isHealthy.
@Override
public Health isHealthy() {
boolean allPassed = true;
Health.Builder builder = new Health.Builder();
for (ComponentInfo componentInfo : SofaFrameworkHolder.getSofaFramework().getSofaRuntimeContext(Slite2Configuration.getAppName()).getComponentManager().getComponents()) {
HealthResult healthy = componentInfo.isHealthy();
if (healthy.isHealthy()) {
builder.withDetail(healthy.getHealthName(), "passed");
} else {
builder.withDetail(healthy.getHealthName(), healthy.getHealthReport());
allPassed = false;
}
}
if (allPassed) {
return builder.status(Status.UP).build();
} else {
return builder.status(Status.DOWN).build();
}
}
use of com.alipay.sofa.runtime.spi.health.HealthResult in project sofa-boot by alipay.
the class ReferenceComponent method isHealthy.
@Override
public HealthResult isHealthy() {
if (!isActivated()) {
return super.isHealthy();
}
HealthResult result = new HealthResult(componentName.getRawName());
List<HealthResult> bindingHealth = new ArrayList<HealthResult>();
JvmBinding jvmBinding = null;
HealthResult jvmBindingHealthResult = null;
if (reference.hasBinding()) {
for (Binding binding : reference.getBindings()) {
bindingHealth.add(binding.healthCheck());
if (JvmBinding.JVM_BINDING_TYPE.equals(binding.getBindingType())) {
jvmBinding = (JvmBinding) binding;
jvmBindingHealthResult = bindingHealth.get(bindingHealth.size() - 1);
}
}
}
// check reference has a corresponding service
if (!skipJVMReferenceHealth() && jvmBinding != null) {
Object serviceTarget = getServiceTarget();
if (serviceTarget == null && !jvmBinding.hasBackupProxy()) {
jvmBindingHealthResult.setHealthy(false);
jvmBindingHealthResult.setHealthReport("can not find corresponding jvm service");
}
}
List<HealthResult> failedBindingHealth = new ArrayList<HealthResult>();
for (HealthResult healthResult : bindingHealth) {
if (healthResult != null && !healthResult.isHealthy()) {
failedBindingHealth.add(healthResult);
}
}
if (failedBindingHealth.size() == 0) {
result.setHealthy(true);
} else {
String healthReport = "|";
for (HealthResult healthResult : failedBindingHealth) {
healthReport = healthReport + healthResult.getHealthName() + "#" + healthResult.getHealthReport();
}
result.setHealthReport(healthReport.substring(1, healthReport.length()));
result.setHealthy(false);
}
return result;
}
use of com.alipay.sofa.runtime.spi.health.HealthResult in project sofa-boot by alipay.
the class ServiceComponent method isHealthy.
@Override
public HealthResult isHealthy() {
HealthResult healthResult = new HealthResult(componentName.getRawName());
healthResult.setHealthy(true);
return healthResult;
}
use of com.alipay.sofa.runtime.spi.health.HealthResult in project sofa-boot by alipay.
the class AbstractComponent method isHealthy.
@Override
public HealthResult isHealthy() {
HealthResult healthResult = new HealthResult(componentName.getRawName());
if (!isActivated()) {
healthResult.setHealthy(false);
healthResult.setHealthReport("Status: " + this.getState().toString());
} else {
healthResult.setHealthy(true);
}
return healthResult;
}
Aggregations