private WinFabricManifestManager InitializeWinFabManifestManager()
        {
            // Figure out which Service Fabric manifests we have.
            // Try the repository first ...
            string manifestFileDirectory;

            try
            {
                manifestFileDirectory = LttTraceProcessor.WinfabManifestRepository.RepositoryPath;
            }
            catch (Exception)
            {
                // If we couldn't access the repository for any reason, fall back to
                // the manifests that we shipped with.
                manifestFileDirectory = Path.GetDirectoryName(Utility.DcaProgramDirectory);
            }

            string[] manifestFiles = Directory.GetFiles(manifestFileDirectory, "*.man", SearchOption.TopDirectoryOnly);

            WinFabricManifestManager manifestManager = null;

            try
            {
                manifestManager = new WinFabricManifestManager(
                    manifestFiles,
                    this.LoadManifest,
                    this.etwManifestCache.UnloadManifest);
            }
            catch (Exception e)
            {
                this.traceSource.WriteError(
                    this.logSourceId,
                    "Exception encountered while identifying the Windows Fabric manifests available. Exception information: {0}",
                    e);
                return(manifestManager);
            }

            if (!manifestManager.FabricManifests.Any())
            {
                this.traceSource.WriteError(
                    this.logSourceId,
                    "No Fabric manifests were found.");
            }

            if (!manifestManager.LeaseLayerManifests.Any())
            {
                this.traceSource.WriteError(
                    this.logSourceId,
                    "No lease layer manifests were found.");
            }

            if (!manifestManager.KtlManifests.Any())
            {
                this.traceSource.WriteError(
                    this.logSourceId,
                    "No KTL manifests were found.");
            }

            return(manifestManager);
        }
Пример #2
0
        private void UnloadManifest(string manifestFile)
        {
            Utility.TraceSource.WriteInfo(
                TraceType,
                "Unloading manifest file {0}",
                manifestFile);

            string manifestFileName = Path.GetFileName(manifestFile);

            if (WinFabricManifestManager.IsFabricManifestFileName(manifestFileName))
            {
                UnloadManifest(manifestFile, ref this.currentFabricManifest);
            }
            else if (WinFabricManifestManager.IsLeaseLayerManifestFileName(manifestFileName))
            {
                UnloadManifest(manifestFile, ref this.currentLeaseLayerManifest);
            }
            else if (WinFabricManifestManager.IsKtlManifestFileName(manifestFileName))
            {
                UnloadManifest(manifestFile, ref this.currentKtlManifest);
            }
            else
            {
                Verify.Fail("Unexpected prefix in manifest file name");
            }
        }
Пример #3
0
        internal EtlProcessor(
            bool loadWinFabManifests,
            bool dynamicWinFabManifestLoad,
            IEnumerable <string> customManifestPaths,
            string applicationType,
            string markerFileDirectory,
            WinFabricEtlType winFabricEtlType,
            FabricEvents.ExtensionsEvents traceSource,
            string logSourceId,
            EtlPerformance perfHelper,
            IEnumerable <IEtlFileSink> sinks,
            IEnumerable <EtlToCsvFileWriter> etlToCsvFileWriters,
            IEnumerable <BufferedEtwEventProvider> bufferedEtwEventProviders,
            IEnumerable <Guid> appEtwGuids,
            ITraceFileEventReaderFactory traceFileEventReaderFactory)
        {
            this.traceSource            = traceSource;
            this.logSourceId            = logSourceId;
            this.processingWinFabEvents = loadWinFabManifests;
            this.applicationType        = applicationType;
            this.markerFileDirectory    = markerFileDirectory;
            this.windowsFabricEtlType   = winFabricEtlType;
            this.perfHelper             = perfHelper;
            this.sinks = sinks.ToList().AsReadOnly();
            this.etlToCsvFileWriters       = etlToCsvFileWriters.ToList().AsReadOnly();
            this.bufferedEtwEventProviders = bufferedEtwEventProviders.ToList().AsReadOnly();
            this.appEtwGuids = appEtwGuids != null?appEtwGuids.ToList().AsReadOnly() : null;

            this.traceFileEventReaderFactory = traceFileEventReaderFactory;

            // Load the custom manifests (if any) into the manifest cache
            this.LoadManifests(customManifestPaths);

            if (loadWinFabManifests)
            {
                if (dynamicWinFabManifestLoad)
                {
                    // We are going to be loading manifests dynamically based on the version
                    // in the ETL file. Initialize the manifest manager object to manage this
                    // for us.
                    this.winFabManifestMgr = this.InitializeWinFabManifestManager();
                }
                else
                {
                    // We'll load the default manifests now and just use them throughout
                    this.LoadDefaultManifests();
                }
            }

            // Provide the sinks a reference to the manifest cache.
            this.OnEtwManifestCacheAvailable();
        }
Пример #4
0
        internal EtlProcessor(
            bool loadWinFabManifests,
            bool dynamicWinFabManifestLoad,
            string markerFileDirectory,
            WinFabricEtlType winFabricEtlType,
            FabricEvents.ExtensionsEvents traceSource,
            string logSourceId,
            EtlInMemoryPerformance perfHelper,
            IEnumerable <IEtlInMemorySink> sinks,
            IEnumerable <EtlToInMemoryBufferWriter> etlToInMemoryBufferWriters,
            ITraceFileEventReaderFactory traceFileEventReaderFactory)
        {
            this.traceSource            = traceSource;
            this.logSourceId            = logSourceId;
            this.processingWinFabEvents = loadWinFabManifests;
            this.markerFileDirectory    = markerFileDirectory;
            this.windowsFabricEtlType   = winFabricEtlType;
            this.sinks = sinks.ToList().AsReadOnly();
            this.etlToInMemoryBufferWriters  = etlToInMemoryBufferWriters.ToList().AsReadOnly();
            this.traceFileEventReaderFactory = traceFileEventReaderFactory;
            this.perfHelper = perfHelper;

            if (loadWinFabManifests)
            {
                if (dynamicWinFabManifestLoad)
                {
                    // We are going to be loading manifests dynamically based on the version
                    // in the ETL file. Initialize the manifest manager object to manage this
                    // for us.
                    this.winFabManifestMgr = this.InitializeWinFabManifestManager();
                }
                else
                {
                    // We'll load the default manifests now and just use them throughout
                    this.LoadDefaultManifests();
                }
            }

            // Provide the sinks a reference to the manifest cache.
            this.sinks.ForEach(sink => sink.SetEtwManifestCache(this.etwManifestCache));
        }
        internal LttTraceProcessor(
            FabricEvents.ExtensionsEvents traceSource,
            string logSourceId,
            string dtrTracesDir,
            ReadOnlyCollection <IEtlFileSink> sinksIEtlFile,
            ReadOnlyCollection <ICsvFileSink> sinksICsvFile)
        {
            this.traceSource        = traceSource;
            this.logSourceId        = logSourceId;
            this.dtrTracesDirectory = dtrTracesDir;

            this.sinksIEtlFile = sinksIEtlFile;
            this.sinksICsvFile = sinksICsvFile;

            this.createTableFiles = sinksICsvFile.Any();

            this.winFabManifestMgr = this.InitializeWinFabManifestManager();

            // initialize white list of table events from file
            if (this.createTableFiles)
            {
                this.tableEventsWhiteList = this.CreateTableEventsFromConfigFile(Path.Combine(Directory.GetCurrentDirectory(), TableEventsConfigFileName));
            }
            else
            {
                this.tableEventsWhiteList = new HashSet <string>();
            }

            this.traceSource.WriteInfo(
                this.logSourceId,
                "Creating table events file set to {0}. The number of whitelist events parsed is {1}",
                this.createTableFiles,
                this.tableEventsWhiteList.Count);

            // Provide the sinks a reference to the manifest cache.
            this.OnEtwManifestCacheAvailable();
        }
Пример #6
0
        public void MapEtlToManifestTest()
        {
            this.currentFabricManifest     = null;
            this.currentLeaseLayerManifest = null;
            this.currentKtlManifest        = null;

            string[] manifests = testContext.DataRow["Manifests"] as string[];
            for (int i = 0; i < manifests.Length; i++)
            {
                manifests[i] = manifests[i].Trim();
            }

            WinFabricManifestManager manifestMgr = new WinFabricManifestManager(
                manifests,
                this.LoadManifest,
                this.UnloadManifest);

            string[] mapping = testContext.DataRow["ExpectedMapping"] as string[];
            foreach (string etlToMan in mapping)
            {
                string[] etlToManParts = etlToMan.Split(',');
                Verify.IsTrue(etlToManParts.Length > 0);
                string etlFile = etlToManParts[0].Trim();

                Utility.TraceSource.WriteInfo(
                    TraceType,
                    "Processing ETL file {0}",
                    etlFile);

                bool exactMatch;
                manifestMgr.EnsureCorrectWinFabManifestVersionLoaded(etlFile, out exactMatch);

                List <string> expectedManifests = new List <string>();
                for (int i = 1; i < etlToManParts.Length; i++)
                {
                    expectedManifests.Add(etlToManParts[i].Trim());
                }

                string etlFileName = Path.GetFileName(etlFile);
                if (etlFileName.StartsWith(WinFabricManifestManager.FabricEtlPrefix))
                {
                    VerifyCurrentManifest(this.currentFabricManifest, expectedManifests);
                }
                else if (etlFileName.StartsWith(WinFabricManifestManager.LeaseLayerEtlPrefix))
                {
                    VerifyCurrentManifest(this.currentLeaseLayerManifest, expectedManifests);
                    VerifyCurrentManifest(this.currentKtlManifest, expectedManifests);
                }
                else
                {
                    Verify.Fail("Unexpected prefix in ETL file name");
                }

                foreach (string expectedManifest in expectedManifests)
                {
                    Utility.TraceSource.WriteError(
                        TraceType,
                        "Expected manifest {0} was not loaded.",
                        expectedManifest);
                    Verify.Fail("Expected manifest not loaded.");
                }
            }
        }
Пример #7
0
        private WinFabricManifestManager InitializeWinFabManifestManager()
        {
            // Figure out which Windows Fabric manifests we have.
            // Try the repository first ...
            string manifestFileDirectory;

            try
            {
                manifestFileDirectory = EtlProcessor.WinfabManifestRepository.RepositoryPath;
            }
            catch (Exception)
            {
                // If we couldn't access the repository for any reason, fall back to
                // the manifests that we shipped with.
                string assemblyLocation = Process.GetCurrentProcess().MainModule.FileName;
                manifestFileDirectory = Path.GetDirectoryName(assemblyLocation);
            }

            string[] manifestFiles = FabricDirectory.GetFiles(manifestFileDirectory, "*.man");

            WinFabricManifestManager manifestManager = null;

            try
            {
                manifestManager = new WinFabricManifestManager(
                    manifestFiles,
                    this.LoadManifest,
                    this.etwManifestCache.UnloadManifest);
            }
            catch (Exception e)
            {
                this.traceSource.WriteError(
                    this.logSourceId,
                    "Exception encountered while identifying the Windows Fabric manifests available. Exception information: {0}",
                    e);
                return(manifestManager);
            }

            if (!manifestManager.FabricManifests.Any())
            {
                this.traceSource.WriteError(
                    this.logSourceId,
                    "No Fabric manifests were found.");
            }

            if (!manifestManager.LeaseLayerManifests.Any())
            {
                this.traceSource.WriteError(
                    this.logSourceId,
                    "No lease layer manifests were found.");
            }

            if (!manifestManager.KtlManifests.Any())
            {
                this.traceSource.WriteError(
                    this.logSourceId,
                    "No KTL manifests were found.");
            }

            return(manifestManager);
        }