diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-03-15 12:55:42 +0100 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-03-15 13:23:53 +0100 |
commit | 1b959abd3224c00f0347a8078dc333abfdd3ce9f (patch) | |
tree | 48ec988c4e337a0a7dbfcd54d6406ac47364f329 /clustercontroller-core | |
parent | 1c8c0c815f872347c2ed85e997fbede3e29f3686 (diff) |
Print deferred activation flag in `ClusterStateBundle.toString`
Diffstat (limited to 'clustercontroller-core')
2 files changed, 36 insertions, 4 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundle.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundle.java index ca50701b763..7e9a4ed6fca 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundle.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundle.java @@ -175,12 +175,14 @@ public class ClusterStateBundle { @Override public String toString() { if (derivedBucketSpaceStates.isEmpty()) { - return String.format("ClusterStateBundle('%s')", baselineState); + return String.format("ClusterStateBundle('%s'%s)", baselineState, + deferredActivation ? " (deferred activation)" : ""); } Map<String, AnnotatedClusterState> orderedStates = new TreeMap<>(derivedBucketSpaceStates); - return String.format("ClusterStateBundle('%s', %s)", baselineState, orderedStates.entrySet().stream() + return String.format("ClusterStateBundle('%s', %s%s)", baselineState, orderedStates.entrySet().stream() .map(e -> String.format("%s '%s'", e.getKey(), e.getValue())) - .collect(Collectors.joining(", "))); + .collect(Collectors.joining(", ")), + deferredActivation ? " (deferred activation)" : ""); } @Override diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java index e10694d553f..db9c8b4dd73 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java @@ -90,7 +90,7 @@ public class ClusterStateBundleTest { public void toString_without_bucket_space_states_prints_only_baseline_state() { ClusterStateBundle bundle = ClusterStateBundle.ofBaselineOnly( annotatedStateOf("distributor:2 storage:2")); - assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2')")); + assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2' (deferred activation))")); } @Test @@ -99,6 +99,36 @@ public class ClusterStateBundleTest { assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2', " + "default 'distributor:2 storage:2 .0.s:d', " + "global 'distributor:2 storage:2', " + + "narnia 'distributor:2 .0.s:d storage:2' (deferred activation))")); + } + + @Test + public void toString_without_derived_states_specifies_deferred_activation_iff_set() { + var bundle = ClusterStateBundle.ofBaselineOnly(annotatedStateOf("distributor:2 storage:2"), true); + assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2' (deferred activation))")); + } + + @Test + public void toString_without_derived_states_does_not_specify_deferred_activation_iff_not_set() { + var bundle = ClusterStateBundle.ofBaselineOnly(annotatedStateOf("distributor:2 storage:2"), false); + assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2')")); + } + + @Test + public void toString_with_derived_states_specifies_deferred_activation_iff_set() { + var bundle = createTestBundleBuilder(true).deferredActivation(true).deriveAndBuild(); + assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2', " + + "default 'distributor:2 storage:2 .0.s:d', " + + "global 'distributor:2 storage:2', " + + "narnia 'distributor:2 .0.s:d storage:2' (deferred activation))")); + } + + @Test + public void toString_with_derived_states_does_not_specify_deferred_activation_iff_not_set() { + var bundle = createTestBundleBuilder(true).deferredActivation(false).deriveAndBuild(); + assertThat(bundle.toString(), equalTo("ClusterStateBundle('distributor:2 storage:2', " + + "default 'distributor:2 storage:2 .0.s:d', " + + "global 'distributor:2 storage:2', " + "narnia 'distributor:2 .0.s:d storage:2')")); } |