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

#include <vespa/document/bucket/bucketspace.h>
#include <vespa/storage/bucketdb/storbucketdb.h>
#include <mutex>

namespace storage {

namespace lib {
class ClusterState;
class Distribution;
}

/**
 * Class representing a bucket space (with associated bucket database) on a content node.
 */
class ContentBucketSpace {
private:
    document::BucketSpace _bucketSpace;
    StorBucketDatabase _bucketDatabase;
    mutable std::mutex _lock;
    std::shared_ptr<const lib::ClusterState> _clusterState;
    std::shared_ptr<const lib::Distribution> _distribution;
    bool _nodeUpInLastNodeStateSeenByProvider;
    bool _nodeMaintenanceInLastNodeStateSeenByProvider;

public:
    using UP = std::unique_ptr<ContentBucketSpace>;
    explicit ContentBucketSpace(document::BucketSpace bucketSpace, const ContentBucketDbOptions& db_opts);

    document::BucketSpace bucketSpace() const noexcept { return _bucketSpace; }
    StorBucketDatabase &bucketDatabase() { return _bucketDatabase; }
    void setClusterState(std::shared_ptr<const lib::ClusterState> clusterState);
    std::shared_ptr<const lib::ClusterState> getClusterState() const;
    void setDistribution(std::shared_ptr<const lib::Distribution> distribution);
    std::shared_ptr<const lib::Distribution> getDistribution() const;
    bool getNodeUpInLastNodeStateSeenByProvider() const;
    void setNodeUpInLastNodeStateSeenByProvider(bool nodeUpInLastNodeStateSeenByProvider);
    bool getNodeMaintenanceInLastNodeStateSeenByProvider() const;
    void setNodeMaintenanceInLastNodeStateSeenByProvider(bool nodeMaintenanceInLastNodeStateSeenByProvider);
};

}