internal static void Shutdown() { if (_instance == null) { _started = false; SnLog.WriteWarning("Repository shutdown has already completed."); return; } lock (_startStopSync) { if (_instance == null) { _started = false; SnLog.WriteWarning("Repository shutdown has already completed."); return; } SnTrace.Repository.Write("Sending a goodbye message."); _instance.ConsoleWriteLine(); _instance.ConsoleWriteLine("Sending a goodbye message..."); DistributedApplication.ClusterChannel.ClusterMemberInfo.NeedToRecover = false; var pingMessage = new PingMessage(); pingMessage.SendAsync(CancellationToken.None).GetAwaiter().GetResult(); foreach (var svc in _instance.serviceInstances) { SnTrace.Repository.Write("Shutting down {0}", svc.GetType().Name); svc.Shutdown(); } SnTrace.Repository.Write("Shutting down {0}", DistributedApplication.ClusterChannel.GetType().Name); DistributedApplication.ClusterChannel.ShutDownAsync(CancellationToken.None).GetAwaiter().GetResult(); SnTrace.Repository.Write("Shutting down Security."); SecurityHandler.ShutDownSecurity(); SnTrace.Repository.Write("Shutting down IndexingEngine."); IndexManager.ShutDown(); ContextHandler.Reset(); var t = DateTime.UtcNow - _instance._startupInfo.Starting; var msg = $"Repository has stopped. Running time: {t.Days}.{t.Hours:d2}:{t.Minutes:d2}:{t.Seconds:d2}"; SnTrace.Repository.Write(msg); SnTrace.Flush(); _instance.ConsoleWriteLine(msg); _instance.ConsoleWriteLine(); SnLog.WriteInformation(msg); _instance = null; _started = false; } }
public void _FinishTest(TestContext testContext) { if (_snTraceOperation != null) { _snTraceOperation.Successful = true; _snTraceOperation.Dispose(); } SnTrace.Flush(); }
protected virtual void Application_End(object sender, EventArgs e, HttpApplication application) { using (var op = SnTrace.Repository.StartOperation("Application_End")) { Repository.Shutdown(); SnLog.WriteInformation("Application_End", EventId.RepositoryLifecycle, properties: new Dictionary <string, object> { { "ShutdownReason", HostingEnvironment.ShutdownReason } }); op.Successful = true; } SnTrace.Flush(); }
public void CleanupTest() { SnTrace.Test.Enabled = true; //SnTrace.Test.Write("END test: {0}", TestContext.TestName); if (_testMethodOperation != null) { _testMethodOperation.Successful = true; _testMethodOperation.Dispose(); } SnTrace.Flush(); }
public void CleanupTest() { SnTrace.Test.Enabled = true; SnTrace.Test.Write("{0}: {1}", TestContext.TestName, TestContext.CurrentTestOutcome); if (_testMethodOperation != null) { _testMethodOperation.Successful = true; _testMethodOperation.Dispose(); } SnTrace.Flush(); }
public override void Execute(ExecutionContext context) { Tracer.Write("Phase-0: Initializing."); DataHandler.InstallTables(); using (var op = Tracer.StartOperation("Phase-1: Reindex metadata.")) { ReindexMetadata(); op.Successful = true; } using (var op = Tracer.StartOperation("Phase-2: Create background tasks.")) { DataHandler.StartBackgroundTasks(); op.Successful = true; } // commit all buffered lines SnTrace.Flush(); }
private void WriteStructure1() { SnTrace.Test.Write("1"); SnTrace.Write("2"); SnTrace.Test.Write("3"); SnTrace.Write("4"); SnTrace.Web.Write("5"); SnTrace.Repository.Write("6"); using (var op = SnTrace.Test.StartOperation("7")) { using (var op1 = SnTrace.StartOperation("8")) { op1.Successful = true; } using (var op2 = SnTrace.Repository.StartOperation("9")) { op2.Successful = true; } using (var op2 = SnTrace.Test.StartOperation("10")) { op2.Successful = true; } using (var op2 = SnTrace.Test.StartOperation("11")) { op2.Successful = false; } op.Successful = true; } SnTrace.Test.Write("12"); SnTrace.Repository.Write("13"); using (var op2 = SnTrace.Test.StartOperation("14")) { op2.Successful = true; } SnTrace.Repository.Write("15"); SnTrace.Test.Write("16"); SnTrace.Flush(); }
public static void FinishTestTest(this TestContext testContext) { using (new Swindler <bool>(true, () => SnTrace.Test.Enabled, x => SnTrace.Test.Enabled = x)) { var op = (SnTrace.Operation)testContext.Properties["SnTrace.Operation"]; SnTrace.Test.Write("TESTMETHOD: {0}.{1}: {2}", testContext.FullyQualifiedTestClassName, testContext.TestName, testContext.CurrentTestOutcome); if (op != null) { op.Successful = true; op.Dispose(); } SnTrace.Flush(); } var originalTracers = (ISnTracer[])testContext.Properties["SnTrace.Operation.Writers"]; if (originalTracers != null) { SnTrace.SnTracers.Clear(); SnTrace.SnTracers.AddRange(originalTracers); } }
public override void Execute(ExecutionContext context) { Tracer.Write("Phase-0: Initializing."); _dataHandler = new ReindexBinariesDataHandler(DataOptions.GetLegacyConfiguration(), context.ConnectionStrings); _dataHandler.InstallTables(_cancel); using (var op = Tracer.StartOperation("Phase-1: Reindex metadata.")) { ReindexMetadata(); op.Successful = true; } using (var op = Tracer.StartOperation("Phase-2: Create background tasks.")) { _dataHandler.StartBackgroundTasks(_cancel); op.Successful = true; } // commit all buffered lines SnTrace.Flush(); }
private void WriteStructure2() { SnTrace.Write("noise"); Wait(1); SnTrace.Write("noise"); Wait(1); SnTrace.Test.Write("noise"); Wait(1); SnTrace.Write("noise"); Wait(1); SnTrace.Test.Write("TEST START"); Wait(1); // relevant SnTrace.Write("noise"); Wait(1); SnTrace.Test.Write("noise"); Wait(1); SnTrace.Write("noise"); Wait(1); using (var op1 = SnTrace.Test.StartOperation("Op1")) { SnTrace.Test.Write("noise"); Wait(1); SnTrace.Write("noise"); Wait(1); SnTrace.Test.Write("noise"); Wait(1); op1.Successful = true; } // relevant SnTrace.Write("noise"); Wait(1); using (var op2 = SnTrace.Test.StartOperation("Op2")) { SnTrace.Test.Write("noise"); Wait(1); SnTrace.Write("noise"); Wait(1); SnTrace.Test.Write("noise"); Wait(1); op2.Successful = true; } // relevant SnTrace.Test.Write("TEST END"); Wait(1); SnTrace.Write("noise"); Wait(1); SnTrace.Test.Write("noise"); Wait(1); SnTrace.Test.Write("TEST START"); Wait(1); // (irrelevant) SnTrace.Flush(); }
protected List <string> DisableAllAndGetLog() { SnTrace.Flush(); SnTrace.DisableAll(); return(GetLog()); }
public void CleanupTest() { SnTrace.Test.Enabled = true; SnTrace.Test.Write("END test: {0}", TestContext.TestName); SnTrace.Flush(); }
internal static void Shutdown() { if (_instance == null) { SnLog.WriteWarning("Repository shutdown has already completed."); return; } lock (_shutDownSync) { if (_instance == null) { SnLog.WriteWarning("Repository shutdown has already completed."); return; } SnTrace.Repository.Write("Sending a goodbye message."); _instance.ConsoleWriteLine(); _instance.ConsoleWriteLine("Sending a goodbye message..."); DistributedApplication.ClusterChannel.ClusterMemberInfo.NeedToRecover = false; var pingMessage = new PingMessage(); pingMessage.Send(); foreach (var svc in _instance.serviceInstances) { SnTrace.Repository.Write("Shutting down {0}", svc.GetType().Name); svc.Shutdown(); } SnTrace.Repository.Write("Shutting down {0}", DistributedApplication.ClusterChannel.GetType().Name); DistributedApplication.ClusterChannel.ShutDown(); if (Instance.StartSettings.BackupIndexAtTheEnd) { SnTrace.Repository.Write("Backing up the index."); if (LuceneManagerIsRunning) { _instance.ConsoleWriteLine("Backing up the index..."); SenseNet.Search.Indexing.BackupTools.SynchronousBackupIndex(); _instance.ConsoleWriteLine("The backup of index is finished."); } else { _instance.ConsoleWriteLine("Backing up index is skipped because Lucene was not started."); } } if (LuceneManagerIsRunning) { SnTrace.Repository.Write("Shutting down LuceneManager."); SenseNet.Search.Indexing.LuceneManager.ShutDown(); } SnTrace.Repository.Write("Waiting for writer lock file is released."); WaitForWriterLockFileIsReleased(WaitForLockFileType.OnEnd); var t = DateTime.UtcNow - _instance._startupInfo.Starting; var msg = String.Format("Repository has stopped. Running time: {0}.{1:d2}:{2:d2}:{3:d2}", t.Days, t.Hours, t.Minutes, t.Seconds); SnTrace.Repository.Write(msg); SnTrace.Flush(); _instance.ConsoleWriteLine(msg); _instance.ConsoleWriteLine(); SnLog.WriteInformation(msg); _instance = null; } }