/Users/deen/code/yugabyte-db/src/yb/yql/cql/cqlserver/cql_server.h
Line | Count | Source |
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 | | // This file contains the CQLServer class that listens for connections from Cassandra clients |
15 | | // using the CQL native protocol. |
16 | | |
17 | | #ifndef YB_YQL_CQL_CQLSERVER_CQL_SERVER_H |
18 | | #define YB_YQL_CQL_CQLSERVER_CQL_SERVER_H |
19 | | |
20 | | #include <stdint.h> |
21 | | #include <string.h> |
22 | | |
23 | | #include <atomic> |
24 | | #include <cstdarg> |
25 | | #include <mutex> |
26 | | #include <string> |
27 | | #include <type_traits> |
28 | | |
29 | | #include <boost/asio.hpp> |
30 | | #include <boost/container/small_vector.hpp> |
31 | | #include <boost/date_time/posix_time/posix_time.hpp> |
32 | | #include <boost/optional/optional_fwd.hpp> |
33 | | #include <boost/version.hpp> |
34 | | #include <gflags/gflags_declare.h> |
35 | | |
36 | | #include "yb/gutil/macros.h" |
37 | | |
38 | | #include "yb/rpc/service_if.h" |
39 | | |
40 | | #include "yb/server/server_base.h" |
41 | | |
42 | | #include "yb/tserver/tserver_fwd.h" |
43 | | |
44 | | #include "yb/util/status_fwd.h" |
45 | | #include "yb/util/faststring.h" |
46 | | #include "yb/util/math_util.h" |
47 | | #include "yb/util/memory/memory_usage.h" |
48 | | #include "yb/util/net/net_util.h" |
49 | | #include "yb/util/net/sockaddr.h" |
50 | | |
51 | | #include "yb/yql/cql/cqlserver/cql_server_options.h" |
52 | | #include "yb/yql/cql/ql/util/cql_message.h" |
53 | | |
54 | | namespace yb { |
55 | | |
56 | | namespace cqlserver { |
57 | | |
58 | | class CQLServer : public server::RpcAndWebServerBase { |
59 | | public: |
60 | | static const uint16_t kDefaultPort = 9042; |
61 | | static const uint16_t kDefaultWebPort = 12000; |
62 | | |
63 | | CQLServer(const CQLServerOptions& opts, |
64 | | boost::asio::io_service* io, |
65 | | tserver::TabletServerIf* tserver); |
66 | | |
67 | | CHECKED_STATUS Start(); |
68 | | |
69 | | void Shutdown(); |
70 | | |
71 | 35.2k | tserver::TabletServerIf* tserver() const { return tserver_; } |
72 | | |
73 | | private: |
74 | | CQLServerOptions opts_; |
75 | | void CQLNodeListRefresh(const boost::system::error_code &e); |
76 | | void RescheduleTimer(); |
77 | | boost::asio::deadline_timer timer_; |
78 | | tserver::TabletServerIf* const tserver_; |
79 | | |
80 | | std::unique_ptr<ql::CQLServerEvent> BuildTopologyChangeEvent(const std::string& event_type, |
81 | | const Endpoint& addr); |
82 | | |
83 | | DISALLOW_COPY_AND_ASSIGN(CQLServer); |
84 | | }; |
85 | | |
86 | | } // namespace cqlserver |
87 | | } // namespace yb |
88 | | #endif // YB_YQL_CQL_CQLSERVER_CQL_SERVER_H |