Skip to content

Commit 493df77

Browse files
coteeqblinkov
authored andcommitted
YT-20179: Implement PatchSpec
* Changelog entry Type: feature Component: map-reduce New PatchSpec API call can be used to tweak spec at runtime. Now it only supports changing max_failed_job_count, but more spec options are on the way! commit_hash:21ce2961e5d685a66d4139b8f4bcf0e68f5c49cc
1 parent b527509 commit 493df77

File tree

8 files changed

+23
-1
lines changed

8 files changed

+23
-1
lines changed

yt/yt/client/formats/format.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ const IAttributeDictionary& TFormat::Attributes() const
5252
return *Attributes_;
5353
}
5454

55+
bool TFormat::operator==(const TFormat& other) const
56+
{
57+
return GetType() == other.GetType() && Attributes() == other.Attributes();
58+
}
59+
5560
void Serialize(const TFormat& value, IYsonConsumer* consumer)
5661
{
5762
BuildYsonFluently(consumer)

yt/yt/client/formats/format.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class TFormat
3030

3131
const NYTree::IAttributeDictionary& Attributes() const;
3232

33+
bool operator==(const TFormat& other) const;
34+
3335
private:
3436
NYTree::IAttributeDictionaryPtr Attributes_;
3537

yt/yt/client/misc/workload.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ struct TWorkloadDescriptor
4949
//! Computes the aggregated priority.
5050
//! Larger is better.
5151
i64 GetPriority() const;
52+
53+
bool operator==(const TWorkloadDescriptor& other) const = default;
5254
};
5355

5456
i64 GetBasicPriority(EWorkloadCategory category);

yt/yt/client/scheduler/public.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ YT_DEFINE_ERROR_ENUM(
7878
((CannotUseBothAclAndAco) (221))
7979
((GangOperationsAllowedOnlyInFifoPools) (222))
8080
((OperationLaunchedInNonexistentPool) (223))
81+
((OperationHasNoController) (224))
8182
);
8283

8384
DEFINE_ENUM(EUnavailableChunkAction,

yt/yt/client/scheduler/spec_patch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ void FromProto(TSpecPatchPtr patch, const NProto::TSpecPatch* protoPatch)
2828
patch->Value = ConvertToNode(TYsonString(protoPatch->value()));
2929
}
3030

31+
void FromProto(TSpecPatchPtr* patch, const NProto::TSpecPatch& protoPatch)
32+
{
33+
*patch = New<TSpecPatch>();
34+
FromProto(*patch, &protoPatch);
35+
}
36+
3137
void FormatValue(TStringBuilderBase* builder, const TSpecPatchPtr& patch, TStringBuf /*spec*/)
3238
{
3339
builder->AppendString(ConvertToYsonString(patch).ToString());

yt/yt/client/scheduler/spec_patch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ DEFINE_REFCOUNTED_TYPE(TSpecPatch)
2626

2727
void ToProto(NProto::TSpecPatch* protoPatch, const TSpecPatchPtr& patch);
2828
void FromProto(TSpecPatchPtr patch, const NProto::TSpecPatch* protoPatch);
29+
void FromProto(TSpecPatchPtr* patch, const NProto::TSpecPatch& protoPatch);
2930

3031
void FormatValue(TStringBuilderBase* builder, const TSpecPatchPtr& patch, TStringBuf spec);
3132

yt/yt/core/misc/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ struct TExponentialBackoffOptions
2323
TDuration MaxBackoff = DefaultMaxBackoff;
2424
double BackoffMultiplier = DefaultBackoffMultiplier;
2525
double BackoffJitter = DefaultBackoffJitter;
26+
27+
bool operator==(const TExponentialBackoffOptions& other) const = default;
2628
};
2729

2830
////////////////////////////////////////////////////////////////////////////////

yt/yt/core/ytree/yson_struct_update-inl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ void Update(
174174
TIntrusivePtr<TStruct> newStruct)
175175
{
176176
const auto* meta = oldStruct->GetMeta();
177+
YT_VERIFY(meta == newStruct->GetMeta());
177178
const auto& parameterToFieldRegistrar = registrar.RegisteredFields_->ParameterToFieldRegistrar;
179+
YT_VERIFY(registrar.RegisteredFields_->Meta == meta);
178180
for (const auto& [name, parameter] : meta->GetParameterMap()) {
179181
if (parameter->CompareParameter(oldStruct.Get(), newStruct.Get())) {
180182
continue;
@@ -183,8 +185,9 @@ void Update(
183185
auto fieldDescIter = parameterToFieldRegistrar.find(parameter);
184186
if (fieldDescIter == parameterToFieldRegistrar.end()) {
185187
THROW_ERROR_EXCEPTION("Field %Qv is not marked as updatable, but was changed", name);
188+
} else {
189+
fieldDescIter->second->DoUpdate(parameter, oldStruct.Get(), newStruct.Get());
186190
}
187-
fieldDescIter->second->DoUpdate(parameter, oldStruct.Get(), newStruct.Get());
188191
}
189192
}
190193

0 commit comments

Comments
 (0)