aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java
blob: f4706fca27c141fa8fcc7d9ce0cc4adf4e79092c (plain) (blame)
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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.configserver;

import com.yahoo.component.Version;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.CloudAccount;
import com.yahoo.config.provision.DockerImage;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.NodeResources;
import com.yahoo.config.provision.NodeType;
import com.yahoo.config.provision.TenantName;

import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;

/**
 * A node in hosted Vespa.
 *
 * This is immutable and all fields are guaranteed to be non-null. This should never leak any wire format types or
 * types from third-party libraries.
 *
 * Use {@link Node#builder()} or {@link Node#builder(Node)} to create instances of this.
 *
 * @author mpolden
 * @author jonmv
 */
public class Node {

    private final String id;
    private final HostName hostname;
    private final Optional<HostName> parentHostname;
    private final State state;
    private final NodeType type;
    private final NodeResources resources;
    private final Optional<ApplicationId> owner;
    private final Version currentVersion;
    private final Version wantedVersion;
    private final Version currentOsVersion;
    private final Version wantedOsVersion;
    private final boolean deferOsUpgrade;
    private final DockerImage currentDockerImage;
    private final DockerImage wantedDockerImage;
    private final ServiceState serviceState;
    private final Optional<Instant> suspendedSince;
    private final Optional<Instant> currentFirmwareCheck;
    private final Optional<Instant> wantedFirmwareCheck;
    private final long restartGeneration;
    private final long wantedRestartGeneration;
    private final long rebootGeneration;
    private final long wantedRebootGeneration;
    private final int cost;
    private final int failCount;
    private final Optional<String> flavor;
    private final String clusterId;
    private final ClusterType clusterType;
    private final String group;
    private final int index;
    private final boolean retired;
    private final boolean wantToRetire;
    private final boolean wantToDeprovision;
    private final boolean wantToRebuild;
    private final boolean down;
    private final Optional<TenantName> reservedTo;
    private final Optional<ApplicationId> exclusiveTo;
    private final Optional<ClusterType> exclusiveToClusterType;
    private final Map<String, String> reports;
    private final List<Event> history;
    private final List<String> ipAddresses;
    private final List<String> additionalIpAddresses;
    private final List<String> additionalHostnames;
    private final Optional<String> switchHostname;
    private final Optional<String> modelName;
    private final Environment environment;
    private final CloudAccount cloudAccount;

    private Node(String id, HostName hostname, Optional<HostName> parentHostname, State state, NodeType type,
                 NodeResources resources, Optional<ApplicationId> owner, Version currentVersion, Version wantedVersion,
                 Version currentOsVersion, Version wantedOsVersion, boolean deferOsUpgrade, Optional<Instant> currentFirmwareCheck,
                 Optional<Instant> wantedFirmwareCheck, ServiceState serviceState, Optional<Instant> suspendedSince,
                 long restartGeneration, long wantedRestartGeneration, long rebootGeneration,
                 long wantedRebootGeneration, int cost, int failCount, Optional<String> flavor, String clusterId,
                 ClusterType clusterType, String group, int index, boolean retired, boolean wantToRetire, boolean wantToDeprovision,
                 boolean wantToRebuild, boolean down, Optional<TenantName> reservedTo, Optional<ApplicationId> exclusiveTo,
                 DockerImage wantedDockerImage, DockerImage currentDockerImage, Optional<ClusterType> exclusiveToClusterType, Map<String, String> reports,
                 List<Event> history, List<String> ipAddresses, List<String> additionalIpAddresses,
                 List<String> additionalHostnames, Optional<String> switchHostname,
                 Optional<String> modelName, Environment environment, CloudAccount cloudAccount) {
        this.id = Objects.requireNonNull(id, "id must be non-null");
        this.hostname = Objects.requireNonNull(hostname, "hostname must be non-null");
        this.parentHostname = Objects.requireNonNull(parentHostname, "parentHostname must be non-null");
        this.state = Objects.requireNonNull(state, "state must be non-null");
        this.type = Objects.requireNonNull(type, "type must be non-null");
        this.resources = Objects.requireNonNull(resources, "resources must be non-null");
        this.owner = Objects.requireNonNull(owner, "owner must be non-null");
        this.currentVersion = Objects.requireNonNull(currentVersion, "currentVersion must be non-null");
        this.wantedVersion = Objects.requireNonNull(wantedVersion, "wantedVersion must be non-null");
        this.currentOsVersion = Objects.requireNonNull(currentOsVersion, "currentOsVersion must be non-null");
        this.wantedOsVersion = Objects.requireNonNull(wantedOsVersion, "wantedOsVersion must be non-null");
        this.deferOsUpgrade = deferOsUpgrade;
        this.currentFirmwareCheck = Objects.requireNonNull(currentFirmwareCheck, "currentFirmwareCheck must be non-null");
        this.wantedFirmwareCheck = Objects.requireNonNull(wantedFirmwareCheck, "wantedFirmwareCheck must be non-null");
        this.serviceState = Objects.requireNonNull(serviceState, "serviceState must be non-null");
        this.suspendedSince = Objects.requireNonNull(suspendedSince, "suspendedSince must be non-null");
        this.restartGeneration = restartGeneration;
        this.wantedRestartGeneration = wantedRestartGeneration;
        this.rebootGeneration = rebootGeneration;
        this.wantedRebootGeneration = wantedRebootGeneration;
        this.cost = cost;
        this.failCount = failCount;
        this.flavor = Objects.requireNonNull(flavor, "flavor must be non-null");
        this.clusterId = Objects.requireNonNull(clusterId, "clusterId must be non-null");
        this.clusterType = Objects.requireNonNull(clusterType, "clusterType must be non-null");
        this.retired = retired;
        this.group = Objects.requireNonNull(group, "group must be non-null");
        this.index = index;
        this.wantToRetire = wantToRetire;
        this.wantToDeprovision = wantToDeprovision;
        this.reservedTo = Objects.requireNonNull(reservedTo, "reservedTo must be non-null");
        this.exclusiveToClusterType = Objects.requireNonNull(exclusiveToClusterType, "exclusiveToClusterType");
        this.exclusiveTo = Objects.requireNonNull(exclusiveTo, "exclusiveTo must be non-null");
        this.wantedDockerImage = Objects.requireNonNull(wantedDockerImage, "wantedDockerImage must be non-null");
        this.currentDockerImage = Objects.requireNonNull(currentDockerImage, "currentDockerImage must be non-null");
        this.wantToRebuild = wantToRebuild;
        this.down = down;
        this.reports = Map.copyOf(Objects.requireNonNull(reports, "reports must be non-null"));
        this.history = List.copyOf(Objects.requireNonNull(history, "history must be non-null"));
        this.ipAddresses = List.copyOf(Objects.requireNonNull(ipAddresses, "ipAddresses must be non-null"));
        this.additionalIpAddresses = List.copyOf(Objects.requireNonNull(additionalIpAddresses, "additionalIpAddresses must be non-null"));
        this.additionalHostnames = List.copyOf(Objects.requireNonNull(additionalHostnames, "additionalHostnames must be non-null"));
        this.switchHostname = Objects.requireNonNull(switchHostname, "switchHostname must be non-null");
        this.modelName = Objects.requireNonNull(modelName, "modelName must be non-null");
        this.environment = Objects.requireNonNull(environment, "environment must be non-ull");
        this.cloudAccount = Objects.requireNonNull(cloudAccount, "cloudAccount must be non-null");
    }

    /** The cloud provider's unique ID for this */
    public String id() {
        return id;
    }

    /** The hostname of this */
    public HostName hostname() {
        return hostname;
    }

    /** The parent hostname of this, if any */
    public Optional<HostName> parentHostname() {
        return parentHostname;
    }

    /** Current state of this */
    public State state() { return state; }

    /** The node type of this */
    public NodeType type() {
        return type;
    }

    /** Resources, such as CPU and memory, of this */
    public NodeResources resources() {
        return resources;
    }

    /** The application owning this, if any */
    public Optional<ApplicationId> owner() {
        return owner;
    }

    /** The Vespa version this is currently running */
    public Version currentVersion() {
        return currentVersion;
    }

    /** The wanted Vespa version */
    public Version wantedVersion() {
        return wantedVersion;
    }

    /** The OS version this is currently running */
    public Version currentOsVersion() {
        return currentOsVersion;
    }

    /** The wanted OS version */
    public Version wantedOsVersion() {
        return wantedOsVersion;
    }

    /** Returns whether the node is currently deferring any OS upgrade */
    public boolean deferOsUpgrade() {
        return deferOsUpgrade;
    }

    /** The container image of this is currently running */
    public DockerImage currentDockerImage() {
        return currentDockerImage;
    }

    /** The wanted Docker image */
    public DockerImage wantedDockerImage() {
        return wantedDockerImage;
    }

    /** The last time this checked for a firmware update */
    public Optional<Instant> currentFirmwareCheck() {
        return currentFirmwareCheck;
    }

    /** The wanted time this should check for a firmware update */
    public Optional<Instant> wantedFirmwareCheck() {
        return wantedFirmwareCheck;
    }

    /** The current service state of this */
    public ServiceState serviceState() {
        return serviceState;
    }

    /** The most recent time this suspended, if any */
    public Optional<Instant> suspendedSince() {
        return suspendedSince;
    }

    /** The current restart generation */
    public long restartGeneration() {
        return restartGeneration;
    }

    /** The wanted restart generation */
    public long wantedRestartGeneration() {
        return wantedRestartGeneration;
    }

    /** The current reboot generation */
    public long rebootGeneration() {
        return rebootGeneration;
    }

    /** The wanted reboot generation */
    public long wantedRebootGeneration() {
        return wantedRebootGeneration;
    }

    /** A number representing the cost of this */
    public int cost() {
        return cost;
    }

    /** How many times this has failed */
    public int failCount() {
        return failCount;
    }

    /** The flavor of this */
    public Optional<String> flavor() {
        return flavor;
    }

    /** The cluster ID of this, empty string if unallocated */
    public String clusterId() {
        return clusterId;
    }

    /** The cluster type of this */
    public ClusterType clusterType() {
        return clusterType;
    }

    /** Whether this is retired */
    public boolean retired() {
        return retired;
    }

    /** The group of this node, empty string if unallocated */
    public String group() { return group; }

    /** The membership index of this node */
    public int index() { return index; }

    /** Whether this node has been requested to retire */
    public boolean wantToRetire() {
        return wantToRetire;
    }

    /** Whether this node has been requested to deprovision */
    public boolean wantToDeprovision() {
        return wantToDeprovision;
    }

    /** Whether this node has been requested to rebuild */
    public boolean wantToRebuild() {
        return wantToRebuild;
    }

    /** Whether this node is currently down */
    public boolean down() { return down; }

    /** The tenant this has been reserved to, if any */
    public Optional<TenantName> reservedTo() { return reservedTo; }

    /** The application this has been provisioned exclusively for, if any */
    public Optional<ApplicationId> exclusiveTo() { return exclusiveTo; }

    /** The cluster type this has been provisioned exclusively for, if any */
    public Optional<ClusterType> exclusiveToClusterType() { return exclusiveToClusterType; }

    /** Returns the reports of this node. Key is the report ID. Value is untyped, but is typically a JSON string */
    public Map<String, String> reports() {
        return reports;
    }

    /** History of events affecting this */
    public List<Event> history() {
        return history;
    }

    /** IP addresses of this */
    public List<String> ipAddresses() {
        return ipAddresses;
    }

    /** Additional IP addresses available on this, usable by child nodes */
    public List<String> additionalIpAddresses() {
        return additionalIpAddresses;
    }

    /** Additional hostnames available on this, usable by child nodes */
    public List<String> additionalHostnames() {
        return additionalHostnames;
    }

    /** Hostname of the switch this is connected to, if any */
    public Optional<String> switchHostname() {
        return switchHostname;
    }

    /** The server model of this, if any */
    public Optional<String> modelName() { return modelName; }

    /** The environment this runs in */
    public Environment environment() {
        return environment;
    }

    public CloudAccount cloudAccount() {
        return cloudAccount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Node node = (Node) o;
        return Objects.equals(hostname, node.hostname);
    }

    @Override
    public int hashCode() {
        return Objects.hash(hostname);
    }

    /** Known node states */
    public enum State {
        provisioned,
        ready,
        reserved,
        active,
        inactive,
        dirty,
        failed,
        parked,
        breakfixed,
        deprovisioned,
        unknown
    }

    /** Known node states with regards to service orchestration */
    public enum ServiceState {
        expectedUp,
        allowedDown,
        permanentlyDown,
        unorchestrated,
        unknown
    }

    /** Known cluster types. */
    public enum ClusterType {
        admin,
        container,
        content,
        combined,
        unknown
    }

    /** Known nope environments */
    public enum Environment {
        bareMetal,
        virtualMachine,
        dockerContainer,
        unknown,
    }

    /** A node event */
    public static class Event {

        private final Instant at;
        private final String agent;
        private final String name;

        public Event(Instant at, String agent, String name) {
            this.at = Objects.requireNonNull(at);
            this.agent = Objects.requireNonNull(agent);
            this.name = Objects.requireNonNull(name);
        }

        /** The time this occurred */
        public Instant at() {
            return at;
        }

        /** The agent responsible for this */
        public String agent() {
            return agent;
        }

        /** Name of the event */
        public String name() {
            return name;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Event event = (Event) o;
            return at.equals(event.at) && agent.equals(event.agent) && name.equals(event.name);
        }

        @Override
        public int hashCode() {
            return Objects.hash(at, agent, name);
        }
    }

    public static Builder builder() {
        return new Builder();
    }

    public static Builder builder(Node node) {
        return new Builder(node);
    }

    /**
     * Builder for a {@link Node}.
     *
     * The appropriate builder method must be called for any field that does not have a default value.
     */
    public static class Builder {

        private HostName hostname;

        private String id = UUID.randomUUID().toString();
        private Optional<HostName> parentHostname = Optional.empty();
        private State state = State.active;
        private NodeType type = NodeType.host;
        private NodeResources resources = NodeResources.unspecified();
        private Optional<ApplicationId> owner = Optional.empty();
        private Version currentVersion = Version.emptyVersion;
        private Version wantedVersion = Version.emptyVersion;
        private Version currentOsVersion = Version.emptyVersion;
        private Version wantedOsVersion = Version.emptyVersion;
        private boolean deferOsUpgrade = false;
        private DockerImage currentDockerImage = DockerImage.EMPTY;
        private DockerImage wantedDockerImage = DockerImage.EMPTY;
        private Optional<Instant> currentFirmwareCheck = Optional.empty();
        private Optional<Instant> wantedFirmwareCheck = Optional.empty();
        private ServiceState serviceState = ServiceState.expectedUp;
        private Optional<Instant> suspendedSince = Optional.empty();
        private long restartGeneration = 0;
        private long wantedRestartGeneration = 0;
        private long rebootGeneration = 0;
        private long wantedRebootGeneration = 0;
        private int cost = 0;
        private int failCount = 0;
        private Optional<String> flavor = Optional.empty();
        private String clusterId = "";
        private ClusterType clusterType = ClusterType.unknown;
        private String group = "";
        private int index = 0;
        private boolean retired = false;
        private boolean wantToRetire = false;
        private boolean wantToDeprovision = false;
        private boolean wantToRebuild = false;
        private boolean down = false;
        private Optional<TenantName> reservedTo = Optional.empty();
        private Optional<ApplicationId> exclusiveTo = Optional.empty();
        private Optional<ClusterType> exclusiveToClusterType = Optional.empty();
        private Map<String, String> reports = Map.of();
        private List<Event> history = List.of();
        private List<String> ipAddresses = List.of();
        private List<String> additionalIpAddresses = List.of();
        private List<String> additionalHostnames = List.of();
        private Optional<String> switchHostname = Optional.empty();
        private Optional<String> modelName = Optional.empty();
        private Environment environment = Environment.unknown;
        private CloudAccount cloudAccount = CloudAccount.empty;

        private Builder() {}

        private Builder(Node node) {
            this.id = node.id;
            this.hostname = node.hostname;
            this.parentHostname = node.parentHostname;
            this.state = node.state;
            this.type = node.type;
            this.resources = node.resources;
            this.owner = node.owner;
            this.currentVersion = node.currentVersion;
            this.wantedVersion = node.wantedVersion;
            this.currentOsVersion = node.currentOsVersion;
            this.wantedOsVersion = node.wantedOsVersion;
            this.deferOsUpgrade = node.deferOsUpgrade;
            this.currentDockerImage = node.currentDockerImage;
            this.wantedDockerImage = node.wantedDockerImage;
            this.serviceState = node.serviceState;
            this.suspendedSince = node.suspendedSince;
            this.currentFirmwareCheck = node.currentFirmwareCheck;
            this.wantedFirmwareCheck = node.wantedFirmwareCheck;
            this.restartGeneration = node.restartGeneration;
            this.wantedRestartGeneration = node.wantedRestartGeneration;
            this.rebootGeneration = node.rebootGeneration;
            this.wantedRebootGeneration = node.wantedRebootGeneration;
            this.cost = node.cost;
            this.failCount = node.failCount;
            this.flavor = node.flavor;
            this.clusterId = node.clusterId;
            this.clusterType = node.clusterType;
            this.group = node.group;
            this.index = node.index;
            this.retired = node.retired;
            this.wantToRetire = node.wantToRetire;
            this.wantToDeprovision = node.wantToDeprovision;
            this.wantToRebuild = node.wantToRebuild;
            this.down = node.down;
            this.reservedTo = node.reservedTo;
            this.exclusiveTo = node.exclusiveTo;
            this.exclusiveToClusterType = node.exclusiveToClusterType;
            this.reports = node.reports;
            this.history = node.history;
            this.ipAddresses = node.ipAddresses;
            this.additionalIpAddresses = node.additionalIpAddresses;
            this.additionalHostnames = node.additionalHostnames;
            this.switchHostname = node.switchHostname;
            this.modelName = node.modelName;
            this.environment = node.environment;
        }

        public Builder id(String id) {
            this.id = id;
            return this;
        }

        public Builder hostname(String hostname) {
            return hostname(HostName.of(hostname));
        }

        public Builder hostname(HostName hostname) {
            this.hostname = hostname;
            return this;
        }

        public Builder parentHostname(String parentHostname) {
            return parentHostname(HostName.of(parentHostname));
        }

        public Builder parentHostname(HostName parentHostname) {
            this.parentHostname = Optional.ofNullable(parentHostname);
            return this;
        }

        public Builder state(State state) {
            this.state = state;
            return this;
        }

        public Builder type(NodeType type) {
            this.type = type;
            return this;
        }

        public Builder resources(NodeResources resources) {
            this.resources = resources;
            return this;
        }

        public Builder owner(ApplicationId owner) {
            this.owner = Optional.ofNullable(owner);
            return this;
        }

        public Builder currentVersion(Version currentVersion) {
            this.currentVersion = currentVersion;
            return this;
        }

        public Builder wantedVersion(Version wantedVersion) {
            this.wantedVersion = wantedVersion;
            return this;
        }

        public Builder currentOsVersion(Version currentOsVersion) {
            this.currentOsVersion = currentOsVersion;
            return this;
        }

        public Builder wantedOsVersion(Version wantedOsVersion) {
            this.wantedOsVersion = wantedOsVersion;
            return this;
        }

        public Builder deferOsUpgrade(boolean deferOsUpgrade) {
            this.deferOsUpgrade = deferOsUpgrade;
            return this;
        }

        public Builder currentDockerImage(DockerImage currentDockerImage) {
            this.currentDockerImage = currentDockerImage;
            return this;
        }

        public Builder wantedDockerImage(DockerImage wantedDockerImage) {
            this.wantedDockerImage = wantedDockerImage;
            return this;
        }

        public Builder currentFirmwareCheck(Instant currentFirmwareCheck) {
            this.currentFirmwareCheck = Optional.ofNullable(currentFirmwareCheck);
            return this;
        }

        public Builder wantedFirmwareCheck(Instant wantedFirmwareCheck) {
            this.wantedFirmwareCheck = Optional.ofNullable(wantedFirmwareCheck);
            return this;
        }

        public Builder serviceState(ServiceState serviceState) {
            this.serviceState = serviceState;
            return this;
        }

        public Builder suspendedSince(Instant suspendedSince) {
            this.suspendedSince = Optional.ofNullable(suspendedSince);
            return this;
        }

        public Builder restartGeneration(long restartGeneration) {
            this.restartGeneration = restartGeneration;
            return this;
        }

        public Builder wantedRestartGeneration(long wantedRestartGeneration) {
            this.wantedRestartGeneration = wantedRestartGeneration;
            return this;
        }

        public Builder rebootGeneration(long rebootGeneration) {
            this.rebootGeneration = rebootGeneration;
            return this;
        }

        public Builder wantedRebootGeneration(long wantedRebootGeneration) {
            this.wantedRebootGeneration = wantedRebootGeneration;
            return this;
        }

        public Builder cost(int cost) {
            this.cost = cost;
            return this;
        }

        public Builder failCount(int failCount) {
            this.failCount = failCount;
            return this;
        }

        public Builder flavor(String flavor) {
            this.flavor = Optional.of(flavor);
            return this;
        }

        public Builder clusterId(String clusterId) {
            this.clusterId = clusterId;
            return this;
        }

        public Builder clusterType(ClusterType clusterType) {
            this.clusterType = clusterType;
            return this;
        }

        public Builder group(String group) {
            this.group = group;
            return this;
        }

        public Builder index(int index) {
            this.index = index;
            return this;
        }

        public Builder retired(boolean retired) {
            this.retired = retired;
            return this;
        }

        public Builder wantToRetire(boolean wantToRetire) {
            this.wantToRetire = wantToRetire;
            return this;
        }

        public Builder wantToDeprovision(boolean wantToDeprovision) {
            this.wantToDeprovision = wantToDeprovision;
            return this;
        }

        public Builder wantToRebuild(boolean wantToRebuild) {
            this.wantToRebuild = wantToRebuild;
            return this;
        }

        public Builder down(boolean down) {
            this.down = down;
            return this;
        }

        public Builder reservedTo(TenantName tenant) {
            this.reservedTo = Optional.of(tenant);
            return this;
        }

        public Builder exclusiveTo(ApplicationId exclusiveTo) {
            this.exclusiveTo = Optional.of(exclusiveTo);
            return this;
        }

        public Builder exclusiveToClusterType(ClusterType exclusiveToClusterType) {
            this.exclusiveToClusterType = Optional.of(exclusiveToClusterType);
            return this;
        }

        public Builder history(List<Event> history) {
            this.history = history;
            return this;
        }

        public Builder ipAddresses(List<String> ipAdresses) {
            this.ipAddresses = ipAdresses;
            return this;
        }

        public Builder additionalIpAddresses(List<String> additionalIpAddresses) {
            this.additionalIpAddresses = additionalIpAddresses;
            return this;
        }

        public Builder additionalHostnames(List<String> additionalHostnames) {
            this.additionalHostnames = additionalHostnames;
            return this;
        }

        public Builder switchHostname(String switchHostname) {
            this.switchHostname = Optional.ofNullable(switchHostname);
            return this;
        }

        public Builder modelName(String modelName) {
            this.modelName = Optional.ofNullable(modelName);
            return this;
        }

        public Builder reports(Map<String, String> reports) {
            this.reports = reports;
            return this;
        }

        public Builder environment(Environment environment) {
            this.environment = environment;
            return this;
        }

        public Builder cloudAccount(CloudAccount cloudAccount) {
            this.cloudAccount = cloudAccount;
            return this;
        }

        public Node build() {
            return new Node(id, hostname, parentHostname, state, type, resources, owner, currentVersion, wantedVersion,
                            currentOsVersion, wantedOsVersion, deferOsUpgrade, currentFirmwareCheck, wantedFirmwareCheck, serviceState,
                            suspendedSince, restartGeneration, wantedRestartGeneration, rebootGeneration,
                            wantedRebootGeneration, cost, failCount, flavor, clusterId, clusterType, group, index, retired,
                            wantToRetire, wantToDeprovision, wantToRebuild, down, reservedTo, exclusiveTo, wantedDockerImage,
                            currentDockerImage, exclusiveToClusterType, reports, history, ipAddresses, additionalIpAddresses,
                            additionalHostnames, switchHostname, modelName, environment, cloudAccount);
        }

    }

}