private void BuildStandaloneBrokerStartInfo(string serviceName, Version serviceVersion, string sessionId, bool durable, bool attached) { this.brokerInfo = new BrokerStartInfo(); this.brokerInfo.Headnode = this.startInfo.Headnode; // Secure will be set to false and the following two settings are ignored this.brokerInfo.JobOwnerSID = null; this.brokerInfo.JobTemplateACL = null; this.brokerInfo.PersistVersion = BrokerVersion.DefaultPersistVersion; this.brokerInfo.SessionId = sessionId; this.brokerInfo.Attached = attached; this.brokerInfo.Durable = durable; this.brokerInfo.NetworkPrefix = Constant.EnterpriseNetwork; //rewrite the method building configuration file since regpath gotten from input. string regPath = this.startInfo.RegPath; ServiceRegistrationRepo serviceRegistration = new ServiceRegistrationRepo(regPath, null); this.brokerInfo.ConfigurationFile = serviceRegistration.GetServiceRegistrationPath(serviceName, serviceVersion); if (string.IsNullOrEmpty(this.brokerInfo.ConfigurationFile) && serviceVersion == null) { Version version = serviceRegistration.GetServiceVersionInternal(serviceName, false); if (version != null) { string serviceConfigFile = serviceRegistration.GetServiceRegistrationPath(serviceName, version); if (!string.IsNullOrEmpty(serviceConfigFile)) { this.brokerInfo.ConfigurationFile = serviceConfigFile; this.startInfoContract.ServiceVersion = version; } } } }
/// <summary> /// Fetch service registration path /// </summary> /// <param name="serviceName">indicating the service name</param> /// <param name="serviceVersion">indicating the server version</param> /// <returns>returns tha path of the service registration file</returns> private async Task <string> FetchServiceRegistrationPath(string serviceName, Version serviceVersion) { string centralPath = null; if (this.isDebugModeEnabled) { // Fetch central path directly from environment if debug mode is enabled centralPath = Environment.GetEnvironmentVariable(Constant.RegistryPathEnv); } else { // Fetch central path from session launcher via GetSOAConfiguration on the other hand SessionLauncherClient client = new SessionLauncherClient(await Utility.GetSessionLauncherAsync(this.startInfo, this.binding).ConfigureAwait(false), this.binding, this.startInfo.IsAadOrLocalUser); try { centralPath = await client.GetSOAConfigurationAsync(Constant.RegistryPathEnv).ConfigureAwait(false); } catch (Exception e) { SessionBase.TraceSource.TraceEvent(TraceEventType.Error, 0, "[InprocBrokerAdapter] Failed to get service registration path via session launcher service: {0}", e); } finally { Utility.SafeCloseCommunicateObject(client); } } if (centralPath == null) { ThrowHelper.ThrowSessionFault(SOAFaultCode.ServiceRegistrationPathEnvironmentMissing, SR.ServiceRegistrationPathEnvironmentMissing); } // setup the service registery helper ServiceRegistrationRepo serviceRegistration = new ServiceRegistrationRepo(centralPath, null); string serviceRegistrationPath = serviceRegistration.GetServiceRegistrationPath(serviceName, serviceVersion); if (serviceRegistrationPath == null) { throw new FileNotFoundException("Registration file is not found", serviceName); } return(serviceRegistrationPath); }