-
Notifications
You must be signed in to change notification settings - Fork 826
Submit a feature that applies graceful up and down #4670
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
Changes from 13 commits
83b1585
8d5c0bb
8c5d8e4
cae38de
ff52d42
7ca6e02
004aa32
a76ae7d
2d6e04b
860b5d4
1352218
c100c8a
fc48c8f
83339e8
95bb8bc
89b84d5
568c627
2a0801f
e70bcfb
2da0311
911429c
b4ecf04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,15 @@ public NacosDiscoveryInstance(Instance instance, String application, String serv | |
|
|
||
| @Override | ||
| public MicroserviceInstanceStatus getStatus() { | ||
| return instance.isEnabled() ? MicroserviceInstanceStatus.UP : MicroserviceInstanceStatus.DOWN; | ||
| if (instance.isEnabled()) { | ||
| String instanceStatus = instance.getMetadata().get(NacosConst.NACOS_STATUS); | ||
| if (StringUtils.isBlank(instanceStatus)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be isEmpty?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. U said "instance.getMetadata().get(NacosConst.NACOS_STATUS maybe null for old versions instance." before,so i do it . |
||
| return MicroserviceInstanceStatus.UP; | ||
| } | ||
| return MicroserviceInstanceStatus.valueOf(instanceStatus); | ||
| } else { | ||
| return MicroserviceInstanceStatus.DOWN; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,8 @@ public class NacosDiscoveryProperties { | |
|
|
||
| private boolean enableSwaggerRegistration = false; | ||
|
|
||
| private String initialStatus = "UP"; | ||
|
|
||
| public String getServerAddr() { | ||
| return serverAddr; | ||
| } | ||
|
|
@@ -160,4 +162,12 @@ public boolean isEnableSwaggerRegistration() { | |
| public void setEnableSwaggerRegistration(boolean enableSwaggerRegistration) { | ||
| this.enableSwaggerRegistration = enableSwaggerRegistration; | ||
| } | ||
|
|
||
| public String getInitialStatus() { | ||
| return initialStatus; | ||
| } | ||
|
|
||
| public void setInitialStatus(String initialStatus) { | ||
| this.initialStatus = initialStatus; | ||
| } | ||
| } | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,9 +132,20 @@ public NacosRegistrationInstance getMicroserviceInstance() { | |
|
|
||
| @Override | ||
| public boolean updateMicroserviceInstanceStatus(MicroserviceInstanceStatus status) { | ||
| // Do not support Nacos update status now. Because update status will fail | ||
| // due to some unknown reasons(Maybe different constrains in register and maintain api). | ||
| return true; | ||
| try { | ||
| if (MicroserviceInstanceStatus.DOWN == status) { | ||
| instance.getMetadata().put(NacosConst.NACOS_STATUS, MicroserviceInstanceStatus.DOWN.name()); | ||
| namingService.deregisterInstance(nacosRegistrationInstance.getServiceName(), | ||
| nacosRegistrationInstance.getApplication(), instance); | ||
| } else { | ||
| instance.getMetadata().put(NacosConst.NACOS_STATUS, status.name()); | ||
| namingService.registerInstance(nacosRegistrationInstance.getServiceName(), | ||
| nacosRegistrationInstance.getApplication(), instance); | ||
| } | ||
| return true; | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,9 +76,9 @@ public String getVersion() { | |
|
|
||
| @Override | ||
| public DataCenterInfo getDataCenterInfo() { | ||
| return new DataCenterInfo(microserviceInstance.getDataCenterInfo().getName(), | ||
| microserviceInstance.getDataCenterInfo().getRegion(), | ||
| microserviceInstance.getDataCenterInfo().getAvailableZone()); | ||
| return new DataCenterInfo(microserviceInstance.getDataCenterInfo().getName(), | ||
| microserviceInstance.getDataCenterInfo().getRegion(), | ||
| microserviceInstance.getDataCenterInfo().getAvailableZone()); | ||
|
||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why made this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don`r need method 'getnitialStatus()' and 'getReadyStatus()'