From 0a78220415f590da91e4710d38c52c42a0f7572c Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Thu, 11 Mar 2021 17:41:14 +0100 Subject: Don't store full bundle objects in cluster state history Bundles have a lot of sub-objects per state, so in systems with a high amount of node entries, this adds unnecessary pressure on the heap. Instead, store the string representations of the bundle and the string representation of the diff to the previous state version (if any). This is also inherently faster than computing the diffs on-demand on every status page render. Also remove mutable `official` field from `ClusterState`. Not worth violating immutability of an object just to get some prettier (but with high likelihood actually more confusing) status page rendering. --- .../main/java/com/yahoo/vdslib/state/ClusterState.java | 16 ---------------- .../com/yahoo/vdslib/state/ClusterStateTestCase.java | 8 +++----- 2 files changed, 3 insertions(+), 21 deletions(-) (limited to 'vdslib') diff --git a/vdslib/src/main/java/com/yahoo/vdslib/state/ClusterState.java b/vdslib/src/main/java/com/yahoo/vdslib/state/ClusterState.java index b13b6230d3e..c536fc0f4cd 100644 --- a/vdslib/src/main/java/com/yahoo/vdslib/state/ClusterState.java +++ b/vdslib/src/main/java/com/yahoo/vdslib/state/ClusterState.java @@ -30,7 +30,6 @@ public class ClusterState implements Cloneable { private String description = ""; private int distributionBits = 16; - private boolean official = false; public ClusterState(String serialized) throws ParseException { nodeCount.add(0); @@ -169,16 +168,6 @@ public class ClusterState implements Cloneable { : DEFAULT_DISTRIBUTOR_UP_NODE_STATE; } - /** - * Fleet controller marks states that are actually sent out to nodes as official states. Only fleetcontroller - * should set this to official, and only just before sending it out. This state is currently not serialized with - * the system state, but only used internally in the fleetcontroller. Might be useful client side though, where - * clients modify states to mark nodes down that they cannot speak with. - */ - public void setOfficial(boolean official) { this.official = official; } - /** Whether this system state is an unmodified version of an official system state. */ - public boolean isOfficial() { return official; } - /** Used during deserialization */ private class NodeData { @@ -202,7 +191,6 @@ public class ClusterState implements Cloneable { } private void deserialize(String serialized) throws ParseException { - official = false; StringTokenizer st = new StringTokenizer(serialized, " \t\n\f\r", false); NodeData nodeData = new NodeData(); String lastAbsolutePath = ""; @@ -323,9 +311,6 @@ public class ClusterState implements Cloneable { if (distributionBits != other.distributionBits) { diff.add(new Diff.Entry("bits", distributionBits, other.distributionBits)); } - if (official != other.official) { - diff.add(new Diff.Entry("official", official, other.official)); - } for (NodeType type : NodeType.getTypes()) { Diff typeDiff = new Diff(); int maxCount = Math.max(getNodeCount(type), other.getNodeCount(type)); @@ -348,7 +333,6 @@ public class ClusterState implements Cloneable { } public void setVersion(int version) { - official = false; this.version = version; } diff --git a/vdslib/src/test/java/com/yahoo/vdslib/state/ClusterStateTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/state/ClusterStateTestCase.java index 258a79f5362..dbc8888cfda 100644 --- a/vdslib/src/test/java/com/yahoo/vdslib/state/ClusterStateTestCase.java +++ b/vdslib/src/test/java/com/yahoo/vdslib/state/ClusterStateTestCase.java @@ -188,9 +188,8 @@ public class ClusterStateTestCase{ state2.setDistributionBits(21); state1.setVersion(123); state1.setNodeState(new Node(NodeType.STORAGE, 2), new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.2f).setDescription("Booting")); - state2.setOfficial(true); - assertEquals("version: 123 => 0, bits: 16 => 21, official: false => true, storage: [2: [Initializing => Up, description: Booting => ], 4: Down => Up, 5: Down => Up], distributor: [7: Up => Down, 8: Up => Down]", state1.getTextualDifference(state2)); + assertEquals("version: 123 => 0, bits: 16 => 21, storage: [2: [Initializing => Up, description: Booting => ], 4: Down => Up, 5: Down => Up], distributor: [7: Up => Down, 8: Up => Down]", state1.getTextualDifference(state2)); } @Test @@ -221,9 +220,8 @@ public class ClusterStateTestCase{ state1.setVersion(123); state1.setNodeState(new Node(NodeType.STORAGE, 2), new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.2f).setDescription("Booting")); state2.setDistributionBits(21); - state2.setOfficial(true); - assertEquals("version: 123 => 0, bits: 16 => 21, official: false => true, storage: [2: [Initializing => Up, description: Booting => ], 4: Down => Up, 5: Down => Up], distributor: [7: Up => Down, 8: Up => Down]", state1.getTextualDifference(state2)); - assertEquals("version: 123 => 0, bits: 16 => 21, official: false => true, storage: [
\n" + + assertEquals("version: 123 => 0, bits: 16 => 21, storage: [2: [Initializing => Up, description: Booting => ], 4: Down => Up, 5: Down => Up], distributor: [7: Up => Down, 8: Up => Down]", state1.getTextualDifference(state2)); + assertEquals("version: 123 => 0, bits: 16 => 21, storage: [
\n" + " 2: [Initializing => Up, description: Booting => ],
\n" + " 4: Down => Up,
\n" + " 5: Down => Up
\n" + -- cgit v1.2.3