YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/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
6.11k
  explicit CQLServerEnt(Args&&... args) : CQLServer(std::forward<Args>(args)...) {
53
6.11k
  }
54
55
 private:
56
6.11k
  CHECKED_STATUS SetupMessengerBuilder(rpc::MessengerBuilder* builder) override {
57
6.11k
    RETURN_NOT_OK(CQLServer::SetupMessengerBuilder(builder));
58
6.11k
    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
6.11k
    } else {
65
6.11k
      const string &hosts = !options_.server_broadcast_addresses.empty()
66
6.11k
                          ? 
options_.server_broadcast_addresses0
67
6.11k
                          : options_.rpc_opts.rpc_bind_addresses;
68
6.11k
      secure_context_ = VERIFY_RESULT(server::SetupSecureContext(
69
6.11k
          hosts, *fs_manager_, server::SecureContextType::kExternal, builder));
70
6.11k
    }
71
6.11k
    return Status::OK();
72
6.11k
  }
73
74
  std::unique_ptr<rpc::SecureContext> secure_context_;
75
};
76
77
class Factory {
78
 public:
79
7.75k
  std::unique_ptr<TabletServer> CreateTabletServer(const TabletServerOptions& options) {
80
7.75k
    return std::make_unique<TabletServer>(options);
81
7.75k
  }
82
83
  std::unique_ptr<cqlserver::CQLServer> CreateCQLServer(
84
      const cqlserver::CQLServerOptions& options, IoService* io,
85
6.11k
      tserver::TabletServer* tserver) {
86
6.11k
    return std::make_unique<CQLServerEnt>(options, io, tserver);
87
6.11k
  }
88
};
89
90
} // namespace enterprise
91
} // namespace tserver
92
} // namespace yb
93
94
#endif // ENT_SRC_YB_TSERVER_FACTORY_H