aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/tests/common/testnodestateupdater.cpp
blob: c7fd47e37c7c0f7b2dd589a173fa92b04f3e011f (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 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "testnodestateupdater.h"
#include <vespa/vdslib/state/cluster_state_bundle.h>

namespace storage {

TestNodeStateUpdater::TestNodeStateUpdater(const lib::NodeType& type)
    : _reported(new lib::NodeState(type, lib::State::UP)),
      _current(new lib::NodeState(type, lib::State::UP)),
      _clusterStateBundle(),
      _listeners()
{ }

TestNodeStateUpdater::~TestNodeStateUpdater() = default;

std::shared_ptr<const lib::ClusterStateBundle>
TestNodeStateUpdater::getClusterStateBundle() const
{
    return _clusterStateBundle;
}

void
TestNodeStateUpdater::setClusterState(lib::ClusterState::CSP c)
{
    _clusterStateBundle = std::make_shared<const lib::ClusterStateBundle>(*c);
    for (uint32_t i = 0; i < _listeners.size(); ++i) {
        _listeners[i]->handleNewState();
    }
}

}