You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2020/05/18 02:52:39 UTC
[servicecomb-java-chassis] branch master updated: [SCB-1912]create
sub-module for registry-zero-config (#1753)
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 3a77e0b [SCB-1912]create sub-module for registry-zero-config (#1753)
3a77e0b is described below
commit 3a77e0bc95420ccc196c4ccd1737ba883200b2bc
Author: Jun Gan <ju...@gmail.com>
AuthorDate: Sun May 17 22:52:28 2020 -0400
[SCB-1912]create sub-module for registry-zero-config (#1753)
* add registry-zero-config sub-module under service-registry module
* add sub-module for registry-zero-config
* add license
---
service-registry/pom.xml | 1 +
.../{ => registry-zero-config}/pom.xml | 35 ++---
.../ZeroConfigRegistryConstants.java | 72 +++++++++++
.../server/ServerMicroserviceInstance.java | 141 +++++++++++++++++++++
4 files changed, 233 insertions(+), 16 deletions(-)
diff --git a/service-registry/pom.xml b/service-registry/pom.xml
index 09ee6cf..b4752e2 100644
--- a/service-registry/pom.xml
+++ b/service-registry/pom.xml
@@ -32,5 +32,6 @@
<modules>
<module>registry-service-center</module>
+ <module>registry-zero-config</module>
</modules>
</project>
diff --git a/service-registry/pom.xml b/service-registry/registry-zero-config/pom.xml
similarity index 53%
copy from service-registry/pom.xml
copy to service-registry/registry-zero-config/pom.xml
index 09ee6cf..0b013e8 100644
--- a/service-registry/pom.xml
+++ b/service-registry/registry-zero-config/pom.xml
@@ -16,21 +16,24 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>java-chassis-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <relativePath>../parents/default</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>service-registry-parent</artifactId>
+ <groupId>org.apache.servicecomb</groupId>
+ <version>2.1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
- <artifactId>service-registry-parent</artifactId>
- <name>Java Chassis::Service Registry</name>
- <packaging>pom</packaging>
+ <artifactId>registry-zero-config</artifactId>
+ <name>Java Chassis::Registry Zero Config</name>
- <modules>
- <module>registry-service-center</module>
- </modules>
-</project>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>provider-rest-common</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/serviceregistry/ZeroConfigRegistryConstants.java b/service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/serviceregistry/ZeroConfigRegistryConstants.java
new file mode 100644
index 0000000..ce45747
--- /dev/null
+++ b/service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/serviceregistry/ZeroConfigRegistryConstants.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.serviceregistry;
+
+public interface ZeroConfigRegistryConstants {
+
+ String ZERO_CONFIG_REGISTRY_FLAG = "zeroconfig.registry.flag";
+ String ZERO_CONFIG_REGISTRY_ENABLE_FLAG = "enable";
+
+ // MulticastSocket related
+ String GROUP = "225.0.0.0";
+ Integer PORT = 6666;
+ /**
+ * ttl=1,local network, ttl=32,local network station, ttl=64,local area;ttl=128,local continent
+ * ttl=255,all places. Default value is 1;
+ */
+ Integer TIME_TO_LIVE = 1;
+ Integer DATA_PACKET_BUFFER_SIZE = 2048; // 2K
+ long HEALTH_CHECK_INTERVAL = 3;
+ long CLIENT_DELAY = 2;
+ long SERVER_DELAY = 5;
+
+ // Event
+ String EVENT = "event";
+ String REGISTER_EVENT = "register";
+ String UNREGISTER_EVENT = "unregister";
+ String HEARTBEAT_EVENT = "heartbeat";
+
+ // Microservice & Instance Attributes
+ String APP_ID = "appId";
+ String SERVICE_NAME = "serviceName";
+ String VERSION = "version";
+ String SERVICE_ID = "serviceId";
+ String STATUS = "status";
+ String SCHEMA_IDS = "schemas";
+ String INSTANCE_ID = "instanceId";
+ String ENDPOINTS = "endpoints";
+ String HOST_NAME = "hostName";
+ String INSTANCE_HEARTBEAT_RESPONSE_MESSAGE_OK = "OK";
+
+ // Schema Content Endpoint and Path related
+ String SCHEMA_CONTENT_ENDPOINT = "schemaContentEndpoint";
+ String SCHEMA_CONTENT_ENDPOINT_BASE_PATH = "/schemaEndpoint";
+ String SCHEMA_CONTENT_ENDPOINT_SUBPATH = "/schemas";
+ String SCHEMA_CONTENT_ENDPOINT_QUERY_KEYWORD= "schemaId";
+
+ // others
+ String MAP_STRING_LEFT = "{";
+ String MAP_STRING_RIGHT = "}";
+ String MAP_ELEMENT_SPILITER = ",";
+ String MAP_KV_SPILITER = "=";
+ String LIST_STRING_SPLITER = "$";
+ String UUID_SPLITER = "-";
+ String SERVICE_ID_SPLITER = "/";
+ String ENDPOINT_PREFIX_REST = "rest";
+ String ENDPOINT_PREFIX_HTTP = "http";
+
+}
diff --git a/service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/serviceregistry/server/ServerMicroserviceInstance.java b/service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/serviceregistry/server/ServerMicroserviceInstance.java
new file mode 100644
index 0000000..06b39ad
--- /dev/null
+++ b/service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/serviceregistry/server/ServerMicroserviceInstance.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.serviceregistry.server;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ServerMicroserviceInstance {
+ private String appId;
+
+ private String serviceName;
+
+ private String version;
+
+ private String instanceId;
+
+ private String serviceId;
+
+ private List<String> endpoints = new ArrayList<>();
+
+ private List<String> schemas = new ArrayList<>();
+
+ private String hostName;
+
+ private String status;
+
+ private Instant lastHeartbeatTimeStamp;
+
+ public ServerMicroserviceInstance(){}
+
+ public Instant getLastHeartbeatTimeStamp() {
+ return lastHeartbeatTimeStamp;
+ }
+
+ public void setLastHeartbeatTimeStamp(Instant lastHeartbeatTimeStamp) {
+ this.lastHeartbeatTimeStamp = lastHeartbeatTimeStamp;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public void setAppId(String appId) {
+ this.appId = appId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public String getServiceId() {
+ return serviceId;
+ }
+
+ public void setServiceId(String serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ public List<String> getEndpoints() {
+ return endpoints;
+ }
+
+ public void setEndpoints(List<String> endpoints) {
+ this.endpoints = endpoints;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public List<String> getSchemas() {
+ return schemas;
+ }
+
+ public void setSchemas(List<String> schemas) {
+ this.schemas = schemas;
+ }
+
+ @Override
+ public String toString() {
+ return "ServerMicroserviceInstance{" +
+ "appId='" + appId + '\'' +
+ ", serviceName='" + serviceName + '\'' +
+ ", version='" + version + '\'' +
+ ", instanceId='" + instanceId + '\'' +
+ ", serviceId='" + serviceId + '\'' +
+ ", endpoints=" + endpoints +
+ ", schemas=" + schemas +
+ ", hostName='" + hostName + '\'' +
+ ", status='" + status + '\'' +
+ ", lastHeartbeatTimeStamp=" + lastHeartbeatTimeStamp +
+ '}';
+ }
+}