Exemplo n.º 1
0
        /// <summary>
        /// Connects to the master and enables this node to receive build requests
        /// </summary>
        /// <param name="schedule">the engine schedule</param>
        /// <returns>true if the operation was successful</returns>
        internal async Task <bool> ConnectToMasterAsync(EngineSchedule schedule)
        {
            Contract.Requires(schedule != null);
            Contract.Requires(schedule.Scheduler != null);
            Contract.Requires(schedule.SchedulingQueue != null);
            Contract.Assert(AttachCompletion.IsCompleted && AttachCompletion.GetAwaiter().GetResult(), "ProcessBuildRequests called before finishing attach on worker");

            m_workerPipStateManager = new WorkerServicePipStateManager(this);
            m_pipTable         = schedule.PipTable;
            m_pipQueue         = schedule.SchedulingQueue;
            m_scheduler        = schedule.Scheduler;
            m_operationTracker = m_scheduler.OperationTracker;
            m_environment      = m_scheduler;
            m_environment.ContentFingerprinter.FingerprintSalt            = BuildStartData.FingerprintSalt;
            m_environment.State.PipEnvironment.MasterEnvironmentVariables = BuildStartData.EnvironmentVariables;
            m_resultSerializer        = new ExecutionResultSerializer(maxSerializableAbsolutePathIndex: schedule.MaxSerializedAbsolutePath, executionContext: m_scheduler.Context);
            m_forwardingEventListener = new ForwardingEventListener(this);

            bool success = await SendAttachCompletedAfterProcessBuildRequestStartedAsync();

            // Wait until the build finishes or we discovered that the master is dead
            success &= await ExitCompletion;

            success &= !m_hasFailures;
            if (m_masterFailureMessage != null)
            {
                Logger.Log.DistributionWorkerExitFailure(m_appLoggingContext, m_masterFailureMessage);
            }

            m_pipQueue.SetAsFinalized();

            return(success);
        }
Exemplo n.º 2
0
        /// <nodoc/>
        public WorkerNotificationManager(WorkerService workerService, EngineSchedule schedule, IPipExecutionEnvironment environment, DistributionServices services)
        {
            WorkerService        = workerService;
            DistributionServices = services;

            m_scheduler   = schedule.Scheduler;
            m_environment = environment;

            m_forwardingEventListener = new ForwardingEventListener(this);
            m_sendCancellationSource  = new CancellationTokenSource();
            m_pipResultListener       = new PipResultListener(this, schedule, environment);
            m_sendThread = new Thread(() => SendNotifications(m_sendCancellationSource.Token));
        }
Exemplo n.º 3
0
        public void Start(IOrchestratorClient orchestratorClient, EngineSchedule schedule, IPipResultSerializer serializer)
        {
            Contract.AssertNotNull(orchestratorClient);

            m_orchestratorClient      = orchestratorClient;
            m_executionLogTarget      = new NotifyOrchestratorExecutionLogTarget(this, schedule);
            m_forwardingEventListener = new ForwardingEventListener(this);
            m_pipResultListener       = new PipResultListener(this, serializer);
            m_sendCancellationSource  = new CancellationTokenSource();
            m_sendThread = new Thread(() => SendNotifications(m_sendCancellationSource.Token));
            m_sendThread.Start();

            m_started = true;
        }
Exemplo n.º 4
0
        internal void Start(EngineSchedule schedule)
        {
            Contract.Requires(schedule != null);
            Contract.Requires(schedule.Scheduler != null);
            Contract.Requires(schedule.SchedulingQueue != null);
            Contract.Assert(AttachCompletion.IsCompleted && AttachCompletion.GetAwaiter().GetResult(), "ProcessBuildRequests called before finishing attach on worker");

            m_workerPipStateManager = new WorkerServicePipStateManager(this);
            m_pipTable         = schedule.PipTable;
            m_pipQueue         = schedule.SchedulingQueue;
            m_scheduler        = schedule.Scheduler;
            m_operationTracker = m_scheduler.OperationTracker;
            m_environment      = m_scheduler;
            m_environment.ContentFingerprinter.FingerprintSalt            = BuildStartData.FingerprintSalt;
            m_environment.State.PipEnvironment.MasterEnvironmentVariables = BuildStartData.EnvironmentVariables;
            m_resultSerializer        = new ExecutionResultSerializer(maxSerializableAbsolutePathIndex: schedule.MaxSerializedAbsolutePath, executionContext: m_scheduler.Context);
            m_forwardingEventListener = new ForwardingEventListener(this);
        }