aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/common/distributorcomponent.cpp
blob: 41e875a4ed7cd374ff798cd355426b6d3271e8d0 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "distributorcomponent.h"

namespace storage {

DistributorComponent::DistributorComponent(DistributorComponentRegister& compReg,
                                           vespalib::stringref name)
    : StorageComponent(compReg, name),
      _timeCalculator(0),
      _distributorConfig(),
      _visitorConfig(),
      _internal_config_generation(0),
      _config_snapshot(std::make_shared<DistributorConfiguration>(*this))
{
    compReg.registerDistributorComponent(*this);
}

DistributorComponent::~DistributorComponent() = default;

void DistributorComponent::update_config_snapshot() {
    auto new_snapshot = std::make_shared<DistributorConfiguration>(*this);
    new_snapshot->configure(_visitorConfig);
    new_snapshot->configure(_distributorConfig);
    // TODO make thread safe if necessary; access currently synchronized by config updates
    // and checks all being routed through the same "critical tick" global lock.
    ++_internal_config_generation;
    _config_snapshot = std::move(new_snapshot);
}

} // storage