private string CreateBootstrapAvroJobConfig(JobParameters jobParameters, string driverFolder) { var bootstrapJobArgs = new AvroJobSubmissionParameters { jobSubmissionFolder = driverFolder, jobId = jobParameters.JobIdentifier, }; var bootstrapLocalJobArgs = new AvroLocalJobSubmissionParameters { sharedJobSubmissionParameters = bootstrapJobArgs, driverStdoutFilePath = jobParameters.StdoutFilePath.IsPresent() ? jobParameters.StdoutFilePath.Value : _fileNames.GetDriverStdoutFileName(), driverStderrFilePath = jobParameters.StderrFilePath.IsPresent() ? jobParameters.StderrFilePath.Value : _fileNames.GetDriverStderrFileName() }; var submissionArgsFilePath = Path.Combine(driverFolder, _fileNames.GetJobSubmissionParametersFile()); using (var argsFileStream = new FileStream(submissionArgsFilePath, FileMode.CreateNew)) { var serializedArgs = AvroJsonSerializer <AvroLocalJobSubmissionParameters> .ToBytes(bootstrapLocalJobArgs); argsFileStream.Write(serializedArgs, 0, serializedArgs.Length); } return(submissionArgsFilePath); }
/// <summary> /// Builds the command to be submitted to YARNRM /// </summary> /// <returns>Command string</returns> public string GetJobSubmissionCommand() { var sb = new StringBuilder(); sb.Append(_fileNames.GetBridgeExePath()); sb.Append(" " + JavaExe); sb.Append(" " + JvmOptionsPermSize); sb.Append(" " + string.Format(JvmOptionsMaxPermSizeFormat, _driverMaxPermSizeMB)); sb.Append(" " + string.Format(JvmOptionsMaxMemoryAllocationPoolSizeFormat, _driverMaxMemoryAllocationPoolSizeMB)); sb.Append(" " + ClassPathToken); sb.Append(" " + string.Join(";", _yarnCommandLineEnvironment.GetYarnClasspathList())); sb.Append(" " + ProcReefProperty); if (_enableDebugLogging) { sb.Append(" " + JavaLoggingProperty); } sb.Append(" " + LauncherClassName); sb.Append(" " + string.Format("{0}/{1}/{2}", _fileNames.GetReefFolderName(), _fileNames.GetLocalFolderName(), _fileNames.GetJobSubmissionParametersFile())); sb.Append(" " + _fileNames.GetDriverLoggingConfigCommand()); return(sb.ToString()); }
private string CreateBootstrapAvroConfig(IJobSubmission jobSubmission, string driverFolder) { var paramInjector = TangFactory.GetTang().NewInjector(jobSubmission.DriverConfigurations.ToArray()); var bootstrapArgs = new AvroJobSubmissionParameters { jobSubmissionFolder = driverFolder, jobId = jobSubmission.JobIdentifier, tcpBeginPort = paramInjector.GetNamedInstance <TcpPortRangeStart, int>(), tcpRangeCount = paramInjector.GetNamedInstance <TcpPortRangeCount, int>(), tcpTryCount = paramInjector.GetNamedInstance <TcpPortRangeTryCount, int>(), }; var avroLocalBootstrapArgs = new AvroLocalJobSubmissionParameters { sharedJobSubmissionParameters = bootstrapArgs, maxNumberOfConcurrentEvaluators = _maxNumberOfConcurrentEvaluators }; var submissionArgsFilePath = Path.Combine(driverFolder, _fileNames.GetJobSubmissionParametersFile()); using (var argsFileStream = new FileStream(submissionArgsFilePath, FileMode.CreateNew)) { var serializedArgs = AvroJsonSerializer <AvroLocalJobSubmissionParameters> .ToBytes(avroLocalBootstrapArgs); argsFileStream.Write(serializedArgs, 0, serializedArgs.Length); } return(submissionArgsFilePath); }
/// <summary> /// Serializes the job parameters to job-submission-params.json. /// </summary> internal void SerializeJobFile(JobParameters jobParameters, string localDriverFolderPath, string jobSubmissionDirectory) { var serializedArgs = SerializeJobArgsToBytes(jobParameters, localDriverFolderPath, jobSubmissionDirectory); var submissionJobArgsFilePath = Path.Combine(localDriverFolderPath, _fileNames.GetJobSubmissionParametersFile()); using (var jobArgsFileStream = new FileStream(submissionJobArgsFilePath, FileMode.CreateNew)) { jobArgsFileStream.Write(serializedArgs, 0, serializedArgs.Length); } }
/// <summary> /// Serializes the job parameters to job-submission-params.json. /// </summary> internal string SerializeJobFile(JobParameters jobParameters, IInjector paramInjector, string driverFolderPath) { var serializedArgs = SerializeJobArgsToBytes(jobParameters, driverFolderPath); var submissionArgsFilePath = Path.Combine(driverFolderPath, _fileNames.GetJobSubmissionParametersFile()); using (var argsFileStream = new FileStream(submissionArgsFilePath, FileMode.CreateNew)) { argsFileStream.Write(serializedArgs, 0, serializedArgs.Length); } return(submissionArgsFilePath); }
public string BuildDriverCommand(int driverMemory) { var sb = new StringBuilder(); sb.Append(_fileNames.GetBridgeExePath()) .Append(" " + JavaExe) .Append(" " + string.Format(JvmOptionsMaxMemoryAllocationPoolSizeFormat, driverMemory)) .Append(" " + JvmOptionsPermSize) .Append(" " + JvmOptionsMaxPermSizeFormat) .Append(" " + ClassPathToken) .Append(" " + GetDriverClasspath()) .Append(" " + ProcReefProperty) .Append(" " + LauncherClassName) .Append(" " + Path.Combine(_fileNames.GetReefFolderName(), _fileNames.GetJobSubmissionParametersFile())); return(string.Format(_osCommandFormat, _commandPrefix + sb.ToString())); }
private void Launch(IJobSubmission jobSubmission, string driverFolderPath) { _driverFolderPreparationHelper.PrepareDriverFolder(jobSubmission, driverFolderPath); // TODO: Remove this when we have a generalized way to pass config to java var paramInjector = TangFactory.GetTang().NewInjector(jobSubmission.DriverConfigurations.ToArray()); var avroJobSubmissionParameters = new AvroJobSubmissionParameters { jobId = jobSubmission.JobIdentifier, tcpBeginPort = paramInjector.GetNamedInstance <TcpPortRangeStart, int>(), tcpRangeCount = paramInjector.GetNamedInstance <TcpPortRangeCount, int>(), tcpTryCount = paramInjector.GetNamedInstance <TcpPortRangeTryCount, int>(), jobSubmissionFolder = driverFolderPath }; var avroYarnJobSubmissionParameters = new AvroYarnJobSubmissionParameters { driverMemory = jobSubmission.DriverMemory, driverRecoveryTimeout = paramInjector.GetNamedInstance <DriverBridgeConfigurationOptions.DriverRestartEvaluatorRecoverySeconds, int>(), jobSubmissionDirectoryPrefix = _jobSubmissionPrefix, sharedJobSubmissionParameters = avroJobSubmissionParameters }; var avroYarnClusterJobSubmissionParameters = new AvroYarnClusterJobSubmissionParameters { maxApplicationSubmissions = paramInjector.GetNamedInstance <DriverBridgeConfigurationOptions.MaxApplicationSubmissions, int>(), securityTokenKind = _securityTokenKind, securityTokenService = _securityTokenService, yarnJobSubmissionParameters = avroYarnJobSubmissionParameters }; var submissionArgsFilePath = Path.Combine(driverFolderPath, _fileNames.GetJobSubmissionParametersFile()); using (var argsFileStream = new FileStream(submissionArgsFilePath, FileMode.CreateNew)) { var serializedArgs = AvroJsonSerializer <AvroYarnClusterJobSubmissionParameters> .ToBytes(avroYarnClusterJobSubmissionParameters); argsFileStream.Write(serializedArgs, 0, serializedArgs.Length); } // Submit the driver _javaClientLauncher.Launch(JavaClassName, submissionArgsFilePath); Logger.Log(Level.Info, "Submitted the Driver for execution." + jobSubmission.JobIdentifier); }
private void SerializeJobFile(string localDriverFolderPath, AvroAzureBatchJobSubmissionParameters jobParameters) { var serializedArgs = AvroJsonSerializer <AvroAzureBatchJobSubmissionParameters> .ToBytes(jobParameters); var submissionJobArgsFilePath = Path.Combine(localDriverFolderPath, _fileNames.GetReefFolderName(), _fileNames.GetJobSubmissionParametersFile()); using (var jobArgsFileStream = new FileStream(submissionJobArgsFilePath, FileMode.CreateNew)) { jobArgsFileStream.Write(serializedArgs, 0, serializedArgs.Length); } }
public void Submit(JobRequest jobRequest) { string jobId = jobRequest.JobIdentifier; // todo: Future client interface should be async. // Using GetAwaiter().GetResult() instead of .Result to avoid exception // getting wrapped in AggregateException. var newApplication = _yarnRMClient.CreateNewApplicationAsync().GetAwaiter().GetResult(); string applicationId = newApplication.ApplicationId; // create job submission remote path string jobSubmissionDirectory = _jobSubmissionDirectoryProvider.GetJobSubmissionRemoteDirectory(applicationId); // create local driver folder. var localDriverFolderPath = CreateDriverFolder(jobId, applicationId); try { Log.Log(Level.Verbose, "Preparing driver folder in {0}", localDriverFolderPath); _driverFolderPreparationHelper.PrepareDriverFolder(jobRequest.AppParameters, localDriverFolderPath); // prepare configuration var paramInjector = TangFactory.GetTang().NewInjector(jobRequest.DriverConfigurations.ToArray()); _paramSerializer.SerializeAppFile(jobRequest.AppParameters, paramInjector, localDriverFolderPath); _paramSerializer.SerializeJobFile(jobRequest.JobParameters, localDriverFolderPath, jobSubmissionDirectory); var archiveResource = _jobResourceUploader.UploadArchiveResourceAsync(localDriverFolderPath, jobSubmissionDirectory) .GetAwaiter() .GetResult(); // Path to the job args file. var jobArgsFilePath = Path.Combine(localDriverFolderPath, _fileNames.GetJobSubmissionParametersFile()); var argFileResource = _jobResourceUploader.UploadFileResourceAsync(jobArgsFilePath, jobSubmissionDirectory) .GetAwaiter() .GetResult(); // upload prepared folder to DFS var jobResources = new List <JobResource> { archiveResource, argFileResource }; // submit job Log.Log(Level.Verbose, @"Assigned application id {0}", applicationId); var submissionReq = CreateApplicationSubmissionRequest( jobRequest.JobParameters, applicationId, jobRequest.MaxApplicationSubmissions, jobResources); var submittedApplication = _yarnRMClient.SubmitApplicationAsync(submissionReq).GetAwaiter().GetResult(); Log.Log(Level.Info, @"Submitted application {0}", submittedApplication.Id); } finally { if (Directory.Exists(localDriverFolderPath)) { Directory.Delete(localDriverFolderPath, recursive: true); } } }