< Summary

Class:Microsoft.Azure.Batch.JobPreparationTask
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Generated\JobPreparationTask.cs
C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\JobPreparationTask.cs
Covered lines:93
Uncovered lines:4
Coverable lines:97
Total lines:303
Line coverage:95.8% (93 of 97)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
get_CommandLine()-100%100%
set_CommandLine(...)-100%100%
get_Constraints()-100%100%
set_Constraints(...)-100%100%
get_ContainerSettings()-100%100%
set_ContainerSettings(...)-100%100%
get_EnvironmentSettings()-100%100%
set_EnvironmentSettings(...)-100%100%
get_Id()-100%100%
set_Id(...)-100%100%
get_RerunOnComputeNodeRebootAfterSuccess()-100%100%
set_RerunOnComputeNodeRebootAfterSuccess(...)-100%100%
get_ResourceFiles()-100%100%
set_ResourceFiles(...)-100%100%
get_UserIdentity()-100%100%
set_UserIdentity(...)-100%100%
get_WaitForSuccess()-100%100%
set_WaitForSuccess(...)-100%100%
Microsoft.Azure.Batch.IModifiable.get_HasBeenModified()-0%100%
Microsoft.Azure.Batch.IReadOnly.get_IsReadOnly()-0%100%
Microsoft.Azure.Batch.IReadOnly.set_IsReadOnly(...)-100%100%
Microsoft.Azure.Batch.ITransportObjectProvider<Microsoft.Azure.Batch.Protocol.Models.JobPreparationTask>.GetTransportObject()-100%100%
.ctor()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Generated\JobPreparationTask.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for license information.
 3//
 4// Code generated by Microsoft (R) AutoRest Code Generator.
 5// Changes may cause incorrect behavior and will be lost if the code is
 6// regenerated.
 7
 8//
 9// This file was autogenerated by a tool.
 10// Do not modify it.
 11//
 12
 21413namespace Microsoft.Azure.Batch
 14{
 21415    using Models = Microsoft.Azure.Batch.Protocol.Models;
 16    using System;
 17    using System.Collections.Generic;
 18    using System.Linq;
 19
 20    /// <summary>
 21    /// A Job Preparation task to run before any tasks of the job on any given compute node.
 22    /// </summary>
 23    /// <remarks>
 24    /// Batch will retry tasks when a recovery operation is triggered on a compute node. Examples of recovery operations
 25    /// include (but are not limited to) when an unhealthy compute node is rebooted or a compute node disappeared due to
 26    /// host failure. Retries due to recovery operations are independent of and are not counted against the <see cref="T
 27    /// />. Even if the <see cref="TaskConstraints.MaxTaskRetryCount" /> is 0, an internal retry due to a recovery opera
 28    /// may occur. Because of this, all tasks should be idempotent. This means tasks need to tolerate being interrupted 
 29    /// restarted without causing any corruption or duplicate data. The best practice for long running tasks is to use s
 30    /// form of checkpointing.
 31    /// </remarks>
 32    public partial class JobPreparationTask : ITransportObjectProvider<Models.JobPreparationTask>, IPropertyMetadata
 33    {
 34        private class PropertyContainer : PropertyCollection
 35        {
 36            public readonly PropertyAccessor<string> CommandLineProperty;
 37            public readonly PropertyAccessor<TaskConstraints> ConstraintsProperty;
 38            public readonly PropertyAccessor<TaskContainerSettings> ContainerSettingsProperty;
 39            public readonly PropertyAccessor<IList<EnvironmentSetting>> EnvironmentSettingsProperty;
 40            public readonly PropertyAccessor<string> IdProperty;
 41            public readonly PropertyAccessor<bool?> RerunOnComputeNodeRebootAfterSuccessProperty;
 42            public readonly PropertyAccessor<IList<ResourceFile>> ResourceFilesProperty;
 43            public readonly PropertyAccessor<UserIdentity> UserIdentityProperty;
 44            public readonly PropertyAccessor<bool?> WaitForSuccessProperty;
 45
 21446            public PropertyContainer() : base(BindingState.Unbound)
 47            {
 21448                this.CommandLineProperty = this.CreatePropertyAccessor<string>(nameof(CommandLine), BindingAccess.Read |
 21449                this.ConstraintsProperty = this.CreatePropertyAccessor<TaskConstraints>(nameof(Constraints), BindingAcce
 21450                this.ContainerSettingsProperty = this.CreatePropertyAccessor<TaskContainerSettings>(nameof(ContainerSett
 21451                this.EnvironmentSettingsProperty = this.CreatePropertyAccessor<IList<EnvironmentSetting>>(nameof(Environ
 21452                this.IdProperty = this.CreatePropertyAccessor<string>(nameof(Id), BindingAccess.Read | BindingAccess.Wri
 21453                this.RerunOnComputeNodeRebootAfterSuccessProperty = this.CreatePropertyAccessor<bool?>(nameof(RerunOnCom
 21454                this.ResourceFilesProperty = this.CreatePropertyAccessor<IList<ResourceFile>>(nameof(ResourceFiles), Bin
 21455                this.UserIdentityProperty = this.CreatePropertyAccessor<UserIdentity>(nameof(UserIdentity), BindingAcces
 21456                this.WaitForSuccessProperty = this.CreatePropertyAccessor<bool?>(nameof(WaitForSuccess), BindingAccess.R
 21457            }
 58
 76359            public PropertyContainer(Models.JobPreparationTask protocolObject) : base(BindingState.Bound)
 60            {
 76361                this.CommandLineProperty = this.CreatePropertyAccessor(
 76362                    protocolObject.CommandLine,
 76363                    nameof(CommandLine),
 76364                    BindingAccess.Read | BindingAccess.Write);
 76365                this.ConstraintsProperty = this.CreatePropertyAccessor(
 113466                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.Constraints, o => new TaskConstraints(o))
 76367                    nameof(Constraints),
 76368                    BindingAccess.Read | BindingAccess.Write);
 76369                this.ContainerSettingsProperty = this.CreatePropertyAccessor(
 113770                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ContainerSettings, o => new TaskContainer
 76371                    nameof(ContainerSettings),
 76372                    BindingAccess.Read);
 76373                this.EnvironmentSettingsProperty = this.CreatePropertyAccessor(
 76374                    EnvironmentSetting.ConvertFromProtocolCollection(protocolObject.EnvironmentSettings),
 76375                    nameof(EnvironmentSettings),
 76376                    BindingAccess.Read | BindingAccess.Write);
 76377                this.IdProperty = this.CreatePropertyAccessor(
 76378                    protocolObject.Id,
 76379                    nameof(Id),
 76380                    BindingAccess.Read | BindingAccess.Write);
 76381                this.RerunOnComputeNodeRebootAfterSuccessProperty = this.CreatePropertyAccessor(
 76382                    protocolObject.RerunOnNodeRebootAfterSuccess,
 76383                    nameof(RerunOnComputeNodeRebootAfterSuccess),
 76384                    BindingAccess.Read | BindingAccess.Write);
 76385                this.ResourceFilesProperty = this.CreatePropertyAccessor(
 76386                    ResourceFile.ConvertFromProtocolCollection(protocolObject.ResourceFiles),
 76387                    nameof(ResourceFiles),
 76388                    BindingAccess.Read | BindingAccess.Write);
 76389                this.UserIdentityProperty = this.CreatePropertyAccessor(
 115590                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.UserIdentity, o => new UserIdentity(o).Fr
 76391                    nameof(UserIdentity),
 76392                    BindingAccess.Read);
 76393                this.WaitForSuccessProperty = this.CreatePropertyAccessor(
 76394                    protocolObject.WaitForSuccess,
 76395                    nameof(WaitForSuccess),
 76396                    BindingAccess.Read | BindingAccess.Write);
 76397            }
 98        }
 99
 100        private readonly PropertyContainer propertyContainer;
 101
 102        #region Constructors
 103
 104        /// <summary>
 105        /// Initializes a new instance of the <see cref="JobPreparationTask"/> class.
 106        /// </summary>
 107        /// <param name='commandLine'>The command line of the task.</param>
 214108        public JobPreparationTask(
 214109            string commandLine)
 110        {
 214111            this.propertyContainer = new PropertyContainer();
 214112            this.CommandLine = commandLine;
 214113        }
 114
 763115        internal JobPreparationTask(Models.JobPreparationTask protocolObject)
 116        {
 763117            this.propertyContainer = new PropertyContainer(protocolObject);
 763118        }
 119
 120        #endregion Constructors
 121
 122        #region JobPreparationTask
 123
 124        /// <summary>
 125        /// Gets or sets the command line of the task.
 126        /// </summary>
 127        /// <remarks>
 128        /// The command line does not run under a shell, and therefore cannot take advantage of shell features such as e
 129        /// variable expansion. If you want to take advantage of such features, you should invoke the shell in the comma
 130        /// line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command lin
 131        /// refers to file paths, it should use a relative path (relative to the task working directory), or use the Bat
 132        /// provided environment variables (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-
 133        /// </remarks>
 134        public string CommandLine
 135        {
 1189136            get { return this.propertyContainer.CommandLineProperty.Value; }
 637137            set { this.propertyContainer.CommandLineProperty.Value = value; }
 138        }
 139
 140        /// <summary>
 141        /// Gets or sets the execution constraints provided by the user for this Job Preparation task.
 142        /// </summary>
 143        public TaskConstraints Constraints
 144        {
 1189145            get { return this.propertyContainer.ConstraintsProperty.Value; }
 219146            set { this.propertyContainer.ConstraintsProperty.Value = value; }
 147        }
 148
 149        /// <summary>
 150        /// Gets or sets the settings for the container under which the task runs.
 151        /// </summary>
 152        /// <remarks>
 153        /// When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batc
 154        /// directories on the node) are mapped into the container, all task environment variables are mapped into the c
 155        /// and the task command line is executed in the container.
 156        /// </remarks>
 157        public TaskContainerSettings ContainerSettings
 158        {
 1189159            get { return this.propertyContainer.ContainerSettingsProperty.Value; }
 213160            set { this.propertyContainer.ContainerSettingsProperty.Value = value; }
 161        }
 162
 163        /// <summary>
 164        /// Gets or sets the collection of EnvironmentSetting instances.
 165        /// </summary>
 166        public IList<EnvironmentSetting> EnvironmentSettings
 167        {
 1189168            get { return this.propertyContainer.EnvironmentSettingsProperty.Value; }
 169            set
 170            {
 107171                this.propertyContainer.EnvironmentSettingsProperty.Value = ConcurrentChangeTrackedModifiableList<Environ
 106172            }
 173        }
 174
 175        /// <summary>
 176        /// Gets or sets the id of the task.
 177        /// </summary>
 178        public string Id
 179        {
 1190180            get { return this.propertyContainer.IdProperty.Value; }
 211181            set { this.propertyContainer.IdProperty.Value = value; }
 182        }
 183
 184        /// <summary>
 185        /// Gets or sets whether the Batch service should rerun the Job Preparation task after a compute node reboots.
 186        /// </summary>
 187        /// <remarks>
 188        /// The Job Preparation task is always rerun if a compute node is reimaged, or if the Job Preparation task did n
 189        /// complete (e.g. because the reboot occurred while the task was running). Therefore, you should always write a
 190        /// Job Preparation task to be idempotent and to behave correctly if run multiple times. If this property is not
 191        /// specified, a default value of true is assigned by the Batch service.
 192        /// </remarks>
 193        public bool? RerunOnComputeNodeRebootAfterSuccess
 194        {
 1189195            get { return this.propertyContainer.RerunOnComputeNodeRebootAfterSuccessProperty.Value; }
 221196            set { this.propertyContainer.RerunOnComputeNodeRebootAfterSuccessProperty.Value = value; }
 197        }
 198
 199        /// <summary>
 200        /// Gets or sets a list of files that the Batch service will download to the compute node before running the com
 201        /// line.
 202        /// </summary>
 203        /// <remarks>
 204        /// There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail
 205        /// and the response error code will be RequestEntityTooLarge. If this occurs, the collection of resource files 
 206        /// be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers.
 207        /// </remarks>
 208        public IList<ResourceFile> ResourceFiles
 209        {
 1189210            get { return this.propertyContainer.ResourceFilesProperty.Value; }
 211            set
 212            {
 97213                this.propertyContainer.ResourceFilesProperty.Value = ConcurrentChangeTrackedModifiableList<ResourceFile>
 96214            }
 215        }
 216
 217        /// <summary>
 218        /// Gets or sets the user identity under which the task runs.
 219        /// </summary>
 220        /// <remarks>
 221        /// If omitted, the task runs as a non-administrative user unique to the task.
 222        /// </remarks>
 223        public UserIdentity UserIdentity
 224        {
 1189225            get { return this.propertyContainer.UserIdentityProperty.Value; }
 205226            set { this.propertyContainer.UserIdentityProperty.Value = value; }
 227        }
 228
 229        /// <summary>
 230        /// Gets or sets whether the Batch service should wait for the successful completion of the Job Preparation task
 231        /// before scheduling any tasks on the compute node.
 232        /// </summary>
 233        /// <remarks>
 234        /// A Job Preparation task execution is considered successful if its ExitCode is 0. If this property is not spec
 235        /// a default value of true is assigned by the Batch service.
 236        /// </remarks>
 237        public bool? WaitForSuccess
 238        {
 1189239            get { return this.propertyContainer.WaitForSuccessProperty.Value; }
 203240            set { this.propertyContainer.WaitForSuccessProperty.Value = value; }
 241        }
 242
 243        #endregion // JobPreparationTask
 244
 245        #region IPropertyMetadata
 246
 247        bool IModifiable.HasBeenModified
 248        {
 0249            get { return this.propertyContainer.HasBeenModified; }
 250        }
 251
 252        bool IReadOnly.IsReadOnly
 253        {
 0254            get { return this.propertyContainer.IsReadOnly; }
 1042255            set { this.propertyContainer.IsReadOnly = value; }
 256        }
 257
 258        #endregion //IPropertyMetadata
 259
 260        #region Internal/private methods
 261        /// <summary>
 262        /// Return a protocol object of the requested type.
 263        /// </summary>
 264        /// <returns>The protocol object of the requested type.</returns>
 265        Models.JobPreparationTask ITransportObjectProvider<Models.JobPreparationTask>.GetTransportObject()
 266        {
 213267            Models.JobPreparationTask result = new Models.JobPreparationTask()
 213268            {
 213269                CommandLine = this.CommandLine,
 322270                Constraints = UtilitiesInternal.CreateObjectWithNullCheck(this.Constraints, (o) => o.GetTransportObject(
 319271                ContainerSettings = UtilitiesInternal.CreateObjectWithNullCheck(this.ContainerSettings, (o) => o.GetTran
 213272                EnvironmentSettings = UtilitiesInternal.ConvertToProtocolCollection(this.EnvironmentSettings),
 213273                Id = this.Id,
 213274                RerunOnNodeRebootAfterSuccess = this.RerunOnComputeNodeRebootAfterSuccess,
 213275                ResourceFiles = UtilitiesInternal.ConvertToProtocolCollection(this.ResourceFiles),
 315276                UserIdentity = UtilitiesInternal.CreateObjectWithNullCheck(this.UserIdentity, (o) => o.GetTransportObjec
 213277                WaitForSuccess = this.WaitForSuccess,
 213278            };
 279
 213280            return result;
 281        }
 282
 283
 284        #endregion // Internal/private methods
 285    }
 286}

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\JobPreparationTask.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for license information.
 3
 4namespace Microsoft.Azure.Batch
 5{
 6    using System;
 7
 8    public partial class JobPreparationTask
 9    {
 10        /// <summary>
 11        /// Initializes a new instance of the <see cref="JobPreparationTask"/> class.
 12        /// </summary>
 013        public JobPreparationTask() : this(commandLine: null)
 14        {
 015        }
 16    }
 17}