/// <summary> /// Create a logging directory under a specified path. /// </summary> /// <param name="logPath"> Path to the directory to be used by the analyzer. </param> /// <param name="loggingContext"> Logging context to log if a failure occurs when creating the directory. </param> public static bool CreateLoggingDirectory(string logPath, LoggingContext loggingContext) { bool success = true; try { FileUtilities.CreateDirectoryWithRetry(logPath); } catch (Exception ex) { // If log directory creation fails, then disable the runtime analyzer for this build and log the exception. Logger.Log.DumpPipLiteUnableToCreateLogDirectory(loggingContext, logPath, ex.GetLogEventMessage()); success = false; } return(success); }
/// <summary> /// Constructor /// </summary> public EngineSerializer( LoggingContext loggingContext, string engineCacheLocation, FileEnvelopeId?correlationId = null, bool useCompression = false, bool debug = false, bool readOnly = false, FileSystemStreamProvider readStreamProvider = null, ITempCleaner tempDirectoryCleaner = null) { Contract.Requires(loggingContext != null); Contract.Requires(engineCacheLocation != null); Contract.Requires(Path.IsPathRooted(engineCacheLocation)); Contract.Requires(!string.IsNullOrWhiteSpace(engineCacheLocation)); LoggingContext = loggingContext; m_engineCacheLocation = engineCacheLocation; m_debug = debug; m_correlationId = correlationId; m_useCompression = useCompression; m_readStreamProvider = readStreamProvider ?? FileSystemStreamProvider.Default; m_tempDirectoryCleaner = tempDirectoryCleaner; if (!readOnly) { try { FileUtilities.CreateDirectoryWithRetry(engineCacheLocation); } catch (Exception ex) { ExceptionRootCause rootCause = ExceptionUtilities.AnalyzeExceptionRootCause(ex); BuildXL.Tracing.UnexpectedCondition.Log(LoggingContext, ex.ToStringDemystified() + Environment.NewLine + rootCause); throw new BuildXLException("Unable to create engine serializer cache directory: ", ex); } } }
/// <summary> /// Creates a <see cref="FingerprintStoreExecutionLogTarget"/>. /// </summary> /// <returns> /// If successful, a <see cref="FingerprintStoreExecutionLogTarget"/> that logs to /// a <see cref="Tracing.FingerprintStore"/> at the provided directory; /// otherwise, null. /// </returns> public static FingerprintStoreExecutionLogTarget Create( PipExecutionContext context, PipTable pipTable, PipContentFingerprinter pipContentFingerprinter, LoggingContext loggingContext, IConfiguration configuration, EngineCache cache, IReadonlyDirectedGraph graph, CounterCollection <FingerprintStoreCounters> counters, IDictionary <PipId, RunnablePipPerformanceInfo> runnablePipPerformance = null, FingerprintStoreTestHooks testHooks = null) { var fingerprintStorePathString = configuration.Layout.FingerprintStoreDirectory.ToString(context.PathTable); var cacheLookupFingerprintStorePathString = configuration.Logging.CacheLookupFingerprintStoreLogDirectory.ToString(context.PathTable); try { FileUtilities.CreateDirectoryWithRetry(fingerprintStorePathString); } catch (BuildXLException ex) { Logger.Log.FingerprintStoreUnableToCreateDirectory(loggingContext, fingerprintStorePathString, ex.Message); throw new BuildXLException("Unable to create fingerprint store directory: ", ex); } var maxEntryAge = new TimeSpan(hours: 0, minutes: configuration.Logging.FingerprintStoreMaxEntryAgeMinutes, seconds: 0); var possibleExecutionStore = FingerprintStore.Open( fingerprintStorePathString, maxEntryAge: maxEntryAge, mode: configuration.Logging.FingerprintStoreMode, loggingContext: loggingContext, counters: counters, testHooks: testHooks); Possible <FingerprintStore> possibleCacheLookupStore = new Failure <string>("No attempt to create a cache lookup fingerprint store yet."); if (configuration.Logging.FingerprintStoreMode != FingerprintStoreMode.ExecutionFingerprintsOnly) { try { FileUtilities.CreateDirectoryWithRetry(cacheLookupFingerprintStorePathString); } catch (BuildXLException ex) { Logger.Log.FingerprintStoreUnableToCreateDirectory(loggingContext, fingerprintStorePathString, ex.Message); throw new BuildXLException("Unable to create fingerprint store directory: ", ex); } possibleCacheLookupStore = FingerprintStore.Open( cacheLookupFingerprintStorePathString, maxEntryAge: maxEntryAge, mode: configuration.Logging.FingerprintStoreMode, loggingContext: loggingContext, counters: counters, testHooks: testHooks); } if (possibleExecutionStore.Succeeded && (possibleCacheLookupStore.Succeeded || configuration.Logging.FingerprintStoreMode == FingerprintStoreMode.ExecutionFingerprintsOnly)) { return(new FingerprintStoreExecutionLogTarget( loggingContext, context, pipTable, pipContentFingerprinter, possibleExecutionStore.Result, possibleCacheLookupStore.Succeeded ? possibleCacheLookupStore.Result : null, configuration, cache, graph, counters, runnablePipPerformance)); } else { if (!possibleExecutionStore.Succeeded) { Logger.Log.FingerprintStoreUnableToOpen(loggingContext, possibleExecutionStore.Failure.DescribeIncludingInnerFailures()); } if (!possibleCacheLookupStore.Succeeded) { Logger.Log.FingerprintStoreUnableToOpen(loggingContext, possibleCacheLookupStore.Failure.DescribeIncludingInnerFailures()); } } return(null); }