aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortanghua <tang.hua52@zte.com.cn>2016-10-20 19:49:32 +0800
committertanghua <tang.hua52@zte.com.cn>2016-10-21 09:20:14 +0800
commit71da542da90eb156db0c5c0e5130c043ba73c3b3 (patch)
treecb700a6f28697196a539c70191d23010a89e82c3
parent45a8046221d9880ed6dd51d84c1f454af44ea0a1 (diff)
OCS-79 repair register services fails by interface because of delete api service
Change-Id: I50fc840c116533ff69724eacadd67679099b79dd Issue-Id: OCS-79 Signed-off-by: tanghua <tang.hua52@zte.com.cn>
-rw-r--r--msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/ApiRouteServiceWrapper.java15
-rw-r--r--msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/CustomRouteServiceWrapper.java13
-rw-r--r--msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/IuiRouteServiceWrapper.java12
-rw-r--r--msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/MicroServiceWrapper.java43
-rw-r--r--msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/MicroServiceDB.java6
5 files changed, 37 insertions, 52 deletions
diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/ApiRouteServiceWrapper.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/ApiRouteServiceWrapper.java
index 6bd104b..3d6672b 100644
--- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/ApiRouteServiceWrapper.java
+++ b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/ApiRouteServiceWrapper.java
@@ -490,16 +490,15 @@ public class ApiRouteServiceWrapper {
Set<String> infoSet = jedis.keys(routekey);
if (infoSet.isEmpty()) {
- throw new ExtendedNotFoundException("delete ApiRoute FAIL:serviceName-"
- + serviceName + ",version:" + version + " not fond ");
+ LOGGER.warn("delete ApiRoute FAIL:serviceName-"
+ + serviceName + ",version:" + version + " not fond ");
}
+ else{
- String[] paths = new String[infoSet.size()];
-
-
- infoSet.toArray(paths);
-
- jedis.del(paths);
+ String[] paths = new String[infoSet.size()];
+ infoSet.toArray(paths);
+ jedis.del(paths);
+ }
} catch (ExtendedNotFoundException e) {
diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/CustomRouteServiceWrapper.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/CustomRouteServiceWrapper.java
index d0d4250..14f5523 100644
--- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/CustomRouteServiceWrapper.java
+++ b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/CustomRouteServiceWrapper.java
@@ -388,16 +388,15 @@ public class CustomRouteServiceWrapper {
Set<String> infoSet = jedis.keys(routekey);
if (infoSet.isEmpty()) {
- throw new ExtendedNotFoundException("delete CustomRoute FAIL:serviceName-"
+ LOGGER.warn("delete CustomRoute FAIL:serviceName-"
+ serviceName + " not fond ");
}
+ else{
-
- String[] paths = new String[infoSet.size()];
-
- infoSet.toArray(paths);
-
- jedis.del(paths);
+ String[] paths = new String[infoSet.size()];
+ infoSet.toArray(paths);
+ jedis.del(paths);
+ }
} catch (ExtendedNotFoundException e) {
throw e;
diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/IuiRouteServiceWrapper.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/IuiRouteServiceWrapper.java
index f70a126..b85b5ad 100644
--- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/IuiRouteServiceWrapper.java
+++ b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/IuiRouteServiceWrapper.java
@@ -363,15 +363,15 @@ public class IuiRouteServiceWrapper {
Set<String> infoSet = jedis.keys(routekey);
if (infoSet.isEmpty()) {
- throw new ExtendedNotFoundException("delete IuiRoute FAIL:serviceName-"
+ LOGGER.warn("delete IuiRoute FAIL:serviceName-"
+ serviceName + " not fond ");
}
+ else{
- String[] paths = new String[infoSet.size()];
-
- infoSet.toArray(paths);
-
- jedis.del(paths);
+ String[] paths = new String[infoSet.size()];
+ infoSet.toArray(paths);
+ jedis.del(paths);
+ }
} catch (ExtendedNotFoundException e) {
diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/MicroServiceWrapper.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/MicroServiceWrapper.java
index 2611605..0099481 100644
--- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/MicroServiceWrapper.java
+++ b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/MicroServiceWrapper.java
@@ -303,50 +303,31 @@ public class MicroServiceWrapper {
+ RouteUtil.PROTOCOL_LIST + ")");
}
- MicroServiceFullInfo existingMicroServiceInfo;
+
try {
- //To determine whether a service already exists
- existingMicroServiceInfo =
- MicroServiceDB.getInstance().getMicroServiceInstance(
- microServiceInfo.getServiceName().trim(), microServiceInfo.getVersion().trim(),serverPort);
-
- MicroServiceFullInfo newMicroServiceInfo ;
- if (existingMicroServiceInfo != null) {
- //a service already exists
-
- if (!existingMicroServiceInfo.getProtocol().equals(microServiceInfo.getProtocol())) {
- throw new ExtendedNotSupportedException(
- "MicroServiceInfo with different protocols and same serviceName is already existing");
- }
+
+
if (createOrUpdate == false) {
//After the first remove added
MicroServiceDB.getInstance().deleteMicroService(
microServiceInfo.getServiceName(), microServiceInfo.getVersion(),serverPort);
- MicroServiceDB.getInstance().saveMicroServiceInfo2Redis(microServiceInfo,serverPort);
+ //Notify the listeners
+ MicroServiceDB.getInstance().noticeApiListener(microServiceInfo, "DELETE",serverPort);
- } else {
- //Add the original record and save directly
- MicroServiceDB.getInstance().saveMicroServiceInfo2Redis(microServiceInfo,serverPort);
- }
+ }
- newMicroServiceInfo =
- MicroServiceDB.getInstance().getMicroServiceInstance(
- microServiceInfo.getServiceName(), microServiceInfo.getVersion(),serverPort);
-
- //Notify the listeners
- MicroServiceDB.getInstance().noticeUpdateApiListener(microServiceInfo.getServiceName(),microServiceInfo.getVersion(),newMicroServiceInfo,serverPort);
-
- } else {
//Save the new record
MicroServiceDB.getInstance().saveMicroServiceInfo2Redis(microServiceInfo,serverPort);
//Notify the listeners
MicroServiceDB.getInstance().noticeApiListener(microServiceInfo, "ADD",serverPort);
- newMicroServiceInfo =
- MicroServiceDB.getInstance().getMicroServiceInstance(
- microServiceInfo.getServiceName(), microServiceInfo.getVersion(),serverPort);
- }
+
+
+
+ MicroServiceFullInfo newMicroServiceInfo =
+ MicroServiceDB.getInstance().getMicroServiceInstance(
+ microServiceInfo.getServiceName(), microServiceInfo.getVersion(),serverPort);
diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/MicroServiceDB.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/MicroServiceDB.java
index edba477..56c8aff 100644
--- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/MicroServiceDB.java
+++ b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/MicroServiceDB.java
@@ -346,11 +346,17 @@ public class MicroServiceDB {
String routekey = MicroServiceUtil.getPrefixedKey(serverPort,serviceName, version, "*");
Set<String> infoSet = jedis.keys(routekey);
+ if (infoSet.isEmpty()) {
+ LOGGER.error("delete MicroService FAIL:serviceName-"
+ + serviceName + ",version:" + version + " not fond ");
+ }
+ else{
String[] paths = new String[infoSet.size()];
infoSet.toArray(paths);
jedis.del(paths);
+ }
} catch (Exception e) {
LOGGER.error("call redis throw exception", e);
throw new Exception("call redis throw exception:"+e.getMessage());