blob: 281c37eb9d572a3579cfa84f2587f9f669943612 (
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
58
59
60
61
62
63
64
65
66
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/persistence/spi/bucket.h>
#include <vespa/persistence/spi/clusterstate.h>
namespace storage {
namespace spi {
/**
* Used to determine the state of the current node and its buckets.
*/
class ClusterStateImpl : public ClusterState{
public:
ClusterStateImpl();
ClusterStateImpl(const lib::ClusterState& state,
uint16_t nodeIndex,
const lib::Distribution& distribution);
ClusterStateImpl(vespalib::nbostream& i);
ClusterStateImpl(const ClusterStateImpl& other);
ClusterStateImpl& operator=(const ClusterStateImpl& other);
/**
* Returns true if the given bucket is in the ideal state
* for readiness.
*
* @param b The bucket to check.
*/
bool shouldBeReady(const Bucket& b) const;
/**
* Returns false if the cluster has been deemed down. This can happen
* if the fleet controller has detected that too many nodes are down
* compared to the complete list of nodes, and deigns the system to be
* unusable.
*/
bool clusterUp() const;
/**
* Returns false if this node has been set in a state where it should not
* receive external load.
*/
bool nodeUp() const;
/**
* Returns a serialized form of this object.
*/
void serialize(vespalib::nbostream& o) const;
private:
std::unique_ptr<lib::ClusterState> _state;
uint16_t _nodeIndex;
std::unique_ptr<lib::Distribution> _distribution;
void deserialize(vespalib::nbostream&);
};
}
}
|