You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/01/09 06:41:06 UTC

[GitHub] WillemJiang closed pull request #460: [SCB-171] report type/version when register to SC

WillemJiang closed pull request #460: [SCB-171] report type/version when register to SC
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/460
 
 
   

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/foundations/foundation-common/src/main/java/io/servicecomb/foundation/common/base/ServiceCombConstants.java b/foundations/foundation-common/src/main/java/io/servicecomb/foundation/common/base/ServiceCombConstants.java
index a6eb95322..de09bad77 100644
--- a/foundations/foundation-common/src/main/java/io/servicecomb/foundation/common/base/ServiceCombConstants.java
+++ b/foundations/foundation-common/src/main/java/io/servicecomb/foundation/common/base/ServiceCombConstants.java
@@ -50,4 +50,11 @@
   String CONFIG_CSE_PREFIX = "cse.";
 
   String CONFIG_KEY_SPLITER = "_";
+
+  String CONFIG_FRAMEWORK_DEFAULT_NAME = "servicecomb-java-chassis";
+
+  String CONFIG_FRAMEWORK_DEFAULT_VERSION = "";
+  
+  String CONFIG_DEFAULT_REGISTER_BY = "SDK";
+  
 }
diff --git a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/Const.java b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/Const.java
index 9c4d590f1..90e8e61fc 100644
--- a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/Const.java
+++ b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/Const.java
@@ -148,6 +148,6 @@ private Const() {
   public static final String PATH_CHECKSESSION = "checksession";
 
   public static final String URL_PREFIX = "urlPrefix";
-  
+
   public static final String INSTANCE_PUBKEY_PRO = "publickey";
 }
diff --git a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Framework.java b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Framework.java
new file mode 100644
index 000000000..ac9c63528
--- /dev/null
+++ b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Framework.java
@@ -0,0 +1,44 @@
+/*
+ * 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 io.servicecomb.serviceregistry.api.registry;
+
+/**
+ * Created by on 2017/12/20.
+ */
+public class Framework {
+  private String name;
+
+  private String version;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+}
diff --git a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Microservice.java b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Microservice.java
index c39eef526..8e883affd 100644
--- a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Microservice.java
+++ b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/Microservice.java
@@ -34,6 +34,10 @@
 public class Microservice {
   private String serviceId;
 
+  private Framework framework;
+
+  private String registerBy;
+
   private String appId;
 
   private String serviceName;
@@ -189,4 +193,20 @@ public static String generateAbsoluteMicroserviceName(String appId, String micro
   public void setPaths(List<BasePath> paths) {
     this.paths = paths;
   }
+
+  public Framework getFramework() {
+    return framework;
+  }
+
+  public void setFramework(Framework framework) {
+    this.framework = framework;
+  }
+
+  public String getRegisterBy() {
+    return registerBy;
+  }
+
+  public void setRegisterBy(String registerBy) {
+    this.registerBy = registerBy;
+  }
 }
diff --git a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
index 86e0e3d28..77e071454 100644
--- a/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
+++ b/service-registry/src/main/java/io/servicecomb/serviceregistry/api/registry/MicroserviceFactory.java
@@ -21,6 +21,9 @@
 import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY;
 import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_ROLE_KEY;
 import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY;
+import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_FRAMEWORK_DEFAULT_NAME;
+import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_FRAMEWORK_DEFAULT_VERSION;
+import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_DEFAULT_REGISTER_BY;
 import static io.servicecomb.foundation.common.base.ServiceCombConstants.DEFAULT_MICROSERVICE_NAME;
 import static io.servicecomb.serviceregistry.definition.DefinitionConst.CONFIG_ALLOW_CROSS_APP_KEY;
 import static io.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_APPLICATION_ID;
@@ -66,6 +69,13 @@ private Microservice createMicroserviceFromDefinition(Configuration configuratio
           microservice.getServiceName()));
     }
 
+    // use default values, we can add configure item in future.
+    Framework framework = new Framework();
+    framework.setName(CONFIG_FRAMEWORK_DEFAULT_NAME);
+    framework.setVersion(CONFIG_FRAMEWORK_DEFAULT_VERSION);
+    microservice.setFramework(framework);
+    microservice.setRegisterBy(CONFIG_DEFAULT_REGISTER_BY);
+
     return microservice;
   }
 
diff --git a/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestFramework.java b/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestFramework.java
new file mode 100644
index 000000000..e4a059af6
--- /dev/null
+++ b/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestFramework.java
@@ -0,0 +1,39 @@
+/*
+ * 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 io.servicecomb.serviceregistry.api.registry;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestFramework {
+  @Test
+  public void testDefaultValues() {
+    Framework framework = new Framework();
+    Assert.assertNull(framework.getName());
+    Assert.assertNull(framework.getVersion());
+  }
+
+  @Test
+  public void testInitializedValues() {
+    Framework framework = new Framework();
+    framework.setName("JAVA-CHASSIS");
+    framework.setVersion("x.x.x");
+    Assert.assertEquals("JAVA-CHASSIS", framework.getName());
+    Assert.assertEquals("x.x.x", framework.getVersion());
+  }
+}
diff --git a/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestMicroService.java b/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestMicroService.java
index efc667a50..957046079 100644
--- a/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestMicroService.java
+++ b/service-registry/src/test/java/io/servicecomb/serviceregistry/api/registry/TestMicroService.java
@@ -61,6 +61,7 @@ public void testDefaultValues() {
     Assert.assertEquals(MicroserviceInstanceStatus.UP.toString(), oMicroservice.getStatus());
     Assert.assertNull(oMicroservice.getVersion());
     Assert.assertEquals(0, oMicroservice.getPaths().size());
+    Assert.assertNull(oMicroservice.getFramework());
   }
 
   @Test
@@ -76,6 +77,9 @@ public void testInitializedValues() {
     Assert.assertEquals("fakeProxy", oMicroservice.getProperties().get("proxy"));
     Assert.assertEquals(1, oMicroservice.getSchemas().size());
     Assert.assertEquals(1, oMicroservice.getPaths().size());
+    Assert.assertEquals("JAVA-CHASSIS", oMicroservice.getFramework().getName());
+    Assert.assertEquals("x.x.x", oMicroservice.getFramework().getVersion());
+    Assert.assertEquals("SDK", oMicroservice.getRegisterBy());
   }
 
   private void initMicroservice() {
@@ -91,5 +95,10 @@ private void initMicroservice() {
     oMicroservice.setProperties(oMapProperties);
     oMicroservice.setSchemas(oListSchemas);
     oMicroservice.getPaths().add(new BasePath());
+    Framework framework = new Framework();
+    framework.setName("JAVA-CHASSIS");
+    framework.setVersion("x.x.x");
+    oMicroservice.setFramework(framework);
+    oMicroservice.setRegisterBy("SDK");
   }
 }


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services