Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2725: mv acquire/release disk actors from DR to libs/storage/core #2855

Closed
wants to merge 11 commits into from

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions cloud/blockstore/libs/storage/core/acquire_release_devices.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#pragma once

#include <cloud/blockstore/libs/kikimr/events.h>
#include <cloud/blockstore/libs/storage/api/disk_agent.h>

#include <contrib/ydb/library/actors/core/actor.h>
vladstepanyuk marked this conversation as resolved.
Show resolved Hide resolved
#include <contrib/ydb/library/actors/interconnect/types.h>

namespace NCloud::NBlockStore::NStorage::NAcquireReleaseDevices {

struct TAgentAcquireDevicesCachedRequest
{
TString AgentId;
NProto::TAcquireDevicesRequest Request;
TInstant RequestTime;
};

struct TAgentReleaseDevicesCachedRequest
{
TString AgentId;
NProto::TReleaseDevicesRequest Request;
};

struct TDevicesAcquireFinished
{
TString DiskId;
TString ClientId;
TVector<TAgentAcquireDevicesCachedRequest> SentRequests;
TVector<NProto::TDeviceConfig> Devices;
NProto::TError Error;

TDevicesAcquireFinished(
TString diskId,
TString clientId,
TVector<TAgentAcquireDevicesCachedRequest> sentRequests,
TVector<NProto::TDeviceConfig> devices,
NProto::TError error)
: DiskId(std::move(diskId))
, ClientId(std::move(clientId))
, SentRequests(std::move(sentRequests))
, Devices(std::move(devices))
, Error(std::move(error))
{}
};

struct TDevicesReleaseFinished
{
TString DiskId;
TString ClientId;
TVector<TAgentReleaseDevicesCachedRequest> SentRequests;
NProto::TError Error;

TDevicesReleaseFinished(
TString diskId,
TString clientId,
TVector<TAgentReleaseDevicesCachedRequest> sentRequests,
NProto::TError error)
: DiskId(std::move(diskId))
, ClientId(std::move(clientId))
, SentRequests(std::move(sentRequests))
, Error(std::move(error))
{}
};

enum EEvents
{
EvBegin,

EvDevicesAcquireFinished,
EvDevicesReleaseFinished,

EvEnd
};

using TEvDevicesAcquireFinished =
TRequestEvent<TDevicesAcquireFinished, EvDevicesAcquireFinished>;

using TEvDevicesReleaseFinished =
TRequestEvent<TDevicesReleaseFinished, EvDevicesReleaseFinished>;

TActorId CreateAcquireDevicesActor(
const NActors::TActorContext& ctx,
const TActorId& owner,
TVector<NProto::TDeviceConfig> devices,
TString diskId,
TString clientId,
NProto::EVolumeAccessMode accessMode,
ui64 mountSeqNumber,
ui32 volumeGeneration,
TDuration requestTimeout,
bool muteIOErrors,
NActors::NLog::EComponent component);

TActorId CreateReleaseDevicesActor(
const NActors::TActorContext& ctx,
const TActorId& owner,
TString diskId,
TString clientId,
ui32 volumeGeneration,
TDuration requestTimeout,
TVector<NProto::TDeviceConfig> devices,
bool muteIOErrors,
NActors::NLog::EComponent component);

} // namespace NCloud::NBlockStore::NStorage::NAcquireReleaseDevices
11 changes: 11 additions & 0 deletions cloud/blockstore/libs/storage/core/proto_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,15 @@ ui64 GetVolumeRequestId(const TEvDiskAgent::TEvZeroDeviceBlocksRequest& request)
return request.Record.GetVolumeRequestId();
}

TString LogDevices(const TVector<NProto::TDeviceConfig>& devices)
{
TStringBuilder sb;
sb << "( ";
for (const auto& d: devices) {
sb << d.GetDeviceUUID() << "@" << d.GetAgentId() << " ";
}
sb << ")";
return sb;
}

} // namespace NCloud::NBlockStore::NStorage
1 change: 1 addition & 0 deletions cloud/blockstore/libs/storage/core/proto_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,5 @@ TBlockRange64 BuildRequestBlockRange(
ui64 GetVolumeRequestId(const TEvDiskAgent::TEvWriteDeviceBlocksRequest& request);
ui64 GetVolumeRequestId(const TEvDiskAgent::TEvZeroDeviceBlocksRequest& request);

TString LogDevices(const TVector<NProto::TDeviceConfig>& devices);
} // namespace NCloud::NBlockStore::NStorage
Loading
Loading