aboutsummaryrefslogtreecommitdiffstats
path: root/storageserver/src/vespa/storageserver/app/servicelayerprocess.h
blob: dcc56f373c4d861c8a4f015b8a72ac8672de66f1 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "process.h"
#include <vespa/config-persistence.h>
#include <vespa/config-stor-filestor.h>
#include <vespa/storage/common/visitorfactory.h>
#include <vespa/storage/storageserver/servicelayernodecontext.h>
#include <vespa/storage/visiting/config-stor-visitor.h>

namespace config { class ConfigUri; }

namespace storage {

namespace spi { struct PersistenceProvider; }

class ServiceLayerNode;
class IStorageChainBuilder;

class ServiceLayerProcess : public Process {
protected:
    VisitorFactory::Map _externalVisitors;
private:
    using PersistenceConfig  = vespa::config::content::PersistenceConfig;
    using StorVisitorConfig  = vespa::config::content::core::StorVisitorConfig;
    using StorFilestorConfig = vespa::config::content::StorFilestorConfig;

    std::unique_ptr<config::ConfigHandle<PersistenceConfig>>  _persistence_cfg_handle;
    std::unique_ptr<config::ConfigHandle<StorVisitorConfig>>  _visitor_cfg_handle;
    std::unique_ptr<config::ConfigHandle<StorFilestorConfig>> _filestor_cfg_handle;

    std::unique_ptr<ServiceLayerNode> _node;
    std::unique_ptr<IStorageChainBuilder> _storage_chain_builder;

protected:
    ServiceLayerNodeContext _context;

public:
    explicit ServiceLayerProcess(const config::ConfigUri & configUri);
    ~ServiceLayerProcess() override;

    void shutdown() override;

    void setupConfig(vespalib::duration subscribe_timeout) override;
    bool configUpdated() override;
    void updateConfig() override;

    virtual void setupProvider() = 0;
    virtual spi::PersistenceProvider& getProvider() = 0;

    void createNode() override;
    StorageNode& getNode() override;
    StorageNodeContext& getContext() override;
    std::string getComponentName() const override;
    void set_storage_chain_builder(std::unique_ptr<IStorageChainBuilder> builder);
    virtual void add_external_visitors();
};

} // storage