summaryrefslogtreecommitdiffstats
path: root/holmes-actions/src/main/java/org/onap
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2023-09-04 19:03:50 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2023-09-04 19:03:50 +0800
commitade480b317fe7bcf9ce94ef34e6c42b71a0ea1a3 (patch)
treed2ec01803eeb34ffe88b2b665630bb9742a3f49e /holmes-actions/src/main/java/org/onap
parent86debb28ef983f8176da06258e8f09c8783cddc7 (diff)
Removed MSB Dependencies
Issue-ID: HOLMES-629 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn> Change-Id: Ia74c8456822ba71f465a7142431327a884c50a70
Diffstat (limited to 'holmes-actions/src/main/java/org/onap')
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/msb/MsbRegister.java (renamed from holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java)12
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/CustomDateSerializer.java35
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/KeyValuePair.java49
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/MicroServiceFullInfo.java71
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/MicroServiceInfo.java49
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/Node.java97
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/NodeInfo.java80
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/Service.java121
8 files changed, 509 insertions, 5 deletions
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java b/holmes-actions/src/main/java/org/onap/holmes/common/msb/MsbRegister.java
index 78ac59b..cc83ae5 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/msb/MsbRegister.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onap.holmes.common.utils;
+package org.onap.holmes.common.msb;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.MediaType;
@@ -22,8 +22,10 @@ import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.holmes.common.exception.CorrelationException;
-import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
-import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
+import org.onap.holmes.common.msb.entity.MicroServiceFullInfo;
+import org.onap.holmes.common.msb.entity.MicroServiceInfo;
+import org.onap.holmes.common.utils.GsonUtil;
+import org.onap.holmes.common.utils.JerseyClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -60,14 +62,14 @@ public class MsbRegister {
MicroServiceFullInfo microServiceFullInfo = null;
int retry = 0;
while (null == microServiceFullInfo && retry < totalRetryTimes) {
- int time = interval * ++retry;
+ int time = interval * ++retry;
try {
log.info("Holmes Service Registration. Times: " + retry);
microServiceFullInfo = client
.header("Accept", MediaType.APPLICATION_JSON)
.queryParam("createOrUpdate", true)
.post(String.format("%s://%s:%s/api/microservices/v1/services",
- isHttpsEnabled ? PROTOCOL_HTTPS : PROTOCOL_HTTP, msbAddrInfo[0], msbAddrInfo[1]),
+ isHttpsEnabled ? PROTOCOL_HTTPS : PROTOCOL_HTTP, msbAddrInfo[0], msbAddrInfo[1]),
Entity.entity(msinfo, MediaType.APPLICATION_JSON),
MicroServiceFullInfo.class);
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/CustomDateSerializer.java b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/CustomDateSerializer.java
new file mode 100644
index 0000000..4f6c012
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/CustomDateSerializer.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2023 ZTE Corporation.
+ * <p>
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.onap.holmes.common.msb.entity;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class CustomDateSerializer extends JsonSerializer<Date> {
+ public CustomDateSerializer() {
+ }
+
+ public void serialize(Date value, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
+ jsonGenerator.writeString(sdf.format(value));
+ }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/KeyValuePair.java b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/KeyValuePair.java
new file mode 100644
index 0000000..d35b69e
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/KeyValuePair.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2023 ZTE Corporation.
+ * <p>
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.onap.holmes.common.msb.entity;
+
+import java.io.Serializable;
+
+public class KeyValuePair implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private String key;
+ private String value;
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public KeyValuePair() {
+ }
+
+ public KeyValuePair(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+} \ No newline at end of file
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/MicroServiceFullInfo.java b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/MicroServiceFullInfo.java
new file mode 100644
index 0000000..644f814
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/MicroServiceFullInfo.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2023 ZTE Corporation.
+ * <p>
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.onap.holmes.common.msb.entity;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+public class MicroServiceFullInfo extends Service<NodeInfo> implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private String status = "1";
+
+ public MicroServiceFullInfo() {
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("MicroService List:").append("\r\n");
+ buf.append("serviceName:").append(this.getServiceName()).append("\r\n");
+ buf.append("version:").append(this.getVersion()).append("\r\n");
+ buf.append("url:").append(this.getUrl()).append("\r\n");
+ buf.append("protocol:").append(this.getProtocol()).append("\r\n");
+ buf.append("visualRange:").append(this.getVisualRange()).append("\r\n");
+ buf.append("nodes:").append("\r\n");
+ Iterator nodes = this.getNodes().iterator();
+
+ while (nodes.hasNext()) {
+ NodeInfo nodeInstace = (NodeInfo) nodes.next();
+ buf.append(" nodeId-").append(nodeInstace.getNodeId()).append("\r\n");
+ buf.append(" ip-").append(nodeInstace.getIp()).append("\r\n");
+ buf.append(" port-").append(nodeInstace.getPort()).append("\r\n");
+ buf.append(" ttl-").append(nodeInstace.getTtl()).append("\r\n");
+ buf.append(" Created_at-").append(nodeInstace.getCreated_at()).append("\r\n");
+ buf.append(" Updated_at-").append(nodeInstace.getUpdated_at()).append("\r\n");
+ buf.append(" Expiration-").append(nodeInstace.getExpiration()).append("\r\n");
+ }
+
+ buf.append("metadata:").append("\r\n");
+ if (this.getMetadata() != null && this.getMetadata().size() > 0) {
+ nodes = this.getMetadata().iterator();
+ while (nodes.hasNext()) {
+ KeyValuePair keyValuePair = (KeyValuePair) nodes.next();
+ buf.append(" key-").append(keyValuePair.getKey()).append("\r\n");
+ buf.append(" value-").append(keyValuePair.getValue()).append("\r\n");
+ }
+ }
+
+ return buf.toString();
+ }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/MicroServiceInfo.java b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/MicroServiceInfo.java
new file mode 100644
index 0000000..16fd0b3
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/MicroServiceInfo.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2023 ZTE Corporation.
+ * <p>
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.onap.holmes.common.msb.entity;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+public class MicroServiceInfo extends Service<Node> implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public MicroServiceInfo() {
+ }
+
+ public String toString() {
+ StringBuilder buf = new StringBuilder();
+ buf.append("MicroService List:").append("\r\n");
+ buf.append("serviceName:").append(this.getServiceName()).append("\r\n");
+ buf.append("version:").append(this.getVersion()).append("\r\n");
+ buf.append("url:").append(this.getUrl()).append("\r\n");
+ buf.append("protocol:").append(this.getProtocol()).append("\r\n");
+ buf.append("visualRange:").append(this.getVisualRange()).append("\r\n");
+ buf.append("enable_ssl:").append(this.isEnable_ssl()).append("\r\n");
+ buf.append("nodes:").append("\r\n");
+ Iterator nodes = this.getNodes().iterator();
+
+ while (nodes.hasNext()) {
+ Node nodeInstace = (Node) nodes.next();
+ buf.append(" ip-").append(nodeInstace.getIp()).append("\r\n");
+ buf.append(" port-").append(nodeInstace.getPort()).append("\r\n");
+ buf.append(" ttl-").append(nodeInstace.getTtl()).append("\r\n");
+ }
+
+ return buf.toString();
+ }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/Node.java b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/Node.java
new file mode 100644
index 0000000..1e17a05
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/Node.java
@@ -0,0 +1,97 @@
+/**
+ * Copyright 2023 ZTE Corporation.
+ * <p>
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.onap.holmes.common.msb.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.io.Serializable;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Node implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private String ip;
+ private String port;
+ private String ttl = "";
+ private String checkType = "";
+ private String checkUrl = "";
+ private String checkInterval;
+ private String checkTimeOut;
+
+ public Node() {
+ }
+
+ public String getIp() {
+ return this.ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getPort() {
+ return this.port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getTtl() {
+ return this.ttl;
+ }
+
+ public void setTtl(String ttl) {
+ this.ttl = ttl;
+ }
+
+ public String getCheckType() {
+ return this.checkType;
+ }
+
+ public void setCheckType(String checkType) {
+ this.checkType = checkType;
+ }
+
+ public String getCheckUrl() {
+ return this.checkUrl;
+ }
+
+ public void setCheckUrl(String checkUrl) {
+ this.checkUrl = checkUrl;
+ }
+
+ public String getCheckInterval() {
+ return this.checkInterval;
+ }
+
+ public void setCheckInterval(String checkInterval) {
+ this.checkInterval = checkInterval;
+ }
+
+ public String getCheckTimeOut() {
+ return this.checkTimeOut;
+ }
+
+ public void setCheckTimeOut(String checkTimeOut) {
+ this.checkTimeOut = checkTimeOut;
+ }
+
+ public String toString() {
+ return this.ip + ":" + this.port + " ttl:" + this.ttl;
+ }
+}
+
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/NodeInfo.java b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/NodeInfo.java
new file mode 100644
index 0000000..de2378d
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/NodeInfo.java
@@ -0,0 +1,80 @@
+/**
+ * Copyright 2023 ZTE Corporation.
+ * <p>
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.onap.holmes.common.msb.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+import java.util.Date;
+
+@JsonIgnoreProperties(
+ ignoreUnknown = true
+)
+public class NodeInfo extends Node {
+ private static final long serialVersionUID = 8955786461351557306L;
+ private String nodeId;
+ private String status;
+ @JsonSerialize(using = CustomDateSerializer.class)
+ private Date expiration;
+ @JsonSerialize(using = CustomDateSerializer.class)
+ private Date created_at;
+ @JsonSerialize(using = CustomDateSerializer.class)
+ private Date updated_at;
+
+ public NodeInfo() {
+ }
+
+ public Date getExpiration() {
+ return this.expiration;
+ }
+
+ public void setExpiration(Date expiration) {
+ this.expiration = expiration;
+ }
+
+ public Date getCreated_at() {
+ return this.created_at;
+ }
+
+ public void setCreated_at(Date created_at) {
+ this.created_at = created_at;
+ }
+
+ public Date getUpdated_at() {
+ return this.updated_at;
+ }
+
+ public void setUpdated_at(Date updated_at) {
+ this.updated_at = updated_at;
+ }
+
+ public String getNodeId() {
+ return this.nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/Service.java b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/Service.java
new file mode 100644
index 0000000..a852d24
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/msb/entity/Service.java
@@ -0,0 +1,121 @@
+/**
+ * Copyright 2023 ZTE Corporation.
+ * <p>
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.onap.holmes.common.msb.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Set;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Service<T> implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private String serviceName;
+ private String version = "";
+ private String url = "";
+ private String protocol = "";
+ private String visualRange = "1";
+ private String lb_policy = "";
+ private String path = "";
+ private Set<T> nodes;
+ private List<KeyValuePair> metadata;
+ private boolean enable_ssl = false;
+
+ public Service() {
+ }
+
+ public boolean isEnable_ssl() {
+ return this.enable_ssl;
+ }
+
+ public void setEnable_ssl(boolean enable_ssl) {
+ this.enable_ssl = enable_ssl;
+ }
+
+ public String getPath() {
+ return this.path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getLb_policy() {
+ return this.lb_policy;
+ }
+
+ public void setLb_policy(String lb_policy) {
+ this.lb_policy = lb_policy;
+ }
+
+ public List<KeyValuePair> getMetadata() {
+ return this.metadata;
+ }
+
+ public void setMetadata(List<KeyValuePair> metadata) {
+ this.metadata = metadata;
+ }
+
+ public Set<T> getNodes() {
+ return this.nodes;
+ }
+
+ public void setNodes(Set<T> nodes) {
+ this.nodes = nodes;
+ }
+
+ public String getServiceName() {
+ return this.serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getUrl() {
+ return this.url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getProtocol() {
+ return this.protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getVisualRange() {
+ return this.visualRange;
+ }
+
+ public void setVisualRange(String visualRange) {
+ this.visualRange = visualRange;
+ }
+}