diff options
author | sunqi310 <sun.qi310@zte.com.cn> | 2016-10-28 16:46:24 +0800 |
---|---|---|
committer | sunqi310 <sun.qi310@zte.com.cn> | 2016-10-28 16:46:24 +0800 |
commit | d3061e2899966e968450a8d31035ea40e7548653 (patch) | |
tree | f3fc8afa4dac284b6cabf85b5f6994c2c7ec3fec /catalog-core | |
parent | 49f2427b84421fcaed402df2084e9b8a174181a0 (diff) |
TOSCA-159 Add serviceIp property which is used to config catalog microservice ipaddress
Change-Id: I9faac688747ba9e55cd545716ef927214a24d403
Issue-id: TOSCA-158
Signed-off-by: sunqi310 <sun.qi310@zte.com.cn>
Diffstat (limited to 'catalog-core')
5 files changed, 25 insertions, 4 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java index 10939904..b3204873 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java @@ -48,6 +48,9 @@ public class CatalogAppConfiguration extends Configuration { private String httpServerPath; @Valid + private String serviceIp; + + @Valid @NotNull private DataSourceFactory database = new DataSourceFactory(); @@ -128,5 +131,15 @@ public class CatalogAppConfiguration extends Configuration { public void setHttpServerPath(String httpServerPath) { this.httpServerPath = httpServerPath; } + + @JsonProperty + public String getServiceIp() { + return serviceIp; + } + + @JsonProperty + public void setServiceIp(String serviceIp) { + this.serviceIp = serviceIp; + } } diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java index b81a6561..1e2be58a 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java @@ -15,6 +15,7 @@ */ package org.openo.commontosca.catalog.common; +import org.openo.commontosca.catalog.common.Config; import org.openo.commontosca.catalog.externalservice.msb.MicroserviceBusConsumer; import org.openo.commontosca.catalog.externalservice.msb.ServiceRegisterEntity; import org.slf4j.Logger; @@ -81,7 +82,7 @@ public class ServiceRegistrer implements Runnable { catalogEntity.setProtocol("REST"); catalogEntity.setVersion("v1"); catalogEntity.setUrl("/openoapi/catalog/v1"); - catalogEntity.setSingleNode(null, "8200", 0); + catalogEntity.setSingleNode(Config.getConfigration().getServiceIp(), "8200", 0); catalogEntity.setVisualRange("1"); serviceEntityList.add(catalogEntity); ServiceRegisterEntity httpServiceEntity = new ServiceRegisterEntity(); @@ -89,7 +90,7 @@ public class ServiceRegistrer implements Runnable { httpServiceEntity.setProtocol("REST"); httpServiceEntity.setVersion("v1"); httpServiceEntity.setUrl("/"); - httpServiceEntity.setSingleNode(null, "8201", 0); + httpServiceEntity.setSingleNode(Config.getConfigration().getServiceIp(), "8201", 0); httpServiceEntity.setVisualRange("1"); serviceEntityList.add(httpServiceEntity); } diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java index 3c964b22..33e17009 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java @@ -17,6 +17,7 @@ package org.openo.commontosca.catalog.externalservice.msb; import com.eclipsesource.jaxrs.consumer.ConsumerFactory; import org.glassfish.jersey.client.ClientConfig; +import org.openo.commontosca.catalog.db.util.CatalogDbUtil; import org.openo.commontosca.catalog.common.Config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,6 +33,7 @@ public class MicroserviceBusConsumer { */ public static boolean registerService(ServiceRegisterEntity entity) { ClientConfig config = new ClientConfig(); + LOG.info("microservice register body:" + CatalogDbUtil.objectToString(entity)); try { MicroserviceBusRest resourceserviceproxy = ConsumerFactory.createConsumer(Config.getConfigration().getMsbServerAddr(), config, diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java index acf8ab69..7732437a 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java @@ -44,7 +44,11 @@ public class ServiceRegisterEntity { */ public void setSingleNode(String ip, String port, int ttl) { ServiceNode node = new ServiceNode(); - node.setIp(ip); + if (ip != null && ip.length() > 0) { + node.setIp(ip); + } else { + node.setIp(null); + } node.setPort(port); node.setTtl(ttl); nodes.add(node); diff --git a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog.yml b/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog.yml index c4459173..7bb6a5f7 100644 --- a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog.yml +++ b/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog.yml @@ -17,7 +17,8 @@ template: Hello, %s! defaultName: ${DW_DEFAULT_NAME:-Stranger} - +# the micro service ip +serviceIp: msbServerAddr: http://127.0.0.1:80 httpServerAddr: http://127.0.0.1:8201 |