-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NBS-3864: introduce fast data path external endpoint
volumes with "use-fastpath" tag can connect directly to disk-agent without passing the actor system. When migration needed the endpoint will switch back to actor system based data path
- Loading branch information
Showing
42 changed files
with
655 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "device_path.h" | ||
|
||
#include <library/cpp/uri/uri.h> | ||
|
||
#include <util/string/builder.h> | ||
|
||
namespace NCloud::NBlockStore { | ||
|
||
NProto::TError DevicePath::Parse(const TString& devicePath) | ||
{ | ||
// rdma://myt1-ct5-13.cloud.yandex.net:10020/62ccf40f2743308191205ad6391bfa06 | ||
|
||
NUri::TUri uri; | ||
auto res = uri.Parse( | ||
devicePath, | ||
NUri::TFeature::FeaturesDefault | | ||
NUri::TFeature::FeatureSchemeFlexible); | ||
if (res != NUri::TState::ParsedOK) { | ||
return MakeError( | ||
E_FAIL, | ||
TStringBuilder() << "invalid device path " << devicePath); | ||
} | ||
|
||
if (uri.GetField(NUri::TField::FieldScheme) != Protocol) { | ||
return MakeError( | ||
E_FAIL, | ||
TStringBuilder() | ||
<< "device path doesn't start with " | ||
<< Protocol << "://, " << devicePath); | ||
} | ||
|
||
auto path = uri.GetField(NUri::TField::FieldPath); | ||
if (path.size() < 2 || path[0] != '/') { | ||
return MakeError( | ||
E_FAIL, | ||
TStringBuilder() | ||
<< "invalid uuid inside device path " << devicePath); | ||
} | ||
|
||
Host = uri.GetHost(); | ||
Port = uri.GetPort(); | ||
Uuid = path.substr(1); | ||
|
||
return {}; | ||
} | ||
|
||
TString DevicePath::Serialize() const | ||
{ | ||
return TStringBuilder() | ||
<< Protocol << "://" | ||
<< Host << ":" << Port | ||
<< "/" << Uuid; | ||
} | ||
|
||
} // namespace NCloud::NBlockStore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <cloud/storage/core/libs/common/error.h> | ||
|
||
#include <util/generic/string.h> | ||
|
||
namespace NCloud::NBlockStore { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
struct DevicePath | ||
{ | ||
TString Protocol; | ||
TString Host; | ||
ui16 Port; | ||
TString Uuid; | ||
|
||
DevicePath( | ||
const TString protocol, | ||
const TString& host = {}, | ||
ui16 port = 0, | ||
const TString& uuid = {}) | ||
: Protocol(protocol) | ||
, Host(host) | ||
, Port(port) | ||
, Uuid(uuid) | ||
{} | ||
NProto::TError Parse(const TString& devicePath); | ||
TString Serialize() const; | ||
}; | ||
|
||
} // namespace NCloud::NBlockStore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "device_path.h" | ||
|
||
#include <library/cpp/testing/unittest/registar.h> | ||
|
||
namespace NCloud::NBlockStore { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
Y_UNIT_TEST_SUITE(TDevicePathTest) | ||
{ | ||
Y_UNIT_TEST(TestParseValidDevicePath) | ||
{ | ||
DevicePath devPath("rdma"); | ||
auto error = devPath.Parse("rdma://a.b.c.d:10020/11223344"); | ||
UNIT_ASSERT_C(!HasError(error), error); | ||
|
||
UNIT_ASSERT_EQUAL(devPath.Protocol, "rdma"); | ||
UNIT_ASSERT_EQUAL(devPath.Host, "a.b.c.d"); | ||
UNIT_ASSERT_EQUAL(devPath.Port, 10020); | ||
UNIT_ASSERT_EQUAL(devPath.Uuid, "11223344"); | ||
} | ||
|
||
Y_UNIT_TEST(TestParseInvalidProtocol) | ||
{ | ||
DevicePath devPath("unknown"); | ||
auto error = devPath.Parse("rdma://a.b.c.d:10020/11223344"); | ||
UNIT_ASSERT(HasError(error)); | ||
} | ||
|
||
Y_UNIT_TEST(TestParseNoUuid) | ||
{ | ||
DevicePath devPath("rdma"); | ||
auto error = devPath.Parse("rdma://a.b.c.d:10020"); | ||
UNIT_ASSERT(HasError(error)); | ||
} | ||
|
||
Y_UNIT_TEST(TestSerialize) | ||
{ | ||
auto expectedPath = "rdma://a.b.c.d:10020/11223344"; | ||
DevicePath devPath("rdma", "a.b.c.d", 10020, "11223344"); | ||
UNIT_ASSERT_EQUAL(devPath.Serialize(), expectedPath); | ||
|
||
DevicePath devPath2("rdma"); | ||
auto error = devPath2.Parse(expectedPath); | ||
UNIT_ASSERT_C(!HasError(error), error); | ||
UNIT_ASSERT_EQUAL(expectedPath, devPath2.Serialize()); | ||
} | ||
} | ||
|
||
} // namespace NCloud::NBlockStore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "endpoint_events.h" | ||
|
||
namespace NCloud::NBlockStore::NServer { | ||
|
||
namespace { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
class TEndpointEventProxy: public IEndpointEventProxy | ||
{ | ||
private: | ||
IEndpointEventHandlerPtr Handler; | ||
|
||
public: | ||
void OnVolumeConnectionEstablished(const TString& diskId) override; | ||
void Register(IEndpointEventHandlerPtr listener) override; | ||
}; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
void TEndpointEventProxy::OnVolumeConnectionEstablished(const TString& diskId) | ||
{ | ||
if (Handler) { | ||
Handler->OnVolumeConnectionEstablished(diskId); | ||
} | ||
} | ||
|
||
void TEndpointEventProxy::Register(IEndpointEventHandlerPtr listener) | ||
{ | ||
Handler = std::move(listener); | ||
} | ||
|
||
} // namespace | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
IEndpointEventProxyPtr CreateEndpointEventProxy() | ||
{ | ||
return std::make_shared<TEndpointEventProxy>(); | ||
} | ||
|
||
} // namespace NCloud::NBlockStore::NServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "public.h" | ||
|
||
#include <cloud/blockstore/public/api/protos/volume.pb.h> | ||
|
||
namespace NCloud::NBlockStore::NServer { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
struct IEndpointEventHandler | ||
{ | ||
virtual ~IEndpointEventHandler() = default; | ||
|
||
virtual void OnVolumeConnectionEstablished(const TString& diskId) = 0; | ||
}; | ||
|
||
struct IEndpointEventProxy: public IEndpointEventHandler | ||
{ | ||
virtual ~IEndpointEventProxy() = default; | ||
|
||
virtual void Register(IEndpointEventHandlerPtr eventHandler) = 0; | ||
}; | ||
|
||
IEndpointEventProxyPtr CreateEndpointEventProxy(); | ||
|
||
} // namespace NCloud::NBlockStore::NServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.