blob: 5ca797674af2570db73e0e526a748a9fc576bb94 (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* \class storage::spi::PartitionState
* \ingroup spi
*
* \brief Information service layer needs about providers partitions.
*
* In order to be able to utilize all hardware in parallel, the service layer
* is aware of partitions, and what buckets exist in various partitions.
*
* The service layer needs information about how many partitions exist, and if
* any of them are currently unavailable. This object describes what the
* service layer need to know about disks.
*/
#pragma once
#include <persistence/spi/types.h>
namespace storage {
namespace spi {
struct PartitionState {
enum State { UP, DOWN };
PartitionState();
PartitionState(State s, vespalib::stringref reason);
State getState() const { return _state; }
const string& getReason() const { return _reason; }
bool isUp() const { return (_state == UP); }
private:
State _state;
string _reason; // If not up, there should be a reason
};
class PartitionStateList {
std::vector<PartitionState> _states;
public:
PartitionStateList(PartitionId::Type partitionCount);
~PartitionStateList();
PartitionState& operator[](PartitionId::Type index);
const PartitionState& operator[](PartitionId::Type index) const
{ return const_cast<PartitionStateList&>(*this)[index]; }
PartitionId size() const { return PartitionId(_states.size()); }
};
} // spi
} // storage
|