aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentTask.java
blob: 3e7895c1ebd8a1aef21e24607a3a53b0662c9ac4 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.nodeagent;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public enum NodeAgentTask {

    // The full task name is prefixed with 'node>', e.g. 'node>DiskCleanup'
    DiskCleanup,
    CoreDumps,
    CredentialsMaintainer,
    AclMaintainer;

    private static final Map<String, NodeAgentTask> tasksByName = Arrays.stream(NodeAgentTask.values())
            .collect(Collectors.toUnmodifiableMap(NodeAgentTask::taskName, n -> n));

    private final String taskName;
    NodeAgentTask() {
        this.taskName = "node>" + name();
    }

    public String taskName() { return taskName; }

    public static Set<NodeAgentTask> fromString(List<String> tasks) {
        return tasks.stream().filter(tasksByName::containsKey).map(tasksByName::get).collect(Collectors.toUnmodifiableSet());
    }
}