Example code for MSB SDK
[msb/java-sdk.git] / src / main / java / org / onap / msb / sdk / discovery / entity / Node.java
1 /*******************************************************************************
2  * Copyright 2017 ZTE, Inc. and others.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  * 
7  * http://www.apache.org/licenses/LICENSE-2.0
8  * 
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  ******************************************************************************/
14 package org.onap.msb.sdk.discovery.entity;
15
16 import java.io.Serializable;
17
18 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
19
20 @JsonIgnoreProperties(ignoreUnknown = true)
21 public class Node implements Serializable {
22   private static final long serialVersionUID = 1L;
23
24   private String ip;
25
26   private String port;
27
28   private String ttl = "";
29
30   // 负载均衡策略参数
31   private String lb_server_params = "";
32
33   // 健康检查参数
34   private String checkType = "";
35   private String checkUrl = "";
36   private String checkInterval = "";
37   private String checkTimeOut = "";
38
39   private String ha_role = "";
40
41
42   public String getHa_role() {
43     return ha_role;
44   }
45
46
47   /**
48    * @Title setHa_role
49    * @Description TODO(实例主备状态,取值范围:active,standby)
50    * @param ha_role
51    * @return void
52    */
53   public void setHa_role(String ha_role) {
54     this.ha_role = ha_role;
55   }
56
57
58
59   public String getIp() {
60     return ip;
61   }
62
63   public void setIp(String ip) {
64     this.ip = ip;
65   }
66
67   public String getPort() {
68     return port;
69   }
70
71   public void setPort(String port) {
72     this.port = port;
73   }
74
75   public String getTtl() {
76     return ttl;
77   }
78
79   public void setTtl(String ttl) {
80     this.ttl = ttl;
81   }
82
83
84   @Override
85   public String toString() {
86     // TODO Auto-generated method stub
87     return (new StringBuilder().append(ip).append(":").append(port).append("  ttl:").append(ttl))
88         .toString();
89   }
90
91   public String getLb_server_params() {
92     return lb_server_params;
93   }
94
95   /**
96    * @Title setLb_server_params
97    * @Description TODO(针对协议为TCP或UDP的服务实例配置负载均衡参数) <br>
98    *              支持的server参数设置: <br>
99    *              1. weight: server的权重,不显式设置默认为1 <br>
100    *              2.
101    *              max_fails:在fail_timeout设置的时间间隔内,允许失败尝试的次数,不显式设置默认为1.比如fail_timeout=30s,max_fails=6,那表示在30s内如果6次连接失败,那认定该server为unavailable
102    *              <br>
103    *              3. fail_timeout:判定server为unavailable的时间间隔。如果不显式设置,默认设置为10s
104    * @param lb_server_params (示例:weight=5,max_fails=3,fail_timeout=30s)
105    * @return void
106    */
107   public void setLb_server_params(String lb_server_params) {
108     this.lb_server_params = lb_server_params;
109   }
110
111   public String getCheckType() {
112     return checkType;
113   }
114
115   /**
116    * @Title setCheckType
117    * @Description TODO(健康检查类型,可选范围:TTL,HTTP,TCP) <br>
118    *              1.HTTP保活由"MSB"每隔checkInterval时间向"服务提供方"发送 GET请求。如果请求返回任何2xx状态码,检测成功。 <br>
119    *              2.TCP保活原理同HTTP,协议不同。 <br>
120    *              3.TTL保活由"服务提供方"向"MSB"发送HTTP请求以保持联通状态,在checkInterval设置的时间间隔内未能收到保活请求,服务发现将此服务状态设置为无效。
121    * @param checkType
122    * @return void
123    */
124   public void setCheckType(String checkType) {
125     this.checkType = checkType;
126   }
127
128   public String getCheckUrl() {
129     return checkUrl;
130   }
131
132   /**
133    * @Title setCheckUrl
134    * @Description TODO(健康检查类型为HTTP或TCP,填写检查URL)
135    * @param checkUrl
136    * @return void
137    */
138   public void setCheckUrl(String checkUrl) {
139     this.checkUrl = checkUrl;
140   }
141
142   public String getCheckInterval() {
143     return checkInterval;
144   }
145
146   /**
147    * @Title setCheckInterval
148    * @Description TODO(健康检查轮询时间,单位:秒)
149    * @param checkInterval
150    * @return void
151    */
152   public void setCheckInterval(String checkInterval) {
153     this.checkInterval = checkInterval;
154   }
155
156
157   public String getCheckTimeOut() {
158     return checkTimeOut;
159   }
160
161
162   public void setCheckTimeOut(String checkTimeOut) {
163     this.checkTimeOut = checkTimeOut;
164   }
165
166 }