summaryrefslogtreecommitdiffstats
path: root/vespaclient/src/perl/lib/Yahoo/Vespa/ClusterState.pm
blob: c59caf2db984f93a46e8356a78468ecdcd4eecd1 (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
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#
# Defines structs to represent a cluster state
#
package Yahoo::Vespa::ClusterState;

use strict;
use warnings;
use Class::Struct;

struct( ClusterState => {
    globalState => '$', # A state primitive
    distributor => '%', # Index to Node map
    storage => '%'      # Index to Node map
});

struct( Node => {
    group => '$',         # Hierarchical group node belongs to
    unit => 'State',
    generated => 'State',
    user => 'State',
    partition => '%'
});

struct( Partition => {
    generated => 'State',
    bucketcount => '$',
    doccount => '$',
    totaldocsize => '$'
});

struct( State => {
    state => '$',     # A state primitive
    reason => '$',    # Textual reason for it to be set.
    timestamp => '$', # Timestamp of the time it got set.
    source => '$'     # What type of state is it (unit/generated/user)
});

return 1;

sub legalState { # (State) -> Bool
    my ($state) = @_;
    return ($state =~ /^(up|down|maintenance|retired|stopping|initializing)$/);
}