requests.cpp 1.7 KB

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