Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.alipay.sofa.boot.actuator.health;

import com.alipay.sofa.ark.spi.model.Biz;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;

Expand All @@ -35,16 +36,17 @@ public Health health() {
boolean allPassed = true;
Health.Builder builder = new Health.Builder();
for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) {
Biz biz = DynamicJvmServiceProxyFinder.getBiz(sofaRuntimeManager);
if (biz == null) {
continue;
}

if (!sofaRuntimeManager.isLivenessHealth()) {
allPassed = false;
builder.withDetail(
String.format("Biz: %s health check",
DynamicJvmServiceProxyFinder.getBiz(sofaRuntimeManager).getIdentity()),
builder.withDetail(String.format("Biz: %s health check", biz.getIdentity()),
"failed");
} else {
builder.withDetail(
String.format("Biz: %s health check",
DynamicJvmServiceProxyFinder.getBiz(sofaRuntimeManager).getIdentity()),
builder.withDetail(String.format("Biz: %s health check", biz.getIdentity()),
"passed");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public boolean isReadinessHealth() {
@Override
public boolean isLivenessHealth() {
for (HealthIndicator healthIndicator : healthIndicators) {
if (healthIndicator.getClass().getSimpleName()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use getName.

.equals("MultiApplicationHealthIndicator")) {
continue;
}
if (healthIndicator.health().getStatus().equals(Status.DOWN)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ private ServiceComponent findServiceComponent(String uniqueId, String interfaceT
* @return
*/
public static Biz getBiz(SofaRuntimeManager sofaRuntimeManager) {
if (getDynamicJvmServiceProxyFinder().bizManagerService == null) {
return null;
}

for (Biz biz : getDynamicJvmServiceProxyFinder().bizManagerService.getBizInOrder()) {
if (sofaRuntimeManager.getAppClassLoader().equals(biz.getBizClassLoader())) {
return biz;
Expand Down