private async Task SubmitMapperTasksAsync(BatchClient batchClient, string containerSas)
        {
            Console.WriteLine("Submitting {0} mapper tasks.", this.configurationSettings.NumberOfMapperTasks);

            //The collection of tasks to add to the Batch Service.
            List <CloudTask> tasksToAdd = new List <CloudTask>();

            for (int i = 0; i < this.configurationSettings.NumberOfMapperTasks; i++)
            {
                string taskId       = Helpers.GetMapperTaskId(i);
                string fileBlobName = Helpers.GetSplitFileName(i);
                string fileBlobPath = SampleHelpers.ConstructBlobSource(containerSas, fileBlobName);

                string    commandLine       = string.Format("{0} {1}", Constants.MapperTaskExecutable, fileBlobPath);
                CloudTask unboundMapperTask = new CloudTask(taskId, commandLine);

                //The set of files (exes, dlls and configuration files) required to run the mapper task.
                IReadOnlyList <string> mapperTaskRequiredFiles = Constants.RequiredExecutableFiles;

                List <ResourceFile> mapperTaskResourceFiles = SampleHelpers.GetResourceFiles(containerSas, mapperTaskRequiredFiles);

                unboundMapperTask.ResourceFiles = mapperTaskResourceFiles;

                tasksToAdd.Add(unboundMapperTask);
            }

            //Submit the unbound task collection to the Batch Service.
            //Use the AddTask method which takes a collection of CloudTasks for the best performance.
            await batchClient.JobOperations.AddTaskAsync(this.jobId, tasksToAdd);
        }
Esempio n. 2
0
        private IEnumerable <CloudTask> CreateMapperTasks(string inputContainerSas, string outputContainerSas)
        {
            //The collection of tasks to add to the Batch Service.
            List <CloudTask> tasksToAdd = new List <CloudTask>();

            for (int i = 0; i < this.textSearchSettings.NumberOfMapperTasks; i++)
            {
                string taskId            = Helpers.GetMapperTaskId(i);
                string fileBlobName      = Helpers.GetSplitFileName(i);
                string mapperFileBlobSas = SampleHelpers.ConstructBlobSource(inputContainerSas, fileBlobName);

                string    commandLine       = string.Format("{0} {1}", Constants.MapperTaskExecutable, fileBlobName);
                CloudTask unboundMapperTask = new CloudTask(taskId, commandLine);

                //The set of files (exes, dlls and configuration files) required to run the mapper task. They have already been uploaded
                //so just get their sas's
                IReadOnlyList <string> mapperTaskRequiredFiles = Constants.RequiredExecutableFiles;
                List <ResourceFile>    mapperTaskResourceFiles = SampleHelpers.GetResourceFiles(inputContainerSas, mapperTaskRequiredFiles);
                mapperTaskResourceFiles.Add(ResourceFile.FromUrl(mapperFileBlobSas, fileBlobName));

                unboundMapperTask.OutputFiles = new List <OutputFile>
                {
                    new OutputFile(
                        filePattern: "..\\stdout.txt",
                        destination: new OutputFileDestination(
                            container: new OutputFileBlobContainerDestination(outputContainerSas, path: taskId)),
                        uploadOptions: new OutputFileUploadOptions(uploadCondition: OutputFileUploadCondition.TaskSuccess))
                };
                unboundMapperTask.ResourceFiles = mapperTaskResourceFiles;

                yield return(unboundMapperTask);
            }
        }