requests.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "requests.h"
  2. #include "context.h"
  3. #include "host_manager.h"
  4. #include "retry_request.h"
  5. #include <yt/cpp/mapreduce/client/transaction.h>
  6. #include <yt/cpp/mapreduce/common/helpers.h>
  7. #include <yt/cpp/mapreduce/common/retry_lib.h>
  8. #include <yt/cpp/mapreduce/common/node_builder.h>
  9. #include <yt/cpp/mapreduce/common/wait_proxy.h>
  10. #include <yt/cpp/mapreduce/interface/config.h>
  11. #include <yt/cpp/mapreduce/interface/errors.h>
  12. #include <yt/cpp/mapreduce/interface/logging/yt_log.h>
  13. #include <yt/cpp/mapreduce/interface/serialize.h>
  14. #include <util/stream/file.h>
  15. #include <util/string/builder.h>
  16. #include <util/generic/buffer.h>
  17. namespace NYT {
  18. ////////////////////////////////////////////////////////////////////////////////
  19. bool ParseBoolFromResponse(const TString& response)
  20. {
  21. return GetBool(NodeFromYsonString(response));
  22. }
  23. TGUID ParseGuidFromResponse(const TString& response)
  24. {
  25. auto node = NodeFromYsonString(response);
  26. return GetGuid(node.AsString());
  27. }
  28. ////////////////////////////////////////////////////////////////////////////////
  29. TString GetProxyForHeavyRequest(const TClientContext& context)
  30. {
  31. if (!context.Config->UseHosts) {
  32. return context.ProxyAddress ? *context.ProxyAddress : context.ServerName;
  33. }
  34. return NPrivate::THostManager::Get().GetProxyForHeavyRequest(context);
  35. }
  36. void LogRequestError(
  37. const TString& requestId,
  38. const THttpHeader& header,
  39. const TString& message,
  40. const TString& attemptDescription)
  41. {
  42. YT_LOG_ERROR("RSP %v - %v - %v - %v - X-YT-Parameters: %v",
  43. requestId,
  44. header.GetUrl(),
  45. message,
  46. attemptDescription,
  47. NodeToYsonString(header.GetParameters()));
  48. }
  49. ////////////////////////////////////////////////////////////////////////////////
  50. } // namespace NYT