aboutsummaryrefslogtreecommitdiffstats
path: root/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h
blob: 9b36f1094fd85495f8b638ceeb5a76607c228fd4 (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 Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * A cache for an ideal nodes implementation. Making it cheap for localized
 * access, regardless of real implementation.
 */
#pragma once

#include "idealnodecalculator.h"

namespace storage::lib {

class IdealNodeCalculatorImpl : public IdealNodeCalculatorConfigurable {
    std::vector<const char*> _upStates;
    const Distribution* _distribution;
    const ClusterState* _clusterState;

public:
    IdealNodeCalculatorImpl();
    ~IdealNodeCalculatorImpl();

    void setDistribution(const Distribution& d) override;
    void setClusterState(const ClusterState& cs) override;

    IdealNodeList getIdealNodes(const NodeType& nodeType,
                                const document::BucketId& bucket,
                                UpStates upStates) const override;
private:
    void initUpStateMapping();
};

}