Skip to content

Commit

Permalink
fix probes (#9638)
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj authored Jan 28, 2022
1 parent dfe4fca commit cbce5f1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.qos.probe.ReadinessProbe;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.model.ModuleModel;

import java.util.List;

@Activate
public class DeployerReadinessProbe implements ReadinessProbe {


private ApplicationModel applicationModel;

public DeployerReadinessProbe(ApplicationModel applicationModel) {
this.applicationModel = applicationModel;
}

@Override
public boolean check() {
for (ModuleModel moduleModel : applicationModel.getModuleModels()) {
if (!moduleModel.getDeployer().isStarted()) {
return false;
List<ApplicationModel> applicationModels = FrameworkModel.defaultModel().getAllApplicationModels();
for (ApplicationModel applicationModel : applicationModels) {
for (ModuleModel moduleModel : applicationModel.getModuleModels()) {
if (!moduleModel.getDeployer().isStarted()) {
return false;
}
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.qos.probe.StartupProbe;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.model.ModuleModel;

import java.util.List;

@Activate
public class DeployerStartupProbe implements StartupProbe {

private ApplicationModel applicationModel;

public DeployerStartupProbe(ApplicationModel applicationModel) {
this.applicationModel = applicationModel;
}

@Override
public boolean check() {
for (ModuleModel moduleModel : applicationModel.getModuleModels()) {
if (moduleModel.getDeployer().isRunning()) {
return true;
List<ApplicationModel> applicationModels = FrameworkModel.defaultModel().getAllApplicationModels();
for (ApplicationModel applicationModel : applicationModels) {
for (ModuleModel moduleModel : applicationModel.getModuleModels()) {
if (moduleModel.getDeployer().isRunning()) {
return true;
}
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void setUp() {
Mockito.when(frameworkModel.getExtensionLoader(ReadinessProbe.class)).thenReturn(loader);
URL url = URL.valueOf("application://").addParameter(CommonConstants.QOS_READY_PROBE_EXTENSION, "");
List<ReadinessProbe> readinessProbes = Arrays.asList(
new DeployerReadinessProbe(frameworkModel.newApplication()),
new DeployerReadinessProbe(),
new ProviderReadinessProbe()
);
Mockito.when(loader.getActivateExtension(url, CommonConstants.QOS_READY_PROBE_EXTENSION)).thenReturn(readinessProbes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void setUp() {
Mockito.when(frameworkModel.getExtensionLoader(StartupProbe.class)).thenReturn(loader);
URL url = URL.valueOf("application://").addParameter(CommonConstants.QOS_STARTUP_PROBE_EXTENSION, "");
List<StartupProbe> readinessProbes = Arrays.asList(
new DeployerStartupProbe(frameworkModel.newApplication())
new DeployerStartupProbe()
);
Mockito.when(loader.getActivateExtension(url, CommonConstants.QOS_STARTUP_PROBE_EXTENSION)).thenReturn(readinessProbes);
}
Expand Down

0 comments on commit cbce5f1

Please sign in to comment.