aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/maintenance/maintenancepriority.h
blob: 3585d8f41e648a6db9f706f0bd29975d06f2eb21 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

namespace storage::distributor {

class MaintenancePriority
{
public:
    enum Priority {
        NO_MAINTENANCE_NEEDED,
        VERY_LOW,
        LOW,
        MEDIUM,
        HIGH,
        VERY_HIGH,
        HIGHEST,
        PRIORITY_LIMIT
    };

    static constexpr const char* toString(Priority pri) noexcept {
        switch (pri) {
        case NO_MAINTENANCE_NEEDED: return "NO_MAINTENANCE_NEEDED";
        case VERY_LOW:              return "VERY_LOW";
        case LOW:                   return "LOW";
        case MEDIUM:                return "MEDIUM";
        case HIGH:                  return "HIGH";
        case VERY_HIGH:             return "VERY_HIGH";
        case HIGHEST:               return "HIGHEST";
        default:                    return "INVALID";
        }
    }

    constexpr MaintenancePriority() noexcept
        : _priority(NO_MAINTENANCE_NEEDED)
    {}

    constexpr explicit MaintenancePriority(Priority priority) noexcept
        : _priority(priority)
    {}

    constexpr Priority getPriority() const noexcept {
        return _priority;
    }

    constexpr bool requiresMaintenance() const noexcept {
        return _priority != NO_MAINTENANCE_NEEDED;
    }

    static constexpr MaintenancePriority noMaintenanceNeeded() noexcept {
        return MaintenancePriority(NO_MAINTENANCE_NEEDED);
    }

private:
    Priority _priority;
};

}