YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/ent/src/yb/tserver/factory.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 ENT_SRC_YB_TSERVER_FACTORY_H
15
#define ENT_SRC_YB_TSERVER_FACTORY_H
16
17
#include <memory>
18
19
#include "yb/rpc/rpc_fwd.h"
20
#include "yb/rpc/secure_stream.h"
21
22
#include "yb/server/secure.h"
23
24
#include "yb/tserver/ts_tablet_manager.h"
25
26
#include "yb/util/result.h"
27
28
DECLARE_string(cert_node_filename);
29
30
namespace yb {
31
32
namespace cqlserver {
33
34
class CQLServer;
35
class CQLServerOptions;
36
37
}
38
39
namespace tserver {
40
41
class TabletServer;
42
class TabletServerOptions;
43
44
namespace enterprise {
45
46
class CQLServer;
47
class TabletServer;
48
49
class CQLServerEnt : public cqlserver::CQLServer {
50
 public:
51
  template <class... Args>
52
4.54k
  explicit CQLServerEnt(Args&&... args) : CQLServer(std::forward<Args>(args)...) {
53
4.54k
  }
54
55
 private:
56
4.54k
  CHECKED_STATUS SetupMessengerBuilder(rpc::MessengerBuilder* builder) override {
57
4.54k
    RETURN_NOT_OK(CQLServer::SetupMessengerBuilder(builder));
58
4.54k
    if (!FLAGS_cert_node_filename.empty()) {
59
0
      secure_context_ = VERIFY_RESULT(server::SetupSecureContext(
60
0
          server::DefaultRootDir(*fs_manager_),
61
0
          FLAGS_cert_node_filename,
62
0
          server::SecureContextType::kExternal,
63
0
          builder));
64
4.54k
    } else {
65
4.54k
      const string &hosts = !options_.server_broadcast_addresses.empty()
66
0
                          ? options_.server_broadcast_addresses
67
4.54k
                          : options_.rpc_opts.rpc_bind_addresses;
68
4.54k
      secure_context_ = VERIFY_RESULT(server::SetupSecureContext(
69
4.54k
          hosts, *fs_manager_, server::SecureContextType::kExternal, builder));
70
4.54k
    }
71
4.54k
    return Status::OK();
72
4.54k
  }
73
74
  std::unique_ptr<rpc::SecureContext> secure_context_;
75
};
76
77
class Factory {
78
 public:
79
5.39k
  std::unique_ptr<TabletServer> CreateTabletServer(const TabletServerOptions& options) {
80
5.39k
    return std::make_unique<TabletServer>(options);
81
5.39k
  }
82
83
  std::unique_ptr<cqlserver::CQLServer> CreateCQLServer(
84
      const cqlserver::CQLServerOptions& options, IoService* io,
85
4.54k
      tserver::TabletServer* tserver) {
86
4.54k
    return std::make_unique<CQLServerEnt>(options, io, tserver);
87
4.54k
  }
88
};
89
90
} // namespace enterprise
91
} // namespace tserver
92
} // namespace yb
93
94
#endif // ENT_SRC_YB_TSERVER_FACTORY_H