Skip to content

Commit

Permalink
Changes required for auto-sync with Arcadia
Browse files Browse the repository at this point in the history
  • Loading branch information
abyss7 committed Apr 16, 2020
1 parent 871d3f2 commit e230632
Show file tree
Hide file tree
Showing 154 changed files with 2,723 additions and 721 deletions.
4 changes: 4 additions & 0 deletions base/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ using Int16 = int16_t;
using Int32 = int32_t;
using Int64 = int64_t;

#if __cplusplus <= 201703L
using char8_t = unsigned char;
#endif

using UInt8 = char8_t;
using UInt16 = uint16_t;
using UInt32 = uint32_t;
Expand Down
35 changes: 35 additions & 0 deletions base/common/ya.make
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
LIBRARY()

ADDINCL(
GLOBAL clickhouse/base
contrib/libs/cctz/include
)

CFLAGS (GLOBAL -DARCADIA_BUILD)

IF (OS_DARWIN)
CFLAGS (GLOBAL -DOS_DARWIN)
ELSEIF (OS_FREEBSD)
CFLAGS (GLOBAL -DOS_FREEBSD)
ELSEIF (OS_LINUX)
CFLAGS (GLOBAL -DOS_LINUX)
ENDIF ()

PEERDIR(
contrib/libs/cctz/src
contrib/libs/cxxsupp/libcxx-filesystem
contrib/libs/poco/Net
contrib/libs/poco/Util
contrib/restricted/boost
contrib/restricted/cityhash-1.0.2
)

SRCS(
argsToConfig.cpp
coverage.cpp
DateLUT.cpp
DateLUTImpl.cpp
demangle.cpp
getFQDNOrHostName.cpp
getMemoryAmount.cpp
getThreadId.cpp
JSON.cpp
LineReader.cpp
mremap.cpp
phdr_cache.cpp
preciseExp10.c
setTerminalEcho.cpp
shift10.cpp
sleep.cpp
terminalColors.cpp
)

END()
16 changes: 9 additions & 7 deletions base/daemon/BaseDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@
#include <Common/getMultipleKeysFromConfig.h>
#include <Common/ClickHouseRevision.h>
#include <Common/Config/ConfigProcessor.h>
#include <Common/config_version.h>

#ifdef __APPLE__
// ucontext is not available without _XOPEN_SOURCE
#define _XOPEN_SOURCE 700
#if !defined(ARCADIA_BUILD)
# include <Common/config_version.h>
#endif

#if defined(OS_DARWIN)
# define _XOPEN_SOURCE 700 // ucontext is not available without _XOPEN_SOURCE
#endif
#include <ucontext.h>

Expand Down Expand Up @@ -410,7 +412,7 @@ std::string BaseDaemon::getDefaultCorePath() const

void BaseDaemon::closeFDs()
{
#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(__MACH__))
#if defined(OS_FREEBSD) || defined(OS_DARWIN)
Poco::File proc_path{"/dev/fd"};
#else
Poco::File proc_path{"/proc/self/fd"};
Expand All @@ -430,7 +432,7 @@ void BaseDaemon::closeFDs()
else
{
int max_fd = -1;
#ifdef _SC_OPEN_MAX
#if defined(_SC_OPEN_MAX)
max_fd = sysconf(_SC_OPEN_MAX);
if (max_fd == -1)
#endif
Expand All @@ -448,7 +450,7 @@ namespace
/// the maximum is 1000, and chromium uses 300 for its tab processes. Ignore
/// whatever errors that occur, because it's just a debugging aid and we don't
/// care if it breaks.
#if defined(__linux__) && !defined(NDEBUG)
#if defined(OS_LINUX) && !defined(NDEBUG)
void debugIncreaseOOMScore()
{
const std::string new_score = "555";
Expand Down
14 changes: 14 additions & 0 deletions base/daemon/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
LIBRARY()

NO_COMPILER_WARNINGS()

PEERDIR(
clickhouse/src/Common
)

SRCS(
BaseDaemon.cpp
GraphiteWriter.cpp
)

END()
15 changes: 15 additions & 0 deletions base/loggers/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
LIBRARY()

PEERDIR(
clickhouse/src/Common
)

SRCS(
ExtendedLogChannel.cpp
Loggers.cpp
OwnFormattingChannel.cpp
OwnPatternFormatter.cpp
OwnSplitChannel.cpp
)

END()
5 changes: 5 additions & 0 deletions base/pcg-random/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LIBRARY()

ADDINCL (GLOBAL clickhouse/base/pcg-random)

END()
9 changes: 9 additions & 0 deletions base/widechar_width/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
LIBRARY()

ADDINCL(GLOBAL clickhouse/base/widechar_width)

SRCS(
widechar_width.cpp
)

END()
4 changes: 4 additions & 0 deletions base/ya.make
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
RECURSE(
common
daemon
loggers
pcg-random
widechar_width
)
6 changes: 5 additions & 1 deletion programs/server/HTTPHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <common/getFQDNOrHostName.h>
#include <Common/CurrentThread.h>
#include <Common/setThreadName.h>
#include <Common/config.h>
#include <Common/SettingsChanges.h>
#include <Disks/DiskSpaceMonitor.h>
#include <Compression/CompressedReadBuffer.h>
Expand All @@ -36,6 +35,11 @@
#include <Common/typeid_cast.h>
#include <Poco/Net/HTTPStream.h>

#if !defined(ARCADIA_BUILD)
# include <Common/config.h>
#endif


namespace DB
{

Expand Down
16 changes: 9 additions & 7 deletions programs/server/MySQLHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include <Common/config.h>

#include "MySQLHandler.h"

#include <limits>
#include <ext/scope_guard.h>
#include <Columns/ColumnVector.h>
#include <Common/config_version.h>
#include <Common/NetException.h>
#include <Common/OpenSSLHelpers.h>
#include <Core/MySQLProtocol.h>
Expand All @@ -18,11 +16,15 @@
#include <boost/algorithm/string/replace.hpp>
#include <regex>

#if !defined(ARCADIA_BUILD)
# include <Common/config_version.h>
#endif

#if USE_POCO_NETSSL
#include <Poco/Net/SecureStreamSocket.h>
#include <Poco/Net/SSLManager.h>
#include <Poco/Crypto/CipherFactory.h>
#include <Poco/Crypto/RSAKey.h>
# include <Poco/Crypto/CipherFactory.h>
# include <Poco/Crypto/RSAKey.h>
# include <Poco/Net/SSLManager.h>
# include <Poco/Net/SecureStreamSocket.h>
#endif

namespace DB
Expand Down
8 changes: 6 additions & 2 deletions programs/server/MySQLHandler.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#pragma once
#include <Common/config.h>

#include <Poco/Net/TCPServerConnection.h>
#include <common/getFQDNOrHostName.h>
#include <Common/CurrentMetrics.h>
#include <Core/MySQLProtocol.h>
#include "IServer.h"

#if !defined(ARCADIA_BUILD)
# include <Common/config.h>
#endif

#if USE_POCO_NETSSL
#include <Poco/Net/SecureStreamSocket.h>
# include <Poco/Net/SecureStreamSocket.h>
#endif

namespace CurrentMetrics
Expand Down
8 changes: 6 additions & 2 deletions programs/server/MySQLHandlerFactory.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#pragma once

#include <Common/config.h>
#include <Poco/Net/TCPServerConnectionFactory.h>
#include <atomic>
#include "IServer.h"

#if !defined(ARCADIA_BUILD)
# include <Common/config.h>
#endif

#if USE_SSL
#include <openssl/rsa.h>
# include <openssl/rsa.h>
#endif

namespace DB
Expand Down
21 changes: 12 additions & 9 deletions programs/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <ext/scope_guard.h>
#include <common/logger_useful.h>
#include <common/phdr_cache.h>
#include <common/config_common.h>
#include <common/ErrorHandlers.h>
#include <common/getMemoryAmount.h>
#include <common/coverage.h>
Expand All @@ -26,7 +25,6 @@
#include <Common/StringUtils/StringUtils.h>
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Common/ZooKeeper/ZooKeeperNodeCache.h>
#include "config_core.h"
#include <common/getFQDNOrHostName.h>
#include <Common/getMultipleKeysFromConfig.h>
#include <Common/getNumberOfPhysicalCPUCores.h>
Expand Down Expand Up @@ -59,19 +57,24 @@
#include "MetricsTransmitter.h"
#include <Common/StatusFile.h>
#include "TCPHandlerFactory.h"
#include "Common/config_version.h"
#include <Common/SensitiveDataMasker.h>
#include <Common/ThreadFuzzer.h>
#include "MySQLHandlerFactory.h"

#if !defined(ARCADIA_BUILD)
# include <common/config_common.h>
# include "config_core.h"
# include "Common/config_version.h"
#endif

#if defined(OS_LINUX)
#include <Common/hasLinuxCapability.h>
#include <sys/mman.h>
# include <sys/mman.h>
# include <Common/hasLinuxCapability.h>
#endif

#if USE_POCO_NETSSL
#include <Poco/Net/Context.h>
#include <Poco/Net/SecureServerSocket.h>
# include <Poco/Net/Context.h>
# include <Poco/Net/SecureServerSocket.h>
#endif

namespace CurrentMetrics
Expand Down Expand Up @@ -248,7 +251,7 @@ int Server::main(const std::vector<std::string> & /*args*/)

const auto memory_amount = getMemoryAmount();

#if defined(__linux__)
#if defined(OS_LINUX)
std::string executable_path = getExecutablePath();
if (executable_path.empty())
executable_path = "/usr/bin/clickhouse"; /// It is used for information messages.
Expand Down Expand Up @@ -631,7 +634,7 @@ int Server::main(const std::vector<std::string> & /*args*/)
dns_cache_updater = std::make_unique<DNSCacheUpdater>(*global_context, config().getInt("dns_cache_update_period", 15));
}

#if defined(__linux__)
#if defined(OS_LINUX)
if (!TaskStatsInfoGetter::checkPermissions())
{
LOG_INFO(log, "It looks like the process has no CAP_NET_ADMIN capability, 'taskstats' performance statistics will be disabled."
Expand Down
5 changes: 4 additions & 1 deletion programs/server/TCPHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <Common/Stopwatch.h>
#include <Common/NetException.h>
#include <Common/setThreadName.h>
#include <Common/config_version.h>
#include <IO/Progress.h>
#include <Compression/CompressedReadBuffer.h>
#include <Compression/CompressedWriteBuffer.h>
Expand All @@ -33,6 +32,10 @@

#include "TCPHandler.h"

#if !defined(ARCADIA_BUILD)
# include <Common/config_version.h>
#endif


namespace DB
{
Expand Down
30 changes: 30 additions & 0 deletions programs/server/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
PROGRAM(clickhouse-server)

PEERDIR(
clickhouse/base/common
clickhouse/base/daemon
clickhouse/base/loggers
clickhouse/src
contrib/libs/poco/NetSSL_OpenSSL
)

SRCS(
clickhouse-server.cpp

HTTPHandler.cpp
HTTPHandlerFactory.cpp
InterserverIOHTTPHandler.cpp
MetricsTransmitter.cpp
MySQLHandler.cpp
MySQLHandlerFactory.cpp
NotFoundHandler.cpp
PingRequestHandler.cpp
PrometheusMetricsWriter.cpp
PrometheusRequestHandler.cpp
ReplicasStatusHandler.cpp
RootRequestHandler.cpp
Server.cpp
TCPHandler.cpp
)

END()
3 changes: 3 additions & 0 deletions programs/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RECURSE(
server
)
8 changes: 4 additions & 4 deletions src/Access/AccessFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class AccessFlags::Impl
}
else
{
if (nodes.contains(keyword))
if (nodes.count(keyword))
throw Exception(keyword + " declared twice", ErrorCodes::LOGICAL_ERROR);
node = std::make_unique<Node>(keyword, node_type);
nodes[node->keyword] = node.get();
Expand All @@ -279,7 +279,7 @@ class AccessFlags::Impl
{
auto parent_node = std::make_unique<Node>(parent_keyword);
it_parent = nodes.emplace(parent_node->keyword, parent_node.get()).first;
assert(!owned_nodes.contains(parent_node->keyword));
assert(!owned_nodes.count(parent_node->keyword));
std::string_view parent_keyword_as_string_view = parent_node->keyword;
owned_nodes[parent_keyword_as_string_view] = std::move(parent_node);
}
Expand All @@ -299,9 +299,9 @@ class AccessFlags::Impl

#undef MAKE_ACCESS_FLAGS_TO_KEYWORD_TREE_NODE

if (!owned_nodes.contains("NONE"))
if (!owned_nodes.count("NONE"))
throw Exception("'NONE' not declared", ErrorCodes::LOGICAL_ERROR);
if (!owned_nodes.contains("ALL"))
if (!owned_nodes.count("ALL"))
throw Exception("'ALL' not declared", ErrorCodes::LOGICAL_ERROR);

flags_to_keyword_tree = std::move(owned_nodes["ALL"]);
Expand Down
Loading

0 comments on commit e230632

Please sign in to comment.