/// <summary> /// Open an existing DataClient with the specified ID, job ID and job secret /// </summary> /// <param name="hpcContext">The <see cref="IHpcContext"/> instance.</param> /// <param name="dataClientId">ID of the DataClient to be opened</param> /// <param name="jobId">Job ID</param> /// <param name="jobSecret">Job Secret</param> /// <returns>DataClient instance that provides read/write access to the specified DataClient</returns> internal static DataClient Open(string dataClientId, int jobId, string jobSecret) { var context = HpcContext.GetOrAdd(EndpointsConnectionString.LoadFromEnvVarsOrWindowsRegistry(), CancellationToken.None, true); Utility.ValidateDataClientId(dataClientId); DataClientInfo info = OpenBySecretInternal(context, dataClientId, jobId, jobSecret); return(new DataClient(context.ResolveSessionLauncherNodeAsync().GetAwaiter().GetResult(), dataClientId, info.PrimaryDataPath, true, TransportScheme.NetTcp, null, null)); }
/// <summary> /// Get the service info from registry (x64 boot) or info file (x86 boot) /// </summary> static string GetServiceInfo(string serviceConfigFileName) { string serviceConfigFile = string.Empty; try { //TODO get headnode string headnode; if (ServiceHostRuntimeConfiguration.Standalone) { headnode = System.Net.Dns.GetHostName(); } else { headnode = EndpointsConnectionString.LoadFromEnvVarsOrWindowsRegistry().ConnectionString; } Debug.WriteLine($"[{nameof(GetServiceInfo)}](Debug) headnode: {headnode}."); Debug.Assert(!string.IsNullOrEmpty(headnode), "Head node connection string is null or empty."); ServiceRegistrationRepo serviceRegistration = new ServiceRegistrationRepo(Environment.GetEnvironmentVariable(Constant.RegistryPathEnv), null); // Get the path to the service config file name serviceConfigFile = serviceRegistration.GetServiceRegistrationPath(serviceConfigFileName); if (serviceConfigFile == null) { // Make a part for the error message string CentrialPath = serviceRegistration.CentrialPath; StringBuilder serviceRegDirsBuilder = new StringBuilder(); if (!string.IsNullOrEmpty(CentrialPath)) { serviceRegDirsBuilder.Append("\n\t"); serviceRegDirsBuilder.Append(CentrialPath); } serviceRegDirsBuilder.Append("\n"); Console.Error.WriteLine( string.Format( CultureInfo.CurrentCulture, StringTable.CantFindServiceRegistrationFileUnderFolders, serviceRegDirsBuilder.ToString())); } } catch (Exception e) { Console.Error.WriteLine( string.Format(CultureInfo.CurrentCulture, StringTable.ExceptionInReadingRegistrationFile, serviceConfigFile, e.ToString())); } return(serviceConfigFile); }