diff options
author | babenko <babenko@yandex-team.com> | 2024-07-25 18:42:34 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2024-07-25 18:52:29 +0300 |
commit | c4df9035ef733d9287a31ffae8c682f8bed97d32 (patch) | |
tree | 10cdb286c90a870c107cc2bd30472f86924d4f0d | |
parent | ed241e54f17dc3333638d54e3086b8927d156388 (diff) | |
download | ydb-c4df9035ef733d9287a31ffae8c682f8bed97d32.tar.gz |
Alert if erasure part type is being passed to some IsXXXChunk(Type,Id) helpers
e180312d5e975d3748a057632c36ad2e6dae733a
-rw-r--r-- | yt/yt/client/chunk_client/chunk_replica-inl.h | 92 | ||||
-rw-r--r-- | yt/yt/client/chunk_client/chunk_replica.h | 3 | ||||
-rw-r--r-- | yt/yt/client/chunk_client/private.h | 16 | ||||
-rw-r--r-- | yt/yt/client/object_client/helpers.h | 1 |
4 files changed, 101 insertions, 11 deletions
diff --git a/yt/yt/client/chunk_client/chunk_replica-inl.h b/yt/yt/client/chunk_client/chunk_replica-inl.h index 38871e8dfa..473f6bab15 100644 --- a/yt/yt/client/chunk_client/chunk_replica-inl.h +++ b/yt/yt/client/chunk_client/chunk_replica-inl.h @@ -6,6 +6,10 @@ #include <yt/yt/client/object_client/helpers.h> +#include <library/cpp/yt/logging/logger.h> + +#include "private.h" + namespace NYT::NChunkClient { //////////////////////////////////////////////////////////////////////////////// @@ -213,60 +217,128 @@ inline bool IsPhysicalChunkId(TChunkId id) return IsPhysicalChunkType(NObjectClient::TypeFromId(id)); } -inline bool IsJournalChunkType(NObjectClient::EObjectType type) +inline bool IsJournalChunkTypeImpl(NObjectClient::EObjectType type) { return type == NObjectClient::EObjectType::JournalChunk || type == NObjectClient::EObjectType::ErasureJournalChunk; } +inline bool IsJournalChunkType(NObjectClient::EObjectType type) +{ + constexpr auto& Logger = ChunkClientLogger; + YT_LOG_ALERT_IF( + IsErasureChunkPartType(type), + "Erasure chunk part type passed to IsJournalChunkType (Type: %v)", + type); + return IsJournalChunkTypeImpl(type); +} + inline bool IsJournalChunkId(TChunkId id) { - return IsJournalChunkType(NObjectClient::TypeFromId(id)); + auto type = NObjectClient::TypeFromId(id); + constexpr auto& Logger = ChunkClientLogger; + YT_LOG_ALERT_IF( + IsErasureChunkPartType(type), + "Erasure chunk part type passed to IsJournalChunkId (ChunkId: %v)", + id); + return IsJournalChunkTypeImpl(type); } -inline bool IsBlobChunkType(NObjectClient::EObjectType type) +inline bool IsBlobChunkTypeImpl(NObjectClient::EObjectType type) { return type == NObjectClient::EObjectType::Chunk || type == NObjectClient::EObjectType::ErasureChunk; } +inline bool IsBlobChunkType(NObjectClient::EObjectType type) +{ + constexpr auto& Logger = ChunkClientLogger; + YT_LOG_ALERT_IF( + IsErasureChunkPartType(type), + "Erasure chunk part type passed to IsBlobChunkType (Type: %v)", + type); + return IsBlobChunkTypeImpl(type); +} + inline bool IsBlobChunkId(TChunkId id) { - return IsBlobChunkType(NObjectClient::TypeFromId(id)); + auto type = NObjectClient::TypeFromId(id); + constexpr auto& Logger = ChunkClientLogger; + YT_LOG_ALERT_IF( + IsErasureChunkPartType(type), + "Erasure chunk part type passed to IsBlobChunkId (ChunkId: %v)", + id); + return IsBlobChunkTypeImpl(type); } -inline bool IsErasureChunkType(NObjectClient::EObjectType type) +inline bool IsErasureChunkTypeImpl(NObjectClient::EObjectType type) { return type == NObjectClient::EObjectType::ErasureChunk || type == NObjectClient::EObjectType::ErasureJournalChunk; } -inline bool IsErasureChunkId(TChunkId id) +inline bool IsErasureChunkType(NObjectClient::EObjectType type) { - return IsErasureChunkType(NObjectClient::TypeFromId(id)); + constexpr auto& Logger = ChunkClientLogger; + YT_LOG_ALERT_IF( + IsErasureChunkPartType(type), + "Erasure chunk part type passed to IsErasureChunkType (Type: %v)", + type); + return IsErasureChunkTypeImpl(type); } -inline bool IsErasureChunkPartId(TChunkId id) +inline bool IsErasureChunkId(TChunkId id) { auto type = NObjectClient::TypeFromId(id); + constexpr auto& Logger = ChunkClientLogger; + YT_LOG_ALERT_IF( + IsErasureChunkPartType(type), + "Erasure chunk part type passed to IsErasureChunkId (ChunkId: %v)", + id); + return IsErasureChunkTypeImpl(type); +} + +inline bool IsErasureChunkPartType(NObjectClient::EObjectType type) +{ return type >= NObjectClient::MinErasureChunkPartType && type <= NObjectClient::MaxErasureChunkPartType || type >= NObjectClient::MinErasureJournalChunkPartType && type <= NObjectClient::MaxErasureJournalChunkPartType; } -inline bool IsRegularChunkType(NObjectClient::EObjectType type) +inline bool IsErasureChunkPartId(TChunkId id) +{ + return IsErasureChunkPartType(NObjectClient::TypeFromId(id)); +} + +inline bool IsRegularChunkTypeImpl(NObjectClient::EObjectType type) { return type == NObjectClient::EObjectType::Chunk || type == NObjectClient::EObjectType::JournalChunk; } +inline bool IsRegularChunkType(NObjectClient::EObjectType type) +{ + constexpr auto& Logger = ChunkClientLogger; + YT_LOG_ALERT_IF( + IsErasureChunkPartType(type), + "Erasure chunk part type passed to IsRegularChunkType (Type: %v)", + type); + return IsRegularChunkTypeImpl(type); +} + inline bool IsRegularChunkId(TChunkId id) { - return IsRegularChunkType(NObjectClient::TypeFromId(id)); + auto type = NObjectClient::TypeFromId(id); + constexpr auto& Logger = ChunkClientLogger; + YT_LOG_ALERT_IF( + IsErasureChunkPartType(type), + "Erasure chunk part type passed to IsRegularChunkId (ChunkId: %v)", + id); + return IsRegularChunkTypeImpl(type); } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/chunk_client/chunk_replica.h b/yt/yt/client/chunk_client/chunk_replica.h index e11a7b23e8..bc61c40be3 100644 --- a/yt/yt/client/chunk_client/chunk_replica.h +++ b/yt/yt/client/chunk_client/chunk_replica.h @@ -200,6 +200,9 @@ bool IsErasureChunkType(NObjectClient::EObjectType type); bool IsErasureChunkId(TChunkId id); //! Returns |true| iff this is an erasure chunk part. +bool IsErasureChunkPartType(NObjectClient::EObjectType type); + +//! Returns |true| iff this is an erasure chunk part. bool IsErasureChunkPartId(TChunkId id); //! Returns |true| iff this is a regular (not erasure) chunk. diff --git a/yt/yt/client/chunk_client/private.h b/yt/yt/client/chunk_client/private.h new file mode 100644 index 0000000000..94046385ff --- /dev/null +++ b/yt/yt/client/chunk_client/private.h @@ -0,0 +1,16 @@ +#pragma once + +#include "public.h" + +#include <yt/yt/core/logging/log.h> + +namespace NYT::NChunkClient { + +//////////////////////////////////////////////////////////////////////////////// + +YT_DEFINE_GLOBAL(const NLogging::TLogger, ChunkClientLogger, "ChunkClient"); + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT::NChunkClient + diff --git a/yt/yt/client/object_client/helpers.h b/yt/yt/client/object_client/helpers.h index 997d6fc337..f590b095d0 100644 --- a/yt/yt/client/object_client/helpers.h +++ b/yt/yt/client/object_client/helpers.h @@ -10,7 +10,6 @@ #include <yt/yt/core/rpc/public.h> - namespace NYT::NObjectClient { //////////////////////////////////////////////////////////////////////////////// |