/// <summary> /// Initializes a new instance of the BrokerManager class /// </summary> public BrokerManager(bool needRecover, ITelepathyContext context) { TraceHelper.TraceEvent(TraceEventType.Verbose, "[BrokerManager] Constructor: needRecover={0}", needRecover); this.headnode = SoaHelper.GetSchedulerName(); this.context = context; this.brokerDic = new Dictionary <string, BrokerInfo>(); this.staleSessionCleanupTimer = new Timer(this.CleanStaleSessionData, null, Timeout.Infinite, Timeout.Infinite); #if HPCPACK if (!SoaHelper.IsOnAzure()) { // TODO: on azure, about the MSMQ. Don't use the MSMQ in the Azure cluster. this.updateQueueLengthTimer = new Timer(this.CallbackToUpdateMSMQLength, null, Timeout.Infinite, Timeout.Infinite); } #endif this.pool = new BrokerProcessPool(); // TODO: enable recovery in Telepathy #if HPCPACK if (needRecover && !BrokerLauncherEnvironment.Standalone) { this.ts = new CancellationTokenSource(); CancellationToken ct = ts.Token; this.RecoverTask = Task.Run(async() => await this.RecoverThreadProc(ct), ct); } #endif }
/// <summary> /// Initializes a new instance of the AzureQueueManager class. /// </summary> /// <param name="sessionId">session Id</param> public AzureQueueManager(string sessionId, string clusterName, string clusterId) { ThreadPool.SetMinThreads(MinThreadsOfThreadpool, MinThreadsOfThreadpool); this.sessionId = sessionId; string schedulerName = null; try { schedulerName = SoaHelper.GetSchedulerName(); } catch (InvalidOperationException e) { // It can happen in the in-proc broker scenario, because client // machine doesn't have registry key storing the headnode name. BrokerTracing.TraceError( "[AzureQueueManager].AzureQueueManager: Failed to get scheduler name, {0}", e); } this.clusterName = clusterName; this.clusterId = new Guid(clusterId); }
/// <summary> /// Stores the fabric cluster context; /// </summary> //private IHpcContext context; /// <summary> /// Initializes a new instance of the SoaDiagAuthenticator class /// </summary> public SoaDiagAuthenticator() { this.headNode = SoaHelper.GetSchedulerName(); //this.schedulerHelper = new SchedulerHelper(fabricClient, token); }
private static void Main(string[] args) { var log = new LoggerConfiguration().ReadFrom.AppSettings().Enrich.WithMachineName().CreateLogger(); Log.Logger = log; if (!ParseAndSetBrokerLauncherSettings(args, BrokerLauncherSettings.Default)) { // parsing failed return; } if (ConfigureLogging) { Trace.TraceInformation("Log configuration for Broker Launcher has done successfully."); Log.CloseAndFlush(); return; } // clusterconnectionstring could be a machine name (for single headnode) or a connection string ITelepathyContext context; string clusterConnectionString = SoaHelper.GetSchedulerName(); context = TelepathyContext.GetOrAdd(clusterConnectionString); Trace.TraceInformation("Get diag trace enabled internal."); SoaDiagTraceHelper.IsDiagTraceEnabledInternal = (sessionId) => { try { using (ISchedulerHelper helper = SchedulerHelperFactory.GetSchedulerHelper(context)) { return(helper.IsDiagTraceEnabled(sessionId).GetAwaiter().GetResult()); } } catch (Exception e) { Trace.TraceError("[SoaDiagTraceHelper] Failed to get IsDiagTraceEnabled property: {0}", e); return(false); } }; TraceHelper.IsDiagTraceEnabled = SoaDiagTraceHelper.IsDiagTraceEnabled; LauncherHostService host = null; BrokerManagement brokerManagement = null; // richci : Run as a console application if user wants to debug (-D) or run in MSCS (-FAILOVER) if (BrokerLauncherSettings.Default.AsConsole) { try { host = new LauncherHostService(true, context); // This instance of HpcBroker is running as a failover generic application or in debug // mode so startup the brokerManagement WCF service to accept management commands brokerManagement = new BrokerManagement(host.BrokerLauncher); brokerManagement.Open(); Console.WriteLine("Press any key to exit..."); Thread.Sleep(-1); } finally { if (host != null) { try { host.Stop(); } catch (Exception e) { Trace.TraceError("Exception stopping HpcBroker service - " + e); } } if (brokerManagement != null) { try { brokerManagement.Close(); } catch (Exception e) { Trace.TraceError("Exception closing broker managment WCF service - " + e); } } } } else { ServiceBase[] servicesToRun; servicesToRun = new ServiceBase[] { new LauncherHostService(context) }; ServiceBase.Run(servicesToRun); } Log.CloseAndFlush(); }
/// <summary> /// Open the session launcher service /// </summary> public async Task OpenService() { try { // If running on Azure, monitor HAController service and terminate this service // if HAController dies. Note that SCM service dependency monitoring does not provide // this if (SoaHelper.IsOnAzure()) { ServiceControllerHelpers.MonitorHAControllerStopAsync(HpcServiceNames.HpcSession); TraceHelper.TraceEvent(TraceEventType.Information, "Azure HAController service monitoring enabled"); } if (SessionLauncherRuntimeConfiguration.SchedulerType == SchedulerType.HpcPack) { #if HPCPACK this.brokerNodesManager = new BrokerNodesManager(); this.sessionLauncher = SessionLauncherFactory.CreateHpcPackSessionLauncher(SoaHelper.GetSchedulerName(), false, this.brokerNodesManager); this.schedulerDelegation = new HpcSchedulerDelegation(this.sessionLauncher, this.brokerNodesManager); #endif } else if (SessionLauncherRuntimeConfiguration.SchedulerType == SchedulerType.AzureBatch) { var instance = SessionLauncherFactory.CreateAzureBatchSessionLauncher(); this.sessionLauncher = instance; this.schedulerDelegation = new AzureBatchSchedulerDelegation(instance); } else if (SessionLauncherRuntimeConfiguration.SchedulerType == SchedulerType.Local) { var instance = SessionLauncherFactory.CreateLocalSessionLauncher(); this.sessionLauncher = instance; this.schedulerDelegation = new LocalSchedulerDelegation(instance); } TraceHelper.IsDiagTraceEnabled = _ => true; #if HPCPACK // Bug 18448: Need to enable traces only for those who have enabled trace if (this.schedulerDelegation is IHpcSchedulerAdapterInternal hpcAdapterInternal) { SoaDiagTraceHelper.IsDiagTraceEnabledInternal = hpcAdapterInternal.IsDiagTraceEnabled; TraceHelper.IsDiagTraceEnabled = SoaDiagTraceHelper.IsDiagTraceEnabled; } #endif // start session launcher service this.StartSessionLauncherService(); if (SessionLauncherRuntimeConfiguration.SchedulerType == SchedulerType.HpcPack || SessionLauncherRuntimeConfiguration.SchedulerType == SchedulerType.Local || SessionLauncherRuntimeConfiguration.SchedulerType == SchedulerType.AzureBatch) { // start scheduler delegation service this.StartSchedulerDelegationService(); } #if HPCPACK // start data service if (!SoaHelper.IsOnAzure() && this.sessionLauncher is HpcPackSessionLauncher hpcSessionLauncher) { this.dataService = hpcSessionLauncher.GetDataService(); this.StartDataWcfService(); this.StartDataRestService(this.dataService); } #endif } catch (Exception e) { TraceHelper.TraceEvent(TraceEventType.Critical, "Failed to open the service host - {0}", e); throw; } await Task.CompletedTask; }