aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h
blob: 93499d9ebce0c1db1c9d16cb1d63939b2630d0d7 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * \class storage::framework::DistributorComponentRegisterImpl
 * \ingroup component
 *
 * \brief Subclass of component register impl that handles storage components.
 */
#pragma once

#include "storagecomponentregisterimpl.h"
#include <vespa/storage/common/distributorcomponent.h>
#include <vespa/storage/common/nodestateupdater.h>

namespace storage::lib {
    class IdealNodeCalculatorConfigurable;
    class ClusterState;
}

namespace storage {

class DistributorComponentRegisterImpl
        : public virtual DistributorComponentRegister,
          public virtual StorageComponentRegisterImpl,
          private StateListener
{
    std::mutex _componentLock;
    std::vector<DistributorManagedComponent*> _components;

    UniqueTimeCalculator* _timeCalculator;
    DistributorConfig _distributorConfig;
    VisitorConfig _visitorConfig;
    std::shared_ptr<lib::ClusterState> _clusterState;

public:
    using UP = std::unique_ptr<DistributorComponentRegisterImpl>;

    DistributorComponentRegisterImpl();
    ~DistributorComponentRegisterImpl() override;

    void registerDistributorComponent(DistributorManagedComponent&) override;
    void setTimeCalculator(UniqueTimeCalculator& calc);
    void setDistributorConfig(const DistributorConfig&);
    void setVisitorConfig(const VisitorConfig&);
private:
    void handleNewState() noexcept override;
    void setNodeStateUpdater(NodeStateUpdater& updater) override;
};

}