aboutsummaryrefslogtreecommitdiffstats
path: root/vdslib/src
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-03-11 00:29:19 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2021-03-11 00:29:19 +0100
commit08e55ca8619e5da823b8fba0f9667abdcc0ee7d4 (patch)
treea902fded74f8f0783817bac04c8d35100bd989a0 /vdslib/src
parentf9b4a509c0acd9499fe885f5b71c771bef5300e7 (diff)
Shrink the size of the NodeState object by using float over double for initProgress and capacity. Also gc unused 'reliability' member.
Diffstat (limited to 'vdslib/src')
-rw-r--r--vdslib/src/main/java/com/yahoo/vdslib/state/NodeState.java17
-rw-r--r--vdslib/src/test/java/com/yahoo/vdslib/state/ClusterStateTestCase.java6
-rw-r--r--vdslib/src/test/java/com/yahoo/vdslib/state/NodeStateTestCase.java4
3 files changed, 13 insertions, 14 deletions
diff --git a/vdslib/src/main/java/com/yahoo/vdslib/state/NodeState.java b/vdslib/src/main/java/com/yahoo/vdslib/state/NodeState.java
index 373e3d0a4ba..d9778287b0e 100644
--- a/vdslib/src/main/java/com/yahoo/vdslib/state/NodeState.java
+++ b/vdslib/src/main/java/com/yahoo/vdslib/state/NodeState.java
@@ -21,18 +21,17 @@ public class NodeState implements Cloneable {
public static final String ORCHESTRATOR_RESERVED_DESCRIPTION = "Orchestrator";
private final NodeType type;
- private State state = State.UP;
+ private State state;
private String description = "";
- private double capacity = 1.0;
- private int reliability = 1;
- private double initProgress = 1.0;
+ private float capacity = 1.0f;
+ private float initProgress = 1.0f;
private int minUsedBits = 16;
private List<DiskState> diskStates = new ArrayList<>();
/** When generating ideal states, we want to cheaply check if any disks are down in the nodestate. */
private boolean anyDiskDown = false;
private long startTimestamp = 0;
- public static double getListingBucketsInitProgressLimit() { return 0.01; }
+ public static float getListingBucketsInitProgressLimit() { return 0.01f; }
public NodeState(NodeType type, State state) {
this.type = type;
@@ -199,9 +198,9 @@ public class NodeState implements Cloneable {
}
/** Capacity is set by deserializing a node state. This seems odd, as it is config */
- public NodeState setCapacity(double c) { this.capacity = c; return this; }
+ public NodeState setCapacity(float c) { this.capacity = c; return this; }
- public NodeState setInitProgress(double p) { this.initProgress = p; return this; }
+ public NodeState setInitProgress(float p) { this.initProgress = p; return this; }
public NodeState setDescription(String desc) { this.description = desc; return this; }
public NodeState setMinUsedBits(int u) { this.minUsedBits = u; return this; }
public NodeState setState(State state) { this.state = state; return this; }
@@ -397,7 +396,7 @@ public class NodeState implements Cloneable {
if (key.length() > 1) break;
if (type != null && !type.equals(NodeType.STORAGE)) break;
try{
- newState.setCapacity(Double.valueOf(value));
+ newState.setCapacity(Float.valueOf(value));
} catch (Exception e) {
throw new ParseException("Illegal capacity '" + value + "'. Capacity must be a positive floating point number", 0);
}
@@ -405,7 +404,7 @@ public class NodeState implements Cloneable {
case 'i':
if (key.length() > 1) break;
try{
- newState.setInitProgress(Double.valueOf(value));
+ newState.setInitProgress(Float.valueOf(value));
} catch (Exception e) {
throw new ParseException("Illegal init progress '" + value + "'. Init progress must be a floating point number from 0.0 to 1.0", 0);
}
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 9a8413b250a..cd0b1484748 100644
--- a/vdslib/src/test/java/com/yahoo/vdslib/state/ClusterStateTestCase.java
+++ b/vdslib/src/test/java/com/yahoo/vdslib/state/ClusterStateTestCase.java
@@ -34,7 +34,7 @@ public class ClusterStateTestCase{
public void testClone() throws ParseException {
ClusterState state = new ClusterState("");
state.setNodeState(new Node(NodeType.DISTRIBUTOR, 1), new NodeState(NodeType.DISTRIBUTOR, State.UP).setDescription("available"));
- state.setNodeState(new Node(NodeType.STORAGE, 0), new NodeState(NodeType.STORAGE, State.UP).setCapacity(1.2));
+ state.setNodeState(new Node(NodeType.STORAGE, 0), new NodeState(NodeType.STORAGE, State.UP).setCapacity(1.2f));
state.setNodeState(new Node(NodeType.STORAGE, 2), new NodeState(NodeType.STORAGE, State.UP).setDiskCount(2).setDiskState(1, new DiskState(State.DOWN)));
ClusterState other = state.clone();
assertEquals(state.toString(true), other.toString(true));
@@ -187,7 +187,7 @@ public class ClusterStateTestCase{
state2.setDistributionBits(21);
state1.setVersion(123);
- state1.setNodeState(new Node(NodeType.STORAGE, 2), new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.2).setDiskCount(2).setDescription("Booting"));
+ state1.setNodeState(new Node(NodeType.STORAGE, 2), new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.2f).setDiskCount(2).setDescription("Booting"));
state2.setOfficial(true);
assertEquals("version: 123 => 0, bits: 16 => 21, official: false => true, storage: [2: [Initializing => Up, disks: 2 => 0, description: Booting => ], 4: Down => Up, 5: Down => Up], distributor: [7: Up => Down, 8: Up => Down]", state1.getTextualDifference(state2));
@@ -219,7 +219,7 @@ public class ClusterStateTestCase{
"]", state2.getHtmlDifference(state3));
state1.setVersion(123);
- state1.setNodeState(new Node(NodeType.STORAGE, 2), new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.2).setDiskCount(2).setDescription("Booting"));
+ state1.setNodeState(new Node(NodeType.STORAGE, 2), new NodeState(NodeType.STORAGE, State.INITIALIZING).setInitProgress(0.2f).setDiskCount(2).setDescription("Booting"));
state2.setDistributionBits(21);
state2.setOfficial(true);
assertEquals("version: 123 => 0, bits: 16 => 21, official: false => true, storage: [2: [Initializing => Up, disks: 2 => 0, description: Booting => ], 4: Down => Up, 5: Down => Up], distributor: [7: Up => Down, 8: Up => Down]", state1.getTextualDifference(state2));
diff --git a/vdslib/src/test/java/com/yahoo/vdslib/state/NodeStateTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/state/NodeStateTestCase.java
index dbc5ad59edf..d2caac47d41 100644
--- a/vdslib/src/test/java/com/yahoo/vdslib/state/NodeStateTestCase.java
+++ b/vdslib/src/test/java/com/yahoo/vdslib/state/NodeStateTestCase.java
@@ -128,7 +128,7 @@ public class NodeStateTestCase {
assertEquals("m:Foo\\x20bar", ns.serialize(false));
assertEquals("m:Foo\\x20bar", ns.serialize(true));
- ns = new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Foo bar").setCapacity(1.2).setDiskCount(4)
+ ns = new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Foo bar").setCapacity(1.2f).setDiskCount(4)
.setMinUsedBits(12).setStartTimestamp(5).setDiskState(1, new DiskState(State.DOWN, "bad disk", 1))
.setDiskState(3, new DiskState(State.UP, "", 2));
assertEquals(".2.s:m .2.c:1.2 .2.t:5 .2.d:4 .2.d.1.s:d .2.d.3.c:2.0", ns.serialize(2, false));
@@ -204,7 +204,7 @@ public class NodeStateTestCase {
String expected = "Maintenance => Up";
assertEquals(expected, ns.getTextualDifference(new NodeState(NodeType.STORAGE, State.UP)).substring(0, expected.length()));
- NodeState ns1 = new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Foo bar").setCapacity(1.2).setDiskCount(4)
+ NodeState ns1 = new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Foo bar").setCapacity(1.2f).setDiskCount(4)
.setMinUsedBits(12).setStartTimestamp(5).setDiskState(1, new DiskState(State.DOWN, "bad disk", 1))
.setDiskState(3, new DiskState(State.UP, "", 2));
ns1.toString();