aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/MemoryEntityService.java
blob: df782fac2300a78650bce9c71cc7497598d47993 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright Vespa.ai. 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 com.google.common.collect.ImmutableMap;
import com.yahoo.vespa.hosted.controller.api.identifiers.Property;
import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * @author mpolden
 */
public class MemoryEntityService implements EntityService {

    private final Map<String, NodeEntity> nodeEntities = new HashMap<>();

    @Override
    public Map<PropertyId, Property> listProperties() {
        return ImmutableMap.of(new PropertyId("1234"), new Property("foo"),
                               new PropertyId("4321"), new Property("bar"));
    }

    @Override
    public List<NodeEntity> listNodes() {
        return List.copyOf(nodeEntities.values());
    }

    @Override
    public Optional<NodeEntity> findNode(String hostname) {
        return Optional.empty();
    }

    public MemoryEntityService addNodeEntity(NodeEntity nodeEntity) {
        nodeEntities.put(nodeEntity.hostname(), nodeEntity);
        return this;
    }

}