diff options
Diffstat (limited to 'apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service')
6 files changed, 112 insertions, 181 deletions
diff --git a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/IServiceDAO.java b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/IServiceDAO.java index cd17057..1de2c2c 100644 --- a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/IServiceDAO.java +++ b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/IServiceDAO.java @@ -1,17 +1,15 @@ /******************************************************************************* * Copyright 2016-2017 ZTE, Inc. and others. * - * 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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.msb.apiroute.wrapper.dao.service; diff --git a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/ServiceDAOImpl.java b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/ServiceDAOImpl.java index 9ed0455..950963b 100644 --- a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/ServiceDAOImpl.java +++ b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/ServiceDAOImpl.java @@ -1,22 +1,18 @@ /******************************************************************************* * Copyright 2016-2017 ZTE, Inc. and others. * - * 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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.msb.apiroute.wrapper.dao.service; -import com.fasterxml.jackson.core.JsonProcessingException; - import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -25,13 +21,15 @@ import org.onap.msb.apiroute.wrapper.dao.RedisAccessWrapper; import org.onap.msb.apiroute.wrapper.dao.service.bean.ServiceInfo; import org.onap.msb.apiroute.wrapper.util.Jackson; -public class ServiceDAOImpl implements IServiceDAO{ +import com.fasterxml.jackson.core.JsonProcessingException; + +public class ServiceDAOImpl implements IServiceDAO { public void saveService(String key, ServiceInfo serviceInfo) throws Exception { String serviceInfoStr = null; try { serviceInfoStr = Jackson.MAPPER.writeValueAsString(serviceInfo); } catch (JsonProcessingException e) { - throw new Exception("error occurred while parsing ServiceInfo to json data",e); + throw new Exception("error occurred while parsing ServiceInfo to json data", e); } RedisAccessWrapper.save(key, serviceInfoStr); } @@ -44,7 +42,7 @@ public class ServiceDAOImpl implements IServiceDAO{ try { serviceInfo = Jackson.MAPPER.readValue(serviceInfoStr, ServiceInfo.class); } catch (IOException e) { - throw new Exception("error occurred while parsing the redis json data to ServiceInfo",e); + throw new Exception("error occurred while parsing the redis json data to ServiceInfo", e); } return serviceInfo; } @@ -58,7 +56,7 @@ public class ServiceDAOImpl implements IServiceDAO{ serviceInfo = Jackson.MAPPER.readValue(serviceInfoStr, ServiceInfo.class); routeInfoList.add(serviceInfo); } catch (IOException e) { - throw new Exception("error occurred while parsing the redis json data to ServiceInfo",e); + throw new Exception("error occurred while parsing the redis json data to ServiceInfo", e); } } return routeInfoList; @@ -68,7 +66,7 @@ public class ServiceDAOImpl implements IServiceDAO{ return RedisAccessWrapper.delete(key); } - public long deleteMultiService(String keyPattern) throws Exception{ + public long deleteMultiService(String keyPattern) throws Exception { return RedisAccessWrapper.deleteMultiKeys(keyPattern); } } diff --git a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Metadata.java b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Metadata.java index ec22592..687c58e 100644 --- a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Metadata.java +++ b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Metadata.java @@ -1,65 +1,57 @@ /******************************************************************************* * Copyright 2016-2017 ZTE, Inc. and others. * - * 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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.msb.apiroute.wrapper.dao.service.bean; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + import com.fasterxml.jackson.annotation.JsonFormat; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - @AllArgsConstructor @NoArgsConstructor -@Getter @Setter +@Getter +@Setter public class Metadata { private String name; private String namespace; private String uid = ""; - //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") - //private Date creationTimestamp; - // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + // private Date creationTimestamp; + // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX") private Date updateTimestamp; private Map labels = new HashMap(); - //private String[] annotations = new String[]{}; + // private String[] annotations = new String[]{}; private String[] annotations = null; /* - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Metadata metadata = (Metadata) o; - return Objects.equals(name, metadata.name) && - Objects.equals(namespace, metadata.namespace) && - Objects.equals(uid, metadata.uid) && - //Objects.equals(creationTimestamp, metadata.creationTimestamp) && - Objects.equals(updateTimestamp, metadata.updateTimestamp) && - Objects.equals(labels, metadata.labels) && - Objects.equals(annotations, metadata.annotations); - } - - @Override - public int hashCode() { - //return Objects.hash(name, namespace, uid, creationTimestamp, updateTimestamp, labels, annotations); - return Objects.hash(name, namespace, uid, updateTimestamp, labels, annotations); - } - */ + * @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || + * getClass() != o.getClass()) return false; Metadata metadata = (Metadata) o; return + * Objects.equals(name, metadata.name) && Objects.equals(namespace, metadata.namespace) && + * Objects.equals(uid, metadata.uid) && //Objects.equals(creationTimestamp, + * metadata.creationTimestamp) && Objects.equals(updateTimestamp, metadata.updateTimestamp) && + * Objects.equals(labels, metadata.labels) && Objects.equals(annotations, metadata.annotations); + * } + * + * @Override public int hashCode() { //return Objects.hash(name, namespace, uid, + * creationTimestamp, updateTimestamp, labels, annotations); return Objects.hash(name, + * namespace, uid, updateTimestamp, labels, annotations); } + */ } diff --git a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Node.java b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Node.java index 02c2991..72c8da7 100644 --- a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Node.java +++ b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Node.java @@ -1,17 +1,15 @@ /******************************************************************************* * Copyright 2016-2017 ZTE, Inc. and others. * - * 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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.msb.apiroute.wrapper.dao.service.bean; @@ -22,26 +20,18 @@ import lombok.Setter; @AllArgsConstructor @NoArgsConstructor -@Getter @Setter +@Getter +@Setter public class Node { private String ip; private String port; - private int ttl=-1; + private int ttl = -1; /* - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Node node = (Node) o; - return Objects.equals(port, node.port) && - Objects.equals(ttl, node.ttl) && - Objects.equals(ip, node.ip); - } - - @Override - public int hashCode() { - return Objects.hash(ip, port, ttl); - } - */ + * @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || + * getClass() != o.getClass()) return false; Node node = (Node) o; return Objects.equals(port, + * node.port) && Objects.equals(ttl, node.ttl) && Objects.equals(ip, node.ip); } + * + * @Override public int hashCode() { return Objects.hash(ip, port, ttl); } + */ } diff --git a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/ServiceInfo.java b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/ServiceInfo.java index 800c77f..72d940d 100644 --- a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/ServiceInfo.java +++ b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/ServiceInfo.java @@ -1,17 +1,15 @@ /******************************************************************************* * Copyright 2016-2017 ZTE, Inc. and others. * - * 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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.msb.apiroute.wrapper.dao.service.bean; @@ -34,58 +32,24 @@ public class ServiceInfo { private Spec spec; /** - Example Service: - { - "kind" : "service", - "apiVersion" : "v1", - "metadata" : { - "name" : "kubernetes", - "namespace" : "default", - "uid" : "0b6f198e-c6ab-11e6-86aa-fa163ee2118b", - "creationTimestamp" : "2016-12-20T11:54:21Z", - "labels" : { - "component" : "apiserver", - "provider" : "kubernetes" - }, - "annotations" : {} - }, - "spec" : { - "visualRange" : 0, - "url" : "", - "path" : "", - "publish_port" : "", - "host" : "", - "protocol" : "", - "lb_policy" : "", - "enable_ssl" : "0|1", //转发时,使用http还是http转发。http:0/https:1 - "nodes" : [{ - "ip" : 10.10.10.2, - "port" : 8080, - "ttl" : - } - ], - } - "status" : "" - } - + * Example Service: { "kind" : "service", "apiVersion" : "v1", "metadata" : { "name" : + * "kubernetes", "namespace" : "default", "uid" : "0b6f198e-c6ab-11e6-86aa-fa163ee2118b", + * "creationTimestamp" : "2016-12-20T11:54:21Z", "labels" : { "component" : "apiserver", + * "provider" : "kubernetes" }, "annotations" : {} }, "spec" : { "visualRange" : 0, "url" : "", + * "path" : "", "publish_port" : "", "host" : "", "protocol" : "", "lb_policy" : "", + * "enable_ssl" : "0|1", //转发时,使用http还是http转发。http:0/https:1 "nodes" : [{ "ip" : 10.10.10.2, + * "port" : 8080, "ttl" : } ], } "status" : "" } + * */ - /* - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ServiceInfo that = (ServiceInfo) o; - return Objects.equals(kind, that.kind) && - Objects.equals(apiVersion, that.apiVersion) && - Objects.equals(status, that.status) && - Objects.equals(metadata, that.metadata) && - Objects.equals(spec, that.spec); - } - - @Override - public int hashCode() { - return Objects.hash(kind, apiVersion, status, metadata, spec); - } - */ + /* + * @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || + * getClass() != o.getClass()) return false; ServiceInfo that = (ServiceInfo) o; return + * Objects.equals(kind, that.kind) && Objects.equals(apiVersion, that.apiVersion) && + * Objects.equals(status, that.status) && Objects.equals(metadata, that.metadata) && + * Objects.equals(spec, that.spec); } + * + * @Override public int hashCode() { return Objects.hash(kind, apiVersion, status, metadata, + * spec); } + */ } diff --git a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Spec.java b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Spec.java index 4741200..062d868 100644 --- a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Spec.java +++ b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/service/bean/Spec.java @@ -1,17 +1,15 @@ /******************************************************************************* * Copyright 2016-2017 ZTE, Inc. and others. * - * 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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.msb.apiroute.wrapper.dao.service.bean; @@ -22,7 +20,8 @@ import lombok.Setter; @AllArgsConstructor @NoArgsConstructor -@Getter @Setter +@Getter +@Setter public class Spec { private String visualRange = ""; private String url = ""; @@ -35,25 +34,15 @@ public class Spec { private Node[] nodes; /* - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Spec spec = (Spec) o; - return Objects.equals(enable_ssl, spec.enable_ssl) && - Objects.equals(visualRange, spec.visualRange) && - Objects.equals(url, spec.url) && - Objects.equals(path, spec.path) && - Objects.equals(publish_port, spec.publish_port) && - Objects.equals(host, spec.host) && - Objects.equals(protocol, spec.protocol) && - Objects.equals(lb_policy, spec.lb_policy) && - Arrays.equals(nodes, spec.nodes); - } - - @Override - public int hashCode() { - return Objects.hash(visualRange, url, path, publish_port, host, protocol, lb_policy, enable_ssl, nodes); - } - */ + * @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || + * getClass() != o.getClass()) return false; Spec spec = (Spec) o; return + * Objects.equals(enable_ssl, spec.enable_ssl) && Objects.equals(visualRange, spec.visualRange) + * && Objects.equals(url, spec.url) && Objects.equals(path, spec.path) && + * Objects.equals(publish_port, spec.publish_port) && Objects.equals(host, spec.host) && + * Objects.equals(protocol, spec.protocol) && Objects.equals(lb_policy, spec.lb_policy) && + * Arrays.equals(nodes, spec.nodes); } + * + * @Override public int hashCode() { return Objects.hash(visualRange, url, path, publish_port, + * host, protocol, lb_policy, enable_ssl, nodes); } + */ } |