예제 #1
0
        internal void AddPip(PipDescriptor pip, uint processId, string processArgs, TimeSpan kernelTime, TimeSpan userTime, IOCounters ioCounters, DateTime creationTime, DateTime exiTime, uint exitCode, uint parentProcessId)
        {
            ProcessInstanceDescriptor processInstance             = new ProcessInstanceDescriptor(processId, ProcessExecutable, processArgs, kernelTime, userTime, ioCounters, creationTime, exiTime, exitCode, parentProcessId);
            IReadOnlyCollection <ProcessInstanceDescriptor> items = PipsThatExecuteTheProcessDictionary.GetOrAdd(pip, (key) => new ConcurrentHashSet <ProcessInstanceDescriptor>());

            // This is pretty ugly: Doing down casting here so we can add elements to our read only collection
            // The collection is read only because we do no want to allow the Users of the SDK to change it. Unfortunately the only way .NET allows me to define such dictionary
            // is to specify its elements as a IReadOnlyCollection and down cast every time I need to modify it
            // Down casting here is pretty safe though. The collection is only created in this method and we know that it is always a ConcurrentDictionary.
            (items as ConcurrentHashSet <ProcessInstanceDescriptor>).Add(processInstance);
            pip.ReportedProcessesHashset.Add(processInstance);
        }
예제 #2
0
        /// <summary>
        /// Thread safe GetOrAdd method. We use concurrent dictionaries for backing, therefore no lock is needed.
        /// </summary>
        /// <param name="pipId">The pip Id to be used when creating a new pip descriptor</param>
        /// <param name="pipName">The pip name to be used when creating a new pip descriptor</param>
        /// <returns>New PipDescriptor instance that stores the data from the specified pip</returns>
        internal PipDescriptor SynchronizedGetOrAdd(Process fullPip, CachedGraph buildGraph,
                                                    ExecutionLogLoadOptions loadOptions, ConcurrentHashSet <FileDescriptor> emptyConcurrentHashSetOfFileDescriptor,
                                                    ConcurrentHashSet <PipDescriptor> emptyConcurrentHashSetOfPipDescriptor, ConcurrentHashSet <ProcessInstanceDescriptor> emptyConcurrentHashSetOfReportedProcesses,
                                                    StringIdEnvVarDictionary emptyStringIDEnvVarDictionary, AbsolutePathConcurrentHashSet emptyAbsolutePathConcurrentHashSet)
        {
            PipDescriptor newItem = m_pipIdDictionary.GetOrAdd(fullPip.PipId.Value, (p) => { return(new PipDescriptor(fullPip, buildGraph, loadOptions, emptyConcurrentHashSetOfFileDescriptor, emptyConcurrentHashSetOfPipDescriptor, emptyConcurrentHashSetOfReportedProcesses, emptyStringIDEnvVarDictionary, emptyAbsolutePathConcurrentHashSet)); });

            IReadOnlyCollection <PipDescriptor> pipList = m_pipNameDictionary.GetOrAdd(fullPip.Provenance.OutputValueSymbol, new ConcurrentHashSet <PipDescriptor>());

            // This is pretty ugly: Doing down casting here so we can add elements to our read only collection
            // The collection is read only because we do no want to allow the Users of the SDK to change it. Unfortunately the only way .NET allows me to define such dictionary
            // is to specify its elements as a IReadOnlyCollection and down cast every time I need to modify it.
            // Down casting here is pretty safe though. The collection is only created in this method and we know that it is always a ConcurrentDictionary.
            (pipList as ConcurrentHashSet <PipDescriptor>).Add(newItem);

            return(newItem);
        }
예제 #3
0
 /// <summary>
 /// Internal constructor
 /// </summary>
 /// <param name="pip">The pip that executed that process that reported the file access</param>
 /// <param name="reportedFileAccesse">Reported file access descriptor</param>
 /// <param name="pathTable">Path table used to expand path strings</param>
 internal ReportedFileAccessDescriptor(PipDescriptor pip, ref ReportedFileAccess reportedFileAccess, BuildXL.Utilities.PathTable pathTable)
 {
     Pip = pip;
     ReportedFileAccess = new ReportedFileAccess(
         operation: reportedFileAccess.Operation,
         process: reportedFileAccess.Process,
         requestedAccess: reportedFileAccess.RequestedAccess,
         status: reportedFileAccess.Status,
         explicitlyReported: reportedFileAccess.ExplicitlyReported,
         error: reportedFileAccess.Error,
         usn: reportedFileAccess.Usn,
         desiredAccess: reportedFileAccess.DesiredAccess,
         shareMode: reportedFileAccess.ShareMode,
         creationDisposition: reportedFileAccess.CreationDisposition,
         flagsAndAttributes: reportedFileAccess.FlagsAndAttributes,
         manifestPath: reportedFileAccess.ManifestPath,
         path: reportedFileAccess.GetPath(pathTable),
         enumeratePatttern: reportedFileAccess.EnumeratePattern);
 }
예제 #4
0
 /// <summary>
 /// Thread safe TryGetValue method based on a pip Id
 /// </summary>
 /// <param name="keyPipId">The pip Id to locate</param>
 /// <param name="value">The PipDescriptor that matches the pip id</param>
 /// <returns>true, when a mathcing PipDescriptor is found, false otherwise</returns>
 internal bool SynchronizedTryGetValue(uint keyPipId, out PipDescriptor value)
 {
     return(m_pipIdDictionary.TryGetValue(keyPipId, out value));
 }