1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.opencastproject.serviceregistry.api;
23
24 import javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlRootElement;
28 import javax.xml.bind.annotation.XmlType;
29
30
31
32
33 @XmlAccessorType(XmlAccessType.NONE)
34 @XmlType(name = "host", namespace = "http://serviceregistry.opencastproject.org")
35 @XmlRootElement(name = "host", namespace = "http://serviceregistry.opencastproject.org")
36 public class JaxbHostRegistration implements HostRegistration {
37
38
39
40
41
42 @XmlElement(name = "base_url")
43 protected String baseUrl;
44
45 @XmlElement(name = "address")
46 protected String address;
47
48 @XmlElement(name = "node_name")
49 protected String nodeName;
50
51 @XmlElement(name = "memory")
52 protected long memory;
53
54 @XmlElement(name = "cores")
55 protected int cores;
56
57
58
59
60 @XmlElement(name = "max_load")
61 protected float maxLoad;
62
63 @XmlElement(name = "online")
64 protected boolean online;
65
66 @XmlElement(name = "active")
67 protected boolean active;
68
69 @XmlElement(name = "maintenance")
70 protected boolean maintenanceMode;
71
72
73
74
75 public JaxbHostRegistration() {
76 this.online = true;
77 this.active = true;
78 this.maintenanceMode = false;
79 }
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 public JaxbHostRegistration(String baseUrl, String address, String nodeName, long memory, int cores, float maxLoad, boolean online,
102 boolean maintenance) {
103 this.baseUrl = baseUrl;
104 this.address = address;
105 this.nodeName = nodeName;
106 this.memory = memory;
107 this.cores = cores;
108 this.maxLoad = maxLoad;
109 this.online = online;
110 this.maintenanceMode = maintenance;
111 this.active = true;
112 }
113
114
115
116
117
118
119 public JaxbHostRegistration(HostRegistration hostRegistration) {
120 this.baseUrl = hostRegistration.getBaseUrl();
121 this.address = hostRegistration.getIpAddress();
122 this.nodeName = hostRegistration.getNodeName();
123 this.memory = hostRegistration.getMemory();
124 this.cores = hostRegistration.getCores();
125 this.maxLoad = hostRegistration.getMaxLoad();
126 this.online = hostRegistration.isOnline();
127 this.active = hostRegistration.isActive();
128 this.maintenanceMode = hostRegistration.isMaintenanceMode();
129 }
130
131 @Override
132 public Long getId() {
133 return (long) baseUrl.hashCode();
134 }
135
136
137
138
139
140
141 @Override
142 public String getBaseUrl() {
143 return baseUrl;
144 }
145
146
147
148
149
150
151 @Override
152 public void setBaseUrl(String baseUrl) {
153 this.baseUrl = baseUrl;
154 }
155
156
157
158
159
160
161 @Override
162 public String getIpAddress() {
163 return address;
164 }
165
166
167
168
169
170
171 @Override
172 public void setIpAddress(String address) {
173 this.address = address;
174 }
175
176
177
178
179
180
181 @Override
182 public long getMemory() {
183 return memory;
184 }
185
186
187
188
189
190
191 @Override
192 public void setMemory(long memory) {
193 this.memory = memory;
194 }
195
196
197
198
199
200
201 @Override
202 public int getCores() {
203 return cores;
204 }
205
206
207
208
209
210
211 @Override
212 public void setCores(int cores) {
213 this.cores = cores;
214 }
215
216
217
218
219
220
221 @Override
222 public float getMaxLoad() {
223 return maxLoad;
224 }
225
226 @Override
227 public void setMaxLoad(float maxLoad) {
228 this.maxLoad = maxLoad;
229 }
230
231
232
233
234
235
236 @Override
237 public boolean isActive() {
238 return active;
239 }
240
241
242
243
244
245
246 @Override
247 public void setActive(boolean active) {
248 this.active = active;
249 }
250
251
252
253
254
255
256 @Override
257 public boolean isOnline() {
258 return online;
259 }
260
261
262
263
264
265
266 @Override
267 public void setOnline(boolean online) {
268 this.online = online;
269 }
270
271
272
273
274
275
276 @Override
277 public boolean isMaintenanceMode() {
278 return maintenanceMode;
279 }
280
281
282
283
284
285
286 @Override
287 public void setMaintenanceMode(boolean maintenanceMode) {
288 this.maintenanceMode = maintenanceMode;
289 }
290
291
292
293
294
295
296 @Override
297 public int hashCode() {
298 return toString().hashCode();
299 }
300
301
302
303
304
305
306 @Override
307 public boolean equals(Object obj) {
308 if (!(obj instanceof HostRegistration))
309 return false;
310 HostRegistration registration = (HostRegistration) obj;
311 return baseUrl.equals(registration.getBaseUrl());
312 }
313
314
315
316
317
318
319 @Override
320 public String toString() {
321 return baseUrl;
322 }
323
324
325
326
327
328
329 @Override
330 public String getNodeName() {
331 return nodeName;
332 }
333
334
335
336
337
338
339 @Override
340 public void setNodeName(String nodeName) {
341 this.nodeName = nodeName;
342 }
343 }