| 242 | } |
| 243 | |
| 244 | int main(int argc, char** argv) { |
| 245 | gflags::ParseCommandLineFlags(&argc, &argv, true); |
| 246 | |
| 247 | g_server.reset(new arrow::flight::FlightPerfServer); |
| 248 | |
| 249 | arrow::flight::Location bind_location; |
| 250 | arrow::flight::Location connect_location; |
| 251 | if (FLAGS_transport == "grpc") { |
| 252 | if (FLAGS_server_unix.empty()) { |
| 253 | if (!FLAGS_cert_file.empty() || !FLAGS_key_file.empty()) { |
| 254 | if (!FLAGS_cert_file.empty() && !FLAGS_key_file.empty()) { |
| 255 | ARROW_CHECK_OK(arrow::flight::Location::ForGrpcTls("0.0.0.0", FLAGS_port) |
| 256 | .Value(&bind_location)); |
| 257 | ARROW_CHECK_OK( |
| 258 | arrow::flight::Location::ForGrpcTls(FLAGS_server_host, FLAGS_port) |
| 259 | .Value(&connect_location)); |
| 260 | } else { |
| 261 | std::cerr << "If providing TLS cert/key, must provide both" << std::endl; |
| 262 | return EXIT_FAILURE; |
| 263 | } |
| 264 | } else { |
| 265 | ARROW_CHECK_OK(arrow::flight::Location::ForGrpcTcp("0.0.0.0", FLAGS_port) |
| 266 | .Value(&bind_location)); |
| 267 | ARROW_CHECK_OK(arrow::flight::Location::ForGrpcTcp(FLAGS_server_host, FLAGS_port) |
| 268 | .Value(&connect_location)); |
| 269 | } |
| 270 | } else { |
| 271 | ARROW_CHECK_OK( |
| 272 | arrow::flight::Location::ForGrpcUnix(FLAGS_server_unix).Value(&bind_location)); |
| 273 | ARROW_CHECK_OK(arrow::flight::Location::ForGrpcUnix(FLAGS_server_unix) |
| 274 | .Value(&connect_location)); |
| 275 | } |
| 276 | } else { |
| 277 | std::cerr << "Unknown transport: " << FLAGS_transport << std::endl; |
| 278 | return EXIT_FAILURE; |
| 279 | } |
| 280 | arrow::flight::FlightServerOptions options(bind_location); |
| 281 | if (!FLAGS_cert_file.empty() && !FLAGS_key_file.empty()) { |
| 282 | std::cout << "Enabling TLS" << std::endl; |
| 283 | std::ifstream cert_file(FLAGS_cert_file); |
| 284 | std::string cert((std::istreambuf_iterator<char>(cert_file)), |
| 285 | (std::istreambuf_iterator<char>())); |
| 286 | std::ifstream key_file(FLAGS_key_file); |
| 287 | std::string key((std::istreambuf_iterator<char>(key_file)), |
| 288 | (std::istreambuf_iterator<char>())); |
| 289 | options.tls_certificates.push_back(arrow::flight::CertKeyPair{cert, key}); |
| 290 | } |
| 291 | |
| 292 | if (FLAGS_cuda) { |
| 293 | #ifdef ARROW_CUDA |
| 294 | arrow::cuda::CudaDeviceManager* manager = nullptr; |
| 295 | std::shared_ptr<arrow::cuda::CudaDevice> device; |
| 296 | |
| 297 | ARROW_CHECK_OK(arrow::cuda::CudaDeviceManager::Instance().Value(&manager)); |
| 298 | ARROW_CHECK_OK(manager->GetDevice(0).Value(&device)); |
| 299 | options.memory_manager = device->default_memory_manager(); |
| 300 | #else |
| 301 | std::cerr << "-cuda requires that Arrow is built with ARROW_CUDA" << std::endl; |
nothing calls this directly
no test coverage detected