/// <summary> /// Sets up all requisite services and starts listening for requests from workers, API clients, and internal dispatches. /// </summary> /// <param name="runtimeConfiguration">Active runtime configuration settings profile.</param> public override void Setup(RuntimeConfiguration runtimeConfiguration) { // TODO: Some of this can be moved up to the class initializer. workerRegistrationPool = new WorkerRegistrationPool(runtimeConfiguration); jobDispatchManager = new JobDispatchManager(runtimeConfiguration, workerRegistrationPool); apiMessageProcessor = new ApiMessageProcessor(runtimeConfiguration, workerRegistrationPool, jobDispatchManager); workerRegistrationManager = new WorkerRegistrationManager(runtimeConfiguration, workerRegistrationPool); dataStoreManager = new DataStoreManager(); workerMessageProcessor = new WorkerMessageProcessor(runtimeConfiguration, workerRegistrationPool, dataStoreManager); Task.Run(() => workerRegistrationManager.ListenAsync()); Task.Run(() => apiMessageProcessor.ListenAsync()); SharedLogger.Msg("Manager", "API", $"Manager is listening for registrations at {runtimeConfiguration.GetManagerBindAddress().ToString()}:{runtimeConfiguration.GetManagerComPort()}"); }
private void getNewPort(IPAddress managerAddress, int registrationPort) { TCPClient registrationConnection = new TCPClient(managerAddress, registrationPort); SharedLogger.Debug(workerName, "Registration Service", $"Registration sent to {managerAddress}:{registrationPort}."); registrationConnection.SendObject <string>("REGISTER"); //while (!registrationConnection.MessageIsAvailable()) //{ // Thread.Sleep(500); //} string[] registrationInfo = registrationConnection.ReceiveObject <string>().Split('|'); workerName = registrationInfo[1]; managerMessageProcessor.UpdateRunnerName(workerName); SharedLogger.Msg(workerName, "Registration Service", $"Registered to manager server at {managerAddress.ToString()} with port assignment {registrationInfo[0]}."); assignedPort = Convert.ToInt32(registrationInfo[0]); }