/// <summary>
        /// Creates the driver folder structure in this given folder as the root
        /// </summary>
        /// <param name="appParameters">Job submission information</param>
        /// <param name="driverFolderPath">Driver folder path</param>
        internal void CreateDefaultFolderStructure(AppParameters appParameters, string driverFolderPath)
        {
            Directory.CreateDirectory(Path.Combine(driverFolderPath, _fileNames.GetReefFolderName()));
            Directory.CreateDirectory(Path.Combine(driverFolderPath, _fileNames.GetLocalFolderPath()));
            Directory.CreateDirectory(Path.Combine(driverFolderPath, _fileNames.GetGlobalFolderPath()));

            var resourceHelper = new ResourceHelper(typeof(DriverFolderPreparationHelper).Assembly);

            foreach (var fileResources in ResourceHelper.FileResources)
            {
                var fileName = resourceHelper.GetString(fileResources.Key);
                if (ResourceHelper.ClrDriverFullName == fileResources.Key)
                {
                    fileName = Path.Combine(driverFolderPath, _fileNames.GetBridgeExePath());
                }
                if (!File.Exists(fileName))
                {
                    File.WriteAllBytes(fileName, resourceHelper.GetBytes(fileResources.Value));
                }
            }

            // generate .config file for bridge executable
            var config = DefaultDriverConfigurationFileContents;

            if (!string.IsNullOrEmpty(appParameters.DriverConfigurationFileContents))
            {
                config = appParameters.DriverConfigurationFileContents;
            }
            File.WriteAllText(Path.Combine(driverFolderPath, _fileNames.GetBridgeExeConfigPath()), config);

            // generate .config file for Evaluator executable
            File.WriteAllText(Path.Combine(driverFolderPath, _fileNames.GetGlobalFolderPath(), EvaluatorExecutable),
                              DefaultDriverConfigurationFileContents);
        }
Esempio n. 2
0
        public async Task <LauncherStatus> SubmitAsync(
            IConfiguration driverAppConfiguration,
            CancellationToken cancellationToken)
        {
            var driverClientConfiguration =
                Configurations.Merge(driverAppConfiguration,
                                     DriverBridgeConfiguration.ConfigurationModule
                                     .Set(DriverBridgeConfiguration.DriverServiceClient, GenericType <DriverServiceClient> .Class)
                                     .Set(DriverBridgeConfiguration.DriverClientService, GenericType <DriverClientService> .Class)
                                     .Build());
            var jobFolder = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));

            Log.Log(Level.Info, "Job folder {0}", jobFolder);
            Directory.CreateDirectory(jobFolder.FullName);
            AddDependencies(jobFolder, driverClientConfiguration);
            // Launch command
            if (File.Exists(DriverExe))
            {
                _driverClientConfiguration.DriverClientLaunchCommand = string.Format(
                    @"cmd.exe /c {0} {1}",
                    Path.Combine(_reefFileNames.GetGlobalFolderPath(), DriverExe),
                    _reefFileNames.GetClrDriverConfigurationPath());
            }
            else
            {
                _driverClientConfiguration.DriverClientLaunchCommand = string.Format(
                    @"dotnet {0} {1}",
                    Path.Combine(_reefFileNames.GetGlobalFolderPath(), DriverDll),
                    _reefFileNames.GetClrDriverConfigurationPath());
            }

            var driverClientConfigFile = Path.Combine(jobFolder.FullName, "driverclient.json");

            using (var outputFile = new StreamWriter(driverClientConfigFile))
            {
                outputFile.Write(JsonFormatter.Default.Format(_driverClientConfiguration));
            }
            // Submit a new job
            _clientService.Reset();
            var task = _javaClientLauncher.LaunchAsync(JavaLoggingSetting.Info,
                                                       JavaClientLauncherClass,
                                                       new[] { driverClientConfigFile, _grpcServerPort.ToString() },
                                                       cancellationToken);

            lock (_clientService)
            {
                while (!_clientService.IsDone && !cancellationToken.IsCancellationRequested)
                {
                    Monitor.Wait(_clientService, TimeSpan.FromMinutes(1));
                }
            }
            await task;

            return(_clientService.LauncherStatus);
        }
Esempio n. 3
0
        /// <summary>
        /// Merges the Configurations in jobSubmission and serializes them into the right place within driverFolderPath,
        /// assuming
        /// that points to a Driver's working directory.
        /// </summary>
        /// <param name="jobSubmission"></param>
        /// <param name="driverFolderPath"></param>
        internal void CreateDriverConfiguration(IJobSubmission jobSubmission, string driverFolderPath)
        {
            var driverConfiguration = Configurations.Merge(jobSubmission.DriverConfigurations.ToArray());

            _configurationSerializer.ToFile(driverConfiguration,
                                            Path.Combine(driverFolderPath, _fileNames.GetClrDriverConfigurationPath()));

            // TODO: Remove once we cleaned up the Evaluator to not expect this [REEF-216]
            _configurationSerializer.ToFile(driverConfiguration,
                                            Path.Combine(driverFolderPath, _fileNames.GetGlobalFolderPath(), Constants.ClrBridgeRuntimeConfiguration));
        }
        /// <summary>
        /// Merges the Configurations in appParameters and serializes them into the right place within driverFolderPath,
        /// assuming
        /// that points to a Driver's working directory.
        /// </summary>
        /// <param name="appParameters"></param>
        /// <param name="driverFolderPath"></param>
        internal void CreateDriverConfiguration(AppParameters appParameters, string driverFolderPath)
        {
            var driverConfiguration = Configurations.Merge(appParameters.DriverConfigurations.ToArray());

            _configurationSerializer.ToFile(driverConfiguration,
                                            Path.Combine(driverFolderPath, _fileNames.GetClrDriverConfigurationPath()));

            // TODO: Remove once we cleaned up the Evaluator to not expect this [REEF-217]
            _configurationSerializer.ToFile(driverConfiguration,
                                            Path.Combine(driverFolderPath, _fileNames.GetGlobalFolderPath(), _fileNames.GetClrBridgeConfigurationName()));
        }
Esempio n. 5
0
 /// <summary>
 /// </summary>
 /// <returns>The paths of all assemblies in the reef/global folder.</returns>
 private ISet <string> GetAssembliesInGlobalFolder()
 {
     return(new HashSet <string>(Directory.GetFiles(_fileNames.GetGlobalFolderPath())
                                 .Where(e => !(string.IsNullOrWhiteSpace(e)))
                                 .Select(Path.GetFullPath)
                                 .Where(File.Exists)
                                 .Where(IsAssembly)
                                 .Select(Path.GetFileNameWithoutExtension)));
 }
Esempio n. 6
0
        /// <summary>
        /// Copies the files captured to the right places, given that driverFolderPath points to the root folder of the driver.
        /// </summary>
        /// <param name="driverFolderPath"></param>
        internal void CopyToDriverFolder(string driverFolderPath)
        {
            var localFolderPath = Path.Combine(driverFolderPath, _fileNames.GetLocalFolderPath());

            CopyAllToFolder(_localFileSet, localFolderPath);
            var globalFolderPath = Path.Combine(driverFolderPath, _fileNames.GetGlobalFolderPath());

            CopyAllToFolder(_globalFileSet, globalFolderPath);
        }