Exemplo n.º 1
0
        private static void AddAllEventSources()
        {
            // Ensure the event source is loaded
            Assembly.GetAssembly(typeof(Backend.RingMasterBackendCore))
            .GetType("Microsoft.Azure.Networking.Infrastructure.RingMaster.Backend.RingMasterEventSource")
            ?.GetProperty("Log")
            ?.GetValue(null);
            Assembly.GetAssembly(typeof(AbstractPersistedDataFactory))
            .GetType("Microsoft.Azure.Networking.Infrastructure.RingMaster.Persistence.PersistenceEventSource")
            ?.GetProperty("Log")
            ?.GetValue(null);
            Assembly.GetAssembly(typeof(WinFabPersistence.PersistedData))
            .GetType("Microsoft.Azure.Networking.Infrastructure.RingMaster.Persistence.ServiceFabric.ServiceFabricPersistenceEventSource")
            ?.GetProperty("Log")
            ?.GetValue(null);
            Assembly.GetAssembly(typeof(Transport.SecureTransport))
            .GetType("Microsoft.Azure.Networking.Infrastructure.RingMaster.Transport.SecureTransportEventSource")
            ?.GetProperty("Log")
            ?.GetValue(null);

            var level = EventLevel.Informational;

            LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-Fabric-RingMasterService", level, "RingMasterService");
            LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-Backend-RingMasterEvents", level, "RingMasterBackendCore");
            LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-Persistence", EventLevel.Warning, "Persistence");
            LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-Persistence-ServiceFabric", level, "ServiceFabricPersistence");
            LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-SecureTransport", level, "SecureTransport");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Entry point
        /// </summary>
        public static void Main()
        {
            var            path        = System.Reflection.Assembly.GetExecutingAssembly().Location;
            var            builder     = new ConfigurationBuilder().SetBasePath(Path.GetDirectoryName(path)).AddJsonFile("appSettings.json");
            IConfiguration appSettings = builder.Build();

            RingMasterApplicationHelper.AttachDebugger(int.Parse(appSettings["DebuggerAttachTimeout"]));

            LogFileEventTracing.Start(Path.Combine(appSettings["LogFolder"], "RingMasterWatchdog.LogPath"));

            AppDomain.CurrentDomain.ProcessExit +=
                (sender, eventArgs) =>
            {
                LogFileEventTracing.Stop();
            };

            using (FabricRuntime fabricRuntime = FabricRuntime.Create())
            {
                try
                {
                    var monitoringConfiguration = new MonitoringConfiguration(FabricRuntime.GetActivationContext());

                    IfxInstrumentation.Initialize(monitoringConfiguration.IfxSession, monitoringConfiguration.MdmAccount);

                    RingMasterWatchdogEventSource.Log.ConfigurationSettings(
                        monitoringConfiguration.Environment,
                        monitoringConfiguration.Tenant,
                        monitoringConfiguration.Role,
                        monitoringConfiguration.IfxSession,
                        monitoringConfiguration.MdmAccount);

                    LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-Fabric-RingMasterWatchdog", EventLevel.Informational, "RingMasterWatchdog");
                    LogFileEventTracing.AddEventSource("Microsoft-ServiceFabric-Services", EventLevel.Informational, "ServiceFabricServices");
                    Trace.Listeners.Add(new LogFileTraceListener());

                    var metricsFactory = IfxInstrumentation.CreateMetricsFactory(
                        monitoringConfiguration.MdmAccount,
                        monitoringConfiguration.MdmNamespace,
                        monitoringConfiguration.Environment,
                        monitoringConfiguration.Tenant,
                        monitoringConfiguration.Role,
                        monitoringConfiguration.RoleInstance);

                    ServiceRuntime.RegisterServiceAsync(
                        "RingMasterWatchdog",
                        serviceContext => new RingMasterWatchdog(serviceContext, metricsFactory)).Wait();
                    RingMasterWatchdogEventSource.Log.RegisterServiceSucceeded();

                    Thread.Sleep(Timeout.Infinite);
                }
                catch (Exception ex)
                {
                    RingMasterWatchdogEventSource.Log.RegisterServiceFailed(ex.ToString());
                    throw;
                }
            }
        }
Exemplo n.º 3
0
        public static void TestRingMasterRingSetup(TestContext context)
        {
            log = s => context.WriteLine(s);

            LogFileEventTracing.Start(Path.Combine(Environment.CurrentDirectory, "TestLogs"));
            LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-Backend-RingMasterEvents", EventLevel.Warning, "RingMasterBackendCore");
            LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-Persistence", EventLevel.Informational, "Persistence");
            LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-Persistence-InMemory", EventLevel.Informational, "InMemoryPersistence");
            Trace.Listeners.Add(new LogFileTraceListener());

            AppDomain.CurrentDomain.ProcessExit +=
                (sender, eventArgs) =>
            {
                LogFileEventTracing.Stop();
            };
        }
Exemplo n.º 4
0
        /// <summary>
        /// This is the entry point of the service host process.
        /// </summary>
        private static void Main()
        {
            VegaDistributedTestService vegaDistributedTestService = null;

            try
            {
                var path    = Assembly.GetExecutingAssembly().Location;
                var builder = new ConfigurationBuilder().SetBasePath(Path.GetDirectoryName(path)).AddJsonFile("appSettings.json");
                appSettings = builder.Build();

                var tenantName = GetClusterNameFromMsa().GetAwaiter().GetResult();

                var nodeName = FabricRuntime.GetNodeContext().NodeName;

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    var errorContext = default(ErrorContext);

                    var defaultDimensions = new Dictionary <string, string>
                    {
                        { "Tenant", tenantName },
                        { "Node", nodeName },
                    };

                    if (!DefaultConfiguration.SetDefaultDimensionNamesValues(
                            ref errorContext,
                            (uint)defaultDimensions.Count,
                            defaultDimensions.Keys.ToArray(),
                            defaultDimensions.Values.ToArray()))
                    {
                        VegaDistTestEventSource.Log.SetMdmDimensionFailed(errorContext.ErrorCode, errorContext.ErrorMessage);
                    }
                }

                // Ensure the event source is loaded
                Assembly.GetAssembly(typeof(ITestJob))
                .GetType("Microsoft.Vega.DistributedTest.VegaDistTestEventSource")
                ?.GetProperty("Log")
                ?.GetValue(null);

                LogFileEventTracing.Start(Path.Combine(appSettings["LogFolder"], "VegaDistributedTestService.LogPath"));
                Trace.Listeners.Add(new LogFileTraceListener());
                LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-DistributedTestService");

                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                AppDomain.CurrentDomain.ProcessExit        +=
                    (sender, eventArgs) =>
                {
                    LogFileEventTracing.Stop();
                };

                // The ServiceManifest.XML file defines one or more service type names.
                // Registering a service maps a service type name to a .NET type.
                // When Service Fabric creates an instance of this service type,
                // an instance of the class is created in this host process.
                ServiceRuntime.RegisterServiceAsync(
                    "VegaDistTestSvc",
                    context => vegaDistributedTestService = new VegaDistributedTestService(context))
                .GetAwaiter()
                .GetResult();

                VegaDistTestEventSource.Log.RegisterServiceSucceeded();

                // Prevents this host process from terminating so services keep running.
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception ex)
            {
                VegaDistTestEventSource.Log.RegisterServiceFailed(ex.ToString());
                throw;
            }
            finally
            {
                if (vegaDistributedTestService != null)
                {
                    vegaDistributedTestService.Dispose();
                }
            }
        }