-
Notifications
You must be signed in to change notification settings - Fork 8.8k
/
Component.java
445 lines (380 loc) · 15.2 KB
/
Component.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
*
* 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.apache.hadoop.yarn.service.api.records;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
/**
* One or more components of the service. If the service is HBase say,
* then the component can be a simple role like master or regionserver. If the
* service is a complex business webapp then a component can be other
* services say Kafka or Storm. Thereby it opens up the support for complex
* and nested services.
**/
@InterfaceAudience.Public
@InterfaceStability.Unstable
@ApiModel(description = "One or more components of the service. If the service is HBase say, then the component can be a simple role like master or regionserver. If the service is a complex business webapp then a component can be other services say Kafka or Storm. Thereby it opens up the support for complex and nested services.")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-02T08:15:05.615-07:00")
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Component implements Serializable {
private static final long serialVersionUID = -8430058381509087805L;
@JsonProperty("name")
private String name = null;
@JsonProperty("dependencies")
private List<String> dependencies = new ArrayList<String>();
@JsonProperty("readiness_check")
@XmlElement(name = "readiness_check")
private ReadinessCheck readinessCheck = null;
@JsonProperty("artifact")
private Artifact artifact = null;
@JsonProperty("launch_command")
@XmlElement(name = "launch_command")
private String launchCommand = null;
@JsonProperty("resource")
private Resource resource = null;
@JsonProperty("number_of_containers")
@XmlElement(name = "number_of_containers")
private Long numberOfContainers = null;
@JsonProperty("run_privileged_container")
@XmlElement(name = "run_privileged_container")
private Boolean runPrivilegedContainer = false;
@JsonProperty("placement_policy")
@XmlElement(name = "placement_policy")
private PlacementPolicy placementPolicy = null;
@JsonProperty("state")
private ComponentState state = ComponentState.FLEXING;
@JsonProperty("configuration")
private Configuration configuration = new Configuration();
@JsonProperty("quicklinks")
private List<String> quicklinks = new ArrayList<String>();
@JsonProperty("containers")
private List<Container> containers =
Collections.synchronizedList(new ArrayList<Container>());
/**
* Name of the service component (mandatory).
**/
public Component name(String name) {
this.name = name;
return this;
}
@ApiModelProperty(example = "null", required = true, value = "Name of the service component (mandatory).")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* An array of service components which should be in READY state (as
* defined by readiness check), before this component can be started. The
* dependencies across all components of a service should be represented
* as a DAG.
**/
public Component dependencies(List<String> dependencies) {
this.dependencies = dependencies;
return this;
}
@ApiModelProperty(example = "null", value = "An array of service components which should be in READY state (as defined by readiness check), before this component can be started. The dependencies across all components of an service should be represented as a DAG.")
public List<String> getDependencies() {
return dependencies;
}
public void setDependencies(List<String> dependencies) {
this.dependencies = dependencies;
}
/**
* Readiness check for this component.
**/
public Component readinessCheck(ReadinessCheck readinessCheck) {
this.readinessCheck = readinessCheck;
return this;
}
@ApiModelProperty(example = "null", value = "Readiness check for this component.")
public ReadinessCheck getReadinessCheck() {
return readinessCheck;
}
public void setReadinessCheck(ReadinessCheck readinessCheck) {
this.readinessCheck = readinessCheck;
}
/**
* Artifact of the component (optional). If not specified, the service
* level global artifact takes effect.
**/
public Component artifact(Artifact artifact) {
this.artifact = artifact;
return this;
}
@ApiModelProperty(example = "null", value = "Artifact of the component (optional). If not specified, the service level global artifact takes effect.")
public Artifact getArtifact() {
return artifact;
}
public void setArtifact(Artifact artifact) {
this.artifact = artifact;
}
/**
* The custom launch command of this component (optional). When specified at
* the component level, it overrides the value specified at the global level
* (if any).
**/
public Component launchCommand(String launchCommand) {
this.launchCommand = launchCommand;
return this;
}
@ApiModelProperty(example = "null", value = "The custom launch command of this component (optional). When specified at the component level, it overrides the value specified at the global level (if any).")
public String getLaunchCommand() {
return launchCommand;
}
public void setLaunchCommand(String launchCommand) {
this.launchCommand = launchCommand;
}
/**
* Resource of this component (optional). If not specified, the service
* level global resource takes effect.
**/
public Component resource(Resource resource) {
this.resource = resource;
return this;
}
@ApiModelProperty(example = "null", value = "Resource of this component (optional). If not specified, the service level global resource takes effect.")
public Resource getResource() {
return resource;
}
public void setResource(Resource resource) {
this.resource = resource;
}
/**
* Number of containers for this component (optional). If not specified,
* the service level global number_of_containers takes effect.
**/
public Component numberOfContainers(Long numberOfContainers) {
this.numberOfContainers = numberOfContainers;
return this;
}
@ApiModelProperty(example = "null", value = "Number of containers for this component (optional). If not specified, the service level global number_of_containers takes effect.")
public Long getNumberOfContainers() {
return numberOfContainers;
}
public void setNumberOfContainers(Long numberOfContainers) {
this.numberOfContainers = numberOfContainers;
}
@ApiModelProperty(example = "null", value = "Containers of a started component. Specifying a value for this attribute for the POST payload raises a validation error. This blob is available only in the GET response of a started service.")
public List<Container> getContainers() {
return containers;
}
public void setContainers(List<Container> containers) {
this.containers = containers;
}
public void addContainer(Container container) {
this.containers.add(container);
}
public void removeContainer(Container container) {
containers.remove(container);
}
public Container getContainer(String id) {
for (Container container : containers) {
if (container.getId().equals(id)) {
return container;
}
}
return null;
}
/**
* Run all containers of this component in privileged mode (YARN-4262).
**/
public Component runPrivilegedContainer(Boolean runPrivilegedContainer) {
this.runPrivilegedContainer = runPrivilegedContainer;
return this;
}
@ApiModelProperty(example = "null", value = "Run all containers of this component in privileged mode (YARN-4262).")
public Boolean getRunPrivilegedContainer() {
return runPrivilegedContainer;
}
public void setRunPrivilegedContainer(Boolean runPrivilegedContainer) {
this.runPrivilegedContainer = runPrivilegedContainer;
}
/**
* Advanced scheduling and placement policies for all containers of this
* component (optional). If not specified, the service level placement_policy
* takes effect. Refer to the description at the global level for more
* details.
**/
public Component placementPolicy(PlacementPolicy placementPolicy) {
this.placementPolicy = placementPolicy;
return this;
}
@ApiModelProperty(example = "null", value = "Advanced scheduling and placement policies for all containers of this component (optional). If not specified, the service level placement_policy takes effect. Refer to the description at the global level for more details.")
public PlacementPolicy getPlacementPolicy() {
return placementPolicy;
}
public void setPlacementPolicy(PlacementPolicy placementPolicy) {
this.placementPolicy = placementPolicy;
}
/**
* Config properties for this component.
**/
public Component configuration(Configuration configuration) {
this.configuration = configuration;
return this;
}
@ApiModelProperty(example = "null", value = "Config properties for this component.")
public Configuration getConfiguration() {
return configuration;
}
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
/**
* A list of quicklink keys defined at the service level, and to be
* resolved by this component.
**/
public Component quicklinks(List<String> quicklinks) {
this.quicklinks = quicklinks;
return this;
}
@ApiModelProperty(example = "null", value = "A list of quicklink keys defined at the service level, and to be resolved by this component.")
public List<String> getQuicklinks() {
return quicklinks;
}
public void setQuicklinks(List<String> quicklinks) {
this.quicklinks = quicklinks;
}
public Component state(ComponentState state) {
this.state = state;
return this;
}
@ApiModelProperty(example = "null", value = "State of the component.")
public ComponentState getState() {
return state;
}
public void setState(ComponentState state) {
this.state = state;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Component component = (Component) o;
return Objects.equals(this.name, component.name)
&& Objects.equals(this.dependencies, component.dependencies)
&& Objects.equals(this.readinessCheck, component.readinessCheck)
&& Objects.equals(this.artifact, component.artifact)
&& Objects.equals(this.launchCommand, component.launchCommand)
&& Objects.equals(this.resource, component.resource)
&& Objects.equals(this.numberOfContainers, component.numberOfContainers)
&& Objects.equals(this.runPrivilegedContainer,
component.runPrivilegedContainer)
&& Objects.equals(this.placementPolicy, component.placementPolicy)
&& Objects.equals(this.configuration, component.configuration)
&& Objects.equals(this.quicklinks, component.quicklinks)
&& Objects.equals(this.state, component.state);
}
@Override
public int hashCode() {
return Objects.hash(name, dependencies, readinessCheck, artifact,
launchCommand, resource, numberOfContainers,
runPrivilegedContainer, placementPolicy, configuration, quicklinks, state);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Component {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" state: ").append(toIndentedString(state)).append("\n");
sb.append(" dependencies: ").append(toIndentedString(dependencies))
.append("\n");
sb.append(" readinessCheck: ").append(toIndentedString(readinessCheck))
.append("\n");
sb.append(" artifact: ").append(toIndentedString(artifact)).append("\n");
sb.append(" launchCommand: ").append(toIndentedString(launchCommand))
.append("\n");
sb.append(" resource: ").append(toIndentedString(resource)).append("\n");
sb.append(" numberOfContainers: ")
.append(toIndentedString(numberOfContainers)).append("\n");
sb.append(" containers: ").append(toIndentedString(containers))
.append("\n");
sb.append(" runPrivilegedContainer: ")
.append(toIndentedString(runPrivilegedContainer)).append("\n");
sb.append(" placementPolicy: ").append(toIndentedString(placementPolicy))
.append("\n");
sb.append(" configuration: ").append(toIndentedString(configuration))
.append("\n");
sb.append(" quicklinks: ").append(toIndentedString(quicklinks))
.append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
/**
* Merge from another component into this component without overwriting.
*/
public void mergeFrom(Component that) {
if (this.getArtifact() == null) {
this.setArtifact(that.getArtifact());
}
if (this.getResource() == null) {
this.setResource(that.getResource());
}
if (this.getNumberOfContainers() == null) {
this.setNumberOfContainers(that.getNumberOfContainers());
}
if (this.getLaunchCommand() == null) {
this.setLaunchCommand(that.getLaunchCommand());
}
this.getConfiguration().mergeFrom(that.getConfiguration());
if (this.getQuicklinks() == null) {
this.setQuicklinks(that.getQuicklinks());
}
if (this.getRunPrivilegedContainer() == null) {
this.setRunPrivilegedContainer(that.getRunPrivilegedContainer());
}
if (this.getDependencies() == null) {
this.setDependencies(that.getDependencies());
}
if (this.getPlacementPolicy() == null) {
this.setPlacementPolicy(that.getPlacementPolicy());
}
if (this.getReadinessCheck() == null) {
this.setReadinessCheck(that.getReadinessCheck());
}
}
}