root / src / com / rackspace / cloud / loadbalancer / api / client / LoadBalancer.java @ 403bb53b
History | View | Annotate | Download (4.9 kB)
1 |
/**
|
---|---|
2 |
*
|
3 |
*/
|
4 |
package com.rackspace.cloud.loadbalancer.api.client; |
5 |
|
6 |
import java.util.ArrayList; |
7 |
|
8 |
import com.rackspace.cloud.servers.api.client.Account; |
9 |
|
10 |
import android.util.Log; |
11 |
|
12 |
|
13 |
public class LoadBalancer extends Entity { |
14 |
|
15 |
private static final long serialVersionUID = 5994739895998309675L; |
16 |
private String id; |
17 |
private String name; |
18 |
private String protocol; |
19 |
private String port; |
20 |
private String algorithm; |
21 |
private String status; |
22 |
private String isConnectionLoggingEnabled; |
23 |
private String created; |
24 |
private String updated; |
25 |
private String sessionPersistence; |
26 |
private String clusterName; |
27 |
private String virtualIpType; |
28 |
private String region; |
29 |
private ConnectionThrottle connectionThrottle;
|
30 |
private ArrayList<VirtualIp> virtualIps; |
31 |
private ArrayList<Node> nodes; |
32 |
|
33 |
public static String getRegionUrl(String region){ |
34 |
if(region.equals("ORD")){ |
35 |
return Account.getLoadBalancerORDUrl();
|
36 |
} else if(region.equals("DFW")){ |
37 |
return Account.getLoadBalancerDFWUrl();
|
38 |
} else if(region.equals("LON")){ |
39 |
return Account.getLoadBalancerLONUrl();
|
40 |
} else {
|
41 |
return ""; |
42 |
} |
43 |
} |
44 |
|
45 |
public String getId() { |
46 |
return id;
|
47 |
} |
48 |
|
49 |
public void setId(String id) { |
50 |
this.id = id;
|
51 |
} |
52 |
|
53 |
public String getName() { |
54 |
return name;
|
55 |
} |
56 |
|
57 |
public void setName(String name) { |
58 |
this.name = name;
|
59 |
} |
60 |
|
61 |
public String getProtocol() { |
62 |
return protocol;
|
63 |
} |
64 |
|
65 |
public void setProtocol(String protocol) { |
66 |
/*
|
67 |
* protocol may come in as null if the server
|
68 |
* has been deleted, so need to check if not
|
69 |
* null
|
70 |
*/
|
71 |
if(protocol != null){ |
72 |
this.protocol = protocol.toUpperCase();
|
73 |
} else {
|
74 |
this.protocol = ""; |
75 |
} |
76 |
} |
77 |
|
78 |
public String getPort() { |
79 |
return port;
|
80 |
} |
81 |
|
82 |
public void setPort(String port) { |
83 |
this.port = port;
|
84 |
} |
85 |
|
86 |
public String getAlgorithm() { |
87 |
return algorithm;
|
88 |
} |
89 |
|
90 |
public void setAlgorithm(String algorithm) { |
91 |
this.algorithm = algorithm;
|
92 |
} |
93 |
|
94 |
public String getStatus() { |
95 |
return status;
|
96 |
} |
97 |
|
98 |
public void setStatus(String status) { |
99 |
this.status = status;
|
100 |
} |
101 |
|
102 |
public String getIsConnectionLoggingEnabled() { |
103 |
return isConnectionLoggingEnabled;
|
104 |
} |
105 |
|
106 |
public void setIsConnectionLoggingEnabled(String isConnectionLoggingEnabled) { |
107 |
this.isConnectionLoggingEnabled = isConnectionLoggingEnabled;
|
108 |
} |
109 |
|
110 |
public String getCreated() { |
111 |
return created;
|
112 |
} |
113 |
|
114 |
public void setCreated(String created) { |
115 |
this.created = created;
|
116 |
} |
117 |
|
118 |
public String getUpdated() { |
119 |
return updated;
|
120 |
} |
121 |
|
122 |
public void setUpdated(String updated) { |
123 |
this.updated = updated;
|
124 |
} |
125 |
|
126 |
public String getSessionPersistence() { |
127 |
return sessionPersistence;
|
128 |
} |
129 |
|
130 |
public void setSessionPersistence(String sessionPersistence) { |
131 |
this.sessionPersistence = sessionPersistence;
|
132 |
} |
133 |
|
134 |
public String getClusterName() { |
135 |
return clusterName;
|
136 |
} |
137 |
|
138 |
public void setClusterName(String clusterName) { |
139 |
this.clusterName = clusterName;
|
140 |
} |
141 |
|
142 |
public ConnectionThrottle getConnectionThrottle() {
|
143 |
return connectionThrottle;
|
144 |
} |
145 |
|
146 |
public void setConnectionThrottle(ConnectionThrottle connectionThrottle) { |
147 |
this.connectionThrottle = connectionThrottle;
|
148 |
} |
149 |
|
150 |
public ArrayList<VirtualIp> getVirtualIps() { |
151 |
return virtualIps;
|
152 |
} |
153 |
|
154 |
public void setVirtualIps(ArrayList<VirtualIp> virtualIps) { |
155 |
this.virtualIps = virtualIps;
|
156 |
} |
157 |
|
158 |
public ArrayList<Node> getNodes() { |
159 |
return nodes;
|
160 |
} |
161 |
|
162 |
public void setNodes(ArrayList<Node> nodes) { |
163 |
this.nodes = nodes;
|
164 |
} |
165 |
|
166 |
public String getVirtualIpType(){ |
167 |
return virtualIpType;
|
168 |
} |
169 |
|
170 |
public void setVirtualIpType(String virtualIpType){ |
171 |
/*
|
172 |
* protocol may come in as null if the server
|
173 |
* has been deleted, so need to check if not
|
174 |
* null
|
175 |
*/
|
176 |
if(virtualIpType != null){ |
177 |
this.virtualIpType = virtualIpType.toUpperCase();
|
178 |
} else {
|
179 |
this.virtualIpType = ""; |
180 |
} |
181 |
} |
182 |
|
183 |
public String getRegion(){ |
184 |
return region;
|
185 |
} |
186 |
|
187 |
public void setRegion(String region){ |
188 |
this.region = region;
|
189 |
} |
190 |
|
191 |
public static long getSerialversionuid() { |
192 |
return serialVersionUID;
|
193 |
} |
194 |
|
195 |
public String toXML() { |
196 |
String xml = ""; |
197 |
xml = "<loadBalancer xmlns=\"http://docs.rackspacecloud.com/loadbalancers/api/v1.0\" name=\""
|
198 |
+ getName() + "\" id=\"" + getId() + "</loadBalancer>"; |
199 |
return xml;
|
200 |
} |
201 |
|
202 |
public String toDetailedXML(){ |
203 |
String xml = "<loadBalancer xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\"" + |
204 |
" name=\"" + getName() + "\"" + |
205 |
" port=\"" + getPort() + "\"" + |
206 |
" protocol=\"" + getProtocol() + "\"" + |
207 |
" algorithm=\"" + getAlgorithm() + "\"" + ">" + |
208 |
" <virtualIps>";
|
209 |
if(getVirtualIpType().equals("SHARED")){ |
210 |
for(VirtualIp ip : getVirtualIps()){
|
211 |
xml += "<virtualIp id=\"" + ip.getId() + "\"" + "/>"; |
212 |
} |
213 |
} else {
|
214 |
xml += "<virtualIp type=\"" + getVirtualIpType() + "\"" + "/>"; |
215 |
} |
216 |
xml += " </virtualIps>" +
|
217 |
" <nodes>";
|
218 |
for(Node node : getNodes()){
|
219 |
xml += "<node address=\"" + node.getAddress() + "\"" + " port=\"" + node.getPort() + "\"" + |
220 |
" condition=\"" + node.getCondition() + "\"" + "/>"; |
221 |
} |
222 |
xml += " </nodes>" +
|
223 |
" </loadBalancer>";
|
224 |
Log.d("info", xml);
|
225 |
return xml;
|
226 |
} |
227 |
} |