summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2018-02-20 14:06:22 +0100
committerGeir Storli <geirst@oath.com>2018-02-20 14:06:22 +0100
commit255f0759c016c04085b98dce7ce521eca8a70535 (patch)
tree888efa31003eb06fbda20f9729b14fa98b5fb73a
parentf0ca62f5f8e2899a7da8c204897e228afcc506f2 (diff)
Add factory functions for BucketSpaceStats.
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java17
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java4
2 files changed, 14 insertions, 7 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java
index 76edaacf06f..cefb3c3c31f 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentNodeStats.java
@@ -17,16 +17,24 @@ public class ContentNodeStats {
private long bucketsTotal;
private long bucketsPending;
- public BucketSpaceStats() {
+ private BucketSpaceStats() {
this.bucketsTotal = 0;
this.bucketsPending = 0;
}
- public BucketSpaceStats(long bucketsTotal, long bucketsPending) {
+ private BucketSpaceStats(long bucketsTotal, long bucketsPending) {
this.bucketsTotal = bucketsTotal;
this.bucketsPending = bucketsPending;
}
+ public static BucketSpaceStats empty() {
+ return new BucketSpaceStats();
+ }
+
+ public static BucketSpaceStats of(long bucketsTotal, long bucketsPending) {
+ return new BucketSpaceStats(bucketsTotal, bucketsPending);
+ }
+
public long getBucketsTotal() {
return bucketsTotal;
}
@@ -65,11 +73,10 @@ public class ContentNodeStats {
for (StorageNode.BucketSpaceStats stats : storageNode.getBucketSpacesStats()) {
if (stats.valid()) {
this.bucketSpaces.put(stats.getName(),
- new BucketSpaceStats(stats.getBucketStats().getTotal(),
+ BucketSpaceStats.of(stats.getBucketStats().getTotal(),
stats.getBucketStats().getPending()));
} else {
- // TODO: better handling of invalid bucket space stats
- this.bucketSpaces.put(stats.getName(), new BucketSpaceStats());
+ this.bucketSpaces.put(stats.getName(), BucketSpaceStats.empty());
}
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
index 6035ae9d8ce..c92d414aac8 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStatsAggregatorTest.java
@@ -18,10 +18,10 @@ public class ClusterStatsAggregatorTest {
private final Map<Integer, Map<String, ContentNodeStats.BucketSpaceStats> > stats = new HashMap<>();
public StatsBuilder add(int nodeIndex, String bucketSpace, long bucketsTotal, long bucketsPending) {
- return add(nodeIndex, bucketSpace, new ContentNodeStats.BucketSpaceStats(bucketsTotal, bucketsPending));
+ return add(nodeIndex, bucketSpace, ContentNodeStats.BucketSpaceStats.of(bucketsTotal, bucketsPending));
}
public StatsBuilder add(int nodeIndex, String bucketSpace) {
- return add(nodeIndex, bucketSpace, new ContentNodeStats.BucketSpaceStats());
+ return add(nodeIndex, bucketSpace, ContentNodeStats.BucketSpaceStats.empty());
}
public StatsBuilder add(int nodeIndex, String bucketSpace, ContentNodeStats.BucketSpaceStats bucketSpaceStats) {
Map<String, ContentNodeStats.BucketSpaceStats> contentNodeStats = stats.get(nodeIndex);