YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/tserver/server_main_util.cc
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
#include "yb/tserver/server_main_util.h"
15
16
#include <iostream>
17
18
#include "yb/util/init.h"
19
#include "yb/util/flags.h"
20
#include "yb/util/status.h"
21
#include "yb/util/debug/trace_event.h"
22
#include "yb/util/mem_tracker.h"
23
24
#include "yb/common/wire_protocol.h"
25
26
#include "yb/server/skewed_clock.h"
27
28
#include "yb/consensus/log_util.h"
29
#include "yb/consensus/consensus_queue.h"
30
31
DECLARE_int64(remote_bootstrap_rate_limit_bytes_per_sec);
32
33
// Deprecated because it's misspelled.  But if set, this flag takes precedence over
34
// remote_bootstrap_rate_limit_bytes_per_sec for compatibility.
35
DECLARE_int64(remote_boostrap_rate_limit_bytes_per_sec);
36
37
namespace yb {
38
39
14.6k
Status MasterTServerParseFlagsAndInit(const std::string& server_type, int* argc, char*** argv) {
40
14.6k
  debug::EnableTraceEvents();
41
42
  // Do not sync GLOG to disk for INFO, WARNING.
43
  // ERRORs, and FATALs will still cause a sync to disk.
44
14.6k
  FLAGS_logbuflevel = google::GLOG_WARNING;
45
46
  // Only write FATALs by default to stderr.
47
14.6k
  FLAGS_stderrthreshold = google::FATAL;
48
49
14.6k
  server::SkewedClock::Register();
50
51
14.6k
  ParseCommandLineFlags(argc, argv, /* remove_flag= */ true);
52
14.6k
  if (*argc != 1) {
53
0
    std::cerr << "usage: " << (*argv)[0] << std::endl;
54
0
    return STATUS(InvalidArgument, "Error parsing command-line flags");
55
0
  }
56
57
14.6k
  RETURN_NOT_OK(log::ModifyDurableWriteFlagIfNotODirect());
58
59
14.6k
  RETURN_NOT_OK(InitYB(server_type, (*argv)[0]));
60
61
14.6k
  RETURN_NOT_OK(consensus::ValidateFlags());
62
63
14.6k
  if (FLAGS_remote_boostrap_rate_limit_bytes_per_sec > 0) {
64
0
    LOG(WARNING) << "Flag remote_boostrap_rate_limit_bytes_per_sec has been deprecated. "
65
0
                 << "Use remote_bootstrap_rate_limit_bytes_per_sec flag instead";
66
0
    FLAGS_remote_bootstrap_rate_limit_bytes_per_sec =
67
0
        FLAGS_remote_boostrap_rate_limit_bytes_per_sec;
68
0
  }
69
70
14.6k
  RETURN_NOT_OK(GetPrivateIpMode());
71
72
14.6k
  LOG(INFO) << "NumCPUs determined to be: " << base::NumCPUs();
73
74
14.6k
  MemTracker::SetTCMallocCacheMemory();
75
76
14.6k
  return Status::OK();
77
14.6k
}
78
79
}  // namespace yb