/// <summary> /// SaveManifest /// Save manifest on disk /// </summary> public async Task <bool> SaveManifest(ManifestCache cache) { bool bResult = false; using (var releaser = await internalManifestDiskLock.WriterLockAsync()) { System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " internalManifestDiskLock Writer Enter for Uri: " + cache.ManifestUri.ToString()); try { using (MemoryStream ms = new MemoryStream()) { if (ms != null) { System.Runtime.Serialization.DataContractSerializer ser = new System.Runtime.Serialization.DataContractSerializer(typeof(ManifestCache)); ser.WriteObject(ms, cache); bResult = await Save(Path.Combine(Path.Combine(root, cache.StoragePath), manifestFileName), ms.ToArray()); } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " internalManifestDiskLock Writer exception for Uri: " + cache.ManifestUri.ToString() + " Exception: " + e.Message); } System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " internalManifestDiskLock Writer Exit for Uri: " + cache.ManifestUri.ToString()); } return(bResult); }
/// <summary> /// RemoveVideoChunks /// Remove video chunks from disk /// </summary> public async Task <bool> RemoveVideoChunks(ManifestCache cache) { bool bResult = false; string pathContent = Path.Combine(Path.Combine(root, cache.StoragePath), videoContentFileName); string pathIndex = Path.Combine(Path.Combine(root, cache.StoragePath), videoIndexFileName); using (var releaser = await internalVideoDiskLock.WriterLockAsync()) { if (pathContent != null) { bool res = await FileExists(pathContent); if (res) { bResult = await DeleteFile(pathContent); } } if (pathIndex != null) { bool res = await FileExists(pathIndex); if (res) { bResult = await DeleteFile(pathIndex); } } } return(bResult); }
/// <summary> /// GetCacheSize /// Return the current size of the cache on disk: adding the size of each asset /// </summary> public async Task <ulong> GetCacheSize() { ulong Val = 0; List <string> dirs = await GetDirectoryNames(root); if (dirs != null) { for (int i = 0; i < dirs.Count; i++) { string path = Path.Combine(root, dirs[i]); if (!string.IsNullOrEmpty(path)) { string file = Path.Combine(path, manifestFileName); if (!string.IsNullOrEmpty(file)) { ManifestCache de = await GetObjectByType(file, typeof(ManifestCache)) as ManifestCache; if (de != null) { Val += await GetAssetSize(de); } } } } } return(Val); }
private void OnEventRead(object sender, EventRecordEventArgs e) { string[] formattedEvent = ManifestCache.FormatEvent(e.Record)?.Split(new char[] { ',' }, EtlInputFields.Count()); Log.Trivial($"formattedEvent", formattedEvent); if (formattedEvent == null) { EventReadErrors++; Log.Warning("null etl event. enable logdebug 5 and review log"); EventDefinition eventDefinition = ManifestCache.GetEventDefinition(e.Record); Log.Debug($"null etl event: e:", e); Log.Debug($"null etl event: eventDefinition", eventDefinition); return; } _traceDispatcher(new T() { Timestamp = DateTime.FromFileTimeUtc(e.Record.EventHeader.TimeStamp), Level = formattedEvent[EtlInputFields.Level], TID = (int)e.Record.EventHeader.ThreadId, PID = (int)e.Record.EventHeader.ProcessId, Type = formattedEvent[EtlInputFields.Type], Text = formattedEvent[EtlInputFields.Text] }); }
private void LoadWindowsFabricEtwManifest() { // Figure out where the ETW manifests are located string assemblyLocation = typeof(AppInstanceEtwDataReader).GetTypeInfo().Assembly.Location; string manifestFileDirectory = Path.GetDirectoryName(assemblyLocation); // Get the Windows Fabric manifest file string manifestFile = Path.Combine( manifestFileDirectory, WindowsFabricManifestFileName); // Load the manifest this.manifestCache = new ManifestCache(Utility.DcaWorkFolder); try { Utility.PerformIOWithRetries( () => { this.manifestCache.LoadManifest( manifestFile); }); Utility.TraceSource.WriteInfo( TraceType, "Loaded manifest {0}", manifestFile); } catch (Exception e) { Utility.TraceSource.WriteExceptionAsError( TraceType, e, "Failed to load manifest {0}.", manifestFile); } }
/// <summary> /// Return a ManifestCache based on its Uri /// </summary> public async Task <ManifestCache> RestoreAsset(Uri uri) { List <string> dirs = await GetDirectoryNames(root); if (dirs != null) { for (int i = 0; i < dirs.Count; i++) { string path = Path.Combine(root, dirs[i]); if (!string.IsNullOrEmpty(path)) { string file = Path.Combine(path, manifestFileName); if (!string.IsNullOrEmpty(file)) { ManifestCache de = await GetObjectByType(file, typeof(ManifestCache)) as ManifestCache; if (de != null) { if (de.ManifestUri == uri) { return(de); } } } } } } return(null); }
internal AppInstanceEtwDataReader( ServicePackageTableManager.AddOrUpdateHandler addOrUpdateServicePackageHandler, ServicePackageTableManager.RemoveHandler removeServicePackageHandler, ManifestCache manifestCache) { this.AddOrUpdateServicePackageHandler = addOrUpdateServicePackageHandler; this.RemoveServicePackageHandler = removeServicePackageHandler; this.manifestCache = manifestCache; }
/// <summary> /// RemoveAsset /// Remove the asset on disk: audio chunks, video chunks and manifest /// </summary> public async Task <bool> RemoveAsset(ManifestCache cache) { bool bResult = false; await RemoveAudioChunks(cache); await RemoveVideoChunks(cache); await RemoveManifest(cache); bResult = await RemoveDirectory(Path.Combine(root, cache.StoragePath)); return(bResult); }
public void TestManifestLoadingFromByteStream() { string sequenceToCheck = "<provider name=\"TestEventSource\" guid=\"{0d468d81-a713-4c16-a8a3-a3d0d3535eae}\""; string workDirectory = Directory.GetCurrentDirectory(); ManifestCache manifestCache = new ManifestCache(workDirectory); manifestCache.LoadManifest(manifestInBytes); string manifestFilePath = Path.Combine(workDirectory, "WFDynMan", "0d468d81-a713-4c16-a8a3-a3d0d3535eae.man"); // Verify if manifest was generated Assert.IsTrue(File.Exists(manifestFilePath), "Dynamic manifest was not created at " + manifestFilePath); // Verify the sanity of dynamic manifest Assert.IsTrue(File.ReadLines(manifestFilePath).Any(line => line.Contains(sequenceToCheck)), "Dynamic manifest is malformed, check the contents of " + manifestFilePath); }
/// <summary> /// RemoveManifest /// Remove manifest from disk /// </summary> public async Task <bool> RemoveManifest(ManifestCache cache) { bool bResult = false; string path = Path.Combine(Path.Combine(root, cache.StoragePath), manifestFileName); if (path != null) { bool res = await FileExists(path); if (res) { bResult = await DeleteFile(path); } } return(bResult); }
/// <summary> /// <remarks>Adapted from DCA</remarks> /// </summary> private static void LoadManifestCache() { try { string manifestFileDirectory = FabricEnvironment.GetCodePath(); // Get the Windows Fabric manifest file string manifestFile = Path.Combine( manifestFileDirectory, WindowsFabricManifestFileName); // Load the manifest manifestCache = new ManifestCache(Path.Combine(GetLogRoot(), WorkFolder)); manifestCache.LoadManifest(manifestFile); } catch (Exception e) { Console.WriteLine(StringResources.EventStoreError_EventManifestLoadFailure, e.Message); } }
/// <summary> /// SaveAsset /// Save the asset on disk: audio chunks, video chunks and manifest /// </summary> public async Task <bool> SaveAsset(ManifestCache cache) { bool bResult = true; if (!(await SaveAudioChunks(cache))) { bResult = false; System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " Error while saving audio chunks for url: " + cache.ManifestUri.ToString()); } if (!(await SaveVideoChunks(cache))) { bResult = false; System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " Error while saving video chunks for url: " + cache.ManifestUri.ToString()); } if (!(await SaveManifest(cache))) { bResult = false; System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " Error while saving manifest chunks for url: " + cache.ManifestUri.ToString()); } return(bResult); }
/// <summary> /// GetAssetSize /// Return the current asset size on disk: audio chunks, video chunks and manifest /// </summary> public async Task <ulong> GetAssetSize(ManifestCache cache) { ulong val = 0; string path = string.Empty; path = Path.Combine(Path.Combine(root, cache.StoragePath), manifestFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } using (var releaser = await internalVideoDiskLock.ReaderLockAsync()) { path = Path.Combine(Path.Combine(root, cache.StoragePath), videoIndexFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } path = Path.Combine(Path.Combine(root, cache.StoragePath), videoContentFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } } using (var releaser = await internalAudioDiskLock.ReaderLockAsync()) { path = Path.Combine(Path.Combine(root, cache.StoragePath), audioIndexFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } path = Path.Combine(Path.Combine(root, cache.StoragePath), audioContentFileName); if (!string.IsNullOrEmpty(path)) { val += await GetFileSize(path); } } return(val); }
public EtlTraceFileParser(ConfigurationOptions config, ManifestCache cache = null) { lock (_manifestLock) { if (ManifestCache != null && cache == null) { return; } _config = config ?? throw new ArgumentNullException(nameof(config)); if (cache != null) { ManifestCache = cache; } if (ManifestCache == null) { ManifestCache = LoadManifests(_config.EtwManifestsCache, _config.CacheLocation); } } }
public void TestExternalEventWriterEventZeroIsHandled() { const string providerName = "TestProvider"; var providerId = Guid.NewGuid(); var manifestCache = new ManifestCache( new Dictionary <Guid, ProviderDefinition> { { providerId, new ProviderDefinition(new ProviderDefinitionDescription(providerId, providerName, new Dictionary <int, EventDefinitionDescription>())) } }, new Dictionary <string, List <Guid> >()); var reader = new TestableAppInstanceEtwDataReader(manifestCache); reader.TestableOnEtwEventReceived(null, new EventRecordEventArgs(new EventRecord { EventHeader = new EventHeader { EventDescriptor = new EventDescriptor { Id = 0 }, TimeStamp = DateTime.Now.ToFileTimeUtc() } })); }
/// <summary> /// Return a list of all urls in local storage /// </summary> public async Task <List <ManifestCache> > RestoreAllAssets(string pattern) { List <ManifestCache> downloads = new List <ManifestCache>(); List <string> dirs = await GetDirectoryNames(root); if (dirs != null) { for (int i = 0; i < dirs.Count; i++) { string path = Path.Combine(root, dirs[i]); if (!string.IsNullOrEmpty(path)) { string file = Path.Combine(path, manifestFileName); if (!string.IsNullOrEmpty(file)) { ManifestCache de = await GetObjectByType(file, typeof(ManifestCache)) as ManifestCache; if (de != null) { // Sanity check are the manifest file and chunk files consistent if ((de.AudioSavedChunks == (ulong)(await GetFileSize(Path.Combine(path, audioIndexFileName)) / indexSize)) && (de.VideoSavedChunks == (ulong)(await GetFileSize(Path.Combine(path, videoIndexFileName)) / indexSize))) { downloads.Add(de); } else { System.Diagnostics.Debug.WriteLine(string.Format("{0:d/M/yyyy HH:mm:ss.fff}", DateTime.Now) + " DiskCache - RestoreAllAssets - Manifest and Chunk file not consistent for path: " + path.ToString()); } } } } } } return(downloads); }
private bool DecodeEvent(ref EventRecord eventRecord, out DecodedEtwEvent decodedEvent, out string originalEventName) { decodedEvent = new DecodedEtwEvent { EventRecord = eventRecord }; originalEventName = string.Empty; if (false == ManifestCache.IsStringEvent(eventRecord)) { var eventDefinition = this.etwManifestCache.GetEventDefinition( eventRecord); if (null == eventDefinition) { if (eventRecord.EventHeader.EventDescriptor.Task != (ushort)FabricEvents.EventSourceTaskId) { // We couldn't decode this event. Skip it. this.traceSource.WriteError( this.logSourceId, "Unable to decode ETW event. The event will be skipped. Event ID: {0}, Task: {1}, Level: {2}.", eventRecord.EventHeader.EventDescriptor.Id, eventRecord.EventHeader.EventDescriptor.Task, eventRecord.EventHeader.EventDescriptor.Level); } return(false); } if (eventDefinition.IsChildEvent) { // Try to format the event. This causes the ETL reader to save information // about this event. That information is later retrieved when the parent // event is processed. string childEventType; string childEventText; var childStringRepresentation = this.etwManifestCache.FormatEvent( eventRecord, out childEventType, out childEventText); // Only parent events can be decoded. Child events supply additional // information about the parent event and cannot be decoded on their // own. return(false); } decodedEvent.TaskName = eventDefinition.TaskName; originalEventName = eventDefinition.OriginalEventName; } else { decodedEvent.TaskName = EventFormatter.StringEventTaskName; } decodedEvent.Timestamp = DateTime.FromFileTimeUtc(eventRecord.EventHeader.TimeStamp); decodedEvent.Level = eventRecord.EventHeader.EventDescriptor.Level; decodedEvent.ThreadId = eventRecord.EventHeader.ThreadId; decodedEvent.ProcessId = eventRecord.EventHeader.ProcessId; decodedEvent.StringRepresentation = this.etwManifestCache.FormatEvent( eventRecord, out decodedEvent.EventType, out decodedEvent.EventText, 0); if (null == decodedEvent.StringRepresentation) { if (eventRecord.EventHeader.EventDescriptor.Task != (ushort)FabricEvents.EventSourceTaskId) { // We couldn't decode this event. Skip it. this.traceSource.WriteError( this.logSourceId, "Unable to decode ETW event. The event will be skipped. Event ID: {0}, Task: {1}, Level: {2}.", eventRecord.EventHeader.EventDescriptor.Id, eventRecord.EventHeader.EventDescriptor.Task, eventRecord.EventHeader.EventDescriptor.Level); return(false); } } // in case it is a string event and the eventName is not give by the eventDefinition if (string.IsNullOrEmpty(originalEventName)) { originalEventName = decodedEvent.EventType; } // If this is an FMM event, update the last timestamp of FMM events if (decodedEvent.TaskName.Equals(Utility.FmmTaskName)) { Utility.LastFmmEventTimestamp = decodedEvent.Timestamp; } return(true); }
public static void AzureTableUploaderTestSetup(object testContext) { Verify.IsTrue(EntityDeletionAgeMinutes > 0); string assemblyLocation = Assembly.GetExecutingAssembly().Location; string manifestDir = Path.GetDirectoryName(assemblyLocation); // Prepare the manifest cache manifestCache = new ManifestCache(manifestDir); string manifestFullPath = Path.Combine(manifestDir, ManifestFileName); manifestCache.LoadManifest(manifestFullPath); // Create the table name prefix TableNamePrefix = String.Concat("CIT", Guid.NewGuid().ToString("N")); // Create the test data directory const string testDataDirectoryName = "AzureTableUploader.Test.Data"; testDataDirectory = Path.Combine(Directory.GetCurrentDirectory(), testDataDirectoryName); Directory.CreateDirectory(testDataDirectory); var accountKey = GetTestStorageAccountKey(); var escapedAccountKey = accountKey.Replace("=", @"\="); // Create the config file for the test string configFileFullPath = Path.Combine( testDataDirectory, configFileName); string configFileContentsFormatted = String.Format( CultureInfo.InvariantCulture, configFileContents, accountName, escapedAccountKey, TableNamePrefix, EntityDeletionAgeMinutes, ManifestFileName); byte[] configFileBytes = Encoding.ASCII.GetBytes(configFileContentsFormatted); File.WriteAllBytes(configFileFullPath, configFileBytes); Environment.SetEnvironmentVariable("FabricConfigFileName", configFileFullPath); // Initialize config store Utility.InitializeConfigStore((IConfigStoreUpdateHandler)null); Utility.InitializeTracing(); Utility.TraceSource = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.FabricDCA); HealthClient.Disabled = true; Utility.TraceSource.WriteInfo( TraceType, "Table name prefix: {0}", TableNamePrefix); // Create the table client StorageCredentials credentials = new StorageCredentials(accountName, accountKey); CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, true); tableClient = storageAccount.CreateCloudTableClient(); }
public void Refresh(bool PromptForPassword) { try { LastRefresh = DateTime.Now; ArchiveFilename MostRecent; lock (ArchiveFileList) { using (NetworkConnection newself = new NetworkConnection(CompleteBackupFolder, BackupCredentials)) ArchiveFileList.LoadAll(this); // Locate most recent backup... MostRecent = ArchiveFileList.FindMostRecent(); } if (MostRecent == ArchiveFilename.MaxValue) { MostRecentBackup = DateTime.MinValue; } else { try { Manifest Manifest; using (NetworkConnection newself = new NetworkConnection(CompleteBackupFolder, BackupCredentials)) Manifest = MostRecent.LoadArchiveManifest(this, PromptForPassword); MostRecentBackup = Manifest.BackupStartTime; } catch (Ionic.Zip.BadPasswordException bpe) { if (PromptForPassword) { throw bpe; } else { MostRecentBackup = MostRecent.BackupDate; } } } // Also check for an Backup_Status.xml file... // This file is created with each backup, and is particularly helpful when we have an 'empty backup' // where no archive need be created (because nothing has changed). We need to display to the user that // the project was backed up recently, but we needn't create an archive. The Backup_Status.xml file // accomplishes this. FileInfo[] FileList = new DirectoryInfo(CompleteBackupFolder).GetFiles("Backup_Status.xml"); if (FileList.Length > 0) { BackupStatus Status = null; try { Status = BackupStatus.Load(FileList[0].FullName); } catch (Exception exc) { MessageBox.Show("Unable to load backup status file (see error details below). This file helps ZippyBackup keep track of some things, but we can also figure it out from scratch and make a new backup status file when you perform your next backup. Click OK and ZippyBackup will proceed without it. Your next backup may take longer than usual.\n\nDetailed error information: " + exc.Message); } if (Status != null) { if (MostRecent != ArchiveFilename.MaxValue && Status.LastArchive == MostRecent.ToString() && Status.LastBackup.ToUniversalTime() > MostRecentBackup.ToUniversalTime()) { MostRecentBackup = Status.LastBackup; } MostRecentCompleteBackup = Status.LastCompletedBackup; LastScanRelativePath = Status.LastScanRelativePath; LastVerifyRelativePath = Status.LastVerifyRelativePath; MostRecentVerify = Status.LastVerify; MostRecentCompleteVerify = Status.LastCompletedVerify; } } // Clear out the manifest cache... lock (ManifestCache) ManifestCache.Clear(); LoadIssue = false; } catch (System.Security.Authentication.InvalidCredentialException) { LoadIssue = true; } catch (IOException) { LoadIssue = true; } }
public ManifestCache LoadManifests(string manifestPath, string cacheLocation, Version version) { string versionString = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; if (ManifestCache == null) { ManifestCache = new ManifestCache(cacheLocation); } ManifestLoader manifest = new ManifestLoader(); if (Directory.Exists(manifestPath) && Directory.Exists(cacheLocation)) { List <string> manifestFiles = Directory.GetFiles(manifestPath, $"*{Constants.EtwManifestExtension}").ToList(); Log.Info("manifest files:", manifestFiles); if (version != new Version()) { manifestFiles = manifestFiles.Where(x => Regex.IsMatch(x, Regex.Escape(versionString))).ToList(); } else { Log.Info("getting latest version"); string versionPattern = @"_(\d+?\.\d+?\.\d+?\.\d+?)(?:_|\.)"; Version maxVersion = new Version(); List <string> versionedManifestFiles = manifestFiles.Where(x => Regex.IsMatch(x, versionPattern)).ToList(); List <string> unVersionedManifestFiles = manifestFiles.Where(x => !Regex.IsMatch(x, versionPattern)).ToList(); foreach (string file in versionedManifestFiles) { Version fileVersion = new Version(Regex.Match(file, versionPattern).Groups[1].Value); if (fileVersion > maxVersion) { Log.Info($"setting maxVersion:{maxVersion} -> {fileVersion}"); maxVersion = fileVersion; } } versionedManifestFiles = manifestFiles.Where(x => Regex.IsMatch(x, $@"_{maxVersion.Major}\.{maxVersion.Minor}\.{maxVersion.Build}\.{maxVersion.Revision}(?:_|\.)")).ToList(); unVersionedManifestFiles.AddRange(versionedManifestFiles); manifestFiles = unVersionedManifestFiles; } Log.Info("filtered manifest files:", ConsoleColor.Cyan, null, manifestFiles); foreach (string manifestFile in manifestFiles) { ManifestDefinitionDescription description = manifest.LoadManifest(manifestFile); List <ProviderDefinitionDescription> manifestProviderList = description.Providers.ToList(); if (!ManifestCache.ProviderDefinitions.Keys.Any(x => manifestProviderList.Any(y => y.Guid == x))) { ManifestCache.LoadManifest(manifestFile); } else { Log.Warning($"manifest already loaded:{manifestFile}"); } } } else { Log.Error($"manifest path does not exist:{manifestPath} or cachelocation does not exist:{cacheLocation}"); } return(ManifestCache); }
public void SetEtwManifestCache(ManifestCache manifestCache) { this.manifestCache = manifestCache; }
public void SetEtwManifestCache(Tools.EtlReader.ManifestCache manifestCache) { this.manifestCache = manifestCache; }
private bool DecodeEvent(EventRecord eventRecord, out DecodedEtwEvent decodedEvent) { decodedEvent = new DecodedEtwEvent { EventRecord = eventRecord }; if (false == ManifestCache.IsStringEvent(eventRecord)) { var eventDefinition = this.etwManifestCache.GetEventDefinition( eventRecord); if (null == eventDefinition) { if (!EventSourceHelper.CheckForDynamicManifest(eventRecord.EventHeader.EventDescriptor)) { // We couldn't decode this event. Skip it. this.traceSource.WriteError( this.logSourceId, "Unable to decode ETW event. The event will be skipped. Event ID: {0}, Task: {1}, Level: {2}.", eventRecord.EventHeader.EventDescriptor.Id, eventRecord.EventHeader.EventDescriptor.Task, eventRecord.EventHeader.EventDescriptor.Level); } return(false); } if (eventDefinition.IsChildEvent) { // Try to format the event. This causes the ETL reader to save information // about this event. That information is later retrieved when the parent // event is processed. string childEventType; string childEventText; var childStringRepresentation = this.etwManifestCache.FormatEvent( eventRecord, out childEventType, out childEventText); // Only parent events can be decoded. Child events supply additional // information about the parent event and cannot be decoded on their // own. return(false); } decodedEvent.TaskName = eventDefinition.TaskName; } else { decodedEvent.TaskName = EventFormatter.StringEventTaskName; } decodedEvent.Timestamp = DateTime.FromFileTimeUtc(eventRecord.EventHeader.TimeStamp); decodedEvent.Level = eventRecord.EventHeader.EventDescriptor.Level; decodedEvent.ThreadId = eventRecord.EventHeader.ThreadId; decodedEvent.ProcessId = eventRecord.EventHeader.ProcessId; decodedEvent.StringRepresentation = this.etwManifestCache.FormatEvent( eventRecord, out decodedEvent.EventType, out decodedEvent.EventText); if (null == decodedEvent.StringRepresentation) { if (!EventSourceHelper.CheckForDynamicManifest(eventRecord.EventHeader.EventDescriptor)) { // We couldn't decode this event. Skip it. this.traceSource.WriteError( this.logSourceId, "Unable to decode ETW event. The event will be skipped. Event ID: {0}, Task: {1}, Level: {2}.", eventRecord.EventHeader.EventDescriptor.Id, eventRecord.EventHeader.EventDescriptor.Task, eventRecord.EventHeader.EventDescriptor.Level); return(false); } } // If this is an FMM event, update the last timestamp of FMM events if ((WinFabricEtlType.DefaultEtl == this.windowsFabricEtlType) && decodedEvent.TaskName.Equals(Utility.FmmTaskName)) { Utility.LastFmmEventTimestamp = decodedEvent.Timestamp; } return(true); }
/// <summary> /// SaveVideoChunks /// Save video chunks on disk /// </summary> public async Task <bool> SaveVideoChunks(ManifestCache cache) { bool bResult = false; string VideoIndexFile = Path.Combine(Path.Combine(root, cache.StoragePath), videoIndexFileName); string VideoContentFile = Path.Combine(Path.Combine(root, cache.StoragePath), videoContentFileName); if ((!string.IsNullOrEmpty(VideoIndexFile)) && (!string.IsNullOrEmpty(VideoContentFile))) { using (var releaser = await internalVideoDiskLock.WriterLockAsync()) { ulong VideoOffset = await GetFileSize(VideoContentFile); ulong InitialVideoOffset = VideoOffset; // delete the initial files /* * await DeleteFile(VideoIndexFile); * await DeleteFile(VideoContentFile); * cache.VideoSavedChunks = 0; */ for (int Index = (int)cache.VideoSavedChunks; Index < (int)cache.VideoDownloadedChunks; Index++) //foreach (var cc in cache.VideoChunkList) { var cc = cache.VideoChunkList[Index]; if ((cc != null) && (cc.GetLength() > 0)) { IndexCache ic = new IndexCache(cc.Time, VideoOffset, cc.GetLength()); if (ic != null) { ulong res = await Append(VideoContentFile, cc.chunkBuffer); if (res == cc.GetLength()) { VideoOffset += res; ulong result = await Append(VideoIndexFile, ic.GetByteData()); if (result == indexSize) { cache.VideoSavedChunks++; cache.VideoSavedBytes += res; // free buffer cc.chunkBuffer = null; // cache.VideoChunkList[Index].chunkBuffer = null; } } } } else { break; } } if (InitialVideoOffset < VideoOffset) { bResult = true; } if (cache.VideoSavedChunks == cache.VideoDownloadedChunks) { bResult = true; } } } return(bResult); }
public TestableAppInstanceEtwDataReader(ManifestCache manifestCache) : base((name, id, time, packageName, record, timestamp, file) => { }, (name, id, packageName, timestamp, file, inactivity) => { }, manifestCache) { }
public void SetEtwManifestCache(ManifestCache manifestCache) { // We ignore the manifest cache because we don't decode the events // ourselves. Instead, we rely on the producer to decode the events // for us. }