3
3
4
4
#include < ydb/library/yql/providers/common/http_gateway/yql_http_default_retry_policy.h>
5
5
#include < ydb/library/yql/providers/s3/common/util.h>
6
+ #include < ydb/library/yql/utils/actor_log/log.h>
6
7
#include < ydb/library/yql/utils/log/log.h>
7
8
#include < ydb/library/yql/utils/url_builder.h>
8
9
#include < ydb/library/yql/utils/yql_panic.h>
25
26
namespace NYql ::NS3Lister {
26
27
27
28
IOutputStream& operator <<(IOutputStream& stream, const TListingRequest& request) {
28
- return stream << " TListingRequest{.url=" << request.Url
29
+ return stream << " [TS3Lister] TListingRequest{.url=" << request.Url
29
30
<< " ,.Prefix=" << request.Prefix
30
31
<< " ,.Pattern=" << request.Pattern
31
32
<< " ,.PatternType=" << request.PatternType
@@ -51,7 +52,7 @@ std::pair<TPathFilter, TEarlyStopChecker> MakeFilterRegexp(const TString& regex,
51
52
52
53
const size_t numGroups = re->NumberOfCapturingGroups ();
53
54
YQL_CLOG (DEBUG, ProviderS3)
54
- << " Got regex: '" << regex << " ' with " << numGroups << " capture groups " ;
55
+ << " [TS3Lister] Got regex: '" << regex << " ' with " << numGroups << " capture groups " ;
55
56
56
57
auto groups = std::make_shared<std::vector<std::string>>(numGroups);
57
58
auto reArgs = std::make_shared<std::vector<re2::RE2::Arg>>(numGroups);
@@ -101,7 +102,7 @@ std::pair<TPathFilter, TEarlyStopChecker> MakeFilterWildcard(const TString& patt
101
102
}
102
103
103
104
const auto regex = NS3::RegexFromWildcards (pattern);
104
- YQL_CLOG (DEBUG, ProviderS3) << " Got prefix: '" << regexPatternPrefix << " ', regex: '"
105
+ YQL_CLOG (DEBUG, ProviderS3) << " [TS3Lister] Got prefix: '" << regexPatternPrefix << " ', regex: '"
105
106
<< regex << " ' from original pattern '" << pattern << " '" ;
106
107
107
108
return MakeFilterRegexp (regex, sharedCtx);
@@ -238,6 +239,8 @@ class TS3Lister : public IS3Lister {
238
239
const TMaybe<TString> Delimiter;
239
240
const TMaybe<TString> ContinuationToken;
240
241
const ui64 MaxKeys;
242
+ const std::pair<TString, TString> CurrentLogContextPath;
243
+ const NActors::TActorSystem* ActorSystem;
241
244
};
242
245
243
246
TS3Lister (
@@ -246,7 +249,8 @@ class TS3Lister : public IS3Lister {
246
249
const TListingRequest& listingRequest,
247
250
const TMaybe<TString>& delimiter,
248
251
size_t maxFilesPerQuery,
249
- TSharedListingContextPtr sharedCtx)
252
+ TSharedListingContextPtr sharedCtx,
253
+ NActors::TActorSystem* actorSystem)
250
254
: MaxFilesPerQuery(maxFilesPerQuery) {
251
255
Y_ENSURE (
252
256
listingRequest.Url .substr (0 , 7 ) != " file://" ,
@@ -270,7 +274,9 @@ class TS3Lister : public IS3Lister {
270
274
std::move (request),
271
275
delimiter,
272
276
Nothing (),
273
- MaxFilesPerQuery};
277
+ MaxFilesPerQuery,
278
+ NLog::CurrentLogContextPath (),
279
+ actorSystem};
274
280
275
281
YQL_CLOG (TRACE, ProviderS3)
276
282
<< " [TS3Lister] Got URL: '" << ctx.ListingRequest .Url
@@ -335,9 +341,19 @@ class TS3Lister : public IS3Lister {
335
341
/* data=*/ " " ,
336
342
retryPolicy);
337
343
}
344
+
338
345
static IHTTPGateway::TOnResult CallbackFactoryMethod (TListingContext&& listingContext) {
339
346
return [c = std::move (listingContext)](IHTTPGateway::TResult&& result) {
340
- OnDiscovery (c, std::move (result));
347
+ if (c.ActorSystem ) {
348
+ NDq::TYqlLogScope logScope (c.ActorSystem , NKikimrServices::KQP_YQL, c.CurrentLogContextPath .first , c.CurrentLogContextPath .second );
349
+ OnDiscovery (c, std::move (result));
350
+ } else {
351
+ /*
352
+ If the subsystem doesn't use the actor system
353
+ then there is a need to use an own YqlLoggerScope on the top level
354
+ */
355
+ OnDiscovery (c, std::move (result));
356
+ }
341
357
};
342
358
}
343
359
@@ -351,7 +367,7 @@ class TS3Lister : public IS3Lister {
351
367
const NXml::TDocument xml (xmlString, NXml::TDocument::String);
352
368
auto parsedResponse = ParseListObjectV2Response (xml, ctx.RequestId );
353
369
YQL_CLOG (DEBUG, ProviderS3)
354
- << " Listing of " << ctx.ListingRequest .Url
370
+ << " [TS3Lister] Listing of " << ctx.ListingRequest .Url
355
371
<< ctx.ListingRequest .Prefix << " : have " << ctx.Output ->Size ()
356
372
<< " entries, got another " << parsedResponse.KeyCount
357
373
<< " entries, request id: [" << ctx.RequestId << " ]" ;
@@ -380,7 +396,7 @@ class TS3Lister : public IS3Lister {
380
396
}
381
397
382
398
if (parsedResponse.IsTruncated && !earlyStop) {
383
- YQL_CLOG (DEBUG, ProviderS3) << " Listing of " << ctx.ListingRequest .Url
399
+ YQL_CLOG (DEBUG, ProviderS3) << " [TS3Lister] Listing of " << ctx.ListingRequest .Url
384
400
<< ctx.ListingRequest .Prefix
385
401
<< " : got truncated flag, will continue" ;
386
402
@@ -409,14 +425,14 @@ class TS3Lister : public IS3Lister {
409
425
TStringBuilder{} << " request id: [" << ctx.RequestId << " ]" ,
410
426
std::move (result.Issues ));
411
427
YQL_CLOG (INFO, ProviderS3)
412
- << " Listing of " << ctx.ListingRequest .Url << ctx.ListingRequest .Prefix
428
+ << " [TS3Lister] Listing of " << ctx.ListingRequest .Url << ctx.ListingRequest .Prefix
413
429
<< " : got error from http gateway: " << issues.ToString (true );
414
430
ctx.Promise .SetValue (TListError{EListError::GENERAL, std::move (issues)});
415
431
ctx.NextRequestPromise .SetValue (Nothing ());
416
432
}
417
433
} catch (const std::exception& ex) {
418
434
YQL_CLOG (INFO, ProviderS3)
419
- << " Listing of " << ctx.ListingRequest .Url << ctx.ListingRequest .Prefix
435
+ << " [TS3Lister] Listing of " << ctx.ListingRequest .Url << ctx.ListingRequest .Prefix
420
436
<< " : got exception: " << ex.what ();
421
437
ctx.Promise .SetException (std::current_exception ());
422
438
ctx.NextRequestPromise .SetValue (Nothing ());
@@ -452,9 +468,10 @@ class TS3ParallelLimitedListerFactory : public IS3ListerFactory {
452
468
using TPtr = std::shared_ptr<TS3ParallelLimitedListerFactory>;
453
469
454
470
explicit TS3ParallelLimitedListerFactory (
455
- size_t maxParallelOps, TSharedListingContextPtr sharedCtx)
471
+ size_t maxParallelOps, TSharedListingContextPtr sharedCtx, NActors::TActorSystem* actorSystem )
456
472
: SharedCtx(std::move(sharedCtx))
457
- , Semaphore(TAsyncSemaphore::Make(std::max<size_t >(1 , maxParallelOps))) { }
473
+ , Semaphore(TAsyncSemaphore::Make(std::max<size_t >(1 , maxParallelOps)))
474
+ , ActorSystem(actorSystem) { }
458
475
459
476
TFuture<NS3Lister::IS3Lister::TPtr> Make (
460
477
const IHTTPGateway::TPtr& httpGateway,
@@ -464,10 +481,10 @@ class TS3ParallelLimitedListerFactory : public IS3ListerFactory {
464
481
bool allowLocalFiles) override {
465
482
auto acquired = Semaphore->AcquireAsync ();
466
483
return acquired.Apply (
467
- [ctx = SharedCtx, httpGateway, retryPolicy, listingRequest, delimiter, allowLocalFiles](const auto & f) {
484
+ [ctx = SharedCtx, httpGateway, retryPolicy, listingRequest, delimiter, allowLocalFiles, actorSystem = ActorSystem ](const auto & f) {
468
485
return std::shared_ptr<NS3Lister::IS3Lister>(new TListerLockReleaseWrapper{
469
486
NS3Lister::MakeS3Lister (
470
- httpGateway, retryPolicy, listingRequest, delimiter, allowLocalFiles, ctx),
487
+ httpGateway, retryPolicy, listingRequest, delimiter, allowLocalFiles, actorSystem, ctx),
471
488
std::make_unique<TAsyncSemaphore::TAutoRelease>(
472
489
f.GetValue()->MakeAutoRelease())});
473
490
});
@@ -503,6 +520,7 @@ class TS3ParallelLimitedListerFactory : public IS3ListerFactory {
503
520
private:
504
521
TSharedListingContextPtr SharedCtx;
505
522
const TAsyncSemaphore::TPtr Semaphore;
523
+ NActors::TActorSystem* ActorSystem;
506
524
};
507
525
508
526
} // namespace
@@ -513,10 +531,11 @@ IS3Lister::TPtr MakeS3Lister(
513
531
const TListingRequest& listingRequest,
514
532
const TMaybe<TString>& delimiter,
515
533
bool allowLocalFiles,
534
+ NActors::TActorSystem* actorSystem,
516
535
TSharedListingContextPtr sharedCtx) {
517
536
if (listingRequest.Url .substr (0 , 7 ) != " file://" ) {
518
537
return std::make_shared<TS3Lister>(
519
- httpGateway, retryPolicy, listingRequest, delimiter, 1000 , std::move (sharedCtx));
538
+ httpGateway, retryPolicy, listingRequest, delimiter, 1000 , std::move (sharedCtx), actorSystem );
520
539
}
521
540
522
541
if (!allowLocalFiles) {
@@ -530,13 +549,14 @@ IS3ListerFactory::TPtr MakeS3ListerFactory(
530
549
size_t maxParallelOps,
531
550
size_t callbackThreadCount,
532
551
size_t callbackPerThreadQueueSize,
533
- size_t regexpCacheSize) {
552
+ size_t regexpCacheSize,
553
+ NActors::TActorSystem* actorSystem) {
534
554
std::shared_ptr<TSharedListingContext> sharedCtx = nullptr ;
535
555
if (callbackThreadCount != 0 || regexpCacheSize != 0 ) {
536
556
sharedCtx = std::make_shared<TSharedListingContext>(
537
557
callbackThreadCount, callbackPerThreadQueueSize, regexpCacheSize);
538
558
}
539
- return std::make_shared<TS3ParallelLimitedListerFactory>(maxParallelOps, sharedCtx);
559
+ return std::make_shared<TS3ParallelLimitedListerFactory>(maxParallelOps, sharedCtx, actorSystem );
540
560
}
541
561
542
562
} // namespace NYql::NS3Lister
0 commit comments