|
17 | 17 | ## - era-dependent defaults for the aforementioned sections:
|
18 | 18 | ## - profiles/defaults.jq
|
19 | 19 | ##
|
20 |
| -## - overlaid with generated profile variants + ad-hoc profiles: |
21 |
| -## - profiles/variants.jq and profiles/adhoc.jq |
| 20 | +## - overlaid with generated profile variants (including adhoc profiles): |
| 21 | +## - profiles/variants.jq |
22 | 22 | ##
|
23 | 23 | ## - each then further overlaid with derived parameters, computed from the above:
|
24 | 24 | ## - profiles/derived.jq
|
|
58 | 58 | ## ..which simply calls ./profiles.nix with {} params.
|
59 | 59 | ##
|
60 | 60 |
|
61 |
| -include "topology"; |
62 |
| -include "defaults"; |
63 |
| -include "adhoc"; |
64 |
| -include "variants"; |
65 |
| -include "derived"; |
| 61 | +include "prof0-defaults"; |
| 62 | +include "prof1-variants"; |
| 63 | +include "prof2-derived"; |
66 | 64 |
|
67 |
| -def compute_profiles($era; $mcompo; $topo; $extra_profiles): |
| 65 | +## |
| 66 | +## This is the workbench's entry point for everything profile. |
| 67 | +## |
| 68 | +## generate_all_era_profiles :: Era -> Maybe Composition -> Topology -> Map Name Profile |
| 69 | +## |
| 70 | +def generate_all_era_profiles($era; $mcompo; $topo): |
68 | 71 | ($mcompo // topology_composition($topo // {}) // {}) as $compo
|
69 | 72 |
|
70 |
| - ## Profiles are variants + custom (or aux) profiles: |
71 |
| - | all_profile_variants + adhoc_profiles + $extra_profiles |
72 |
| - | map (## Each profile extends defaults: |
| 73 | + | all_profile_variants |
| 74 | + | map (## Each profile is defined as extension of defaults: |
73 | 75 | era_defaults($era) * .
|
74 | 76 |
|
75 |
| - ## Profiles can define their own cluster composition. |
| 77 | + ## Profiles define their own cluster composition: |
76 | 78 | | . * { composition: (.composition // $compo) }
|
77 | 79 |
|
78 |
| - ## Compute the derived params. |
| 80 | + ## Finally, compute the derived ("computed") params. |
79 | 81 | | add_derived_params
|
80 | 82 | );
|
81 |
| - |
82 |
| -def profiles($era; $mcompo; $topo; $extra_profiles): |
83 |
| - compute_profiles($era; $mcompo; $topo; $extra_profiles) |
84 | 83 | | map (## Assemble into a dictionary..
|
85 | 84 | { "\(.name)": .
|
86 | 85 | })
|
87 | 86 | | add;
|
88 | 87 |
|
89 |
| -def profile_names($era; $mcompo; $topo; $extra_profiles): |
90 |
| - compute_profiles($era; $mcompo; $topo; $extra_profiles) |
91 |
| - | map (.name); |
92 | 88 |
|
93 |
| -def has_profile($era; $mcompo; $topo; $extra_profiles; $name): |
94 |
| - compute_profiles($era; $mcompo; $topo; $extra_profiles) |
95 |
| - | map (.name == $name) |
96 |
| - | any; |
| 89 | +## Cluster composition is an extract from the topology, |
| 90 | +## that classifies nodes into BFT, regular pools and dense pools, |
| 91 | +## based on the 'pools' field. |
| 92 | +## |
| 93 | +## Testable with: |
| 94 | +## |
| 95 | +## jq -n 'include "composition" { search: "nix/workbench/profiles" }; topology_composition({ coreNodes: { bft1: { pools: 0 } } })' |
| 96 | +## |
| 97 | +def topology_composition($topo): |
| 98 | + $topo |
| 99 | + | (.Producers // .coreNodes // {}) |
| 100 | + | to_entries |
| 101 | + | map (.value.pools // 0) |
| 102 | + | length as $n_hosts |
| 103 | + | map (select (. == 0)) as $bfts |
| 104 | + | map (select (. != 0)) as $pools |
| 105 | + | ($pools | map (select (. == 1))) as $singular_pools |
| 106 | + | ($pools | map (select (. > 1))) as $dense_pools |
| 107 | + | ($singular_pools | length) as $n_singular_hosts |
| 108 | + | { n_bft_hosts: ($bfts | length) |
| 109 | + , n_singular_hosts: ($singular_pools | length) |
| 110 | + , n_dense_hosts: ($dense_pools | length) |
| 111 | + }; |
0 commit comments