root / src / com / rackspace / cloud / loadbalancer / api / client / LoadBalancer.java @ 4f9d1a69
History | View | Annotate | Download (4.3 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.getAccount().getLoadBalancerORDUrl();
|
36 |
} |
37 |
else if(region.equals("DFW")){ |
38 |
return Account.getAccount().getLoadBalancerDFWUrl();
|
39 |
} |
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 |
this.protocol = protocol.toUpperCase();
|
67 |
} |
68 |
|
69 |
public String getPort() { |
70 |
return port;
|
71 |
} |
72 |
|
73 |
public void setPort(String port) { |
74 |
this.port = port;
|
75 |
} |
76 |
|
77 |
public String getAlgorithm() { |
78 |
return algorithm;
|
79 |
} |
80 |
|
81 |
public void setAlgorithm(String algorithm) { |
82 |
this.algorithm = algorithm;
|
83 |
} |
84 |
|
85 |
public String getStatus() { |
86 |
return status;
|
87 |
} |
88 |
|
89 |
public void setStatus(String status) { |
90 |
this.status = status;
|
91 |
} |
92 |
|
93 |
public String getIsConnectionLoggingEnabled() { |
94 |
return isConnectionLoggingEnabled;
|
95 |
} |
96 |
|
97 |
public void setIsConnectionLoggingEnabled(String isConnectionLoggingEnabled) { |
98 |
this.isConnectionLoggingEnabled = isConnectionLoggingEnabled;
|
99 |
} |
100 |
|
101 |
public String getCreated() { |
102 |
return created;
|
103 |
} |
104 |
|
105 |
public void setCreated(String created) { |
106 |
this.created = created;
|
107 |
} |
108 |
|
109 |
public String getUpdated() { |
110 |
return updated;
|
111 |
} |
112 |
|
113 |
public void setUpdated(String updated) { |
114 |
this.updated = updated;
|
115 |
} |
116 |
|
117 |
public String getSessionPersistence() { |
118 |
return sessionPersistence;
|
119 |
} |
120 |
|
121 |
public void setSessionPersistence(String sessionPersistence) { |
122 |
this.sessionPersistence = sessionPersistence;
|
123 |
} |
124 |
|
125 |
public String getClusterName() { |
126 |
return clusterName;
|
127 |
} |
128 |
|
129 |
public void setClusterName(String clusterName) { |
130 |
this.clusterName = clusterName;
|
131 |
} |
132 |
|
133 |
public ConnectionThrottle getConnectionThrottle() {
|
134 |
return connectionThrottle;
|
135 |
} |
136 |
|
137 |
public void setConnectionThrottle(ConnectionThrottle connectionThrottle) { |
138 |
this.connectionThrottle = connectionThrottle;
|
139 |
} |
140 |
|
141 |
public ArrayList<VirtualIp> getVirtualIps() { |
142 |
return virtualIps;
|
143 |
} |
144 |
|
145 |
public void setVirtualIps(ArrayList<VirtualIp> virtualIps) { |
146 |
this.virtualIps = virtualIps;
|
147 |
} |
148 |
|
149 |
public ArrayList<Node> getNodes() { |
150 |
return nodes;
|
151 |
} |
152 |
|
153 |
public void setNodes(ArrayList<Node> nodes) { |
154 |
this.nodes = nodes;
|
155 |
} |
156 |
|
157 |
public String getVirtualIpType(){ |
158 |
return virtualIpType;
|
159 |
} |
160 |
|
161 |
public String setVirtualIpType(String virtualIpType){ |
162 |
return this.virtualIpType = virtualIpType.toUpperCase(); |
163 |
} |
164 |
|
165 |
public String getRegion(){ |
166 |
return region;
|
167 |
} |
168 |
|
169 |
public String setRegion(String region){ |
170 |
return this.region = region; |
171 |
} |
172 |
|
173 |
public static long getSerialversionuid() { |
174 |
return serialVersionUID;
|
175 |
} |
176 |
|
177 |
public String toXML() { |
178 |
String xml = ""; |
179 |
xml = "<loadBalancer xmlns=\"http://docs.rackspacecloud.com/loadbalancers/api/v1.0\" name=\""
|
180 |
+ getName() + "\" id=\"" + getId() + "</loadBalancer>"; |
181 |
return xml;
|
182 |
} |
183 |
|
184 |
public String toDetailedXML(){ |
185 |
String xml = "<loadBalancer xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\"" + |
186 |
" name=\"" + getName() + "\"" + |
187 |
" port=\"" + getPort() + "\"" + |
188 |
" protocol=\"" + getProtocol() + "\"" + |
189 |
" algorithm=\"" + getAlgorithm() + "\"" + ">" + |
190 |
" <virtualIps>" +
|
191 |
"<virtualIp type=\"" + getVirtualIpType() + "\"" + "/>" + |
192 |
" </virtualIps>" +
|
193 |
" <nodes>";
|
194 |
for(Node node : getNodes()){
|
195 |
xml += "<node address=\"" + node.getAddress() + "\"" + " port=\"" + node.getPort() + "\"" + |
196 |
" condition=\"" + node.getCondition() + "\"" + "/>"; |
197 |
} |
198 |
xml += " </nodes>" +
|
199 |
" </loadBalancer>";
|
200 |
Log.d("info", xml);
|
201 |
return xml;
|
202 |
} |
203 |
} |