aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/http/requests.cpp
blob: 7cf0f673bb4a498cb61c8a4b9f0373c2b99ba9c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "requests.h"

#include "context.h"
#include "host_manager.h"
#include "retry_request.h"

#include <yt/cpp/mapreduce/client/transaction.h>

#include <yt/cpp/mapreduce/common/helpers.h>
#include <yt/cpp/mapreduce/common/retry_lib.h>
#include <yt/cpp/mapreduce/common/node_builder.h>
#include <yt/cpp/mapreduce/common/wait_proxy.h>

#include <yt/cpp/mapreduce/interface/config.h>
#include <yt/cpp/mapreduce/interface/errors.h>
#include <yt/cpp/mapreduce/interface/logging/yt_log.h>
#include <yt/cpp/mapreduce/interface/serialize.h>

#include <util/stream/file.h>
#include <util/string/builder.h>
#include <util/generic/buffer.h>


namespace NYT {

////////////////////////////////////////////////////////////////////////////////

bool ParseBoolFromResponse(const TString& response)
{
    return GetBool(NodeFromYsonString(response));
}

TGUID ParseGuidFromResponse(const TString& response)
{
    auto node = NodeFromYsonString(response);
    return GetGuid(node.AsString());
}

////////////////////////////////////////////////////////////////////////////////

TString GetProxyForHeavyRequest(const TClientContext& context)
{
    if (!context.Config->UseHosts) {
        return context.ServerName;
    }

    return NPrivate::THostManager::Get().GetProxyForHeavyRequest(context);
}

void LogRequestError(
    const TString& requestId,
    const THttpHeader& header,
    const TString& message,
    const TString& attemptDescription)
{
    YT_LOG_ERROR("RSP %v - %v - %v - %v - X-YT-Parameters: %v",
        requestId,
        header.GetUrl(),
        message,
        attemptDescription,
        NodeToYsonString(header.GetParameters()));
}

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT