New.
| 228 | |
| 229 | // New. |
| 230 | void TAcceptQueueServer::SetupConnection(TAcceptQueueEntry* entry) { |
| 231 | DCHECK(entry != nullptr); |
| 232 | if (metrics_enabled_) queue_size_metric_->Increment(-1); |
| 233 | shared_ptr<TTransport> io_transport; |
| 234 | shared_ptr<TTransport> client = entry->client_; |
| 235 | int64_t max_message_size = is_external_facing_ ? ThriftExternalRpcMaxMessageSize() : |
| 236 | ThriftInternalRpcMaxMessageSize(); |
| 237 | SetMaxMessageSize(client.get(), max_message_size); |
| 238 | const string& socket_info = reinterpret_cast<TSocket*>(client.get())->getSocketInfo(); |
| 239 | VLOG(2) << Substitute("TAcceptQueueServer: $0 started connection setup for client $1", |
| 240 | name_, socket_info); |
| 241 | try { |
| 242 | MonotonicStopWatch timer; |
| 243 | // Start timing for connection setup. |
| 244 | timer.Start(); |
| 245 | |
| 246 | // Since THRIFT-5237, it is necessary for Impala to have the same TTransport object |
| 247 | // for both input and output transport. The detailed reasoning on why this TTransport |
| 248 | // object sharing requirement is as follow: |
| 249 | // - Thrift decrements the max message size counter as messages arrive. |
| 250 | // - Thrift resets the max message size counter with a flush. |
| 251 | // - If the input and output transport are distinct, the decrement is happening on |
| 252 | // one object while the reset is happening on a different object, so it eventually |
| 253 | // throws an error. |
| 254 | // Using same transport fixes the counter logic. This also helps with simplifying |
| 255 | // Impala's custom TSaslTransport since its caching algorithm in |
| 256 | // TSaslServerTransport::Factory is not required anymore. |
| 257 | DCHECK(inputTransportFactory_ == outputTransportFactory_); |
| 258 | io_transport = inputTransportFactory_->getTransport(client); |
| 259 | DCHECK_EQ(io_transport->getConfiguration()->getMaxMessageSize(), |
| 260 | client->getConfiguration()->getMaxMessageSize()); |
| 261 | DCHECK_EQ(max_message_size, io_transport->getConfiguration()->getMaxMessageSize()); |
| 262 | |
| 263 | shared_ptr<TProtocol> inputProtocol = |
| 264 | inputProtocolFactory_->getProtocol(io_transport); |
| 265 | shared_ptr<TProtocol> outputProtocol = |
| 266 | outputProtocolFactory_->getProtocol(io_transport); |
| 267 | shared_ptr<TProcessor> processor = |
| 268 | getProcessor(inputProtocol, outputProtocol, client); |
| 269 | |
| 270 | if (metrics_enabled_) { |
| 271 | cnxns_setup_time_us_metric_->Update(timer.ElapsedTime() / NANOS_PER_MICRO); |
| 272 | } |
| 273 | VLOG(2) << Substitute("TAcceptQueueServer: $0 finished connection setup for " |
| 274 | "client $1", name_, socket_info); |
| 275 | |
| 276 | TAcceptQueueServer::Task* task = new TAcceptQueueServer::Task( |
| 277 | *this, processor, inputProtocol, outputProtocol, client); |
| 278 | |
| 279 | // Create a task |
| 280 | shared_ptr<Runnable> runnable = shared_ptr<Runnable>(task); |
| 281 | |
| 282 | // Create a thread for this task |
| 283 | shared_ptr<Thread> thread = shared_ptr<Thread>(threadFactory_->newThread(runnable)); |
| 284 | |
| 285 | // Insert thread into the set of threads. |
| 286 | // Start timing the wait duration for service threads. |
| 287 | timer.Reset(); |
no test coverage detected