MCPcopy Create free account
hub / github.com/ByConity/ByConity / processFile

Method processFile

src/Storages/Distributed/DirectoryMonitor.cpp:613–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611}
612
613void StorageDistributedDirectoryMonitor::processFile(const std::string & file_path)
614{
615 Stopwatch watch;
616 auto timeouts = ConnectionTimeouts::getTCPTimeoutsWithFailover(storage.getContext()->getSettingsRef());
617
618 try
619 {
620 CurrentMetrics::Increment metric_increment{CurrentMetrics::DistributedSend};
621
622 ReadBufferFromFile in(file_path);
623 const auto & distributed_header = readDistributedHeader(in, log);
624
625 LOG_DEBUG(log, "Started processing `{}` ({} rows, {} bytes)", file_path,
626 formatReadableQuantity(distributed_header.rows),
627 formatReadableSizeWithBinarySuffix(distributed_header.bytes));
628
629 auto connection = pool->get(timeouts, &distributed_header.insert_settings);
630 RemoteBlockOutputStream remote{*connection, timeouts,
631 distributed_header.insert_query,
632 distributed_header.insert_settings,
633 distributed_header.client_info,
634 storage.getContext()};
635 remote.writePrefix();
636 bool compression_expected = connection->getCompression() == Protocol::Compression::Enable;
637 writeRemoteConvert(distributed_header, remote, compression_expected, in, log);
638 remote.writeSuffix();
639 }
640 catch (Exception & e)
641 {
642 e.addMessage(fmt::format("While sending {}", file_path));
643 maybeMarkAsBroken(file_path, e);
644 throw;
645 }
646
647 auto dir_sync_guard = getDirectorySyncGuard(dir_fsync, disk, relative_path);
648 markAsSend(file_path);
649 LOG_TRACE(log, "Finished processing `{}` (took {} ms)", file_path, watch.elapsedMilliseconds());
650}
651
652struct StorageDistributedDirectoryMonitor::BatchHeader
653{

Callers

nothing calls this directly

Calls 12

readDistributedHeaderFunction · 0.85
formatReadableQuantityFunction · 0.85
writeRemoteConvertFunction · 0.85
getDirectorySyncGuardFunction · 0.85
getCompressionMethod · 0.80
addMessageMethod · 0.80
getContextMethod · 0.45
getMethod · 0.45
writePrefixMethod · 0.45
writeSuffixMethod · 0.45
elapsedMillisecondsMethod · 0.45

Tested by

no test coverage detected