Skip to content

Commit 1aa104a

Browse files
authored
[Filestore] toggle service state functionality via execute action and remove implementation via a separate service method (#4582)
1 parent 6cfc50c commit 1aa104a

File tree

18 files changed

+97
-93
lines changed

18 files changed

+97
-93
lines changed

cloud/filestore/libs/diagnostics/profile_log_events.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ void FinalizeProfileLogRequestInfo(
127127
IMPLEMENT_DEFAULT_METHOD(CreateSession)
128128
IMPLEMENT_DEFAULT_METHOD(DestroySession)
129129
IMPLEMENT_DEFAULT_METHOD(PingSession)
130-
IMPLEMENT_DEFAULT_METHOD(ToggleServiceState)
131130
IMPLEMENT_DEFAULT_METHOD(AddClusterNode)
132131
IMPLEMENT_DEFAULT_METHOD(RemoveClusterNode)
133132
IMPLEMENT_DEFAULT_METHOD(ListClusterNodes)
@@ -505,7 +504,6 @@ void InitProfileLogRequestInfo(
505504
IMPLEMENT_DEFAULT_METHOD(CreateSession, NProto)
506505
IMPLEMENT_DEFAULT_METHOD(DestroySession, NProto)
507506
IMPLEMENT_DEFAULT_METHOD(PingSession, NProto)
508-
IMPLEMENT_DEFAULT_METHOD(ToggleServiceState, NProto)
509507
IMPLEMENT_DEFAULT_METHOD(AddClusterNode, NProto)
510508
IMPLEMENT_DEFAULT_METHOD(RemoveClusterNode, NProto)
511509
IMPLEMENT_DEFAULT_METHOD(ListClusterNodes, NProto)

cloud/filestore/libs/service/auth_scheme.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ TPermissionList GetRequestPermissions(EFileStoreRequest requestType)
1616
case EFileStoreRequest::DestroySession:
1717
case EFileStoreRequest::ResetSession:
1818
case EFileStoreRequest::PingSession:
19-
case EFileStoreRequest::ToggleServiceState:
2019
case EFileStoreRequest::SubscribeSession:
2120
case EFileStoreRequest::GetSessionEvents:
2221
case EFileStoreRequest::GetSessionEventsStream:

cloud/filestore/libs/service/request.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ static const TString RequestNames[] = {
120120
"AddData",
121121
"ReadBlob",
122122
"WriteBlob",
123-
"ToggleServiceState",
124123
};
125124

126125
static_assert(

cloud/filestore/libs/service/request.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ namespace NCloud::NFileStore {
8585
#define FILESTORE_CONTROL_SERVICE(xxx, ...) \
8686
xxx(Ping, __VA_ARGS__) \
8787
xxx(PingSession, __VA_ARGS__) \
88-
xxx(ToggleServiceState, __VA_ARGS__) \
8988
FILESTORE_SERVICE_METHODS(xxx, __VA_ARGS__) \
9089
// FILESTORE_CONTROL_SERVICE
9190

9291
#define FILESTORE_SERVICE(xxx, ...) \
9392
xxx(Ping, __VA_ARGS__) \
9493
xxx(PingSession, __VA_ARGS__) \
95-
xxx(ToggleServiceState, __VA_ARGS__) \
9694
FILESTORE_SERVICE_METHODS(xxx, __VA_ARGS__) \
9795
FILESTORE_DATA_METHODS(xxx, __VA_ARGS__) \
9896
FILESTORE_LOCAL_DATA_METHODS(xxx, __VA_ARGS__) \
@@ -101,7 +99,6 @@ namespace NCloud::NFileStore {
10199
#define FILESTORE_REMOTE_SERVICE(xxx, ...) \
102100
xxx(Ping, __VA_ARGS__) \
103101
xxx(PingSession, __VA_ARGS__) \
104-
xxx(ToggleServiceState, __VA_ARGS__) \
105102
FILESTORE_SERVICE_METHODS(xxx, __VA_ARGS__) \
106103
FILESTORE_DATA_METHODS(xxx, __VA_ARGS__) \
107104
// FILESTORE_SERVICE
@@ -135,7 +132,6 @@ namespace NCloud::NFileStore {
135132
#define FILESTORE_PROTO_REQUESTS(xxx, ...) \
136133
xxx(Ping, __VA_ARGS__) \
137134
xxx(PingSession, __VA_ARGS__) \
138-
xxx(ToggleServiceState, __VA_ARGS__) \
139135
FILESTORE_SERVICE_METHODS(xxx, __VA_ARGS__) \
140136
FILESTORE_DATA_METHODS(xxx, __VA_ARGS__) \
141137
FILESTORE_LOCAL_DATA_METHODS(xxx, __VA_ARGS__) \
@@ -152,7 +148,6 @@ enum class EFileStoreRequest
152148
AddData,
153149
ReadBlob,
154150
WriteBlob,
155-
ToggleServiceState,
156151
MAX
157152
};
158153

cloud/filestore/libs/service_local/fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ namespace NCloud::NFileStore {
7272
#define FILESTORE_SERVICE_LOCAL_SYNC(xxx, ...) \
7373
xxx(Ping, __VA_ARGS__) \
7474
xxx(PingSession, __VA_ARGS__) \
75-
xxx(ToggleServiceState, __VA_ARGS__) \
7675
FILESTORE_SERVICE_METHODS(xxx, __VA_ARGS__) \
7776
FILESTORE_DATA_METHODS_LOCAL_SYNC(xxx, __VA_ARGS__) \
7877
// FILESTORE_SERVICE_LOCAL_SYNC

cloud/filestore/libs/service_local/service.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,6 @@ FILESTORE_IMPLEMENT_METHOD_ASYNC(WriteDataLocal)
422422
return {};
423423
}
424424

425-
template <>
426-
NProto::TToggleServiceStateResponse Execute<TToggleServiceStateMethod>(
427-
NProto::TToggleServiceStateRequest& request,
428-
NProto::TProfileLogRequestInfo& logRequest)
429-
{
430-
Y_UNUSED(request, logRequest);
431-
return {};
432-
}
433-
434425
template <>
435426
NProto::TCreateFileStoreResponse Execute<TCreateFileStoreMethod>(
436427
NProto::TCreateFileStoreRequest& request,

cloud/filestore/libs/storage/service/service_actor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ class TStorageServiceActor final
261261
TRequestInfoPtr requestInfo,
262262
TString input);
263263

264+
void PerformToggleServiceStateAction(
265+
const NActors::TActorContext& ctx,
266+
TRequestInfoPtr requestInfo,
267+
TString input);
268+
264269
private:
265270
void RenderSessions(IOutputStream& out);
266271
void RenderLocalFileStores(IOutputStream& out);

cloud/filestore/libs/storage/service/service_actor_actions.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,35 @@ void TStorageServiceActor::HandleExecuteAction(
114114
}
115115
};
116116

117+
using TInstantAction = void (TStorageServiceActor::*)(
118+
const NActors::TActorContext&,
119+
TRequestInfoPtr,
120+
TString);
121+
122+
static const THashMap<TString, TInstantAction> instantActions = {
123+
{
124+
"toggleservicestate",
125+
&TStorageServiceActor::PerformToggleServiceStateAction
126+
}
127+
};
128+
117129
auto it = actions.find(action);
118-
if (it == actions.end()) {
119-
NCloud::Reply(ctx, *requestInfo, ActionNotFoundResponse());
130+
if (it != actions.end()) {
131+
auto actorBuilder = it->second;
132+
auto actor =
133+
std::invoke(actorBuilder, this, requestInfo, std::move(input));
134+
NCloud::Register(ctx, std::move(actor));
120135
return;
121136
}
122-
auto actorBuilder = it->second;
123-
auto actor = std::invoke(actorBuilder, this, requestInfo, std::move(input));
124-
NCloud::Register(ctx, std::move(actor));
137+
138+
auto instantIt = instantActions.find(action);
139+
if (instantIt != instantActions.end()) {
140+
auto instantAction = instantIt->second;
141+
std::invoke(instantAction, this, ctx, requestInfo, std::move(input));
142+
return;
143+
}
144+
145+
NCloud::Reply(ctx, *requestInfo, ActionNotFoundResponse());
125146
}
126147

127148
} // namespace NCloud::NFileStore::NStorage
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "service_actor.h"
2+
3+
#include <cloud/filestore/private/api/protos/actions.pb.h>
4+
5+
#include <google/protobuf/util/json_util.h>
6+
7+
namespace NCloud::NFileStore::NStorage {
8+
9+
using namespace NActors;
10+
11+
using namespace NKikimr;
12+
13+
////////////////////////////////////////////////////////////////////////////////
14+
15+
void TStorageServiceActor::PerformToggleServiceStateAction(
16+
const NActors::TActorContext& ctx,
17+
TRequestInfoPtr requestInfo,
18+
TString input)
19+
{
20+
NProtoPrivate::TToggleServiceStateRequest request;
21+
if (!google::protobuf::util::JsonStringToMessage(input, &request).ok()) {
22+
auto msg = std::make_unique<TEvService::TEvExecuteActionResponse>(
23+
TErrorResponse(E_ARGUMENT, "Failed to parse input"));
24+
NCloud::Reply(ctx, *requestInfo, std::move(msg));
25+
return;
26+
}
27+
28+
ServiceState = request.GetDesiredServiceState();
29+
LOG_INFO(
30+
ctx,
31+
TFileStoreComponents::SERVICE,
32+
"Service state changed to %s",
33+
EServiceState_Name(ServiceState).Quote().c_str());
34+
35+
NProtoPrivate::TToggleServiceStateResponse response;
36+
37+
auto msg = std::make_unique<TEvService::TEvExecuteActionResponse>();
38+
google::protobuf::util::MessageToJsonString(
39+
response,
40+
msg->Record.MutableOutput());
41+
NCloud::Reply(ctx, *requestInfo, std::move(msg));
42+
}
43+
44+
} // namespace NCloud::NFileStore::NStorage

cloud/filestore/libs/storage/service/service_actor_toggle_service_state.cpp

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)