public static string GetFabricSystemApplicationCodeFolder(DeploymentFolders deploymentFolders, string servicePackageName, string codePackageName, string codePackageVersion) { string applicationDeploymentFolder = deploymentFolders.ApplicationDeploymentFolder; RunLayoutSpecification runLayout = RunLayoutSpecification.Create(); runLayout.SetRoot(applicationDeploymentFolder); return(runLayout.GetCodePackageFolder(Constants.SystemApplicationId, servicePackageName, codePackageName, codePackageVersion, false)); }
internal AppConfig(string nodeName, string runLayoutRoot, string appInstanceId, string rolloutVersion) { this.configValues = new Dictionary <string, Dictionary <string, string> >(); this.producerNames = new List <string>(); this.consumerNames = new List <string>(); this.runLayout = RunLayoutSpecification.Create(); this.nodeName = nodeName; this.appInstanceId = appInstanceId; // Get the application manifest this.runLayout.SetRoot(runLayoutRoot); this.ApplicationManifest = this.runLayout.GetApplicationPackageFile( this.appInstanceId, rolloutVersion); // Load the manifest bool manifestFound = false; #if DotNetCoreClr XmlDocument doc = new XmlDocument(); #else XmlDocument doc = new XmlDocument { XmlResolver = null }; #endif try { Utility.PerformIOWithRetries( () => { try { XmlReaderSettings settings = new XmlReaderSettings() { #if DotNetCoreClr DtdProcessing = DtdProcessing.Prohibit #else DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null #endif }; using (XmlReader reader = XmlReader.Create(this.ApplicationManifest, settings)) { doc.Load(reader); } manifestFound = true; } catch (Exception e) { DirectoryNotFoundException dnfe = e as DirectoryNotFoundException; FileNotFoundException fnfe = e as FileNotFoundException; if ((null != dnfe) || (null != fnfe)) { Utility.TraceSource.WriteWarning( TraceType, "Manifest {0} was not found. This could be because the application has been deleted, but we haven't yet processed the event that notifies us about the deletion.", this.ApplicationManifest); } else { throw; } } }); } catch (Exception e) { var message = string.Format( "Error occurred while loading manifest {0}", this.ApplicationManifest); Utility.TraceSource.WriteExceptionAsError( TraceType, e, message); throw new InvalidOperationException(message, e); } if (false == manifestFound) { var message = string.Format( "Error occurred while loading manifest {0}", this.ApplicationManifest); Utility.TraceSource.WriteError( TraceType, message); throw new InvalidOperationException(message); } // Get the ApplicationManifest element XmlElement rootElem = doc.DocumentElement; if (rootElem == null) { var message = string.Format( "Unable to find the root element in {0}.", this.ApplicationManifest); Utility.TraceSource.WriteError( TraceType, message); throw new InvalidOperationException(message); } XmlAttribute applicationTypeAttr = rootElem.Attributes[ApplicationTypeNameAttribute]; if (null == applicationTypeAttr) { var message = string.Format( "Unable to find the {0} attribute in root in {1}.", ApplicationTypeNameAttribute, this.ApplicationManifest); Utility.TraceSource.WriteError( TraceType, message); throw new InvalidOperationException(message); } this.ApplicationType = applicationTypeAttr.Value.Trim(); // Get the DigestedEnvironment element XmlElement digestedEnvironmentElem = rootElem[DigestedEnvironmentElement]; // Get the Diagnostics element XmlElement diagnosticsElem = digestedEnvironmentElem[DiagnosticsElement]; // Parse the diagnostics element this.ParseDiagnosticsElement(diagnosticsElem); // Add the producers and consumers to the config dictionary Dictionary <string, string> diagnosticsSection = new Dictionary <string, string>(); diagnosticsSection[ConfigReader.ProducerInstancesParamName] = string.Join(",", this.producerNames); diagnosticsSection[ConfigReader.ConsumerInstancesParamName] = string.Join(",", this.consumerNames); this.configValues[ConfigReader.DiagnosticsSectionName] = diagnosticsSection; }
internal ServiceConfig(string runLayoutRoot, string appInstanceId, string servicePackageName, string serviceRolloutVersion) { this.etwProviderGuids = new List <Guid>(); this.etwManifests = new List <ServiceEtwManifestInfo>(); this.exeNames = new HashSet <string>(); this.runLayout = RunLayoutSpecification.Create(); this.appInstanceId = appInstanceId; this.servicePackageName = servicePackageName; // Get the service manifest this.runLayout.SetRoot(runLayoutRoot); this.servicePackageFile = this.runLayout.GetServicePackageFile( this.appInstanceId, this.servicePackageName, serviceRolloutVersion); // Load the manifest XmlDocument doc = new XmlDocument { #if !DotNetCoreClr XmlResolver = null #endif }; try { Utility.PerformIOWithRetries( () => { XmlReaderSettings settings = new XmlReaderSettings() { #if DotNetCoreClr DtdProcessing = DtdProcessing.Prohibit #else DtdProcessing = DtdProcessing.Prohibit, XmlResolver = null #endif }; using (XmlReader reader = XmlReader.Create(this.servicePackageFile, settings)) { doc.Load(reader); } }); } catch (Exception e) { var message = string.Format( "Error occurred while loading manifest {0}", this.servicePackageFile); Utility.TraceSource.WriteExceptionAsError( TraceType, e, message); throw new InvalidOperationException(message, e); } // Get the ServicePackage element XmlElement rootElem = doc.DocumentElement; if (rootElem == null) { var message = string.Format( "Unable to find the root element in {0}.", this.servicePackageFile); Utility.TraceSource.WriteError( TraceType, message); throw new InvalidOperationException(message); } // Get the Diagnostics element XmlElement diagnosticsElem = rootElem[DiagnosticsElement]; // Parse the Diagnostics element this.ParseDiagnosticsElement(diagnosticsElem); // Parse the manifest to figure out which executables are associated // with this service this.ParseExes(rootElem); }