예제 #1
0
 /// <summary>
 /// Initializes the pool with default settings and binds to the active
 /// Logger output.
 /// </summary>
 /// <param name="runtimeConfiguration">Active configuration settings for the current session.</param>
 public WorkerRegistrationPool(RuntimeConfiguration runtimeConfiguration)
 {
     this.runtimeConfiguration = runtimeConfiguration;
     registrationPool          = new List <WorkerRegistration>();
     hostAddress = runtimeConfiguration.GetManagerBindAddress();
     basePort    = runtimeConfiguration.GetManagerComPort() + 1;
 }
예제 #2
0
        public void TestWorkerRegistration()
        {
            WorkerRegistration workerRegistration = workerRegistrationPool.RegisterNewWorker();

            Assert.IsNotNull(workerRegistration);
            Assert.AreEqual(workerRegistration.Name, "worker-1");
            Assert.AreEqual(workerRegistration.Port, runtimeConfiguration.GetManagerComPort() + 1);
            Assert.IsNull(workerRegistration.ClientServer);
            Assert.IsNotNull(workerRegistration.LastHeartBeat);
        }
예제 #3
0
        /// <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;
        }
예제 #4
0
 /// <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()}");
 }
예제 #5
0
 public override void Setup(RuntimeConfiguration runtimeConfiguration)
 {
     base.Setup(runtimeConfiguration);
     registerWorker(runtimeConfiguration.GetManagerBindAddress(), runtimeConfiguration.GetManagerComPort());
 }