aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.cpp
blob: 4808d39b828022eb93edc8c959e9ce1cb108ec19 (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
61
62
63
64
65
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "bootstrapconfig.h"
#include <vespa/config-bucketspaces.h>
#include <vespa/document/config/documenttypes_config_fwd.h>

using namespace vespa::config::search;
using namespace config;
using document::DocumentTypeRepo;
using search::TuneFileDocumentDB;
using vespa::config::search::core::ProtonConfig;

namespace {
    template <typename T>
    bool equals(const T * lhs, const T * rhs)
    {
        if (lhs == NULL)
            return rhs == NULL;
        return rhs != NULL && *lhs == *rhs;
    }
}

namespace proton {

BootstrapConfig::BootstrapConfig(
               int64_t generation,
               const DocumenttypesConfigSP &documenttypes,
               const std::shared_ptr<const DocumentTypeRepo> &repo,
               const ProtonConfigSP &protonConfig,
               const FiledistributorrpcConfigSP &filedistRpcConfSP,
               const BucketspacesConfigSP &bucketspaces,
               const search::TuneFileDocumentDB::SP &tuneFileDocumentDB,
               const vespalib::HwInfo & hwInfo)
    : _documenttypes(documenttypes),
      _repo(repo),
      _proton(protonConfig),
      _fileDistributorRpc(filedistRpcConfSP),
      _bucketspaces(bucketspaces),
      _tuneFileDocumentDB(tuneFileDocumentDB),
      _hwInfo(hwInfo),
      _generation(generation)
{ }

BootstrapConfig::~BootstrapConfig() = default;

bool
BootstrapConfig::operator==(const BootstrapConfig &rhs) const
{
    return equals<DocumenttypesConfig>(_documenttypes.get(), rhs._documenttypes.get()) &&
        _repo.get() == rhs._repo.get() &&
        equals<ProtonConfig>(_proton.get(), rhs._proton.get()) &&
        equals<FiledistributorrpcConfig>(_fileDistributorRpc.get(), rhs._fileDistributorRpc.get()) &&
        equals<BucketspacesConfig>(_bucketspaces.get(), rhs._bucketspaces.get()) &&
        equals<TuneFileDocumentDB>(_tuneFileDocumentDB.get(), rhs._tuneFileDocumentDB.get()) &&
        (_hwInfo == rhs._hwInfo);
}


bool
BootstrapConfig::valid() const
{
    return _documenttypes && _repo && _proton && _fileDistributorRpc && _bucketspaces && _tuneFileDocumentDB;
}

} // namespace proton