private static void TestOpenExistingFile(DiskIo stream, FileHeaderBlock fat) { Guid id = Guid.NewGuid(); TransactionalEdit trans = new TransactionalEdit(stream); //create 3 files SubFileStream fs1 = trans.OpenFile(0); SubFileStream fs2 = trans.OpenFile(1); SubFileStream fs3 = trans.OpenFile(2); //read from them and verify content. SubFileStreamTest.TestSingleByteRead(fs1); SubFileStreamTest.TestCustomSizeRead(fs2, 5); SubFileStreamTest.TestCustomSizeRead(fs3, BlockDataLength + 20); //rewrite bad data. SubFileStreamTest.TestSingleByteWrite(fs2); SubFileStreamTest.TestCustomSizeWrite(fs3, 5); SubFileStreamTest.TestCustomSizeWrite(fs1, BlockDataLength + 20); fs1.Dispose(); fs2.Dispose(); fs3.Dispose(); trans.CommitAndDispose(); }
public void sample_io_doesnt_crash() { var io = DiskIo.ParseOnUnix(ioStr, Log.Logger); var success = io != null; Assert.That(success, Is.True); }
private static void TestVerifyRollback(DiskIo stream, FileHeaderBlock fat) { Guid id = Guid.NewGuid(); TransactionalEdit trans = new TransactionalEdit(stream); if (trans.Files.Count != 3) { throw new Exception(); } //open files SubFileStream fs1 = trans.OpenFile(0); SubFileStream fs2 = trans.OpenFile(1); SubFileStream fs3 = trans.OpenFile(2); //read from them and verify content. SubFileStreamTest.TestSingleByteRead(fs2); SubFileStreamTest.TestCustomSizeRead(fs3, 5); SubFileStreamTest.TestCustomSizeRead(fs1, BlockDataLength + 20); fs1.Dispose(); fs2.Dispose(); fs3.Dispose(); trans.Dispose(); }
public void sample_io_doesnt_crash() { var io = DiskIo.ParseOnLinux(ioStr, new FakeLogger()); var success = io != null; Assert.That(success, Is.True); }
public void Test() { Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); string fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".tmp"); try { using (DiskIo stream = DiskIo.CreateFile(fileName, Globals.MemoryPool, BlockSize)) { FileHeaderBlock fat = stream.LastCommittedHeader; //obtain a readonly copy of the file allocation table. fat = stream.LastCommittedHeader; TestCreateNewFile(stream, fat); fat = stream.LastCommittedHeader; TestOpenExistingFile(stream, fat); fat = stream.LastCommittedHeader; TestRollback(stream, fat); fat = stream.LastCommittedHeader; TestVerifyRollback(stream, fat); Assert.IsTrue(true); } } finally { File.Delete(fileName); } Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); }
public void Test() { Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); string fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".tmp"); try { using (DiskIo stream = DiskIo.CreateFile(fileName, Globals.MemoryPool, BlockSize)) { TestReadAndWrites(stream); TestReadAndWritesWithCommit(stream); TestReadAndWritesToDifferentFilesWithCommit(stream); TestBinaryStream(stream); } } finally { File.Delete(fileName); } Assert.IsTrue(true); Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); }
private static void TestCreateNewFile(DiskIo stream, FileHeaderBlock fat) { SubFileName id1 = SubFileName.CreateRandom(); SubFileName id2 = SubFileName.CreateRandom(); SubFileName id3 = SubFileName.CreateRandom(); TransactionalEdit trans = new TransactionalEdit(stream); //create 3 files SubFileStream fs1 = trans.CreateFile(id1); SubFileStream fs2 = trans.CreateFile(id2); SubFileStream fs3 = trans.CreateFile(id3); if (fs1.SubFile.FileName != id1) { throw new Exception(); } //write to the three files SubFileStreamTest.TestSingleByteWrite(fs1); SubFileStreamTest.TestCustomSizeWrite(fs2, 5); SubFileStreamTest.TestCustomSizeWrite(fs3, BlockDataLength + 20); //read from them and verify content. SubFileStreamTest.TestCustomSizeRead(fs3, BlockDataLength + 20); SubFileStreamTest.TestCustomSizeRead(fs2, 5); SubFileStreamTest.TestSingleByteRead(fs1); fs1.Dispose(); fs2.Dispose(); fs3.Dispose(); trans.CommitAndDispose(); }
/// <summary> /// Releases all the resources used by the <see cref="TransactionalFileStructure"/> object. /// </summary> public void Dispose() { if (!m_disposed) { try { if (m_currentTransaction != null) { m_currentTransaction.Dispose(); m_currentTransaction = null; } if (m_diskIo != null) { m_diskIo.Dispose(); m_diskIo = null; } } finally { GC.SuppressFinalize(this); m_disposed = true; // Prevent duplicate dispose. } } }
/// <summary> /// Creates a readonly copy of a transaction. /// </summary> /// <param name="dataReader"></param> internal ReadSnapshot(DiskIo dataReader) { if (dataReader is null) { throw new ArgumentNullException("dataReader"); } m_fileHeaderBlock = dataReader.LastCommittedHeader; m_dataReader = dataReader; }
public void bad_io_crashes() { var badIoStr = ioStr.Remove(5, 20); DiskIo io = DiskIo.ParseOnUnix(badIoStr, Log.Logger); var success = io != null; Assert.That(success, Is.False); }
public void bad_io_crashes() { var badIoStr = ioStr.Remove(5, 20); DiskIo io = DiskIo.ParseOnLinux(badIoStr, new FakeLogger()); var success = io != null; Assert.That(success, Is.False); }
/// <summary> /// Creates this file with the following data. /// </summary> /// <param name="diskIo"></param> /// <param name="header"></param> /// <param name="file"></param> /// <param name="isReadOnly"></param> public SubFileDiskIoSessionPool(DiskIo diskIo, FileHeaderBlock header, SubFileHeader file, bool isReadOnly) { LastReadonlyBlock = diskIo.LastCommittedHeader.LastAllocatedBlock; File = file; Header = header; IsReadOnly = isReadOnly; SourceData = diskIo.CreateDiskIoSession(header, file); SourceIndex = diskIo.CreateDiskIoSession(header, file); if (!isReadOnly) { DestinationData = diskIo.CreateDiskIoSession(header, file); DestinationIndex = diskIo.CreateDiskIoSession(header, file); } }
/// <summary> /// Creates an editable copy of the transaction /// </summary> /// <param name="dataReader"> </param> /// <param name="delHasBeenRolledBack">the delegate to call when this transaction has been rolled back</param> /// <param name="delHasBeenCommitted">the delegate to call when this transaction has been committed</param> internal TransactionalEdit(DiskIo dataReader, Action delHasBeenRolledBack = null, Action delHasBeenCommitted = null) { if (dataReader == null) { throw new ArgumentNullException("dataReader"); } m_openedFiles = new List <SubFileStream>(); m_disposed = false; m_fileHeaderBlock = dataReader.LastCommittedHeader.CloneEditable(); m_dataReader = dataReader; m_delHasBeenCommitted = delHasBeenCommitted; m_delHasBeenRolledBack = delHasBeenRolledBack; }
private static void TestBinaryStream(DiskIo stream) { FileHeaderBlock header = stream.LastCommittedHeader; header = header.CloneEditable(); SubFileHeader node = header.CreateNewFile(SubFileName.CreateRandom()); header.CreateNewFile(SubFileName.CreateRandom()); header.CreateNewFile(SubFileName.CreateRandom()); SubFileStream ds = new SubFileStream(stream, node, header, false); BinaryStreamTest.Test(ds); }
/// <summary> /// Creates a new archive file using the provided file. File is editable. /// </summary> public static TransactionalFileStructure CreateFile(string fileName, int blockSize, params Guid[] flags) { if (fileName is null) { throw new ArgumentNullException("fileName"); } if (File.Exists(fileName)) { throw new Exception("fileName Already Exists"); } DiskIo disk = DiskIo.CreateFile(fileName, Globals.MemoryPool, blockSize, flags); return(new TransactionalFileStructure(disk)); }
public void Test() { Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); DiskIo stream = DiskIo.CreateMemoryFile(Globals.MemoryPool, BlockSize); TestReadAndWrites(stream); TestReadAndWritesWithCommit(stream); TestReadAndWritesToDifferentFilesWithCommit(stream); TestBinaryStream(stream); stream.Dispose(); Assert.IsTrue(true); Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); }
/// <summary> /// Creates an SubFileStream /// </summary> /// <param name="dataReader">The location to read from.</param> /// <param name="subFile">The file to read.</param> /// <param name="fileHeaderBlock">The FileAllocationTable</param> /// <param name="isReadOnly">Determines if the stream allows editing.</param> internal SubFileStream(DiskIo dataReader, SubFileHeader subFile, FileHeaderBlock fileHeaderBlock, bool isReadOnly) { if (dataReader == null) { throw new ArgumentNullException("dataReader"); } if (subFile == null) { throw new ArgumentNullException("subFile"); } if (fileHeaderBlock == null) { throw new ArgumentNullException("subFile"); } if (!isReadOnly) { if (dataReader.IsReadOnly) { throw new ArgumentException("This parameter cannot be read only when opening for writing", "dataReader"); } if (fileHeaderBlock.IsReadOnly) { throw new ArgumentException("This parameter cannot be read only when opening for writing", "fileHeaderBlock"); } if (subFile.IsReadOnly) { throw new ArgumentException("This parameter cannot be read only when opening for writing", "subFile"); } } if (isReadOnly) { if (!fileHeaderBlock.IsReadOnly) { throw new ArgumentException("This parameter must be read only when opening for reading", "fileHeaderBlock"); } if (!subFile.IsReadOnly) { throw new ArgumentException("This parameter must be read only when opening for reading", "subFile"); } } m_blockSize = dataReader.BlockSize; m_dataReader = dataReader; m_subFile = subFile; m_fileHeaderBlock = fileHeaderBlock; m_isReadOnly = isReadOnly; }
private static void TestReadAndWritesWithCommit(DiskIo stream) { FileHeaderBlock header; SubFileHeader node; SubFileStream ds, ds1, ds2; //Open The File For Editing header = stream.LastCommittedHeader.CloneEditable(); node = header.Files[0]; ds = new SubFileStream(stream, node, header, false); TestSingleByteWrite(ds); stream.CommitChanges(header); header = stream.LastCommittedHeader; node = header.Files[0]; ds1 = ds = new SubFileStream(stream, node, header, true); TestSingleByteRead(ds); //Open The File For Editing header = stream.LastCommittedHeader.CloneEditable(); node = header.Files[0]; ds = new SubFileStream(stream, node, header, false); TestCustomSizeWrite(ds, 5); stream.CommitChanges(header); header = stream.LastCommittedHeader; node = header.Files[0]; ds2 = ds = new SubFileStream(stream, node, header, true); TestCustomSizeRead(ds, 5); //Open The File For Editing header = stream.LastCommittedHeader.CloneEditable(); node = header.Files[0]; ds = new SubFileStream(stream, node, header, false); TestCustomSizeWrite(ds, BlockDataLength + 20); stream.CommitChanges(header); header = stream.LastCommittedHeader; node = header.Files[0]; ds = new SubFileStream(stream, node, header, true); TestCustomSizeRead(ds, BlockDataLength + 20); //check old versions of the file TestSingleByteRead(ds1); TestCustomSizeRead(ds2, 5); }
public void Test() { int blockSize = 4096; Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); DiskIo stream = DiskIo.CreateMemoryFile(Globals.MemoryPool, blockSize); SubFileName name = SubFileName.CreateRandom(); SubFileHeader node = new SubFileHeader(1, name, false, false); SubFileDiskIoSessionPool pool = new SubFileDiskIoSessionPool(stream, stream.LastCommittedHeader, node, true); IndexParser parse = new IndexParser(pool); parse.SetPositionAndLookup(14312); pool.Dispose(); Assert.IsTrue(true); Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); }
public void Test() { Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); DiskIo stream = DiskIo.CreateMemoryFile(Globals.MemoryPool, BlockSize); FileHeaderBlock fat = stream.LastCommittedHeader; //obtain a readonly copy of the file allocation table. fat = stream.LastCommittedHeader; TestCreateNewFile(stream, fat); fat = stream.LastCommittedHeader; TestOpenExistingFile(stream, fat); fat = stream.LastCommittedHeader; TestRollback(stream, fat); fat = stream.LastCommittedHeader; TestVerifyRollback(stream, fat); Assert.IsTrue(true); stream.Dispose(); Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); }
/// <summary> /// Opens an existing file. /// </summary> public static TransactionalFileStructure OpenFile(string fileName, bool isReadOnly) { if (fileName is null) { throw new ArgumentNullException("fileName"); } if (!File.Exists(fileName)) { throw new Exception("fileName Does Not Exists"); } DiskIo disk = DiskIo.OpenFile(fileName, Globals.MemoryPool, isReadOnly); if (!isReadOnly && disk.LastCommittedHeader.IsSimplifiedFileFormat) { disk.Dispose(); throw new Exception("Cannot open a simplified file structure with write support."); } return(new TransactionalFileStructure(disk)); }
private static void TestReadAndWrites(DiskIo stream) { FileHeaderBlock header = stream.LastCommittedHeader; header = header.CloneEditable(); SubFileHeader node = header.CreateNewFile(SubFileName.CreateRandom()); header.CreateNewFile(SubFileName.CreateRandom()); header.CreateNewFile(SubFileName.CreateRandom()); SubFileStream ds = new SubFileStream(stream, node, header, false); TestSingleByteWrite(ds); TestSingleByteRead(ds); TestCustomSizeWrite(ds, 5); TestCustomSizeRead(ds, 5); TestCustomSizeWrite(ds, BlockDataLength + 20); TestCustomSizeRead(ds, BlockDataLength + 20); stream.CommitChanges(header); }
private static void TestRollback(DiskIo stream, FileHeaderBlock fat) { SubFileName id1 = SubFileName.CreateRandom(); SubFileName id2 = SubFileName.CreateRandom(); SubFileName id3 = SubFileName.CreateRandom(); TransactionalEdit trans = new TransactionalEdit(stream); //create 3 files additional files SubFileStream fs21 = trans.CreateFile(id1); SubFileStream fs22 = trans.CreateFile(id2); SubFileStream fs23 = trans.CreateFile(id3); //open files SubFileStream fs1 = trans.OpenFile(0); SubFileStream fs2 = trans.OpenFile(1); SubFileStream fs3 = trans.OpenFile(2); //read from them and verify content. SubFileStreamTest.TestSingleByteRead(fs2); SubFileStreamTest.TestCustomSizeRead(fs3, 5); SubFileStreamTest.TestCustomSizeRead(fs1, BlockDataLength + 20); //rewrite bad data. SubFileStreamTest.TestSingleByteWrite(fs3); SubFileStreamTest.TestCustomSizeWrite(fs1, 5); SubFileStreamTest.TestCustomSizeWrite(fs2, BlockDataLength + 20); fs1.Dispose(); fs2.Dispose(); fs3.Dispose(); fs21.Dispose(); fs22.Dispose(); fs23.Dispose(); trans.RollbackAndDispose(); }
private static void TestReadAndWritesToDifferentFilesWithCommit(DiskIo stream) { FileHeaderBlock header; SubFileStream ds; //Open The File For Editing header = stream.LastCommittedHeader.CloneEditable(); ds = new SubFileStream(stream, header.Files[0], header, false); TestSingleByteWrite(ds); ds = new SubFileStream(stream, header.Files[1], header, false); TestCustomSizeWrite(ds, 5); ds = new SubFileStream(stream, header.Files[2], header, false); TestCustomSizeWrite(ds, BlockDataLength + 20); stream.CommitChanges(header); header = stream.LastCommittedHeader; ds = new SubFileStream(stream, header.Files[0], header, true); TestSingleByteRead(ds); ds = new SubFileStream(stream, header.Files[1], header, true); TestCustomSizeRead(ds, 5); ds = new SubFileStream(stream, header.Files[2], header, true); TestCustomSizeRead(ds, BlockDataLength + 20); }
public IDictionary <string, object> GetSystemStats() { var stats = new Dictionary <string, object>(); GetPerfCounterInformation(stats, 0); var process = Process.GetCurrentProcess(); var diskIo = DiskIo.GetDiskIo(process.Id, _log); if (diskIo != null) { stats["proc-diskIo-readBytes"] = diskIo.ReadBytes; stats["proc-diskIo-writtenBytes"] = diskIo.WrittenBytes; stats["proc-diskIo-readOps"] = diskIo.ReadOps; stats["proc-diskIo-writeOps"] = diskIo.WriteOps; } var tcp = TcpConnectionMonitor.Default.GetTcpStats(); stats["proc-tcp-connections"] = tcp.Connections; stats["proc-tcp-receivingSpeed"] = tcp.ReceivingSpeed; stats["proc-tcp-sendingSpeed"] = tcp.SendingSpeed; stats["proc-tcp-inSend"] = tcp.InSend; stats["proc-tcp-measureTime"] = tcp.MeasureTime; stats["proc-tcp-pendingReceived"] = tcp.PendingReceived; stats["proc-tcp-pendingSend"] = tcp.PendingSend; stats["proc-tcp-receivedBytesSinceLastRun"] = tcp.ReceivedBytesSinceLastRun; stats["proc-tcp-receivedBytesTotal"] = tcp.ReceivedBytesTotal; stats["proc-tcp-sentBytesSinceLastRun"] = tcp.SentBytesSinceLastRun; stats["proc-tcp-sentBytesTotal"] = tcp.SentBytesTotal; stats["es-checksum"] = _writerCheckpoint.Read(); stats["es-checksumNonFlushed"] = _writerCheckpoint.ReadNonFlushed(); var drive = EsDriveInfo.FromDirectory(_dbPath, _log); if (drive != null) { Func <string, string, string> driveStat = (diskName, stat) => string.Format("sys-drive-{0}-{1}", diskName.Replace("\\", "").Replace(":", ""), stat); stats[driveStat(drive.DiskName, "availableBytes")] = drive.AvailableBytes; stats[driveStat(drive.DiskName, "totalBytes")] = drive.TotalBytes; stats[driveStat(drive.DiskName, "usage")] = drive.Usage; stats[driveStat(drive.DiskName, "usedBytes")] = drive.UsedBytes; } Func <string, string, string> queueStat = (queueName, stat) => string.Format("es-queue-{0}-{1}", queueName, stat); var queues = QueueMonitor.Default.GetStats(); foreach (var queue in queues) { stats[queueStat(queue.Name, "queueName")] = queue.Name; stats[queueStat(queue.Name, "groupName")] = queue.GroupName ?? string.Empty; stats[queueStat(queue.Name, "avgItemsPerSecond")] = queue.AvgItemsPerSecond; stats[queueStat(queue.Name, "avgProcessingTime")] = queue.AvgProcessingTime; stats[queueStat(queue.Name, "currentIdleTime")] = queue.CurrentIdleTime.HasValue ? queue.CurrentIdleTime.Value.ToString("G", CultureInfo.InvariantCulture) : null; stats[queueStat(queue.Name, "currentItemProcessingTime")] = queue.CurrentItemProcessingTime.HasValue ? queue.CurrentItemProcessingTime.Value.ToString("G", CultureInfo.InvariantCulture) : null; stats[queueStat(queue.Name, "idleTimePercent")] = queue.IdleTimePercent; stats[queueStat(queue.Name, "length")] = queue.Length; stats[queueStat(queue.Name, "lengthCurrentTryPeak")] = queue.LengthCurrentTryPeak; stats[queueStat(queue.Name, "lengthLifetimePeak")] = queue.LengthLifetimePeak; stats[queueStat(queue.Name, "totalItemsProcessed")] = queue.TotalItemsProcessed; stats[queueStat(queue.Name, "inProgressMessage")] = queue.InProgressMessageType != null ? queue.InProgressMessageType.Name : "<none>"; stats[queueStat(queue.Name, "lastProcessedMessage")] = queue.LastProcessedMessageType != null ? queue.LastProcessedMessageType.Name : "<none>"; } return(stats); }
public IDictionary <string, object> GetSystemStats() { var stats = new Dictionary <string, object>(); var process = Process.GetCurrentProcess(); var drives = DrivesInfo.GetSystemDrives(); var diskIo = DiskIo.GetDiskIo(process.Id, _log); var tcp = TcpConnectionMonitor.Default.GetTcpStats(); var queues = QueueMonitor.Default.GetStats(); var checksum = _writerCheckpoint.Read(); var checksumNonFlushed = _writerCheckpoint.ReadNonFlushed(); var workingSetMemory = process.WorkingSet64; var startTime = process.StartTime.ToUniversalTime().ToString("O"); var procId = process.Id; var totalCpu = _perfCounter.GetTotalCpuUsage(); var procCpu = _perfCounter.GetProcCpuUsage(); var threadsCount = _perfCounter.GetProcThreadsCount(); var freeMem = OS.IsLinux ? GetFreeMemOnLinux() : _perfCounter.GetFreeMemory(); var gcStats = _perfCounter.GetGcStats(); stats["proc-diskIo-readBytes"] = diskIo.ReadBytes; stats["proc-diskIo-readOps"] = diskIo.ReadOps; stats["proc-diskIo-writeOps"] = diskIo.WriteOps; stats["proc-diskIo-writtenBytes"] = diskIo.WrittenBytes; stats["proc-diskIo-readBytesFriendly"] = diskIo.ReadBytesFriendly; stats["proc-diskIo-readOpsFriendly"] = diskIo.ReadOpsFriendly; stats["proc-diskIo-writeOpsFriendly"] = diskIo.WriteOpsFriendly; stats["proc-diskIo-writtenBytesFriendly"] = diskIo.WrittenBytesFriendly; stats["proc-tcp-connections"] = tcp.Connections; stats["proc-tcp-inSend"] = tcp.InSend; stats["proc-tcp-measureTime"] = tcp.MeasureTime; stats["proc-tcp-pendingReceived"] = tcp.PendingReceived; stats["proc-tcp-pendingSend"] = tcp.PendingSend; stats["proc-tcp-receivedBytesSinceLastRun"] = tcp.ReceivedBytesSinceLastRun; stats["proc-tcp-receivedBytesTotal"] = tcp.ReceivedBytesTotal; stats["proc-tcp-receivingSpeed"] = tcp.ReceivingSpeed; stats["proc-tcp-sendingSpeed"] = tcp.SendingSpeed; stats["proc-tcp-sentBytesSinceLastRun"] = tcp.SentBytesSinceLastRun; stats["proc-tcp-sentBytesTotal"] = tcp.SentBytesTotal; stats["proc-tcp-measureTimeFriendly"] = tcp.MeasureTimeFriendly; stats["proc-tcp-receivedBytesTotalFriendly"] = tcp.ReceivedBytesTotalFriendly; stats["proc-tcp-receivingSpeedFriendly"] = tcp.ReceivingSpeedFriendly; stats["proc-tcp-sendingSpeedFriendly"] = tcp.SendingSpeedFriendly; stats["proc-tcp-sentBytesTotalFriendly"] = tcp.SentBytesTotalFriendly; stats["proc-gc-allocationSpeed"] = gcStats.AllocationSpeed; stats["proc-gc-gen0ItemsCount"] = gcStats.Gen0ItemsCount; stats["proc-gc-gen0Size"] = gcStats.Gen0Size; stats["proc-gc-gen1ItemsCount"] = gcStats.Gen1ItemsCount; stats["proc-gc-gen1Size"] = gcStats.Gen1Size; stats["proc-gc-gen2ItemsCount"] = gcStats.Gen2ItemsCount; stats["proc-gc-gen2Size"] = gcStats.Gen2Size; stats["proc-gc-largeHeapSize"] = gcStats.LargeHeapSize; stats["proc-gc-timeInGc"] = gcStats.TimeInGc; stats["proc-gc-totalBytesInHeaps"] = gcStats.TotalBytesInHeaps; stats["proc-mem"] = workingSetMemory; stats["proc-threadsCount"] = threadsCount; stats["proc-cpu"] = procCpu; stats["proc-startTime"] = startTime; stats["proc-id"] = procId; stats["sys-freeMem"] = freeMem; stats["sys-cpu"] = totalCpu; stats["es-checksum"] = checksum; stats["es-checksumNonFlushed"] = checksumNonFlushed; Func <string, string, string> driveStat = (diskName, stat) => string.Format("sys-drive-{0}-{1}", diskName, stat); foreach (var driveInfo in drives.Drives) { stats[driveStat(driveInfo.DiskName, "availableBytes")] = driveInfo.AvailableBytes; stats[driveStat(driveInfo.DiskName, "totalBytes")] = driveInfo.TotalBytes; stats[driveStat(driveInfo.DiskName, "usage")] = driveInfo.Usage; stats[driveStat(driveInfo.DiskName, "usedBytes")] = driveInfo.UsedBytes; stats[driveStat(driveInfo.DiskName, "availableBytesFriendly")] = driveInfo.AvailableBytesFriendly; stats[driveStat(driveInfo.DiskName, "totalBytesFriendly")] = driveInfo.TotalBytesFriendly; stats[driveStat(driveInfo.DiskName, "usedBytesFriendly")] = driveInfo.UsedBytesFriendly; } Func <string, string, string> queueStat = (queueName, stat) => string.Format("es-queue-{0}-{1}", queueName, stat); foreach (var queue in queues) { stats[queueStat(queue.Name, "queueName")] = queue.Name; stats[queueStat(queue.Name, "avgItemsPerSecond")] = queue.AvgItemsPerSecond; stats[queueStat(queue.Name, "avgProcessingTime")] = queue.AvgProcessingTime; stats[queueStat(queue.Name, "currentIdleTime")] = queue.CurrentIdleTime.HasValue ? queue.CurrentIdleTime.Value.ToString("G") : null; stats[queueStat(queue.Name, "currentItemProcessingTime")] = queue.CurrentItemProcessingTime.HasValue ? queue.CurrentItemProcessingTime.Value.ToString("G") : null; stats[queueStat(queue.Name, "idleTimePercent")] = queue.IdleTimePercent; stats[queueStat(queue.Name, "length")] = queue.Length; stats[queueStat(queue.Name, "lengthCurrentTryPeak")] = queue.LengthCurrentTryPeak; stats[queueStat(queue.Name, "lengthLifetimePeak")] = queue.LengthLifetimePeak; stats[queueStat(queue.Name, "totalItemsProcessed")] = queue.TotalItemsProcessed; stats[queueStat(queue.Name, "lengthLifetimePeakFriendly")] = queue.LengthLifetimePeakFriendly; } return(stats); }
private TransactionalFileStructure(DiskIo diskIo) { m_diskIo = diskIo; m_currentReadTransaction = new ReadSnapshot(diskIo); }
public void write_bytes_parses_ok() { var io = DiskIo.ParseOnLinux(ioStr, new FakeLogger()); Assert.That(io.WrittenBytes, Is.EqualTo(188416)); }
public void read_bytes_parses_ok() { var io = DiskIo.ParseOnLinux(ioStr, new FakeLogger()); Assert.That(io.ReadBytes, Is.EqualTo(13824000)); }
/// <summary> /// Creates a new archive file that is completely in memory /// </summary> public static TransactionalFileStructure CreateInMemory(int blockSize, params Guid[] flags) { DiskIo disk = DiskIo.CreateMemoryFile(Globals.MemoryPool, blockSize, flags); return(new TransactionalFileStructure(disk)); }