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

#include <vespa/document/bucket/bucketidfactory.h>
#include <vespa/storage/common/storagecomponent.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h>

namespace storage::lib { class Distribution; }
namespace storage {

class StorageComponentRegisterImpl
        : public virtual StorageComponentRegister,
          public virtual framework::defaultimplementation::ComponentRegisterImpl
{
    using BucketspacesConfig = vespa::config::content::core::internal::InternalBucketspacesType;

    std::mutex _componentLock;
    std::vector<StorageComponent*> _components;
    vespalib::string _clusterName;
    const lib::NodeType* _nodeType;
    uint16_t _index;
    std::shared_ptr<const document::DocumentTypeRepo> _docTypeRepo;
    document::BucketIdFactory _bucketIdFactory;
    std::shared_ptr<lib::Distribution> _distribution;
    NodeStateUpdater* _nodeStateUpdater;
    BucketspacesConfig _bucketSpacesConfig;

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

    StorageComponentRegisterImpl();
    ~StorageComponentRegisterImpl() override;

    const lib::NodeType& getNodeType() const { return *_nodeType; }
    uint16_t getIndex() const { return _index; }
    std::shared_ptr<const document::DocumentTypeRepo> getTypeRepo() { return _docTypeRepo; }
    const document::BucketIdFactory& getBucketIdFactory() { return _bucketIdFactory; }
    std::shared_ptr<lib::Distribution> & getDistribution() { return _distribution; }
    NodeStateUpdater& getNodeStateUpdater() { return *_nodeStateUpdater; }

    void registerStorageComponent(StorageComponent&) override;

    void setNodeInfo(vespalib::stringref clusterName, const lib::NodeType& nodeType, uint16_t index);
    virtual void setNodeStateUpdater(NodeStateUpdater& updater);
    virtual void setDocumentTypeRepo(std::shared_ptr<const document::DocumentTypeRepo>);
    virtual void setBucketIdFactory(const document::BucketIdFactory&);
    virtual void setDistribution(std::shared_ptr<lib::Distribution>);
    virtual void setBucketSpacesConfig(const BucketspacesConfig&);
};

} // storage