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 "kicli.h"
#include <ydb/public/lib/deprecated/client/msgbus_client.h>
namespace NKikimr {
namespace NClient {
TRegistrationResult::TRegistrationResult(const TResult& result)
: TResult(result)
{
}
const NKikimrClient::TNodeRegistrationResponse& TRegistrationResult::Record() const
{
return GetResponse<NMsgBusProxy::TBusNodeRegistrationResponse>().Record;
}
bool TRegistrationResult::IsSuccess() const
{
return (GetError().Success()
&& Record().GetStatus().GetCode() == NKikimrNodeBroker::TStatus::OK);
}
TString TRegistrationResult::GetErrorMessage() const
{
if (!GetError().Success())
return GetError().GetMessage();
return Record().GetStatus().GetReason();
}
ui32 TRegistrationResult::GetNodeId() const
{
return Record().GetNodeId();
}
NActors::TScopeId TRegistrationResult::GetScopeId() const
{
const auto& record = Record();
if (record.HasScopeTabletId() && record.HasScopePathId()) {
return {record.GetScopeTabletId(), record.GetScopePathId()};
}
return {};
}
TNodeRegistrant::TNodeRegistrant(TKikimr& kikimr)
: Kikimr(&kikimr)
{
}
TRegistrationResult
TNodeRegistrant::SyncRegisterNode(const TString& domainPath,
const TString& host,
ui16 port,
const TString& address,
const TString& resolveHost,
const NActors::TNodeLocation& location,
bool fixedNodeId,
TMaybe<TString> path) const
{
auto future = Kikimr->RegisterNode(domainPath, host, port, address, resolveHost, location, fixedNodeId, path);
auto result = future.GetValue(TDuration::Max());
return TRegistrationResult(result);
}
} // NClient
} // NKikimr
|