示例#1
0
        internal static void InitializeTracing()
        {
            TraceConfig.InitializeFromConfigStore();

            FabricCodePath = FabricEnvironment.GetCodePath();
            FabricLogRoot  = FabricEnvironment.GetLogRoot();
        }
示例#2
0
        public void TestConfigStoreTraceConfig()
        {
            lock (ContextLock)
            {
                var onFilterUpdateCalledCount = 0;
                TraceConfig.OnFilterUpdate += sinkType =>
                {
                    switch (sinkType)
                    {
                    case TraceSinkType.ETW:
                        Assert.IsTrue(
                            TraceConfig.GetEventEnabledStatus(sinkType, EventLevel.Informational, EventTask.None, string.Empty),
                            "ETW should allow info traces.");
                        Assert.IsFalse(
                            TraceConfig.GetEventEnabledStatus(sinkType, EventLevel.Verbose, EventTask.None, string.Empty),
                            "ETW shouldn't allow verbose traces.");
                        Assert.IsTrue(
                            TraceConfig.GetEventEnabledStatus(sinkType, EventLevel.Verbose, FabricEvents.Tasks.FabricDCA, "ServiceResolver"),
                            "ETW should allow DCA.ServiceResolver verbose traces.");
                        Assert.IsTrue(TraceConfig.GetEventProvisionalFeatureStatus(sinkType), "ETW should have Provisional Featue Enabled");
                        break;

                    case TraceSinkType.Console:
                        Assert.IsTrue(
                            TraceConfig.GetEventEnabledStatus(sinkType, EventLevel.Error, EventTask.None, string.Empty),
                            "Console should allow error traces.");
                        Assert.IsFalse(
                            TraceConfig.GetEventEnabledStatus(sinkType, EventLevel.Warning, EventTask.None, string.Empty),
                            "Console shouldn't allow warning traces.");
                        break;

                    case TraceSinkType.TextFile:
                        Console.WriteLine("Entering - TextFile");
                        Assert.IsTrue(
                            TraceConfig.GetEventEnabledStatus(sinkType, EventLevel.Verbose, EventTask.None, string.Empty),
                            "Text file should allow all traces.");
                        break;

                    default:
                        Assert.Fail("Unknown sink type filter updated" + sinkType);
                        break;
                    }

                    onFilterUpdateCalledCount++;
                };

                var mockConfigReader = new Mock <TraceConfig.IConfigReader>(MockBehavior.Strict);
                mockConfigReader.Setup(cr => cr.GetSections()).Returns(new[] { "Trace/File", "Trace/Etw", "Trace/Console" });

                SetMockConfig(mockConfigReader, "Trace/File", EventLevel.Verbose, null, "DoesntMatter.trace");

                SetMockConfig(mockConfigReader, "Trace/Etw", EventLevel.Informational, "FabricDCA.ServiceResolver:5");

                SetMockConfig(mockConfigReader, "Trace/Console", EventLevel.Error);

                TraceConfig.InitializeFromConfigStore(mockConfigReader.Object);
                Assert.AreEqual(3, onFilterUpdateCalledCount);
            }
        }
示例#3
0
        static AppTrace()
        {
            // Try reading config
            TraceConfig.InitializeFromConfigStore();

            // Create the trace source
            AppTrace.traceSource = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.SystemFabric);
        }
        static FileImageStore()
        {
            // Try reading config (this may require access to tracing which is why we setup something up above
            TraceConfig.InitializeFromConfigStore();

            // Create the trace source based on the config
            FileImageStore.traceSource = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.ImageStoreClient);
        }
示例#5
0
        public static int Main(string[] args)
        {
            TraceConfig.InitializeFromConfigStore();

            int status = new ManualTester().Execute(args);

            return(status);
        }
示例#6
0
        static ImageBuilderExe()
        {
            TraceConfig.InitializeFromConfigStore();
            ImageBuilderExe.TraceSource = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.ImageBuilder);

#if !DotNetCoreClr
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
#endif
        }
示例#7
0
 public void TestEmptyConfigStoreTraceConfig()
 {
     lock (ContextLock)
     {
         var mockConfigReader = new Mock <TraceConfig.IConfigReader>(MockBehavior.Strict);
         mockConfigReader.Setup(cr => cr.GetSections()).Returns(new string[0]);
         TraceConfig.InitializeFromConfigStore(mockConfigReader.Object);
         AssertDefaultTracingConfig();
     }
 }
示例#8
0
        static ImageStoreClient()
        {
            // Try reading config
            TraceConfig.InitializeFromConfigStore();

            // Create the trace source based on the config
            ImageStoreClient.TraceSource = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.ImageStoreClient);
#if !DotNetCoreClr
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
#endif
        }
示例#9
0
        static DeployerTrace()
        {
#if DotNetCoreClrLinux
            // TODO - Following code will be removed once fully transitioned to structured traces in Linux
            // this is used to read the configuration which tells whether to use structured traces in Linux.
            TraceConfig.InitializeFromConfigStore();
#endif
            traceSource = FabricEvents.ExtensionsEvents.GetEventSource(FabricEvents.Tasks.FabricDeployer);
            TraceConfig.SetDefaultLevel(TraceSinkType.Console, EventLevel.Error);
            TraceConfig.SetDefaultLevel(TraceSinkType.ETW, EventLevel.Informational);
        }
        public static void Run()
        {
            TraceConfig.InitializeFromConfigStore();

            using (var runtime = FabricRuntime.Create())
            {
                runtime.RegisterStatelessServiceFactory("TokenValidationServiceType", new TokenValidationServiceFactory());

                Console.ReadKey();
            }
        }
示例#11
0
        static ServerUtility()
        {
            TraceConfig.InitializeFromConfigStore();

#if !DotNetCoreClr
            // "System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel"
            // may be encountered when making HttpWebRequest calls to an https endpoint if the cipher suites
            // have been modified according to "https://requirements.azurewebsites.net/Requirements/Details/6417"
            //
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
#endif
        }
示例#12
0
        public static int Main(string[] args)
        {
            TraceConfig.InitializeFromConfigStore();

            Console.CancelKeyPress += Console_CancelKeyPress;
            Trace.ConsoleWriteLine(TraceType, "Microsoft Azure Service Fabric Upgrade Service Host");
            Trace.ConsoleWriteLine(TraceType, "Copyright (c) Microsoft Corporation");
            Console.WriteLine();
            Trace.ConsoleWriteLine(TraceType, "Registering Upgrade service...");

            #if !DotNetCoreClr
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            #endif

            using (var runtime = FabricRuntime.Create())
            {
                factory.RegisterUpgradeSystemService(runtime);
                Trace.ConsoleWriteLine(TraceType, "Upgrade Service host ready. Press [Enter] to exit ...");
                Console.ReadLine();
            }

            return(0);
        }
示例#13
0
 static ServiceTrace()
 {
     TraceConfig.InitializeFromConfigStore();
     Source = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.ServiceFramework);
 }
 static ImageBuilderExe()
 {
     TraceConfig.InitializeFromConfigStore();
     ImageBuilderExe.TraceSource = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.ImageBuilder);
 }
示例#15
0
 static BackupCopier()
 {
     TraceConfig.InitializeFromConfigStore();
     BackupCopier.TraceSource         = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.BackupCopier);
     BackupRestoreUtility.TraceSource = BackupCopier.TraceSource;
 }
示例#16
0
 public void TestInitialize()
 {
     TraceConfig.InitializeFromConfigStore(testReader);
     TraceConfig.SetDefaultLevel(TraceSinkType.ETW, EventLevel.Informational);
 }
示例#17
0
        public static int Main(string[] args)
        {
            // To enable breakForDebugger, add the <Arguments> tag in servicemanifest.xml as shown
            // <EntryPoint>
            //   <ExeHost>
            //     <Program>FabricIS.exe</Program>
            //     <Arguments>-debug</Arguments>
            //   </ExeHost>
            // </EntryPoint>

            bool breakForDebugger = false;
            bool appMode          = false;

            for (int i = 0; i < args.Length; ++i)
            {
                string command = args[i].TrimStart('-', '/').ToLowerInvariant();

                switch (command)
                {
                case "debug":
                    breakForDebugger = true;
                    break;

                case "app":
                    appMode = true;
                    break;

                default:
                    TraceType.ConsoleWriteLine("WARNING: Ignoring unknown argument: {0}", args[i]);
                    break;
                }
            }

            if (breakForDebugger)
            {
                TraceType.ConsoleWriteLine("Waiting for debugger. Press [Enter] to continue execution ...");
                Console.ReadLine();
            }

            TraceConfig.InitializeFromConfigStore();

            Console.CancelKeyPress += Console_CancelKeyPress;

            TraceType.ConsoleWriteLine(
                "Service Fabric Infrastructure Service starting up in {0} mode",
                appMode ? "user application" : "system service");

            if (appMode)
            {
                using (var runtime = FabricRuntime.Create())
                {
                    runtime.RegisterStatefulServiceFactory("InfrastructureServiceType", ServiceFactory.CreateAppServiceFactory());
                    int status = WaitForProgramClosure();
                    return(status);
                }
            }
            else
            {
                ServiceFactory.CreateAndRegister();
                int status = WaitForProgramClosure();
                return(status);
            }
        }