< Summary

Class:Microsoft.Azure.Batch.StartTask
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Generated\StartTask.cs
C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\StartTask.cs
Covered lines:78
Uncovered lines:3
Coverable lines:81
Total lines:268
Line coverage:96.2% (78 of 81)
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_ContainerSettings()-100%100%
set_ContainerSettings(...)-100%100%
get_EnvironmentSettings()-100%100%
set_EnvironmentSettings(...)-100%100%
get_MaxTaskRetryCount()-100%100%
set_MaxTaskRetryCount(...)-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()-100%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.StartTask>.GetTransportObject()-100%100%
.ctor()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Generated\StartTask.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
 24613namespace Microsoft.Azure.Batch
 14{
 24615    using Models = Microsoft.Azure.Batch.Protocol.Models;
 16    using System;
 17    using System.Collections.Generic;
 18    using System.Linq;
 19
 20    /// <summary>
 21    /// A task which is run when a compute node joins a pool in the Azure Batch service, or when the compute node is reb
 22    /// or reimaged.
 23    /// </summary>
 24    /// <remarks>
 25    /// <para>Batch will retry tasks when a recovery operation is triggered on a compute node. Examples of recovery oper
 26    /// include (but are not limited to) when an unhealthy compute node is rebooted or a compute node disappeared due to
 27    /// host failure. Retries due to recovery operations are independent of and are not counted against the <see cref="T
 28    /// />. Even if the <see cref="TaskConstraints.MaxTaskRetryCount" /> is 0, an internal retry due to a recovery opera
 29    /// may occur. Because of this, all tasks should be idempotent. This means tasks need to tolerate being interrupted 
 30    /// restarted without causing any corruption or duplicate data.</para><para>The best practice for long running tasks
 31    /// is to use some form of checkpointing. Special care should be taken to avoid start tasks which create breakaway p
 32    /// or install/launch services from the start task working directory, as this will block Batch from being able to re
 33    /// the start task.</para>
 34    /// </remarks>
 35    public partial class StartTask : ITransportObjectProvider<Models.StartTask>, IPropertyMetadata
 36    {
 37        private class PropertyContainer : PropertyCollection
 38        {
 39            public readonly PropertyAccessor<string> CommandLineProperty;
 40            public readonly PropertyAccessor<TaskContainerSettings> ContainerSettingsProperty;
 41            public readonly PropertyAccessor<IList<EnvironmentSetting>> EnvironmentSettingsProperty;
 42            public readonly PropertyAccessor<int?> MaxTaskRetryCountProperty;
 43            public readonly PropertyAccessor<IList<ResourceFile>> ResourceFilesProperty;
 44            public readonly PropertyAccessor<UserIdentity> UserIdentityProperty;
 45            public readonly PropertyAccessor<bool?> WaitForSuccessProperty;
 46
 24747            public PropertyContainer() : base(BindingState.Unbound)
 48            {
 24749                this.CommandLineProperty = this.CreatePropertyAccessor<string>(nameof(CommandLine), BindingAccess.Read |
 24750                this.ContainerSettingsProperty = this.CreatePropertyAccessor<TaskContainerSettings>(nameof(ContainerSett
 24751                this.EnvironmentSettingsProperty = this.CreatePropertyAccessor<IList<EnvironmentSetting>>(nameof(Environ
 24752                this.MaxTaskRetryCountProperty = this.CreatePropertyAccessor<int?>(nameof(MaxTaskRetryCount), BindingAcc
 24753                this.ResourceFilesProperty = this.CreatePropertyAccessor<IList<ResourceFile>>(nameof(ResourceFiles), Bin
 24754                this.UserIdentityProperty = this.CreatePropertyAccessor<UserIdentity>(nameof(UserIdentity), BindingAcces
 24755                this.WaitForSuccessProperty = this.CreatePropertyAccessor<bool?>(nameof(WaitForSuccess), BindingAccess.R
 24756            }
 57
 108558            public PropertyContainer(Models.StartTask protocolObject) : base(BindingState.Bound)
 59            {
 108560                this.CommandLineProperty = this.CreatePropertyAccessor(
 108561                    protocolObject.CommandLine,
 108562                    nameof(CommandLine),
 108563                    BindingAccess.Read | BindingAccess.Write);
 108564                this.ContainerSettingsProperty = this.CreatePropertyAccessor(
 161565                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ContainerSettings, o => new TaskContainer
 108566                    nameof(ContainerSettings),
 108567                    BindingAccess.Read);
 108568                this.EnvironmentSettingsProperty = this.CreatePropertyAccessor(
 108569                    EnvironmentSetting.ConvertFromProtocolCollection(protocolObject.EnvironmentSettings),
 108570                    nameof(EnvironmentSettings),
 108571                    BindingAccess.Read | BindingAccess.Write);
 108572                this.MaxTaskRetryCountProperty = this.CreatePropertyAccessor(
 108573                    protocolObject.MaxTaskRetryCount,
 108574                    nameof(MaxTaskRetryCount),
 108575                    BindingAccess.Read | BindingAccess.Write);
 108576                this.ResourceFilesProperty = this.CreatePropertyAccessor(
 108577                    ResourceFile.ConvertFromProtocolCollection(protocolObject.ResourceFiles),
 108578                    nameof(ResourceFiles),
 108579                    BindingAccess.Read | BindingAccess.Write);
 108580                this.UserIdentityProperty = this.CreatePropertyAccessor(
 162581                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.UserIdentity, o => new UserIdentity(o)),
 108582                    nameof(UserIdentity),
 108583                    BindingAccess.Read | BindingAccess.Write);
 108584                this.WaitForSuccessProperty = this.CreatePropertyAccessor(
 108585                    protocolObject.WaitForSuccess,
 108586                    nameof(WaitForSuccess),
 108587                    BindingAccess.Read | BindingAccess.Write);
 108588            }
 89        }
 90
 91        private readonly PropertyContainer propertyContainer;
 92
 93        #region Constructors
 94
 95        /// <summary>
 96        /// Initializes a new instance of the <see cref="StartTask"/> class.
 97        /// </summary>
 98        /// <param name='commandLine'>The command line of the task.</param>
 24799        public StartTask(
 247100            string commandLine)
 101        {
 247102            this.propertyContainer = new PropertyContainer();
 247103            this.CommandLine = commandLine;
 247104        }
 105
 1085106        internal StartTask(Models.StartTask protocolObject)
 107        {
 1085108            this.propertyContainer = new PropertyContainer(protocolObject);
 1085109        }
 110
 111        #endregion Constructors
 112
 113        #region StartTask
 114
 115        /// <summary>
 116        /// Gets or sets the command line of the task.
 117        /// </summary>
 118        /// <remarks>
 119        /// The command line does not run under a shell, and therefore cannot take advantage of shell features such as e
 120        /// variable expansion. If you want to take advantage of such features, you should invoke the shell in the comma
 121        /// line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command lin
 122        /// refers to file paths, it should use a relative path (relative to the task working directory), or use the Bat
 123        /// provided environment variables (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-
 124        /// </remarks>
 125        public string CommandLine
 126        {
 1575127            get { return this.propertyContainer.CommandLineProperty.Value; }
 745128            set { this.propertyContainer.CommandLineProperty.Value = value; }
 129        }
 130
 131        /// <summary>
 132        /// Gets or sets the settings for the container under which the task runs.
 133        /// </summary>
 134        /// <remarks>
 135        /// When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batc
 136        /// directories on the node) are mapped into the container, all task environment variables are mapped into the c
 137        /// and the task command line is executed in the container. Files produced in the container outside of AZ_BATCH_
 138        /// might not be reflected to the host disk, meaning that Batch file APIs will not be able to access them.
 139        /// </remarks>
 140        public TaskContainerSettings ContainerSettings
 141        {
 1572142            get { return this.propertyContainer.ContainerSettingsProperty.Value; }
 257143            set { this.propertyContainer.ContainerSettingsProperty.Value = value; }
 144        }
 145
 146        /// <summary>
 147        /// Gets or sets a set of environment settings for the start task.
 148        /// </summary>
 149        public IList<EnvironmentSetting> EnvironmentSettings
 150        {
 1574151            get { return this.propertyContainer.EnvironmentSettingsProperty.Value; }
 152            set
 153            {
 118154                this.propertyContainer.EnvironmentSettingsProperty.Value = ConcurrentChangeTrackedModifiableList<Environ
 117155            }
 156        }
 157
 158        /// <summary>
 159        /// Gets or sets the maximum number of retries for the task.
 160        /// </summary>
 161        public int? MaxTaskRetryCount
 162        {
 1573163            get { return this.propertyContainer.MaxTaskRetryCountProperty.Value; }
 257164            set { this.propertyContainer.MaxTaskRetryCountProperty.Value = value; }
 165        }
 166
 167        /// <summary>
 168        /// Gets or sets a list of files that the Batch service will download to the compute node before running the com
 169        /// line.
 170        /// </summary>
 171        /// <remarks>
 172        /// There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail
 173        /// and the response error code will be RequestEntityTooLarge. If this occurs, the collection of resource files 
 174        /// be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers.
 175        /// </remarks>
 176        public IList<ResourceFile> ResourceFiles
 177        {
 1572178            get { return this.propertyContainer.ResourceFilesProperty.Value; }
 179            set
 180            {
 121181                this.propertyContainer.ResourceFilesProperty.Value = ConcurrentChangeTrackedModifiableList<ResourceFile>
 120182            }
 183        }
 184
 185        /// <summary>
 186        /// Gets or sets the user identity under which the task runs.
 187        /// </summary>
 188        /// <remarks>
 189        /// If omitted, the task runs as a non-administrative user unique to the task.
 190        /// </remarks>
 191        public UserIdentity UserIdentity
 192        {
 1573193            get { return this.propertyContainer.UserIdentityProperty.Value; }
 247194            set { this.propertyContainer.UserIdentityProperty.Value = value; }
 195        }
 196
 197        /// <summary>
 198        /// Gets or sets a value indicating whether the Batch service should wait for the start task to complete before 
 199        /// any tasks on the compute node.
 200        /// </summary>
 201        /// <remarks>
 202        /// If this is not specified, the default is true.
 203        /// </remarks>
 204        public bool? WaitForSuccess
 205        {
 1573206            get { return this.propertyContainer.WaitForSuccessProperty.Value; }
 271207            set { this.propertyContainer.WaitForSuccessProperty.Value = value; }
 208        }
 209
 210        #endregion // StartTask
 211
 212        #region IPropertyMetadata
 213
 214        bool IModifiable.HasBeenModified
 215        {
 4216            get { return this.propertyContainer.HasBeenModified; }
 217        }
 218
 219        bool IReadOnly.IsReadOnly
 220        {
 0221            get { return this.propertyContainer.IsReadOnly; }
 1026222            set { this.propertyContainer.IsReadOnly = value; }
 223        }
 224
 225        #endregion //IPropertyMetadata
 226
 227        #region Internal/private methods
 228        /// <summary>
 229        /// Return a protocol object of the requested type.
 230        /// </summary>
 231        /// <returns>The protocol object of the requested type.</returns>
 232        Models.StartTask ITransportObjectProvider<Models.StartTask>.GetTransportObject()
 233        {
 247234            Models.StartTask result = new Models.StartTask()
 247235            {
 247236                CommandLine = this.CommandLine,
 375237                ContainerSettings = UtilitiesInternal.CreateObjectWithNullCheck(this.ContainerSettings, (o) => o.GetTran
 247238                EnvironmentSettings = UtilitiesInternal.ConvertToProtocolCollection(this.EnvironmentSettings),
 247239                MaxTaskRetryCount = this.MaxTaskRetryCount,
 247240                ResourceFiles = UtilitiesInternal.ConvertToProtocolCollection(this.ResourceFiles),
 370241                UserIdentity = UtilitiesInternal.CreateObjectWithNullCheck(this.UserIdentity, (o) => o.GetTransportObjec
 247242                WaitForSuccess = this.WaitForSuccess,
 247243            };
 244
 247245            return result;
 246        }
 247
 248
 249        #endregion // Internal/private methods
 250    }
 251}

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\StartTask.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 StartTask
 9    {
 10        /// <summary>
 11        /// Initializes a new instance of the <see cref="StartTask"/> class.
 12        /// </summary>
 013        public StartTask() : this(commandLine: null)
 14        {
 015        }
 16    }
 17}