Loading...
Searching...
No Matches
system_info.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include <memory>
23
25#include "platform/proto/resdb.pb.h"
26
27namespace resdb {
28
29// SystemInfo managers the cluster information which
30// has been agreed on, like the primary, the replicas,etc..
32 public:
33 SystemInfo();
34 SystemInfo(const ResDBConfig& config);
35 virtual ~SystemInfo() = default;
36
37 std::vector<ReplicaInfo> GetReplicas() const;
38 void SetReplicas(const std::vector<ReplicaInfo>& replicas);
39 void AddReplica(const ReplicaInfo& replica);
40
41 void ProcessRequest(const SystemInfoRequest& request);
42
43 uint32_t GetPrimaryId() const;
44 void SetPrimary(uint32_t id);
45
46 uint64_t GetCurrentView() const;
47 void SetCurrentView(uint64_t);
48
49 private:
50 std::vector<ReplicaInfo> replicas_;
51 std::atomic<uint32_t> primary_id_;
52 std::atomic<uint64_t> view_;
53};
54} // namespace resdb
void SetCurrentView(uint64_t)
uint32_t GetPrimaryId() const
void SetPrimary(uint32_t id)
virtual ~SystemInfo()=default
void SetReplicas(const std::vector< ReplicaInfo > &replicas)
std::vector< ReplicaInfo > GetReplicas() const
void AddReplica(const ReplicaInfo &replica)
void ProcessRequest(const SystemInfoRequest &request)
uint64_t GetCurrentView() const