Skip to content

Commit

Permalink
CR2
Browse files Browse the repository at this point in the history
  • Loading branch information
budevg committed Sep 22, 2024
1 parent 6f76645 commit 82170b0
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 112 deletions.
26 changes: 26 additions & 0 deletions cloud/filestore/libs/service_kikimr/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,32 @@ class TKikimrFileStore final
std::move(response)));
}

template<>
void ExecuteRequest<TFsyncMethod>(
TCallContextPtr callContext,
std::shared_ptr<TFsyncMethod::TRequest> request,
TPromise<TFsyncMethod::TResponse> response)
{
Y_UNUSED(callContext);
Y_UNUSED(request);
Y_UNUSED(TFsyncMethod::RequestName);

response.SetValue(TFsyncMethod::TResponse());
}

template<>
void ExecuteRequest<TFsyncDirMethod>(
TCallContextPtr callContext,
std::shared_ptr<TFsyncDirMethod::TRequest> request,
TPromise<TFsyncDirMethod::TResponse> response)
{
Y_UNUSED(callContext);
Y_UNUSED(request);
Y_UNUSED(TFsyncDirMethod::RequestName);

response.SetValue(TFsyncDirMethod::TResponse());
}

template <typename T>
void ExecuteStreamRequest(
TCallContextPtr callContext,
Expand Down
88 changes: 79 additions & 9 deletions cloud/filestore/libs/service_kikimr/service_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct TTestServiceActor final

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

Y_UNIT_TEST_SUITE(TIndexStoreTest)
Y_UNIT_TEST_SUITE(KikimrFileStore)
{
Y_UNIT_TEST(ShouldHandleRequests)
{
Expand All @@ -86,17 +86,87 @@ Y_UNIT_TEST_SUITE(TIndexStoreTest)
auto service = CreateKikimrFileStore(actorSystem);
service->Start();

auto context = MakeIntrusive<TCallContext>();
auto request = std::make_shared<NProto::TCreateFileStoreRequest>();
{
auto context = MakeIntrusive<TCallContext>();
auto request = std::make_shared<NProto::TCreateFileStoreRequest>();

auto future = service->CreateFileStore(
std::move(context),
std::move(request));
auto future = service->CreateFileStore(
std::move(context),
std::move(request));

actorSystem->DispatchEvents(WaitTimeout);
actorSystem->DispatchEvents(WaitTimeout);

const auto& response = future.GetValue(WaitTimeout);
UNIT_ASSERT(!HasError(response));
}

{
auto context = MakeIntrusive<TCallContext>();
auto request = std::make_shared<NProto::TCreateNodeRequest>();

auto future = service->CreateNode(
std::move(context),
std::move(request));

actorSystem->DispatchEvents(WaitTimeout);

const auto& response = future.GetValue(WaitTimeout);
UNIT_ASSERT(!HasError(response));
}

service->Stop();
}

Y_UNIT_TEST(ShouldHandleFsyncRequestsOutsideActorSystem)
{
auto serviceActor = std::make_unique<TTestServiceActor>();
serviceActor->FsyncHandler =
[] (const TEvService::TEvFsyncRequest::TPtr& ev) {
Y_UNUSED(ev);
UNIT_ASSERT_C(false, "fsync called in actor system");
return std::make_unique<TEvService::TEvFsyncResponse>();
};

const auto& response = future.GetValue(WaitTimeout);
UNIT_ASSERT(!HasError(response));
serviceActor->FsyncDirHandler =
[] (const TEvService::TEvFsyncDirRequest::TPtr& ev) {
Y_UNUSED(ev);
UNIT_ASSERT_C(false, "fsyncdir called in actor system");
return std::make_unique<TEvService::TEvFsyncDirResponse>();
};

auto actorSystem = MakeIntrusive<TTestActorSystem>();
actorSystem->RegisterTestService(std::move(serviceActor));

auto service = CreateKikimrFileStore(actorSystem);
service->Start();

{
auto context = MakeIntrusive<TCallContext>();
auto request = std::make_shared<NProto::TFsyncRequest>();

auto future = service->Fsync(
std::move(context),
std::move(request));

actorSystem->DispatchEvents(WaitTimeout);

const auto& response = future.GetValue(WaitTimeout);
UNIT_ASSERT(!HasError(response));
}

{
auto context = MakeIntrusive<TCallContext>();
auto request = std::make_shared<NProto::TFsyncDirRequest>();

auto future = service->FsyncDir(
std::move(context),
std::move(request));

actorSystem->DispatchEvents(WaitTimeout);

const auto& response = future.GetValue(WaitTimeout);
UNIT_ASSERT(!HasError(response));
}

service->Stop();
}
Expand Down
5 changes: 1 addition & 4 deletions cloud/filestore/libs/storage/api/components.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ namespace NCloud::NFileStore::NStorage {
#define FILESTORE_ACTORS(xxx) \
xxx(SCHEMESHARD) \
xxx(SERVICE) \
xxx(SERVICE_PART2) \
xxx(SERVICE_WORKER) \
xxx(SERVICE_PROXY) \
xxx(TABLET) \
xxx(TABLET_WORKER) \
xxx(TABLET_PROXY) \
xxx(SS_PROXY) \
xxx(SERVICE_WORKER) \
// FILESTORE_ACTORS

#define FILESTORE_COMPONENTS(xxx) \
Expand Down Expand Up @@ -81,8 +80,6 @@ struct TFileStoreEvents
END
};

static_assert(SERVICE_END + 1 == SERVICE_PART2_START,
"SERVICE_PART2 should follow SERVICE since SERVICE has more than 100 events");
static_assert(END < EventSpaceEnd(NKikimr::TKikimrEvents::ES_FILESTORE),
"END expected to be < EventSpaceEnd(NKikimr::TKikimrEvents::ES_FILESTORE)");
};
Expand Down
15 changes: 9 additions & 6 deletions cloud/filestore/libs/storage/api/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,20 @@ struct TEvService
EvExecuteActionRequest = EvBegin + 95,
EvExecuteActionResponse,

EvFsyncRequest = EvBegin + 97,
EvEnd,

// These events are never handled in actor system.
// We need to specify them here to avoid breaking template code
// which generates handlers for all events in actor system
EvFsyncRequest = TFileStoreEvents::END + 1,
EvFsyncResponse,

EvFsyncDirRequest = EvBegin + 99,
EvFsyncDirRequest,
EvFsyncDirResponse,

EvEnd
};

static_assert(EvEnd < (int)TFileStoreEvents::SERVICE_PART2_END,
"EvEnd expected to be < TFileStoreEvents::SERVICE_PART2_END");
static_assert(EvEnd < (int)TFileStoreEvents::SERVICE_END,
"EvEnd expected to be < TFileStoreEvents::SERVICE_END");

FILESTORE_SERVICE(FILESTORE_DECLARE_PROTO_EVENTS, NProto)

Expand Down
22 changes: 22 additions & 0 deletions cloud/filestore/libs/storage/service/service_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,26 @@ void TStorageServiceActor::HandleUnregisterLocalFileStore(
}
}

void TStorageServiceActor::HandleFsync(
const TEvService::TEvFsyncRequest::TPtr& ev,
const TActorContext& ctx)
{
Y_UNUSED(ev);
Y_UNUSED(ctx);

// Fsync is handled in service_kikimr
Y_ABORT();
}

void TStorageServiceActor::HandleFsyncDir(
const TEvService::TEvFsyncDirRequest::TPtr& ev,
const TActorContext& ctx)
{
Y_UNUSED(ev);
Y_UNUSED(ctx);

// FsyncDir is handled in service_kikimr
Y_ABORT();
}

} // namespace NCloud::NFileStore::NStorage
27 changes: 0 additions & 27 deletions cloud/filestore/libs/storage/service/service_actor_fsync.cpp

This file was deleted.

35 changes: 0 additions & 35 deletions cloud/filestore/libs/storage/service/service_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5809,41 +5809,6 @@ Y_UNIT_TEST_SUITE(TStorageServiceTest)

UNIT_ASSERT_VALUES_EQUAL(lastCompactionMapRangeId, 29);
}

Y_UNIT_TEST(ShouldFsyncFileAndDir)
{
TTestEnv env;
env.CreateSubDomain("nfs");

ui32 nodeIdx = env.CreateNode("nfs");

TServiceClient service(env.GetRuntime(), nodeIdx);
service.CreateFileStore("test", 1'000);

auto headers = service.InitSession("test", "client");

ui64 fileNodeId =
service
.CreateNode(headers, TCreateNodeArgs::File(RootNodeId, "file"))
->Record.GetNode()
.GetId();

ui64 fileHandle =
service
.CreateHandle(headers, "test", fileNodeId, "", TCreateHandleArgs::RDWR)
->Record.GetHandle();

ui64 dirNodeId =
service
.CreateNode(headers, TCreateNodeArgs::Directory(RootNodeId, "dir"))
->Record.GetNode()
.GetId();

for (auto datasync: {true, false}) {
service.Fsync(headers, "test", fileNodeId, fileHandle, datasync);
service.FsyncDir(headers, "test", dirNodeId, datasync);
}
}
}

} // namespace NCloud::NFileStore::NStorage
1 change: 0 additions & 1 deletion cloud/filestore/libs/storage/service/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ SRCS(
service_actor_destroyfs.cpp
service_actor_destroysession.cpp
service_actor_forward.cpp
service_actor_fsync.cpp
service_actor_getfsinfo.cpp
service_actor_getnodeattr.cpp
service_actor_getsessionevents.cpp
Expand Down
30 changes: 0 additions & 30 deletions cloud/filestore/libs/storage/testlib/service_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,36 +444,6 @@ class TServiceClient
return request;
}

std::unique_ptr<TEvService::TEvFsyncRequest> CreateFsyncRequest(
const THeaders& headers,
const TString& fileSystemId,
const ui64 nodeId,
const ui64 handle,
bool dataSync)
{
auto request = std::make_unique<TEvService::TEvFsyncRequest>();
headers.Fill(request->Record);
request->Record.SetFileSystemId(fileSystemId);
request->Record.SetNodeId(nodeId);
request->Record.SetHandle(handle);
request->Record.SetDataSync(dataSync);
return request;
}

std::unique_ptr<TEvService::TEvFsyncDirRequest> CreateFsyncDirRequest(
const THeaders& headers,
const TString& fileSystemId,
const ui64 nodeId,
bool dataSync)
{
auto request = std::make_unique<TEvService::TEvFsyncDirRequest>();
headers.Fill(request->Record);
request->Record.SetFileSystemId(fileSystemId);
request->Record.SetNodeId(nodeId);
request->Record.SetDataSync(dataSync);
return request;
}

std::unique_ptr<TEvService::TEvSetNodeXAttrRequest> CreateSetNodeXAttrRequest(
const THeaders& headers,
const TString& fileSystemId,
Expand Down

0 comments on commit 82170b0

Please sign in to comment.