Example #1
0
        public JobBlockingActionPolicy(CoordinatorEnvironment environment, IJobBlockingPolicyManager jobBlockingPolicyManager)
        {
            environment.Validate("environment");

            this.jobBlockingPolicyManager = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager");
            this.traceType = environment.CreateTraceType("PolicyJobBlocking");
        }
Example #2
0
        public async Task UpdatePolicyAsyncTest1Async()
        {
            var propertyManager = new MockPropertyManagerWrapper
            {
                SubmitPropertyBatchAsyncFunc = WorkflowForUpdatePolicyAsyncTest1
            };

            // mock a result where we return ok on initialize, then an error for the first operation
            // and return okay when an internal Read is called

            IJobBlockingPolicyManager jobPolicyManager = await CreateAsync(propertyManager).ConfigureAwait(false);

            try
            {
                await jobPolicyManager.UpdatePolicyAsync(JobBlockingPolicy.BlockNone).ConfigureAwait(false);

                Assert.Fail("Expected to throw an exception");
            }
            catch (FabricException ex)
            {
                Assert.AreEqual(
                    ex.ErrorCode,
                    FabricErrorCode.WriteConflict,
                    "Throwing FabricException as expected because of version mismatch");
            }

            Assert.AreEqual(
                jobPolicyManager.Policy,
                JobBlockingPolicy.BlockAllJobs,
                "Update policy failed as expected, but reading policy from store succeeded");
        }
Example #3
0
 public DefaultActionPolicyFactory(
     CoordinatorEnvironment environment,
     IJobBlockingPolicyManager jobBlockingPolicyManager,
     IAllowActionMap allowActionMap)
 {
     this.environment = environment.Validate("environment");
     this.jobBlockingPolicyManager = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager");
     this.allowActionMap           = allowActionMap.Validate("allowActionMap");
 }
Example #4
0
        public async Task InitializeTest1Async()
        {
            var propertyManager = new MockPropertyManagerWrapper
            {
                SubmitPropertyBatchAsyncFunc = WorkflowForInitializeTest1
            };

            IJobBlockingPolicyManager jobPolicyManager = await CreateAsync(propertyManager).ConfigureAwait(false);

            Assert.IsNotNull(jobPolicyManager);
            Assert.AreEqual(
                jobPolicyManager.Policy,
                JobBlockingPolicy.BlockAllJobs,
                "Verifying if new policy has been successfully read after Initialize");
        }
Example #5
0
        private async Task <IJobBlockingPolicyManager> CreateAsync(IPropertyManagerWrapper propertyManager)
        {
            var versionedPropertyStore = await VersionedPropertyStore.CreateAsync(
                Guid.NewGuid(),
                TraceType,
                new Uri(Constants.StoreName),
                propertyManager,
                retryPolicyFactory).ConfigureAwait(false);

            IJobBlockingPolicyManager jobPolicyManager =
                await JobBlockingPolicyManager.CreateAsync(
                    TraceType, versionedPropertyStore).ConfigureAwait(false);

            return(jobPolicyManager);
        }
Example #6
0
        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();
        }
Example #7
0
        public async Task UpdatePolicyAsyncTest3Async()
        {
            var propertyManager = new MockPropertyManagerWrapper();

            propertyManager.SubmitPropertyBatchAsyncFunc = WorkflowForUpdatePolicyAsyncTest3;

            IJobBlockingPolicyManager jobPolicyManager = await CreateAsync(propertyManager).ConfigureAwait(false);

            Assert.AreEqual(
                jobPolicyManager.Policy,
                JobBlockingPolicy.BlockNone,
                "Verifying if starting state of policy is as expected");

            await jobPolicyManager.UpdatePolicyAsync(JobBlockingPolicy.BlockAllJobs).ConfigureAwait(false);

            Assert.AreEqual(
                jobPolicyManager.Policy,
                JobBlockingPolicy.BlockAllJobs,
                "Verifying if new policy has been successfully applied");
        }
        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);
        }
Example #9
0
        public async Task MigrationToNamespacePrefixTestAsync()
        {
            var mockVersionedPropertyStore = new MockVersionedPropertyStore();

            IJobBlockingPolicyManager jobPolicyManager = await JobBlockingPolicyManager.CreateAsync(
                TraceType, mockVersionedPropertyStore).ConfigureAwait(false);

            Assert.AreEqual(jobPolicyManager.Policy, JobBlockingPolicy.BlockNone);

            await jobPolicyManager.UpdatePolicyAsync(JobBlockingPolicy.BlockAllJobs).ConfigureAwait(false);

            Assert.AreEqual(jobPolicyManager.Policy, JobBlockingPolicy.BlockAllJobs);

            // IS is migrated to parallel mode with per-tenant jobblocking policy option
            var mockTenantSpecificVersionedPropertyStore = new MockVersionedPropertyStore();
            IJobBlockingPolicyManager jobPolicyManager2  = await JobBlockingPolicyManager.CreateAsync(
                TraceType, mockTenantSpecificVersionedPropertyStore, mockVersionedPropertyStore).ConfigureAwait(false);

            // the namespace properties should have the same policy as the existing old properties
            Assert.AreEqual(jobPolicyManager2.Policy, JobBlockingPolicy.BlockAllJobs);

            var activityId = Guid.NewGuid();
            var vkv        = await mockVersionedPropertyStore
                             .GetValueAsync(activityId, JobBlockingPolicyManager.PolicyPropertyName, JobBlockingPolicyManager.PolicyVersionName)
                             .ConfigureAwait(false);

            Assert.IsNotNull(vkv);

            var vkv2 = await mockTenantSpecificVersionedPropertyStore
                       .GetValueAsync(activityId, JobBlockingPolicyManager.PolicyPropertyName, JobBlockingPolicyManager.PolicyVersionName)
                       .ConfigureAwait(false);

            Assert.IsNotNull(vkv2);

            Assert.AreEqual(vkv.Value, vkv2.Value);
        }