summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorolaaun <olaa@oath.com>2019-02-15 11:00:14 +0100
committerGitHub <noreply@github.com>2019-02-15 11:00:14 +0100
commitc65fe9bcd51f16012ff35b0cae8d707f4f5516d7 (patch)
tree0abc7ccc99f96ecad94a937e0beb2ed3f25a2ca8 /node-repository
parent04397e5e48f04dfe61afdecfb572ce9b50e7baf6 (diff)
Change name of modelId to modelName (#8507)
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java34
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java12
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java4
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java3
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java6
6 files changed, 30 insertions, 31 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
index c0ddfea536d..a02508c3474 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java
@@ -39,7 +39,7 @@ public final class Node {
private final State state;
private final NodeType type;
private final Reports reports;
- private final Optional<String> modelId;
+ private final Optional<String> modelName;
/** Record of the last event of each type happening to this node */
private final History history;
@@ -68,7 +68,7 @@ public final class Node {
/** Creates a node. See also the {@code create} helper methods. */
public Node(String id, Set<String> ipAddresses, Set<String> ipAddressPool, String hostname, Optional<String> parentHostname,
Flavor flavor, Status status, State state, Optional<Allocation> allocation, History history, NodeType type,
- Reports reports, Optional<String> modelId) {
+ Reports reports, Optional<String> modelName) {
Objects.requireNonNull(id, "A node must have an ID");
requireNonEmptyString(hostname, "A node must have a hostname");
requireNonEmptyString(parentHostname, "A parent host name must be a proper value");
@@ -79,7 +79,7 @@ public final class Node {
Objects.requireNonNull(history, "A null node history is not permitted");
Objects.requireNonNull(type, "A null node type is not permitted");
Objects.requireNonNull(reports, "A null reports is not permitted");
- Objects.requireNonNull(modelId, "A null modelId is not permitted");
+ Objects.requireNonNull(modelName, "A null modelName is not permitted");
if (state == State.active)
requireNonEmpty(ipAddresses, "An active node must have at least one valid IP address");
@@ -96,7 +96,7 @@ public final class Node {
this.history = history;
this.type = type;
this.reports = reports;
- this.modelId = modelId;
+ this.modelName = modelName;
}
/** Returns the IP addresses of this node */
@@ -155,7 +155,7 @@ public final class Node {
public Reports reports() { return reports; }
/** Returns the hardware model of this node */
- public Optional<String> modelId() { return modelId; }
+ public Optional<String> modelName() { return modelName; }
/**
* Returns a copy of this node with wantToRetire set to the given value and updated history.
@@ -199,31 +199,31 @@ public final class Node {
/** Returns a node with the status assigned to the given value */
public Node with(Status status) {
- return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelId);
+ return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelName);
}
/** Returns a node with the type assigned to the given value */
public Node with(NodeType type) {
- return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelId);
+ return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelName);
}
/** Returns a node with the flavor assigned to the given value */
public Node with(Flavor flavor) {
- return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelId);
+ return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelName);
}
/** Returns a copy of this with the reboot generation set to generation */
public Node withReboot(Generation generation) {
- return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status.withReboot(generation), state, allocation, history, type, reports, modelId);
+ return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status.withReboot(generation), state, allocation, history, type, reports, modelName);
}
/** Returns a copy of this with the openStackId set */
public Node withOpenStackId(String openStackId) {
- return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelId);
+ return new Node(openStackId, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelName);
}
- public Node withModelId(String modelId) {
- return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, Optional.of(modelId));
+ public Node withModelName(String modelName) {
+ return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, Optional.of(modelName));
}
/** Returns a copy of this with a history record saying it was detected to be down at this instant */
@@ -253,19 +253,19 @@ public final class Node {
/** Returns a copy of this node with the IP addresses set to the given value. */
public Node withIpAddresses(Set<String> ipAddresses) {
return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state,
- allocation, history, type, reports, modelId);
+ allocation, history, type, reports, modelName);
}
/** Returns a copy of this node with IP address pool set to the given value. */
public Node withIpAddressPool(Set<String> ipAddressPool) {
return new Node(id, ipAddresses, ipAddressPool, hostname, parentHostname, flavor, status, state,
- allocation, history, type, reports, modelId);
+ allocation, history, type, reports, modelName);
}
/** Returns a copy of this node with the parent hostname assigned to the given value. */
public Node withParentHostname(String parentHostname) {
return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, Optional.of(parentHostname), flavor, status, state,
- allocation, history, type, reports, modelId);
+ allocation, history, type, reports, modelName);
}
/** Returns a copy of this node with the current reboot generation set to the given number at the given instant */
@@ -279,11 +279,11 @@ public final class Node {
/** Returns a copy of this node with the given history. */
public Node with(History history) {
- return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelId);
+ return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelName);
}
public Node with(Reports reports) {
- return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelId);
+ return new Node(id, ipAddresses, ipAddressPool.asSet(), hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelName);
}
private static void requireNonEmptyString(Optional<String> value, String message) {
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
index 2f100b00982..0a0e5b7c265 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
@@ -217,7 +217,7 @@ public class CuratorDatabaseClient {
toState,
toState.isAllocated() ? node.allocation() : Optional.empty(),
node.history().recordStateTransition(node.state(), toState, agent, clock.instant()),
- node.type(), node.reports(), node.modelId());
+ node.type(), node.reports(), node.modelName());
curatorTransaction.add(CuratorOperations.delete(toPath(node).getAbsolute()))
.add(CuratorOperations.create(toPath(toState, newNode.hostname()).getAbsolute(), nodeSerializer.toJson(newNode)));
writtenNodes.add(newNode);
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
index e9dc186f122..54668c4eda1 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
@@ -64,7 +64,7 @@ public class NodeSerializer {
private static final String osVersionKey = "osVersion";
private static final String firmwareCheckKey = "firmwareCheck";
private static final String reportsKey = "reports";
- private static final String modelIdKey = "modelId";
+ private static final String modelNameKey = "modelName";
// Configuration fields
private static final String flavorKey = "flavor";
@@ -124,7 +124,7 @@ public class NodeSerializer {
node.status().osVersion().ifPresent(version -> object.setString(osVersionKey, version.toString()));
node.status().firmwareVerifiedAt().ifPresent(instant -> object.setLong(firmwareCheckKey, instant.toEpochMilli()));
node.reports().toSlime(object, reportsKey);
- node.modelId().ifPresent(modelId -> object.setString(modelIdKey, modelId));
+ node.modelName().ifPresent(modelName -> object.setString(modelNameKey, modelName));
}
private void toSlime(Allocation allocation, Cursor object) {
@@ -173,7 +173,7 @@ public class NodeSerializer {
historyFromSlime(object.field(historyKey)),
nodeTypeFromString(object.field(nodeTypeKey).asString()),
Reports.fromSlime(object.field(reportsKey)),
- modelIdFromSlime(object));
+ modelNameFromSlime(object));
}
private Status statusFromSlime(Inspector object) {
@@ -278,9 +278,9 @@ public class NodeSerializer {
return Optional.empty();
}
- private Optional<String> modelIdFromSlime(Inspector object) {
- if (object.field(modelIdKey).valid()) {
- return Optional.of(object.field(modelIdKey).asString());
+ private Optional<String> modelNameFromSlime(Inspector object) {
+ if (object.field(modelNameKey).valid()) {
+ return Optional.of(object.field(modelNameKey).asString());
}
return Optional.empty();
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
index 19e1958521a..e0ea8a1369c 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
@@ -145,8 +145,8 @@ public class NodePatcher {
return nodeWithPatchedReports(node, value);
case "openStackId" :
return node.withOpenStackId(asString(value));
- case "modelId":
- return node.withModelId(asString(value));
+ case "modelName":
+ return node.withModelName(asString(value));
default :
throw new IllegalArgumentException("Could not apply field '" + name + "' on a node: No such modifiable field");
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
index 55da42c7ebb..3b5c264fc09 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
@@ -14,7 +14,6 @@ import com.yahoo.vespa.hosted.provision.Node;
import com.yahoo.vespa.hosted.provision.NodeRepository;
import com.yahoo.vespa.hosted.provision.node.History;
import com.yahoo.vespa.hosted.provision.node.filter.NodeFilter;
-import com.yahoo.vespa.orchestrator.HostNameNotFoundException;
import com.yahoo.vespa.orchestrator.Orchestrator;
import com.yahoo.vespa.orchestrator.status.HostStatus;
@@ -187,7 +186,7 @@ class NodesResponse extends HttpResponse {
ipAddressesToSlime(node.ipAddressPool().asSet(), object.setArray("additionalIpAddresses"));
node.status().hardwareDivergence().ifPresent(hardwareDivergence -> object.setString("hardwareDivergence", hardwareDivergence));
node.reports().toSlime(object, "reports");
- node.modelId().ifPresent(modelId -> object.setString("modelId", modelId));
+ node.modelName().ifPresent(modelName -> object.setString("modelName", modelName));
}
private void toSlime(ApplicationId id, Cursor object) {
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
index beec8d19a2e..29229efc662 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
@@ -364,11 +364,11 @@ public class SerializationTest {
@Test
public void model_id_serialization() {
Node node = nodeSerializer.fromJson(State.active, nodeSerializer.toJson(createNode()));
- assertFalse(node.modelId().isPresent());
+ assertFalse(node.modelName().isPresent());
- node = node.withModelId("some model");
+ node = node.withModelName("some model");
node = nodeSerializer.fromJson(State.active, nodeSerializer.toJson(node));
- assertEquals("some model", node.modelId().get());
+ assertEquals("some model", node.modelName().get());
}
private byte[] createNodeJson(String hostname, String... ipAddress) {