-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue-2137: GetStorageStats private API action (#2350)
- Loading branch information
Showing
8 changed files
with
225 additions
and
116 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
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
26 changes: 26 additions & 0 deletions
26
cloud/filestore/libs/storage/service/service_actor_actions_stats.cpp
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,26 @@ | ||
#include "service_actor.h" | ||
|
||
#include "tablet_action_actor.h" | ||
|
||
#include <cloud/filestore/libs/storage/api/tablet.h> | ||
#include <cloud/filestore/libs/storage/core/public.h> | ||
|
||
namespace NCloud::NFileStore::NStorage { | ||
|
||
using namespace NActors; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
IActorPtr TStorageServiceActor::CreateGetStorageStatsActionActor( | ||
TRequestInfoPtr requestInfo, | ||
TString input) | ||
{ | ||
using TGetStorageStatsActor = TTabletActionActor< | ||
TEvIndexTablet::TEvGetStorageStatsRequest, | ||
TEvIndexTablet::TEvGetStorageStatsResponse>; | ||
return std::make_unique<TGetStorageStatsActor>( | ||
std::move(requestInfo), | ||
std::move(input)); | ||
} | ||
|
||
} // namespace NCloud::NFileStore::NStorage |
118 changes: 2 additions & 116 deletions
118
cloud/filestore/libs/storage/service/service_actor_actions_unsafe_node_ops.cpp
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 @@ | ||
#include "tablet_action_actor.h" |
122 changes: 122 additions & 0 deletions
122
cloud/filestore/libs/storage/service/tablet_action_actor.h
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,122 @@ | ||
#pragma once | ||
|
||
#include <cloud/filestore/libs/storage/api/service.h> | ||
#include <cloud/filestore/libs/storage/api/tablet_proxy.h> | ||
#include <cloud/filestore/libs/storage/core/public.h> | ||
|
||
#include <contrib/ydb/library/actors/core/actor_bootstrapped.h> | ||
#include <contrib/ydb/library/actors/core/hfunc.h> | ||
|
||
#include <google/protobuf/util/json_util.h> | ||
|
||
namespace NCloud::NFileStore::NStorage { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
template <typename TRequest, typename TResponse> | ||
class TTabletActionActor final | ||
: public NActors::TActorBootstrapped<TTabletActionActor<TRequest, TResponse>> | ||
{ | ||
private: | ||
const TRequestInfoPtr RequestInfo; | ||
const TString Input; | ||
|
||
using TBase = | ||
NActors::TActorBootstrapped<TTabletActionActor<TRequest, TResponse>>; | ||
|
||
public: | ||
TTabletActionActor( | ||
TRequestInfoPtr requestInfo, | ||
TString input); | ||
|
||
void Bootstrap(const NActors::TActorContext& ctx); | ||
|
||
private: | ||
void ReplyAndDie( | ||
const NActors::TActorContext& ctx, | ||
const TResponse::ProtoRecordType& responseRecord); | ||
|
||
private: | ||
STFUNC(StateWork) | ||
{ | ||
switch (ev->GetTypeRewrite()) { | ||
HFunc(TResponse, HandleResponse); | ||
|
||
default: | ||
HandleUnexpectedEvent(ev, TFileStoreComponents::SERVICE); | ||
break; | ||
} | ||
} | ||
|
||
void HandleResponse( | ||
const TResponse::TPtr& ev, | ||
const NActors::TActorContext& ctx); | ||
}; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
template <typename TRequest, typename TResponse> | ||
TTabletActionActor<TRequest, TResponse>::TTabletActionActor( | ||
TRequestInfoPtr requestInfo, | ||
TString input) | ||
: RequestInfo(std::move(requestInfo)) | ||
, Input(std::move(input)) | ||
{} | ||
|
||
template <typename TRequest, typename TResponse> | ||
void TTabletActionActor<TRequest, TResponse>::Bootstrap( | ||
const NActors::TActorContext& ctx) | ||
{ | ||
typename TRequest::ProtoRecordType request; | ||
if (!google::protobuf::util::JsonStringToMessage(Input, &request).ok()) { | ||
ReplyAndDie( | ||
ctx, | ||
TErrorResponse(E_ARGUMENT, "Failed to parse input")); | ||
return; | ||
} | ||
|
||
if (!request.GetFileSystemId()) { | ||
ReplyAndDie( | ||
ctx, | ||
TErrorResponse(E_ARGUMENT, "FileSystem id should be supplied")); | ||
return; | ||
} | ||
|
||
auto requestToTablet = std::make_unique<TRequest>(); | ||
requestToTablet->Record = std::move(request); | ||
|
||
NCloud::Send( | ||
ctx, | ||
MakeIndexTabletProxyServiceId(), | ||
std::move(requestToTablet)); | ||
|
||
TBase::Become(&TTabletActionActor<TRequest, TResponse>::StateWork); | ||
} | ||
|
||
template <typename TRequest, typename TResponse> | ||
void TTabletActionActor<TRequest, TResponse>::ReplyAndDie( | ||
const NActors::TActorContext& ctx, | ||
const TResponse::ProtoRecordType& response) | ||
{ | ||
auto msg = std::make_unique<TEvService::TEvExecuteActionResponse>( | ||
response.GetError()); | ||
|
||
google::protobuf::util::MessageToJsonString( | ||
response, | ||
msg->Record.MutableOutput()); | ||
|
||
NCloud::Reply(ctx, *RequestInfo, std::move(msg)); | ||
TBase::Die(ctx); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
template <typename TRequest, typename TResponse> | ||
void TTabletActionActor<TRequest, TResponse>::HandleResponse( | ||
const TResponse::TPtr& ev, | ||
const NActors::TActorContext& ctx) | ||
{ | ||
ReplyAndDie(ctx, ev->Get()->Record); | ||
} | ||
|
||
} // namespace NCloud::NFileStore::NStorage |
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