blob: 119d685cad3b571bb69b724e49188e97cfde819c (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#pragma once
#include <yt/cpp/mapreduce/interface/common.h>
#include <yt/cpp/mapreduce/http/context.h>
#include <yt/cpp/mapreduce/raw_client/raw_requests.h>
#include <util/str_stl.h>
#include <util/system/mutex.h>
#include <util/generic/hash.h>
namespace NYT {
namespace NDetail {
////////////////////////////////////////////////////////////////////////////////
class IAbortable
: public TThrRefBase
{
public:
virtual void Abort() = 0;
virtual TString GetType() const = 0;
};
using IAbortablePtr = ::TIntrusivePtr<IAbortable>;
////////////////////////////////////////////////////////////////////////////////
class TTransactionAbortable
: public IAbortable
{
public:
TTransactionAbortable(const TClientContext& context, const TTransactionId& transactionId);
void Abort() override;
TString GetType() const override;
private:
TClientContext Context_;
TTransactionId TransactionId_;
};
////////////////////////////////////////////////////////////////////////////////
class TOperationAbortable
: public IAbortable
{
public:
TOperationAbortable(IClientRetryPolicyPtr clientRetryPolicy, TClientContext context, const TOperationId& operationId);
void Abort() override;
TString GetType() const override;
private:
const IClientRetryPolicyPtr ClientRetryPolicy_;
const TClientContext Context_;
const TOperationId OperationId_;
};
////////////////////////////////////////////////////////////////////////////////
class TAbortableRegistry
: public TThrRefBase
{
public:
TAbortableRegistry() = default;
static ::TIntrusivePtr<TAbortableRegistry> Get();
void AbortAllAndBlockForever();
void Add(const TGUID& id, IAbortablePtr abortable);
void Remove(const TGUID& id);
private:
THashMap<TGUID, IAbortablePtr> ActiveAbortables_;
TMutex Lock_;
bool Running_ = true;
};
////////////////////////////////////////////////////////////////////////////////
} // namespace NDetail
} // namespace NYT
|