Skip to content

Commit

Permalink
[Filestore] add ListTabletBootInfoBackups request/response to TabletB…
Browse files Browse the repository at this point in the history
…ootInfoBackup - later it will be used for booting tablets in emergency mode (#2913)
  • Loading branch information
SvartMetal authored Jan 23, 2025
1 parent 80bb53f commit 4483d4d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 17 deletions.
26 changes: 26 additions & 0 deletions cloud/storage/core/libs/hive_proxy/hive_proxy_events_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "public.h"

#include "tablet_boot_info.h"

#include <cloud/storage/core/libs/kikimr/components.h>
#include <cloud/storage/core/libs/kikimr/events.h>

Expand Down Expand Up @@ -95,6 +97,24 @@ struct TEvHiveProxyPrivate
{}
};

//
// ListTabletBootInfoBackups
//

struct TListTabletBootInfoBackupsRequest
{
};

struct TListTabletBootInfoBackupsResponse
{
TVector<TTabletBootInfo> TabletBootInfos;

explicit TListTabletBootInfoBackupsResponse(
TVector<TTabletBootInfo> tabletBootInfos)
: TabletBootInfos(std::move(tabletBootInfos))
{}
};

//
// Events declaration
//
Expand All @@ -110,6 +130,8 @@ struct TEvHiveProxyPrivate
EvReadTabletBootInfoBackupRequest,
EvReadTabletBootInfoBackupResponse,
EvUpdateTabletBootInfoBackupRequest,
EvListTabletBootInfoBackupsRequest,
EvListTabletBootInfoBackupsResponse,

EvEnd
};
Expand All @@ -128,6 +150,10 @@ struct TEvHiveProxyPrivate
TReadTabletBootInfoBackupResponse, EvReadTabletBootInfoBackupResponse>;
using TEvUpdateTabletBootInfoBackupRequest = TRequestEvent<
TUpdateTabletBootInfoBackupRequest, EvUpdateTabletBootInfoBackupRequest>;
using TEvListTabletBootInfoBackupsRequest = TRequestEvent<
TListTabletBootInfoBackupsRequest, EvListTabletBootInfoBackupsRequest>;
using TEvListTabletBootInfoBackupsResponse = TRequestEvent<
TListTabletBootInfoBackupsResponse, EvListTabletBootInfoBackupsResponse>;
};

} // namespace NCloud::NStorage
26 changes: 26 additions & 0 deletions cloud/storage/core/libs/hive_proxy/tablet_boot_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include "public.h"

#include <cloud/storage/core/libs/kikimr/public.h>

namespace NCloud::NStorage {

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

struct TTabletBootInfo
{
TTabletBootInfo() = default;

TTabletBootInfo(
NKikimr::TTabletStorageInfoPtr storageInfo,
ui64 suggestedGeneration)
: StorageInfo(std::move(storageInfo))
, SuggestedGeneration(suggestedGeneration)
{}

NKikimr::TTabletStorageInfoPtr StorageInfo;
ui64 SuggestedGeneration = 0;
};

} // namespace NCloud::NStorage
18 changes: 18 additions & 0 deletions cloud/storage/core/libs/hive_proxy/tablet_boot_info_backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,23 @@ void TTabletBootInfoBackup::HandleBackupTabletBootInfos(
NCloud::Reply(ctx, *ev, std::move(response));
}

void TTabletBootInfoBackup::HandleListTabletBootInfoBackups(
const TEvHiveProxyPrivate::TEvListTabletBootInfoBackupsRequest::TPtr& ev,
const TActorContext& ctx)
{
TVector<TTabletBootInfo> infos;
for (const auto& [_, info]: BackupProto.GetData()) {
infos.emplace_back(
NKikimr::TabletStorageInfoFromProto(info.GetStorageInfo()),
info.GetSuggestedGeneration());
}

auto response =
std::make_unique<TEvHiveProxyPrivate::TEvListTabletBootInfoBackupsResponse>(
std::move(infos));
NCloud::Reply(ctx, *ev, std::move(response));
}

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

STFUNC(TTabletBootInfoBackup::StateWork)
Expand All @@ -196,6 +213,7 @@ STFUNC(TTabletBootInfoBackup::StateWork)
HFunc(TEvHiveProxyPrivate::TEvReadTabletBootInfoBackupRequest, HandleReadTabletBootInfoBackup);
HFunc(TEvHiveProxyPrivate::TEvUpdateTabletBootInfoBackupRequest, HandleUpdateTabletBootInfoBackup);
HFunc(TEvHiveProxy::TEvBackupTabletBootInfosRequest, HandleBackupTabletBootInfos);
HFunc(TEvHiveProxyPrivate::TEvListTabletBootInfoBackupsRequest, HandleListTabletBootInfoBackups);
default:
HandleUnexpectedEvent(ev, LogComponent);
break;
Expand Down
21 changes: 4 additions & 17 deletions cloud/storage/core/libs/hive_proxy/tablet_boot_info_backup.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ namespace NCloud::NStorage {

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

struct TTabletBootInfo
{
TTabletBootInfo() = default;

TTabletBootInfo(
NKikimr::TTabletStorageInfoPtr storageInfo,
ui64 suggestedGeneration)
: StorageInfo(std::move(storageInfo))
, SuggestedGeneration(suggestedGeneration)
{}

NKikimr::TTabletStorageInfoPtr StorageInfo;
ui64 SuggestedGeneration = 0;
};

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

class TTabletBootInfoBackup final
: public NActors::TActorBootstrapped<TTabletBootInfoBackup>
{
Expand Down Expand Up @@ -78,6 +61,10 @@ class TTabletBootInfoBackup final
void HandleBackupTabletBootInfos(
const TEvHiveProxy::TEvBackupTabletBootInfosRequest::TPtr& ev,
const NActors::TActorContext& ctx);

void HandleListTabletBootInfoBackups(
const TEvHiveProxyPrivate::TEvListTabletBootInfoBackupsRequest::TPtr& ev,
const NActors::TActorContext& ctx);
};

} // namespace NCloud::NStorage

0 comments on commit 4483d4d

Please sign in to comment.