Skip to content

Commit

Permalink
Add allow_lazy_open to machine learning jobs. (#4277)
Browse files Browse the repository at this point in the history
Add allow_lazy_open to machine learning jobs.
  • Loading branch information
codebrain authored Dec 18, 2019
1 parent 1c07db6 commit fb1592b
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Nest/XPack/MachineLearning/Job/Config/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,16 @@ public class Job
/// </summary>
[DataMember(Name = "results_retention_days")]
public long? ResultsRetentionDays { get; set; }

/// <summary>
/// Advanced configuration option. Whether this job should be allowed to open when there is insufficient machine learning
/// node capacity for it to be immediately assigned to a node. The default is false, which means that the
/// machine learning open job will return an error if a machine learning node with capacity to run the job cannot immediately be found.
/// (However, this is also subject to the cluster-wide xpack.ml.max_lazy_ml_nodes setting.)
/// If this option is set to true then the machine learning open job will not return an error, and the job will wait in the opening
/// state until sufficient machine learning node capacity is available.
/// </summary>
[DataMember(Name ="allow_lazy_open")]
public bool? AllowLazyOpen { get; set; }
}
}
19 changes: 19 additions & 0 deletions src/Nest/XPack/MachineLearning/PutJob/PutJobRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public partial interface IPutJobRequest
/// </summary>
[DataMember(Name ="results_index_name")]
IndexName ResultsIndexName { get; set; }

/// <summary>
/// Advanced configuration option. Whether this job should be allowed to open when there is insufficient machine learning
/// node capacity for it to be immediately assigned to a node. The default is false, which means that the
/// machine learning open job will return an error if a machine learning node with capacity to run the job cannot immediately be found.
/// (However, this is also subject to the cluster-wide xpack.ml.max_lazy_ml_nodes setting.)
/// If this option is set to true then the machine learning open job will not return an error, and the job will wait in the opening
/// state until sufficient machine learning node capacity is available.
/// </summary>
[DataMember(Name ="allow_lazy_open")]
bool? AllowLazyOpen { get; set; }
}

/// <inheritdoc />
Expand All @@ -80,6 +91,9 @@ public partial class PutJobRequest

/// <inheritdoc />
public IndexName ResultsIndexName { get; set; }

/// <inheritdoc />
public bool? AllowLazyOpen { get; set; }
}

/// <inheritdoc />
Expand All @@ -92,6 +106,7 @@ public partial class PutJobDescriptor<TDocument> where TDocument : class
IModelPlotConfig IPutJobRequest.ModelPlotConfig { get; set; }
long? IPutJobRequest.ModelSnapshotRetentionDays { get; set; }
IndexName IPutJobRequest.ResultsIndexName { get; set; }
bool? IPutJobRequest.AllowLazyOpen { get; set; }

/// <inheritdoc />
public PutJobDescriptor<TDocument> AnalysisConfig(Func<AnalysisConfigDescriptor<TDocument>, IAnalysisConfig> selector) =>
Expand Down Expand Up @@ -123,6 +138,10 @@ public PutJobDescriptor<TDocument> ResultsIndexName(IndexName indexName) =>
/// <inheritdoc />
public PutJobDescriptor<TDocument> ResultsIndexName<TIndex>() =>
Assign(typeof(TIndex), (a, v) => a.ResultsIndexName = v);

/// <inheritdoc />
public PutJobDescriptor<TDocument> AllowLazyOpen(bool? allowLazyOpen = true) =>
Assign(allowLazyOpen, (a, v) => a.AllowLazyOpen = v);
}

[StringEnum]
Expand Down
12 changes: 11 additions & 1 deletion src/Nest/XPack/MachineLearning/PutJob/PutJobResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ public class PutJobResponse : ResponseBase
/// </summary>
[DataMember(Name ="results_retention_days")]
public long? ResultsRetentionDays { get; internal set; }
}

/// <summary>
/// Advanced configuration option. Whether this job should be allowed to open when there is insufficient machine learning
/// node capacity for it to be immediately assigned to a node. The default is false, which means that the
/// machine learning open job will return an error if a machine learning node with capacity to run the job cannot immediately be found.
/// (However, this is also subject to the cluster-wide xpack.ml.max_lazy_ml_nodes setting.)
/// If this option is set to true then the machine learning open job will not return an error, and the job will wait in the opening
/// state until sufficient machine learning node capacity is available.
/// </summary>
[DataMember(Name ="allow_lazy_open")]
public bool? AllowLazyOpen { get; set; }
}
}
35 changes: 35 additions & 0 deletions src/Nest/XPack/MachineLearning/UpdateJob/UpdateJobRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,48 @@ public partial interface IUpdateJobRequest
/// </summary>
[DataMember(Name ="results_retention_days")]
long? ResultsRetentionDays { get; set; }

/// <summary>
/// Advanced configuration option. Whether this job should be allowed to open when there is insufficient machine learning
/// node capacity for it to be immediately assigned to a node. The default is false, which means that the
/// machine learning open job will return an error if a machine learning node with capacity to run the job cannot immediately be found.
/// (However, this is also subject to the cluster-wide xpack.ml.max_lazy_ml_nodes setting.)
/// If this option is set to true then the machine learning open job will not return an error, and the job will wait in the opening
/// state until sufficient machine learning node capacity is available.
/// </summary>
[DataMember(Name ="allow_lazy_open")]
bool? AllowLazyOpen { get; set; }
}

/// <inheritdoc />
public partial class UpdateJobRequest
{
/// <inheritdoc />
public IAnalysisMemoryLimit AnalysisLimits { get; set; }

/// <inheritdoc />
public Time BackgroundPersistInterval { get; set; }

/// <inheritdoc />
public Dictionary<string, object> CustomSettings { get; set; }

/// <inheritdoc />
public string Description { get; set; }

/// <inheritdoc />
public IModelPlotConfigEnabled ModelPlotConfig { get; set; }

/// <inheritdoc />
public long? ModelSnapshotRetentionDays { get; set; }

/// <inheritdoc />
public long? RenormalizationWindowDays { get; set; }

/// <inheritdoc />
public long? ResultsRetentionDays { get; set; }

/// <inheritdoc />
public bool? AllowLazyOpen { get; set; }
}

/// <inheritdoc />
Expand All @@ -93,6 +122,8 @@ public partial class UpdateJobDescriptor<TDocument> where TDocument : class
long? IUpdateJobRequest.RenormalizationWindowDays { get; set; }
long? IUpdateJobRequest.ResultsRetentionDays { get; set; }

bool? IUpdateJobRequest.AllowLazyOpen { get; set; }

/// <inheritdoc />
public UpdateJobDescriptor<TDocument> AnalysisLimits(Func<AnalysisMemoryLimitDescriptor, IAnalysisMemoryLimit> selector) =>
Assign(selector, (a, v) => a.AnalysisLimits = v?.Invoke(new AnalysisMemoryLimitDescriptor()));
Expand Down Expand Up @@ -123,5 +154,9 @@ public UpdateJobDescriptor<TDocument> RenormalizationWindowDays(long? renormaliz

/// <inheritdoc />
public UpdateJobDescriptor<TDocument> ResultsRetentionDays(long? resultsRetentionDays) => Assign(resultsRetentionDays, (a, v) => a.ResultsRetentionDays = v);

/// <inheritdoc />
public UpdateJobDescriptor<TDocument> AllowLazyOpen(bool? allowLazyOpen = true) =>
Assign(allowLazyOpen, (a, v) => a.AllowLazyOpen = v);
}
}

0 comments on commit fb1592b

Please sign in to comment.