blob: d5831efdbaa759a454e90721e7d788fd5b88e790 (
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
|
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision.zone;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* This class declares the order to use when upgrading zones in a system.
*
* @author mpolden
*/
public class UpgradePolicy {
private final List<List<ZoneId>> zones;
private UpgradePolicy(List<List<ZoneId>> zones) {
this.zones = zones;
}
public List<List<ZoneId>> asList() {
return Collections.unmodifiableList(zones);
}
private UpgradePolicy with(ZoneId... zone) {
List<List<ZoneId>> zones = new ArrayList<>(this.zones);
zones.add(Arrays.asList(zone));
return new UpgradePolicy(zones);
}
/** Upgrade given zone as the next step */
public UpgradePolicy upgrade(ZoneId zone) {
return with(zone);
}
/** Upgrade given zones in parallel as the next step */
public UpgradePolicy upgradeInParallel(ZoneId... zone) {
return with(zone);
}
public static UpgradePolicy create() {
return new UpgradePolicy(Collections.emptyList());
}
}
|