public static void RunStandalone(RuntimeConfiguration runtimeConfiguration) { bool shouldRun = true; // Create a manager thread. Manager manager = new Manager(runtimeConfiguration); // Setup the Manager thread. manager.Setup(runtimeConfiguration); // Start the Manager service thread. Task managerThread = Task.Run(() => manager.RunAsync()); // Wait a few seconds for the manager to get set up. Thread.Sleep(1000); // Set up the workers. WorkerPool workerPool = new WorkerPool(runtimeConfiguration); workerPool.SetupAllWorkers(runtimeConfiguration); workerPool.RunAllWorkersAsync(); Console.CancelKeyPress += (s, e) => { runtimeConfiguration.GetLoggerInstance().Error("Runner", "Overwatch", "Console kill command received. Forcing shutdown."); workerPool.KillAllWorkers(); shouldRun = false; }; Task.WaitAll(managerThread); }
/// <summary> /// Adds a new worker registration to the pool. /// </summary> /// <param name="workerRegistration">Registration details of new worker.</param> public void AddToPool(WorkerRegistration workerRegistration) { lock (registrationPool) { registrationPool.Add(workerRegistration); } runtimeConfiguration.GetLoggerInstance().Msg("Manager", "Worker Registration Pool", $"Worker with name '{workerRegistration.Name}' was added to the pool."); }
public ApiMessageProcessor(RuntimeConfiguration runtimeConfiguration, WorkerRegistrationPool workerRegistrationPool, JobDispatchManager jobDispatchManager) { sharedLogger = runtimeConfiguration.GetLoggerInstance(); apiServer = new TCPServer(runtimeConfiguration.GetManagerBindAddress(), runtimeConfiguration.GetManagerExecPort()); workerPool = workerRegistrationPool; this.jobDispatchManager = jobDispatchManager; reportProcessor = new ReportProcessor(workerRegistrationPool, jobDispatchManager); activeClients = new List <TCPClient>(); commandProcessor = new CommandProcessor(jobDispatchManager); }
public JobDispatchManager(RuntimeConfiguration runtimeConfiguration, WorkerRegistrationPool workerRegistrationPool) { sharedLogger = runtimeConfiguration.GetLoggerInstance(); workerPool = workerRegistrationPool; nextJobId = -1; nextTaskId = -1; dispatchedTasks = new List <DispatchedTask>(); random = new Random(); jobQueue = new Queue <Job>(); }
/// <summary> ///Initializes the manager with specified settings. /// </summary> /// <param name="runtimeConfiguration">Active runtime configuration settings for this session.</param> /// <param name="workerRegistrationPool">Configured pool of workers to manage.</param> /// <exception cref="ArgumentException">When invalid IP/port bindings are configured.</exception> public WorkerRegistrationManager(RuntimeConfiguration runtimeConfiguration, WorkerRegistrationPool workerRegistrationPool) { managerBindIP = runtimeConfiguration.GetManagerBindAddress(); try { tcpServer = new TCPServer(managerBindIP, runtimeConfiguration.GetManagerComPort()); } catch (ArgumentException e) { throw new ArgumentException("Invalid IP or port setting for the Worker Registration Manager. Check settings and try again.", e); } catch (IOException e) { throw new IOException("The Worker Registration Service encountered an error while binding to the configured IP/port configuration. Ensure that you have the correct permissions to use the port and that the requested port is not already in use by another process.", e); } shouldListen = false; registrationPool = workerRegistrationPool; sharedLogger = runtimeConfiguration.GetLoggerInstance(); this.runtimeConfiguration = runtimeConfiguration; }
public Runner(RuntimeConfiguration runtimeConfiguration) { SharedLogger = runtimeConfiguration.GetLoggerInstance(); isRunning = true; }
public ManagerMessageProcessor(RuntimeConfiguration runtimeConfiguration, string runnerName) { logger = runtimeConfiguration.GetLoggerInstance(); this.runnerName = runnerName; }
/// <summary> /// Default constructor with default settings. /// </summary> /// <param name="runtimeConfiguration">Active runtime configuration settings for current session.</param> /// <param name="workerRegistrationPool">Active pool of workers to pull information from.</param> public WorkerMessageProcessor(RuntimeConfiguration runtimeConfiguration, WorkerRegistrationPool workerRegistrationPool, DataStoreManager dataStoreManager) { sharedLogger = runtimeConfiguration.GetLoggerInstance(); this.workerRegistrationPool = workerRegistrationPool; this.dataStoreManager = dataStoreManager; }