public RequestRepairAction(CoordinatorEnvironment environment, IPolicyAgentClient policyAgentClient, IRepairTask repairTask, RepairActionProvider repairActionProvider) : base(environment, ActionType.RequestRepair) { this.policyAgentClient = policyAgentClient.Validate("policyAgentClient"); this.repairTask = repairTask.Validate("repairTask"); this.repairActionProvider = repairActionProvider.Validate("repairActionProvider"); }
private async Task ApproveAllJobsAsync(Guid activityId, CancellationToken cancellationToken) { // Create the PA client; this will fail when MR is off, which it is expected to be IPolicyAgentClient policyAgentClient = await this.policyAgentClientAsyncFactory(); IPolicyAgentDocumentForTenant doc = await policyAgentClient.GetDocumentAsync(activityId, cancellationToken); if (doc == null) { // Parallel job mode is not enabled throw new InvalidOperationException("Failed to get job info. Verify that job parallelism is enabled for this tenant."); } string docString = CoordinatorHelper.FormatDocumentForTracing(doc); traceType.WriteInfo("Received document: {0}", docString); Dictionary <Guid, JobStepResponseEnum> jobResponses = new Dictionary <Guid, JobStepResponseEnum>(); foreach (var job in doc.Jobs) { string message; if (IsJobWaitingForApproval(job)) { message = $"Auto-approving job {job.Id}"; jobResponses.Add(job.Id, JobStepResponseEnum.Acknowledged); } else { message = $"Ignoring job {job.Id} in state that does not require tenant approval"; } traceType.WriteInfo( "{0}: {1} {2} ({3}/{4})", message, job.GetImpactAction(), job.JobStatus, job.JobStep == null ? "-" : job.JobStep.ImpactStep.ToString(), job.JobStep == null ? "-" : job.JobStep.AcknowledgementStatus.ToString()); } if (jobResponses.Count > 0) { // Send all job responses (if any) as a single batch response await policyAgentClient.SendJobResponseAsync( activityId, doc.JobDocumentIncarnation, jobResponses, "Auto-approved by Service Fabric because coordination is disabled", cancellationToken); } else { traceType.WriteInfo("No jobs to approve"); } }
public ActionFactory( CoordinatorEnvironment environment, IPolicyAgentClient policyAgentClient, IRepairManager repairManager, RepairActionProvider repairActionProvider) { this.environment = environment.Validate("environment"); this.policyAgentClient = policyAgentClient.Validate("policyAgentClient"); this.repairManager = repairManager.Validate("repairManager"); this.repairActionProvider = repairActionProvider.Validate("repairActionProvider"); this.jobResponseMap = new Dictionary <Guid, JobStepResponseEnum>(); }
public ReconcilerTest() { configSection = new ConfigSection(Constants.TraceType, configStore, "IS/Reconciler"); var env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", configSection, string.Empty, new MockInfrastructureAgentWrapper()); policyAgentClient = new PolicyAgentClient(env, new MockPolicyAgentService(), activityLogger); }
public CoordinatorCommandProcessor( CoordinatorEnvironment environment, IPolicyAgentClient policyAgentClient, IJobBlockingPolicyManager jobBlockingPolicyManager, IAllowActionMap allowActionMap) { this.environment = environment.Validate("environment"); this.policyAgentClient = policyAgentClient.Validate("policyAgentClient"); this.jobBlockingPolicyManager = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager"); this.allowActionMap = allowActionMap.Validate("allowActionMap"); this.traceType = environment.CreateTraceType("CommandProcessor"); this.commandHandler = new CommandHandler(this.traceType); RegisterCommandHandlers(); }
/// <remarks> /// If <see cref="configSettings"/> is null, a default value is used. /// </remarks> public MockInfrastructureCoordinatorFactory( IDictionary <string, string> configSettings = null, IPolicyAgentClient policyAgentClient = null, IRepairManager repairManager = null) { this.configSettings = configSettings != null ? new Dictionary <string, string>(configSettings, StringComparer.OrdinalIgnoreCase) : new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(Constants.TraceType, new MockConfigStore(), "ConfigSection"), string.Empty, new MockInfrastructureAgentWrapper()); this.policyAgentClient = policyAgentClient ?? new PolicyAgentClient(env, new PolicyAgentServiceWrapper(env, activityLogger), activityLogger); this.repairManager = repairManager ?? new MockRepairManager(); }
public AzureParallelInfrastructureCoordinator( CoordinatorEnvironment environment, string tenantId, IPolicyAgentClient policyAgentClient, IRepairManager repairManager, IHealthClient healthClient, ICoordinatorCommandProcessor coordinatorCommandProcessor, IJobBlockingPolicyManager jobBlockingPolicyManager, IActionPolicyFactory actionPolicyFactory, IActivityLogger activityLogger, Guid partitionId, long replicaId) { this.environment = environment.Validate("environment"); this.tenantId = tenantId.Validate("tenantId"); this.partitionId = partitionId; this.policyAgentClient = policyAgentClient.Validate("policyAgentClient"); this.traceType = environment.CreateTraceType("Coordinator"); this.actionTraceType = environment.CreateTraceType("Action"); this.repairManager = repairManager.Validate("repairManager"); this.healthClient = healthClient.Validate("healthClient"); this.configSection = environment.Config; this.coordinatorCommandProcessor = coordinatorCommandProcessor.Validate("coordinatorCommandProcessor"); this.jobBlockingPolicyManager = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager"); this.actionPolicies = actionPolicyFactory.Validate("actionPolicyFactory").Create(); this.activityLogger = activityLogger.Validate("activityLogger"); var assembly = this.GetType().GetTypeInfo().Assembly; assemblyFileVersion = FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion; var healthWatchdogFactory = new RoleInstanceHealthWatchdogFactory(configSection, healthClient); roleInstanceHealthWatchdog = healthWatchdogFactory.Create(Constants.ConfigKeys.ConfigKeyPrefix); }
public CancelJobAction(CoordinatorEnvironment environment, IPolicyAgentClient policyAgentClient, ITenantJob tenantJob) : base(environment, ActionType.None) { this.policyAgentClient = policyAgentClient.Validate("policyAgentClient"); this.tenantJob = tenantJob.Validate("tenantJob"); }