public void Test2() { Logger.Console.Verbose = VerboseLevel.All; var netStream = new NetworkStreamSimulator(); var dbcfg = new HistorianServerDatabaseConfig("DB", @"C:\Archive", true); var server = new HistorianServer(dbcfg); var auth = new SecureStreamServer <SocketUserPermissions>(); auth.SetDefaultUser(true, new SocketUserPermissions() { CanRead = true, CanWrite = true, IsAdmin = true }); var netServer = new SnapStreamingServer(auth, netStream.ServerStream, server.Host); ThreadPool.QueueUserWorkItem(ProcessClient, netServer); var client = new SnapStreamingClient(netStream.ClientStream, new SecureStreamClientDefault(), true); var db = client.GetDatabase <HistorianKey, HistorianValue>("DB"); long len = db.Read().Count(); System.Console.WriteLine(len); client.Dispose(); server.Dispose(); }
public void CreateScadaDatabase() { Array.ForEach(Directory.GetFiles(@"c:\temp\Scada\", "*.d2", SearchOption.AllDirectories), File.Delete); HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("DB", @"c:\temp\Scada\", true); using (HistorianServer server = new HistorianServer(settings, 12345)) { using (HistorianClient client = new HistorianClient("127.0.0.1", 12345)) using (ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>("DB")) { for (ulong x = 0; x < 1000; x++) { key.Timestamp = x; database.Write(key, value); } database.HardCommit(); System.Threading.Thread.Sleep(1200); } } }
public void TestReadPoints() { Stopwatch sw = new Stopwatch(); int pointCount = 0; HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("PPA", @"C:\Program Files\openHistorian\Archive\", true); using (HistorianServer server = new HistorianServer(settings)) { using (HistorianClient client = new HistorianClient("127.0.0.1", 12345)) using (ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>(String.Empty)) { TreeStream <HistorianKey, HistorianValue> stream = database.Read(0, (ulong)DateTime.MaxValue.Ticks, new ulong[] { 1 }); while (stream.Read(key, value)) { ; } sw.Start(); stream = database.Read(0, (ulong)DateTime.MaxValue.Ticks, new ulong[] { 65, 953, 5562 }); while (stream.Read(key, value)) { pointCount++; } sw.Stop(); } } Console.WriteLine(pointCount); Console.WriteLine(sw.Elapsed.TotalSeconds.ToString()); }
public HistorianHost() { Directory.GetFiles(@"G:\HistorianData\", "*.d2").ToList().ForEach(File.Delete); HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("DB", @"G:\HistorianData\", true); m_server = new HistorianServer(settings); }
public void Test1() { Logger.Console.Verbose = VerboseLevel.All; NetworkStreamSimulator netStream = new NetworkStreamSimulator(); HistorianServerDatabaseConfig dbcfg = new HistorianServerDatabaseConfig("DB", @"C:\Archive", true); HistorianServer server = new HistorianServer(dbcfg); SecureStreamServer <SocketUserPermissions> auth = new SecureStreamServer <SocketUserPermissions>(); auth.SetDefaultUser(true, new SocketUserPermissions() { CanRead = true, CanWrite = true, IsAdmin = true }); SnapStreamingServer netServer = new SnapStreamingServer(auth, netStream.ServerStream, server.Host); ThreadPool.QueueUserWorkItem(ProcessClient, netServer); SnapStreamingClient client = new SnapStreamingClient(netStream.ClientStream, new SecureStreamClientDefault(), true); ClientDatabaseBase db = client.GetDatabase("DB"); client.Dispose(); server.Dispose(); }
public SnapServer CreateServer() { var settings = new HistorianServerDatabaseConfig("PPA", @"C:\Temp\Synchrophasor", true); var server = new SnapServer(settings); return(server); }
public void SendAllPoints() { Stats.Clear(); long points; StopReading = false; var settings = new HistorianServerDatabaseConfig("PPA", @"C:\Program Files\openHistorian\Archive\", true); using (HistorianServer server = new HistorianServer(settings)) { Thread.Sleep(1000); for (int x = 1; x < 30; x++) { StartReader(); Thread.Sleep(1000); if (x == 1) { Thread.Sleep(5000); } Interlocked.Exchange(ref Stats.PointsReturned, 0); Thread.Sleep(1000); long v = Interlocked.Read(ref Stats.PointsReturned); Console.WriteLine("Clients: " + x.ToString() + " points " + v.ToString()); } StopReading = true; Thread.Sleep(2000); } Thread.Sleep(2000); }
public void TestWriteSpeed() { //Logger.ReportToConsole(VerboseLevel.All ^ VerboseLevel.DebugLow); //Logger.SetLoggingPath("c:\\temp\\"); Globals.MemoryPool.SetMaximumBufferSize(4000 * 1024 * 1024L); //Thread th = new Thread(WriteSpeed); //th.IsBackground = true; //th.Start(); //Quit = false; foreach (string file in Directory.GetFiles("c:\\temp\\benchmark\\", "*.*", SearchOption.AllDirectories)) { File.Delete(file); } //PointCount = 0; HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("DB", "c:\\temp\\benchmark\\", true); using (SnapServer engine = new SnapServer(settings)) using (SnapClient client = SnapClient.Connect(engine)) using (ClientDatabaseBase <HistorianKey, HistorianValue> db = client.GetDatabase <HistorianKey, HistorianValue>("DB")) { Thread.Sleep(100); HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < PointsToArchive; x++) { key.PointID = (ulong)x; //PointCount = x; db.Write(key, value); } double totalTime = sw.Elapsed.TotalSeconds; Console.WriteLine("Completed write test in {0:#,##0.00} seconds at {1:#,##0.00} points per second", totalTime, PointsToArchive / totalTime); } //Quit = true; //th.Join(); //Console.WriteLine("Time (sec)\tPoints"); //foreach (var kvp in PointSamples) //{ // Console.WriteLine(kvp.Key.ToString() + "\t" + kvp.Value.ToString()); //} GC.Collect(); GC.WaitForPendingFinalizers(); Thread.Sleep(100); }
private void BtnStart_Click(object sender, EventArgs e) { GSF.Globals.MemoryPool.SetMaximumBufferSize(long.Parse(TxtMaxMB.Text) * 1024 * 1024); HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig(txtDbName.Text, TxtArchivePath.Text, true); m_server = new HistorianServer(settings, int.Parse(TxtLocalPort.Text)); BtnStart.Enabled = false; AllocConsole(); Logger.Console.Verbose = VerboseLevel.High; }
public void Start(string[] paths) { m_database = "PPA"; HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig(m_database, null, false); settings.ImportPaths.AddRange(paths); m_localServer = new HistorianServer(settings); HistorianQuery query = new HistorianQuery(SnapClient.Connect(m_localServer.Host)); m_updateFramework.Start(query); m_updateFramework.Mode = ExecutionMode.Manual; m_updateFramework.Enabled = true; }
private void btnOpenFile_Click(object sender, EventArgs e) { using (OpenFileDialog dlgOpen = new OpenFileDialog()) { dlgOpen.Filter = "openHistorian 2.0 file|*.d2"; if (dlgOpen.ShowDialog() == DialogResult.OK) { HistorianServerDatabaseConfig db = new HistorianServerDatabaseConfig("", "", false); db.ImportPaths.AddRange(dlgOpen.FileNames); m_archiveFile = new HistorianServer(db); } } BuildListOfAllPoints(); }
public DataWriter(Settings settings, int pointCount) { m_settings = settings; if (m_settings.WriteToOpenHistorian) // Initialize OH instance { string historianName = "DestinationHistorian"; HistorianServerDatabaseConfig archiveInfo = new HistorianServerDatabaseConfig(historianName, settings.HistorianArchive, true) { TargetFileSize = (long)(1 * SI.Giga), // Just because DirectoryMethod = ArchiveDirectoryMethod.TopDirectoryOnly, StagingCount = 3, DiskFlushInterval = 1000, // Smallest available time interval CacheFlushInterval = 1000 // Largest available value }; m_historianServer = new HistorianServer(archiveInfo, m_settings.DestinationHistorianDataPort); m_historianArchive = m_historianServer[historianName]; m_historianKey = new HistorianKey(); m_historianValue = new HistorianValue(); } else if (m_settings.WriteToBerkeleyDB) // Initialize BDB instance { m_berkeleyDbCfg = new BTreeDatabaseConfig() { BTreeCompare = BerkeleyDBKeyComparison, CacheSize = new CacheInfo(10, 0, 1), PageSize = 65536, NoMMap = true, Creation = CreatePolicy.IF_NEEDED }; string databasePath = null; if (!m_settings.InMemoryBerkeleyDB) { databasePath = Path.Combine(settings.HistorianArchive, settings.HistorianName); } m_berkeleyDb = BTreeDatabase.Open(databasePath, m_berkeleyDbCfg); m_berkeleyDbKey = new DatabaseEntry(); m_berkeleyDbValue = new DatabaseEntry(); m_berkeleyDbPointList = new KeyValuePair <DatabaseEntry, DatabaseEntry> [pointCount]; Parallel.For(0, m_berkeleyDbPointList.Length, (i) => m_berkeleyDbPointList[i] = new KeyValuePair <DatabaseEntry, DatabaseEntry>( new DatabaseEntry(), new DatabaseEntry())); } }
public void TestReadData() { HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); var settings = new HistorianServerDatabaseConfig("PPA", @"c:\temp\Scada\", true); using (HistorianServer server = new HistorianServer(settings)) { double count = 0; DebugStopwatch sw = new DebugStopwatch(); double time = sw.TimeEvent(() => { count = 0; using (HistorianClient client = new HistorianClient("127.0.0.1", 12345)) using (ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>(String.Empty)) { //IHistorianDatabase<HistorianKey, HistorianValue> database = server.GetDefaultDatabase();//.GetDatabase(); //TreeStream<HistorianKey, HistorianValue> stream = reader.Read(0, ulong.MaxValue, new ulong[] { 2 }); TreeStream <HistorianKey, HistorianValue> stream = database.Read(0, ulong.MaxValue); while (stream.Read(key, value)) { count++; } } }); Console.WriteLine((count / 1000000 / time).ToString() + " Million PPS"); } //Console.WriteLine("KeyMethodsBase calls"); //for (int x = 0; x < 23; x++) //{ // Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString()); //} //Console.WriteLine("ValueMethodsBase calls"); //for (int x = 0; x < 5; x++) //{ // Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString()); //} //for (int x = 0; x < 15; x++) //{ // Console.WriteLine(BinaryStreamBase.CallMethods[x] + "\t" + ((BinaryStreamBase.Method)(x)).ToString()); //} }
public void TestWriteSpeedRandom() { Logger.Console.Verbose = VerboseLevel.All; Random r = new Random(1); Thread th = new Thread(WriteSpeed); th.IsBackground = true; th.Start(); Quit = false; foreach (string file in Directory.GetFiles("c:\\temp\\benchmark\\")) { File.Delete(file); } PointCount = 0; HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("DB", "c:\\temp\\benchmark\\", true); using (SnapServer engine = new SnapServer(settings)) using (SnapClient client = SnapClient.Connect(engine)) using (ClientDatabaseBase <HistorianKey, HistorianValue> db = client.GetDatabase <HistorianKey, HistorianValue>("DB")) { Thread.Sleep(100); HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); for (int x = 0; x < 10000000; x++) { key.Timestamp = (ulong)r.Next(); key.PointID = (ulong)x; PointCount = x; db.Write(key, value); } } Quit = true; th.Join(); Console.WriteLine("Time (sec)\tPoints"); foreach (KeyValuePair <double, int> kvp in PointSamples) { Console.WriteLine(kvp.Key.ToString() + "\t" + kvp.Value.ToString()); } }
public void TestRollover() { Logger.Console.Verbose = VerboseLevel.All; Globals.MemoryPool.SetMaximumBufferSize(4000 * 1024 * 1024L); foreach (string file in Directory.GetFiles("c:\\temp\\Test\\", "*.*", SearchOption.AllDirectories)) { File.Delete(file); } PointCount = 0; HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("DB", "c:\\temp\\Test\\Main\\", true); settings.FinalWritePaths.Add("c:\\temp\\Test\\Rollover\\"); ulong time = (ulong)DateTime.Now.Ticks; using (SnapServer engine = new SnapServer(settings)) using (SnapClient client = SnapClient.Connect(engine)) using (ClientDatabaseBase <HistorianKey, HistorianValue> db = client.GetDatabase <HistorianKey, HistorianValue>("DB")) { Thread.Sleep(100); HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); for (int x = 0; x < 100000000; x++) { if (x % 100 == 0) { Thread.Sleep(10); } key.Timestamp = time; time += TimeSpan.TicksPerMinute; db.Write(key, value); } } GC.Collect(); GC.WaitForPendingFinalizers(); Thread.Sleep(100); }
public void TestReadData() { HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("DB", @"c:\temp\Scada\", true); using (HistorianServer server = new HistorianServer(settings, 12345)) { using (HistorianClient client = new HistorianClient("127.0.0.1", 12345)) using (ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>("DB")) { TreeStream <HistorianKey, HistorianValue> stream = database.Read(0, 1000); while (stream.Read(key, value)) { Console.WriteLine(key.Timestamp); } } } }
public SnapDBEngine(MigrationUtility parent, string instanceName, string destinationFilesLocation, string targetFileSize, string directoryNamingMethod, bool readOnly = false) { m_parent = parent; m_logSubscriber = Logger.CreateSubscriber(VerboseLevel.High); m_logSubscriber.NewLogMessage += m_logSubscriber_Log; if (string.IsNullOrEmpty(instanceName)) { instanceName = "PPA"; } else { instanceName = instanceName.Trim(); } // Establish archive information for this historian instance HistorianServerDatabaseConfig archiveInfo = new HistorianServerDatabaseConfig(instanceName, destinationFilesLocation, !readOnly); double targetSize; if (!double.TryParse(targetFileSize, out targetSize)) { targetSize = 1.5D; } archiveInfo.TargetFileSize = (long)(targetSize * SI.Giga); int methodIndex; if (!int.TryParse(directoryNamingMethod, out methodIndex) || !Enum.IsDefined(typeof(ArchiveDirectoryMethod), methodIndex)) { methodIndex = (int)ArchiveDirectoryMethod.YearThenMonth; } archiveInfo.DirectoryMethod = (ArchiveDirectoryMethod)methodIndex; m_server = new HistorianServer(archiveInfo); m_parent.ShowUpdateMessage("[SnapDB] Engine initialized"); }
public void CreateAllDatabases() { Logger.Console.Verbose = VerboseLevel.All; Array.ForEach(Directory.GetFiles(@"c:\temp\Scada\", "*.d2", SearchOption.AllDirectories), File.Delete); Array.ForEach(Directory.GetFiles(@"c:\temp\Synchrophasor\", "*.d2", SearchOption.AllDirectories), File.Delete); HistorianServerDatabaseConfig config1 = new HistorianServerDatabaseConfig("Scada", @"c:\temp\Scada\", true); HistorianServerDatabaseConfig config2 = new HistorianServerDatabaseConfig("Synchrophasor", @"c:\temp\Synchrophasor\", true); HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); using (HistorianServer server = new HistorianServer()) { server.AddDatabase(config1); server.AddDatabase(config2); using (SnapClient client = SnapClient.Connect(server.Host)) { ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>("Scada"); for (ulong x = 0; x < 10000; x++) { key.Timestamp = x; database.Write(key, value); } database.HardCommit(); database = client.GetDatabase <HistorianKey, HistorianValue>("Synchrophasor"); for (ulong x = 0; x < 10000; x++) { key.Timestamp = x; database.Write(key, value); } database.HardCommit(); } } }
public void TestWriteServer() { HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); Logger.Console.Verbose = VerboseLevel.All; Logger.FileWriter.SetPath(@"C:\Temp\", VerboseLevel.All); var netStream = new NetworkStreamSimulator(); var dbcfg = new HistorianServerDatabaseConfig("DB", @"C:\Temp\Scada", true); var server = new HistorianServer(dbcfg); var auth = new SecureStreamServer <SocketUserPermissions>(); auth.SetDefaultUser(true, new SocketUserPermissions() { CanRead = true, CanWrite = true, IsAdmin = true }); var netServer = new SnapStreamingServer(auth, netStream.ServerStream, server.Host); ThreadPool.QueueUserWorkItem(ProcessClient, netServer); var client = new SnapStreamingClient(netStream.ClientStream, new SecureStreamClientDefault(), false); var db = client.GetDatabase <HistorianKey, HistorianValue>("DB"); for (uint x = 0; x < 1000; x++) { key.Timestamp = x; db.Write(key, value); break; } client.Dispose(); server.Dispose(); }
public void TestReadData() { var config1 = new HistorianServerDatabaseConfig("Scada", @"c:\temp\Scada\", true); var config2 = new HistorianServerDatabaseConfig("Synchrophasor", @"c:\temp\Synchrophasor\", true); using (HistorianServer server = new HistorianServer()) { server.AddDatabase(config1); server.AddDatabase(config2); using (var client = SnapClient.Connect(server.Host)) { var database = client.GetDatabase <HistorianKey, HistorianValue>("Scada"); TreeStream <HistorianKey, HistorianValue> stream = database.Read(0, 100); stream.Dispose(); database = client.GetDatabase <HistorianKey, HistorianValue>("Synchrophasor"); stream = database.Read(0, 100); stream.Dispose(); } } }
public static void ReadAllPoints() { Stopwatch sw = new Stopwatch(); int pointCount = 0; HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("PPA", @"C:\Program Files\openHistorian\Archive\", true); using (HistorianServer server = new HistorianServer(settings)) { DateTime start = DateTime.FromBinary(Convert.ToDateTime("2/1/2014").Date.Ticks + Convert.ToDateTime("6:00:00PM").TimeOfDay.Ticks).ToUniversalTime(); using (HistorianClient client = new HistorianClient("127.0.0.1", 12345)) using (ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>(String.Empty)) { HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); sw.Start(); TreeStream <HistorianKey, HistorianValue> scan = database.Read((ulong)start.Ticks, ulong.MaxValue); while (scan.Read(key, value) && pointCount < 10000000) { pointCount++; } sw.Stop(); //sw.Start(); //using (var frameReader = database.GetPointStream(DateTime.MinValue, DateTime.MaxValue)) //{ // while (frameReader.Read()) // ; //} //sw.Stop(); } } Console.WriteLine(pointCount); Console.WriteLine(sw.Elapsed.TotalSeconds.ToString()); Console.WriteLine((pointCount / sw.Elapsed.TotalSeconds / 1000000).ToString()); }
public void TestRemoteAdapter() { HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("PPA", @"c:\temp\historian\", true); using (HistorianServer server = new HistorianServer(settings)) using (SnapClient client = SnapClient.Connect(server.Host)) { using (HistorianInputQueue queue = new HistorianInputQueue(() => client.GetDatabase <HistorianKey, HistorianValue>(string.Empty))) { for (uint x = 0; x < 100000; x++) { key.PointID = x; queue.Enqueue(key, value); } Thread.Sleep(100); } Thread.Sleep(100); } //Thread.Sleep(100); }
public static void TestReadPoints2() { int pointCount = 0; HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); var settings = new HistorianServerDatabaseConfig("PPA", @"C:\Program Files\openHistorian\Archive\", true); using (HistorianServer server = new HistorianServer(settings)) { Stopwatch sw = new Stopwatch(); sw.Start(); using (var client = new HistorianClient("127.0.0.1", 12345)) using (var database = client.GetDatabase <HistorianKey, HistorianValue>(String.Empty)) { var stream = database.Read(0, (ulong)DateTime.MaxValue.Ticks, new ulong[] { 65, 953, 5562 }); while (stream.Read(key, value)) { pointCount++; } } sw.Stop(); //MessageBox.Show(sw.Elapsed.TotalSeconds.ToString()); } }
public void CreateScadaDatabase() { Logger.Console.Verbose = VerboseLevel.All; Array.ForEach(Directory.GetFiles(@"c:\temp\Scada\", "*.d2", SearchOption.AllDirectories), File.Delete); var key = new HistorianKey(); var value = new HistorianValue(); var settings = new HistorianServerDatabaseConfig("DB", @"c:\temp\Scada\", true); using (var server = new HistorianServer(settings)) using (var client = SnapClient.Connect(server.Host)) { var database = client.GetDatabase <HistorianKey, HistorianValue>("db"); for (ulong x = 0; x < 1000; x++) { key.Timestamp = x; database.Write(key, value); } database.HardCommit(); } }
public void TestReadData() { HistorianServerDatabaseConfig config1 = new HistorianServerDatabaseConfig("Scada", @"c:\temp\Scada\", true); HistorianServerDatabaseConfig config2 = new HistorianServerDatabaseConfig("Synchrophasor", @"c:\temp\Synchrophasor\", true); using (HistorianServer server = new HistorianServer(12345)) { server.AddDatabase(config1); server.AddDatabase(config2); using (HistorianClient client = new HistorianClient("127.0.0.1", 12345)) { ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>("Scada"); TreeStream <HistorianKey, HistorianValue> stream = database.Read(0, 100); stream.Dispose(); database.Dispose(); database = client.GetDatabase <HistorianKey, HistorianValue>("Synchrophasor"); stream = database.Read(0, 100); stream.Dispose(); database.Dispose(); } } }
/// <summary> /// Initializes this <see cref="LocalOutputAdapter"/>. /// </summary> public override void Initialize() { base.Initialize(); //const string errorMessage = "{0} is missing from Settings - Example: instanceName=default; ArchiveDirectories={{c:\\Archive1\\;d:\\Backups2\\}}; dataChannel={{port=9591; interface=0.0.0.0}}"; Dictionary <string, string> settings = Settings; string setting; // Validate settings. if (!settings.TryGetValue("instanceName", out m_instanceName) || string.IsNullOrWhiteSpace(m_instanceName)) { m_instanceName = Name; } // Track instance in static dictionary Instances[InstanceName] = this; if (!settings.TryGetValue("WorkingDirectory", out setting) || string.IsNullOrEmpty(setting)) { setting = "Archive"; } WorkingDirectory = setting; if (settings.TryGetValue("ArchiveDirectories", out setting)) { ArchiveDirectories = setting; } if (settings.TryGetValue("AttachedPaths", out setting)) { AttachedPaths = setting; } if (!settings.TryGetValue("DataChannel", out m_dataChannel)) { m_dataChannel = DefaultDataChannel; } double targetFileSize; if (!settings.TryGetValue("TargetFileSize", out setting) || !double.TryParse(setting, out targetFileSize)) { targetFileSize = DefaultTargetFileSize; } if (targetFileSize < 0.1D || targetFileSize > SI2.Tera) { targetFileSize = DefaultTargetFileSize; } if (!settings.TryGetValue("MaximumArchiveDays", out setting) || !int.TryParse(setting, out m_maximumArchiveDays)) { m_maximumArchiveDays = DefaultMaximumArchiveDays; } if (!settings.TryGetValue("DirectoryNamingMode", out setting) || !Enum.TryParse(setting, true, out m_directoryNamingMode)) { DirectoryNamingMode = DefaultDirectoryNamingMode; } // Handle advanced settings - there are hidden but available from manual entry into connection string int stagingCount, diskFlushInterval, cacheFlushInterval; if (!settings.TryGetValue("StagingCount", out setting) || !int.TryParse(setting, out stagingCount)) { stagingCount = 3; } if (!settings.TryGetValue("DiskFlushInterval", out setting) || !int.TryParse(setting, out diskFlushInterval)) { diskFlushInterval = 10000; } if (!settings.TryGetValue("CacheFlushInterval", out setting) || !int.TryParse(setting, out cacheFlushInterval)) { cacheFlushInterval = 100; } // Establish archive information for this historian instance m_archiveInfo = new HistorianServerDatabaseConfig(InstanceName, WorkingDirectory, true); if ((object)m_archiveDirectories != null) { m_archiveInfo.FinalWritePaths.AddRange(m_archiveDirectories); } if ((object)m_attachedPaths != null) { m_archiveInfo.ImportPaths.AddRange(m_attachedPaths); } m_archiveInfo.TargetFileSize = (long)(targetFileSize * SI.Giga); m_archiveInfo.DirectoryMethod = DirectoryNamingMode; m_archiveInfo.StagingCount = stagingCount; m_archiveInfo.DiskFlushInterval = diskFlushInterval; m_archiveInfo.CacheFlushInterval = cacheFlushInterval; // Provide web service support m_dataServices = new DataServices(); m_dataServices.AdapterCreated += DataServices_AdapterCreated; m_dataServices.AdapterLoaded += DataServices_AdapterLoaded; m_dataServices.AdapterUnloaded += DataServices_AdapterUnloaded; m_dataServices.AdapterLoadException += AdapterLoader_AdapterLoadException; // Provide archive replication support m_replicationProviders = new ReplicationProviders(); m_replicationProviders.AdapterCreated += ReplicationProviders_AdapterCreated; m_replicationProviders.AdapterLoaded += ReplicationProviders_AdapterLoaded; m_replicationProviders.AdapterUnloaded += ReplicationProviders_AdapterUnloaded; m_replicationProviders.AdapterLoadException += AdapterLoader_AdapterLoadException; if (MaximumArchiveDays > 0) { m_dailyTimer = new Timer(Time.SecondsPerDay * 1000.0D); m_dailyTimer.AutoReset = true; m_dailyTimer.Elapsed += m_dailyTimer_Elapsed; m_dailyTimer.Enabled = true; } }
public void VerifyDB() { //Logger.ReportToConsole(VerboseLevel.All ^ VerboseLevel.DebugLow); //Logger.ConsoleSubscriber.AddIgnored(Logger.LookupType("GSF.SortedTreeStore")); Globals.MemoryPool.SetMaximumBufferSize(1000 * 1024 * 1024); Globals.MemoryPool.SetTargetUtilizationLevel(TargetUtilizationLevels.Low); HistorianServerDatabaseConfig settings = new HistorianServerDatabaseConfig("DB", "c:\\temp\\benchmark\\", true); using (SnapServer engine = new SnapServer(settings)) using (SnapClient client = SnapClient.Connect(engine)) using (ClientDatabaseBase <HistorianKey, HistorianValue> db = client.GetDatabase <HistorianKey, HistorianValue>("DB")) using (TreeStream <HistorianKey, HistorianValue> scan = db.Read(null, null, null)) { HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < PointsToArchive; x++) { if (!scan.Read(key, value)) { throw new Exception("Missing points"); } if (key.PointID != (ulong)x) { throw new Exception("Corrupt"); } if (key.Timestamp != 0) { throw new Exception("Corrupt"); } if (key.EntryNumber != 0) { throw new Exception("Corrupt"); } if (value.Value1 != 0) { throw new Exception("Corrupt"); } if (value.Value1 != 0) { throw new Exception("Corrupt"); } if (value.Value1 != 0) { throw new Exception("Corrupt"); } } double totalTime = sw.Elapsed.TotalSeconds; Console.WriteLine("Completed read test in {0:#,##0.00} seconds at {1:#,##0.00} points per second", totalTime, PointsToArchive / totalTime); if (scan.Read(key, value)) { throw new Exception("too many points"); } } }