wujimin closed pull request #1041: [SCB-1083]specify initial instance status
when register
URL: https://github.com/apache/servicecomb-java-chassis/pull/1041
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceInstance.java
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceInstance.java
index 8d4d7f769..4665078e4 100644
---
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceInstance.java
+++
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceInstance.java
@@ -18,7 +18,9 @@
package org.apache.servicecomb.serviceregistry.api.registry;
import static
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.CONFIG_QUALIFIED_INSTANCE_ENVIRONMENT_KEY;
+import static
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.CONFIG_QUALIFIED_INSTANCE_INITIAL_STATUS;
import static
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_INSTANCE_ENVIRONMENT;
+import static
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_INSTANCE_INITIAL_STATUS;
import static
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_STAGE;
import java.util.ArrayList;
@@ -168,6 +170,8 @@ public static MicroserviceInstance
createFromDefinition(Configuration configurat
microserviceInstance
.setEnvironment(
configuration.getString(CONFIG_QUALIFIED_INSTANCE_ENVIRONMENT_KEY,
DEFAULT_INSTANCE_ENVIRONMENT));
+ microserviceInstance.setStatus(MicroserviceInstanceStatus
+
.valueOf(configuration.getString(CONFIG_QUALIFIED_INSTANCE_INITIAL_STATUS,
DEFAULT_INSTANCE_INITIAL_STATUS)));
HealthCheck healthCheck = new HealthCheck();
healthCheck.setMode(HealthCheckMode.HEARTBEAT);
microserviceInstance.setHealthCheck(healthCheck);
@@ -189,7 +193,8 @@ private static void loadDataCenterInfo(MicroserviceInstance
microserviceInstance
DataCenterInfo dataCenterInfo = new DataCenterInfo();
dataCenterInfo.setName(dataCenterName);
dataCenterInfo
-
.setRegion(DynamicPropertyFactory.getInstance().getStringProperty("servicecomb.datacenter.region",
null).get());
+ .setRegion(
+
DynamicPropertyFactory.getInstance().getStringProperty("servicecomb.datacenter.region",
null).get());
dataCenterInfo.setAvailableZone(
DynamicPropertyFactory.getInstance().getStringProperty("servicecomb.datacenter.availableZone",
null).get());
microserviceInstance.setDataCenterInfo(dataCenterInfo);
diff --git
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceInstanceStatus.java
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceInstanceStatus.java
index 58b3642f5..27c56ce88 100644
---
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceInstanceStatus.java
+++
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/registry/MicroserviceInstanceStatus.java
@@ -21,9 +21,10 @@
* Created by on 2016/12/5.
*/
public enum MicroserviceInstanceStatus {
- UNKNOWN,
+ STARTING,
+ TESTING,
UP,
+ OUTOFSERVICE,
DOWN,
- STARTING,
- OUTOFSERVICE
+ UNKNOWN
}
diff --git
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/definition/DefinitionConst.java
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/definition/DefinitionConst.java
index a51e3078d..0ad54a98a 100644
---
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/definition/DefinitionConst.java
+++
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/definition/DefinitionConst.java
@@ -17,10 +17,14 @@
package org.apache.servicecomb.serviceregistry.definition;
+import
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstanceStatus;
+
public interface DefinitionConst {
String CONFIG_QUALIFIED_INSTANCE_ENVIRONMENT_KEY =
"instance_description.environment";
+ String CONFIG_QUALIFIED_INSTANCE_INITIAL_STATUS =
"instance_description.initialStatus";
+
String CONFIG_ALLOW_CROSS_APP_KEY = "allowCrossApp";
String DEFAULT_APPLICATION_ID = "default";
@@ -31,6 +35,8 @@
String DEFAULT_INSTANCE_ENVIRONMENT = "production";
+ String DEFAULT_INSTANCE_INITIAL_STATUS =
MicroserviceInstanceStatus.UP.name();
+
String VERSION_RULE_LATEST = "latest";
String VERSION_RULE_ALL = "0.0.0+";
diff --git
a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/registry/TestRemoteServiceRegistry.java
b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/registry/TestRemoteServiceRegistry.java
index 718e64917..2a2447d05 100644
---
a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/registry/TestRemoteServiceRegistry.java
+++
b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/registry/TestRemoteServiceRegistry.java
@@ -17,6 +17,8 @@
package org.apache.servicecomb.serviceregistry.registry;
import static
org.apache.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY;
+import static
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.CONFIG_QUALIFIED_INSTANCE_INITIAL_STATUS;
+import static
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_INSTANCE_INITIAL_STATUS;
import static
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_MICROSERVICE_VERSION;
import java.util.ArrayList;
@@ -32,6 +34,7 @@
import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
import org.apache.servicecomb.serviceregistry.RegistryUtils;
import org.apache.servicecomb.serviceregistry.ServiceRegistry;
+import
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstanceStatus;
import
org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl;
import org.apache.servicecomb.serviceregistry.client.ServiceRegistryClient;
import org.apache.servicecomb.serviceregistry.config.ServiceRegistryConfig;
@@ -153,6 +156,8 @@ public void
onPullMicroserviceVersionsInstancesEvent(@Injectable ServiceRegistry
configuration.getString(CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY,
DEFAULT_MICROSERVICE_VERSION);
result = "1.0.0";
+ configuration.getString(CONFIG_QUALIFIED_INSTANCE_INITIAL_STATUS,
DEFAULT_INSTANCE_INITIAL_STATUS);
+ result = MicroserviceInstanceStatus.UP.name();
}
};
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services