public void get_debug_info_ForSpecifiedDatabase_IndexBatchSizeAutoTuner() { using (var documentStore = NewDocumentStore()) { documentStore.DatabaseCommands.GlobalAdmin.CreateDatabase(new DatabaseDocument { Id = "Dba1", Settings = { { "Raven/DataDir", "Dba1" } } }); var dbWorkContext = documentStore.ServerIfEmbedded.Options.DatabaseLandlord.GetResourceInternal("Dba1").Result.WorkContext; var dbName = dbWorkContext.DatabaseName; var indexBatchAutoTuner = new IndexBatchSizeAutoTuner(dbWorkContext); var prefetchingBehavior = new PrefetchingBehavior(PrefetchingUser.Indexer, dbWorkContext, indexBatchAutoTuner, string.Empty); indexBatchAutoTuner.AutoThrottleBatchSize(100, 1024, TimeSpan.MinValue); indexBatchAutoTuner.HandleLowMemory(); MemoryStatistics.RunLowMemoryHandlers("System detected low memory"); prefetchingBehavior.OutOfMemoryExceptionHappened(); prefetchingBehavior.HandleLowMemory(); var url = $"http://localhost:8079/databases/{dbName}/debug/auto-tuning-info"; var requestWithDbName = documentStore.JsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(null, url, HttpMethods.Get, documentStore.DatabaseCommands.PrimaryCredentials, documentStore.Conventions)); var results = requestWithDbName.ReadResponseJson().JsonDeserialization <AutoTunerInfo>(); var reason = results.Reason; var reasonForLowMemoryCall = results.LowMemoryCallsRecords.First().Reason; var lowMemoryRecords = results.LowMemoryCallsRecords.First().Operations; Assert.Equal("System detected low memory", reasonForLowMemoryCall); var urlAdmin = $"http://localhost:8079/databases/{dbName}/admin/debug/auto-tuning-info"; var requestWithDbNameAdmin = documentStore.JsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(null, url, HttpMethods.Get, documentStore.DatabaseCommands.PrimaryCredentials, documentStore.Conventions)); var resultsAdmin = requestWithDbNameAdmin.ReadResponseJson().JsonDeserialization <AutoTunerInfo>(); var reasonAdmin = results.Reason; var reasonForLowMemoryCallAdmin = resultsAdmin.LowMemoryCallsRecords.First().Reason; var lowMemoryRecordsAdmin = resultsAdmin.LowMemoryCallsRecords.First().Operations; var cpuUsageRecordsAdmin = resultsAdmin.CpuUsageCallsRecords; Assert.Equal("System detected low memory", reasonForLowMemoryCallAdmin); } }
public void get_debug_info_ForSpecifiedDatabase() { using (var documentStore = NewDocumentStore()) { documentStore.DatabaseCommands.GlobalAdmin.CreateDatabase(new DatabaseDocument { Id = "Dba1", Settings = { { "Raven/DataDir", "Dba1" } } }); new Simple().Execute(documentStore.DatabaseCommands.ForDatabase("Dba1"), documentStore.Conventions); using (var session = documentStore.OpenSession("Dba1")) { var entity1 = new Person { Name = "Rob", Email = "*****@*****.**" }; var entity2 = new Person { Name = "Haim", Email = "*****@*****.**" }; var entity3 = new Person { Name = "Rob", Email = "*****@*****.**" }; session.Store(entity1); session.Store(entity2); session.Store(entity3); var persons = session.Query <Person>().Where(x => x.Name == "Rob").ToList(); } var dbWorkContext = documentStore.ServerIfEmbedded.Options.DatabaseLandlord.GetResourceInternal("Dba1").Result.WorkContext; var dbName = dbWorkContext.DatabaseName; var independentBatchSizeAutoTuner = new IndexBatchSizeAutoTuner(dbWorkContext); var prefetchingBehavior = new PrefetchingBehavior(PrefetchingUser.Indexer, dbWorkContext, independentBatchSizeAutoTuner, string.Empty); prefetchingBehavior.HandleLowMemory(); independentBatchSizeAutoTuner.AutoThrottleBatchSize(100, 1024, TimeSpan.MinValue); independentBatchSizeAutoTuner.HandleLowMemory(); MemoryStatistics.RunLowMemoryHandlers("System detected low memory"); var url = $"http://localhost:8079/databases/{dbName}/debug/auto-tuning-info"; var requestWithDbName = documentStore.JsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(null, url, HttpMethods.Get, documentStore.DatabaseCommands.PrimaryCredentials, documentStore.Conventions)); var results = requestWithDbName.ReadResponseJson().JsonDeserialization <AutoTunerInfo>(); var reason = results.Reason; var reasonForLowMemoryCall = results.LowMemoryCallsRecords.First().Reason; var lowMemoryRecords = results.LowMemoryCallsRecords.First().Operations; Assert.Equal("System detected low memory", reasonForLowMemoryCall); var urlAdmin = $"http://localhost:8079/databases/{dbName}/admin/debug/auto-tuning-info"; var requestWithDbNameAdmin = documentStore.JsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(null, url, HttpMethods.Get, documentStore.DatabaseCommands.PrimaryCredentials, documentStore.Conventions)); var resultsAdmin = requestWithDbNameAdmin.ReadResponseJson().JsonDeserialization <AutoTunerInfo>(); var reasonAdmin = results.Reason; var reasonForLowMemoryCallAdmin = resultsAdmin.LowMemoryCallsRecords.First().Reason; var lowMemoryRecordsAdmin = resultsAdmin.LowMemoryCallsRecords.First().Operations; var cpuUsageRecordsAdmin = resultsAdmin.CpuUsageCallsRecords; Assert.Equal("System detected low memory", reasonForLowMemoryCallAdmin); } }