forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnector_bootstrap.cpp
More file actions
95 lines (80 loc) · 2.97 KB
/
Copy pathconnector_bootstrap.cpp
File metadata and controls
95 lines (80 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright 2021-present StarRocks, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "module/connector_bootstrap.h"
#include <memory>
#include <string>
#include "connector/cache_stats/cache_stats_connector.h"
#include "connector/connector_registry.h"
#include "connector/file/file_connector.h"
#include "connector/hive/hive_connector.h"
#include "connector/lake/lake_connector.h"
#include "connector_primitive/connector.h"
#ifndef __APPLE__
#include "connector/iceberg/iceberg_connector.h"
#endif
#ifdef STARROCKS_WITH_CONNECTOR_BENCHMARK
#include "connector/benchmark/benchmark_connector.h"
#endif
#ifdef STARROCKS_WITH_CONNECTOR_JDBC
#include "connector/jdbc/jdbc_connector.h"
#include "connector/jdbc/jdbc_driver_manager.h"
#endif
#ifdef STARROCKS_WITH_CONNECTOR_ELASTICSEARCH
#include "connector/elasticsearch/es_connector.h"
#endif
#ifdef STARROCKS_WITH_CONNECTOR_MYSQL
#include "connector/mysql/mysql_connector.h"
#endif
namespace starrocks::connector {
namespace {
template <typename ConnectorT>
void install_if_absent(ConnectorRegistry* registry, const std::string& name) {
if (registry->get(name) == nullptr) {
registry->put(name, std::make_unique<ConnectorT>());
}
}
} // namespace
Status bootstrap_builtin_connectors() {
auto* registry = ConnectorRegistry::default_instance();
DCHECK(registry != nullptr);
install_if_absent<HiveConnector>(registry, Connector::HIVE);
install_if_absent<FileConnector>(registry, Connector::FILE);
install_if_absent<LakeConnector>(registry, Connector::LAKE);
install_if_absent<CacheStatsConnector>(registry, Connector::CACHE_STATS);
#ifndef __APPLE__
install_if_absent<IcebergConnector>(registry, Connector::ICEBERG);
#endif
#ifdef STARROCKS_WITH_CONNECTOR_BENCHMARK
install_if_absent<BenchmarkConnector>(registry, Connector::BENCHMARK);
#endif
#ifdef STARROCKS_WITH_CONNECTOR_JDBC
install_if_absent<JDBCConnector>(registry, Connector::JDBC);
#endif
#ifdef STARROCKS_WITH_CONNECTOR_ELASTICSEARCH
install_if_absent<ESConnector>(registry, Connector::ES);
#endif
#ifdef STARROCKS_WITH_CONNECTOR_MYSQL
install_if_absent<MySQLConnector>(registry, Connector::MYSQL);
#endif
return Status::OK();
}
Status init_builtin_connector_runtime(const std::string& jdbc_driver_dir) {
#ifdef STARROCKS_WITH_CONNECTOR_JDBC
return JDBCDriverManager::getInstance()->init(jdbc_driver_dir);
#else
(void)jdbc_driver_dir;
return Status::OK();
#endif
}
} // namespace starrocks::connector