YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/tserver/remote_bootstrap_file_downloader.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_TSERVER_REMOTE_BOOTSTRAP_FILE_DOWNLOADER_H
15
#define YB_TSERVER_REMOTE_BOOTSTRAP_FILE_DOWNLOADER_H
16
17
#include <memory>
18
#include <string>
19
#include <unordered_map>
20
21
#include "yb/rpc/rpc_fwd.h"
22
23
#include "yb/tablet/metadata.pb.h"
24
25
#include "yb/tserver/remote_bootstrap.pb.h"
26
27
#include "yb/util/monotime.h"
28
#include "yb/util/status_fwd.h"
29
30
namespace yb {
31
32
class Env;
33
class FsManager;
34
class MonoDelta;
35
36
namespace tserver {
37
38
class RemoteBootstrapServiceProxy;
39
40
class RemoteBootstrapFileDownloader {
41
 public:
42
  RemoteBootstrapFileDownloader(const std::string* log_prefix, FsManager* fs_manager);
43
44
  void Start(
45
      std::shared_ptr<RemoteBootstrapServiceProxy> proxy, std::string session_id,
46
      MonoDelta session_idle_timeout);
47
48
  CHECKED_STATUS DownloadFile(
49
      const tablet::FilePB& file_pb, const std::string& dir, DataIdPB* data_id);
50
51
  // Download a single remote file. The block and WAL implementations delegate
52
  // to this method when downloading files.
53
  //
54
  // An Appendable is typically a WritableFile (WAL).
55
  //
56
  // Only used in one compilation unit, otherwise the implementation would
57
  // need to be in the header.
58
  template<class Appendable>
59
  CHECKED_STATUS DownloadFile(const DataIdPB& data_id, Appendable* appendable);
60
61
139M
  FsManager& fs_manager() const {
62
139M
    return fs_manager_;
63
139M
  }
64
65
7.72k
  const std::string& session_id() const {
66
7.72k
    return session_id_;
67
7.72k
  }
68
69
 private:
70
  CHECKED_STATUS VerifyData(uint64_t offset, const DataChunkPB& resp);
71
72
0
  const std::string& LogPrefix() const {
73
0
    return log_prefix_;
74
0
  }
75
76
  Env& env() const;
77
78
  const std::string& log_prefix_;
79
  FsManager& fs_manager_;
80
81
  std::shared_ptr<RemoteBootstrapServiceProxy> proxy_;
82
  std::string session_id_;
83
  MonoDelta session_idle_timeout_ = MonoDelta::kZero;
84
  std::unordered_map<uint64_t, std::string> inode2file_;
85
};
86
87
CHECKED_STATUS UnwindRemoteError(const Status& status, const rpc::RpcController& controller);
88
89
} // namespace tserver
90
} // namespace yb
91
92
#endif // YB_TSERVER_REMOTE_BOOTSTRAP_FILE_DOWNLOADER_H