/
TaskConstraints.cs
172 lines (148 loc) · 7.31 KB
/
TaskConstraints.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
//
// This file was autogenerated by a tool.
// Do not modify it.
//
namespace Microsoft.Azure.Batch
{
using Models = Microsoft.Azure.Batch.Protocol.Models;
using System;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Defines the constraints on a particular Azure Batch task.
/// </summary>
public partial class TaskConstraints : ITransportObjectProvider<Models.TaskConstraints>, IPropertyMetadata
{
private class PropertyContainer : PropertyCollection
{
public readonly PropertyAccessor<int?> MaxTaskRetryCountProperty;
public readonly PropertyAccessor<TimeSpan?> MaxWallClockTimeProperty;
public readonly PropertyAccessor<TimeSpan?> RetentionTimeProperty;
public PropertyContainer() : base(BindingState.Unbound)
{
this.MaxTaskRetryCountProperty = this.CreatePropertyAccessor<int?>(nameof(MaxTaskRetryCount), BindingAccess.Read | BindingAccess.Write);
this.MaxWallClockTimeProperty = this.CreatePropertyAccessor<TimeSpan?>(nameof(MaxWallClockTime), BindingAccess.Read | BindingAccess.Write);
this.RetentionTimeProperty = this.CreatePropertyAccessor<TimeSpan?>(nameof(RetentionTime), BindingAccess.Read | BindingAccess.Write);
}
public PropertyContainer(Models.TaskConstraints protocolObject) : base(BindingState.Bound)
{
this.MaxTaskRetryCountProperty = this.CreatePropertyAccessor(
protocolObject.MaxTaskRetryCount,
nameof(MaxTaskRetryCount),
BindingAccess.Read | BindingAccess.Write);
this.MaxWallClockTimeProperty = this.CreatePropertyAccessor(
protocolObject.MaxWallClockTime,
nameof(MaxWallClockTime),
BindingAccess.Read | BindingAccess.Write);
this.RetentionTimeProperty = this.CreatePropertyAccessor(
protocolObject.RetentionTime,
nameof(RetentionTime),
BindingAccess.Read | BindingAccess.Write);
}
}
private readonly PropertyContainer propertyContainer;
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="TaskConstraints"/> class.
/// </summary>
/// <param name='maxWallClockTime'>The maximum elapsed time that the task may run, measured from the time the task starts.</param>
/// <param name='retentionTime'>The minimum time to retain the working directory for the task on the compute node where it ran, from the time
/// it completes execution. After this time, the Batch service may delete the working directory and all its contents.</param>
/// <param name='maxTaskRetryCount'>The maximum number of retries for the task.</param>
public TaskConstraints(
TimeSpan? maxWallClockTime = default(TimeSpan?),
TimeSpan? retentionTime = default(TimeSpan?),
int? maxTaskRetryCount = default(int?))
{
this.propertyContainer = new PropertyContainer();
this.MaxWallClockTime = maxWallClockTime;
this.RetentionTime = retentionTime;
this.MaxTaskRetryCount = maxTaskRetryCount;
}
/// <summary>
/// Default constructor to support mocking the <see cref="TaskConstraints"/> class.
/// </summary>
protected TaskConstraints()
{
this.propertyContainer = new PropertyContainer();
}
internal TaskConstraints(Models.TaskConstraints protocolObject)
{
this.propertyContainer = new PropertyContainer(protocolObject);
}
#endregion Constructors
#region TaskConstraints
/// <summary>
/// Gets or sets the maximum number of retries for the task.
/// </summary>
/// <remarks>
/// Note that this value specifically controls the number of retries for the task executable due to a nonzero exit
/// code. The Batch service will try the task once, and may then retry up to this limit. For example, if the maximum
/// retry count is 3, Batch tries the task up to 4 times (one initial try and 3 retries). If the maximum retry count
/// is 0, the Batch service does not retry the task after the first attempt. If the maximum retry count is -1, the
/// Batch service retries the task without limit. Resource files and application packages are only downloaded again
/// if the task is retried on a new compute node.
/// </remarks>
public int? MaxTaskRetryCount
{
get { return this.propertyContainer.MaxTaskRetryCountProperty.Value; }
set { this.propertyContainer.MaxTaskRetryCountProperty.Value = value; }
}
/// <summary>
/// Gets or sets the maximum elapsed time that the task may run, measured from the time the task starts.
/// </summary>
public TimeSpan? MaxWallClockTime
{
get { return this.propertyContainer.MaxWallClockTimeProperty.Value; }
set { this.propertyContainer.MaxWallClockTimeProperty.Value = value; }
}
/// <summary>
/// Gets or sets the minimum time to retain the working directory for the task on the compute node where it ran,
/// from the time it completes execution. After this time, the Batch service may delete the working directory and
/// all its contents.
/// </summary>
/// <remarks>
/// The default is 7 days, i.e. the task directory will be retained for 7 days unless the compute node is removed
/// or the job is deleted.
/// </remarks>
public TimeSpan? RetentionTime
{
get { return this.propertyContainer.RetentionTimeProperty.Value; }
set { this.propertyContainer.RetentionTimeProperty.Value = value; }
}
#endregion // TaskConstraints
#region IPropertyMetadata
bool IModifiable.HasBeenModified
{
get { return this.propertyContainer.HasBeenModified; }
}
bool IReadOnly.IsReadOnly
{
get { return this.propertyContainer.IsReadOnly; }
set { this.propertyContainer.IsReadOnly = value; }
}
#endregion //IPropertyMetadata
#region Internal/private methods
/// <summary>
/// Return a protocol object of the requested type.
/// </summary>
/// <returns>The protocol object of the requested type.</returns>
Models.TaskConstraints ITransportObjectProvider<Models.TaskConstraints>.GetTransportObject()
{
Models.TaskConstraints result = new Models.TaskConstraints()
{
MaxTaskRetryCount = this.MaxTaskRetryCount,
MaxWallClockTime = this.MaxWallClockTime,
RetentionTime = this.RetentionTime,
};
return result;
}
#endregion // Internal/private methods
}
}