Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix probes #9638

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -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