diff options
author | Martin Polden <mpolden@mpolden.no> | 2019-09-06 09:36:46 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2019-09-06 09:36:46 +0200 |
commit | 6e73acc30557f268446ce3a35ee256d2e2eec745 (patch) | |
tree | 20a37a22c14740868d7b169c4c4a47437425a2a5 /controller-api | |
parent | 8ddea5bd559774c2aa11fef876ec32c0d6e8da40 (diff) |
Add findNode to EntityService
Diffstat (limited to 'controller-api')
3 files changed, 51 insertions, 0 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/EntityService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/EntityService.java index 067686269b2..b9adbf2c742 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/EntityService.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/EntityService.java @@ -5,6 +5,7 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; import java.util.Map; +import java.util.Optional; /** * A service which provides access to business-specific entities. @@ -16,4 +17,6 @@ public interface EntityService { /** List all properties known by the service */ Map<PropertyId, Property> listProperties(); + Optional<NodeEntity> findNode(String hostname); + } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java index a1e633becc6..7b8176c29de 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java @@ -6,6 +6,7 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; import java.util.Map; +import java.util.Optional; /** * @author mpolden @@ -18,4 +19,9 @@ public class MemoryEntityService implements EntityService { new PropertyId("4321"), new Property("bar")); } + @Override + public Optional<NodeEntity> findNode(String hostname) { + return Optional.empty(); + } + } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/NodeEntity.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/NodeEntity.java new file mode 100644 index 00000000000..80f09688ec8 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/NodeEntity.java @@ -0,0 +1,42 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.entity; + +import java.util.Objects; +import java.util.Optional; + +/** + * Information about a node from a {@link EntityService}. + * + * @author mpolden + */ +public class NodeEntity { + + private final String hostname; + private final Optional<String> model; + private final Optional<String> manufacturer; + + public NodeEntity(String hostname, String model, String manufacturer) { + this.hostname = Objects.requireNonNull(hostname); + this.model = nonBlank(model); + this.manufacturer = nonBlank(manufacturer); + } + + public String hostname() { + return hostname; + } + + /** The model name of this node */ + public Optional<String> model() { + return model; + } + + /** The manufacturer of this node */ + public Optional<String> manufacturer() { + return manufacturer; + } + + private static Optional<String> nonBlank(String s) { + return Optional.ofNullable(s).filter(v -> !v.isBlank()); + } + +} |