internal void Start(IMasterClient masterClient) { Contract.AssertNotNull(masterClient); m_masterClient = masterClient; m_executionLogTarget = new NotifyMasterExecutionLogTarget(this, m_environment.Context, m_scheduler.PipGraph.GraphId, m_scheduler.PipGraph.MaxAbsolutePathIndex); m_scheduler.AddExecutionLogTarget(m_executionLogTarget); m_sendThread.Start(); }
private async Task <bool> SendAttachCompletedAfterProcessBuildRequestStartedAsync() { if (!m_isGrpcEnabled) { #if !DISABLE_FEATURE_BOND_RPC m_bondMasterClient.Start(m_services, OnConnectionTimeOutAsync); #endif } var cacheValidationContent = Guid.NewGuid().ToByteArray(); var cacheValidationContentHash = ContentHashingUtilities.HashBytes(cacheValidationContent); var possiblyStored = await m_environment.Cache.ArtifactContentCache.TryStoreAsync( new MemoryStream(cacheValidationContent), cacheValidationContentHash); if (!possiblyStored.Succeeded) { Logger.Log.DistributionFailedToStoreValidationContentToWorkerCacheWithException( m_appLoggingContext, cacheValidationContentHash.ToHex(), possiblyStored.Failure.DescribeIncludingInnerFailures()); Exit(timedOut: true, "Failed to validate retrieve content from master via cache"); return(false); } var attachCompletionInfo = new AttachCompletionInfo { WorkerId = WorkerId, MaxConcurrency = m_maxProcesses, AvailableRamMb = m_scheduler.LocalWorker.TotalMemoryMb, WorkerCacheValidationContentHash = cacheValidationContentHash.ToBondContentHash(), }; Contract.Assert(attachCompletionInfo.WorkerCacheValidationContentHash != null, "worker cache validation content hash is null"); var attachCompletionResult = await m_masterClient.AttachCompletedAsync(attachCompletionInfo); if (!attachCompletionResult.Succeeded) { Logger.Log.DistributionInactiveMaster(m_appLoggingContext, (int)attachCompletionResult.Duration.TotalMinutes); Exit(timedOut: true, "Failed to attach to master"); return(true); } else { m_notifyMasterExecutionLogTarget = new NotifyMasterExecutionLogTarget(WorkerId, m_masterClient, m_environment.Context, m_scheduler.PipGraph.GraphId, m_scheduler.PipGraph.MaxAbsolutePathIndex, m_services); m_scheduler.AddExecutionLogTarget(m_notifyMasterExecutionLogTarget); m_sendThread.Start(); } return(true); }
private async Task <bool> SendAttachCompletedAfterProcessBuildRequestStartedAsync() { var cacheValidationContent = Guid.NewGuid().ToByteArray(); var cacheValidationContentHash = ContentHashingUtilities.HashBytes(cacheValidationContent); var possiblyStored = await m_environment.Cache.ArtifactContentCache.TryStoreAsync( new MemoryStream(cacheValidationContent), cacheValidationContentHash); if (!possiblyStored.Succeeded) { Logger.Log.DistributionFailedToStoreValidationContentToWorkerCacheWithException( m_appLoggingContext, cacheValidationContentHash.ToHex(), possiblyStored.Failure.DescribeIncludingInnerFailures()); Exit("Failed to validate retrieve content from master via cache", isUnexpected: true); return(false); } var attachCompletionInfo = new AttachCompletionInfo { WorkerId = WorkerId, MaxProcesses = m_config.Schedule.MaxProcesses, MaxMaterialize = m_config.Schedule.MaxMaterialize, AvailableRamMb = m_scheduler.LocalWorker.TotalRamMb, AvailableCommitMb = m_scheduler.LocalWorker.TotalCommitMb, WorkerCacheValidationContentHash = cacheValidationContentHash.ToBondContentHash(), }; Contract.Assert(attachCompletionInfo.WorkerCacheValidationContentHash != null, "worker cache validation content hash is null"); var attachCompletionResult = await m_masterClient.AttachCompletedAsync(attachCompletionInfo); if (!attachCompletionResult.Succeeded) { Exit($"Failed to attach to master. Duration: {(int)attachCompletionResult.Duration.TotalMinutes}", isUnexpected: true); return(true); } else { m_notifyMasterExecutionLogTarget = new NotifyMasterExecutionLogTarget(WorkerId, m_masterClient, m_environment.Context, m_scheduler.PipGraph.GraphId, m_scheduler.PipGraph.MaxAbsolutePathIndex, m_services); m_scheduler.AddExecutionLogTarget(m_notifyMasterExecutionLogTarget); m_sendThread.Start(); } return(true); }