public AzureParallelInfrastructureCoordinatorFactory(
            Uri serviceName,
            IConfigStore configStore,
            string configSectionName,
            Guid partitionId,
            long replicaId,
            IInfrastructureAgentWrapper agent)
        {
            this.serviceName = serviceName.Validate("serviceName");
            configStore.Validate("configStore");
            configSectionName.Validate("configSectionName");
            this.agent = agent.Validate("agent");

            this.configSection = new ConfigSection(TraceType, configStore, configSectionName);

            this.partitionId = partitionId;
            this.replicaId   = replicaId;

            try
            {
                this.tenantId = AzureHelper.GetTenantId(configSection);
            }
            catch (Exception ex)
            {
                // this happens on the Linux environment (since there is no registry)
                this.tenantId = PartitionIdPrefix + partitionId;
                TraceType.WriteWarning("Unable to get tenant Id from configuration. Using partition Id '{0}' text instead. Exception: {1}", this.tenantId, ex);
            }

            // TODO use tenant ID or config section name suffix as base trace ID?
            this.env            = new CoordinatorEnvironment(this.serviceName.AbsoluteUri, this.configSection, tenantId, this.agent);
            this.activityLogger = new ActivityLoggerFactory().Create(env.CreateTraceType("Event"));

            this.policyAgentServiceWrapper = new PolicyAgentServiceWrapper(env, activityLogger);
        }
Exemplo n.º 2
0
        public AzureParallelDisabledCoordinator(
            CoordinatorEnvironment environment,
            string tenantId,
            Func <Task <IPolicyAgentClient> > policyAgentClientAsyncFactory,
            IRepairManager repairManager,
            IHealthClient healthClient,
            IActivityLogger activityLogger,
            Guid partitionId,
            long replicaId)
        {
            this.environment = environment.Validate("environment");
            this.tenantId    = tenantId.Validate("tenantId");
            this.partitionId = partitionId;
            this.policyAgentClientAsyncFactory = policyAgentClientAsyncFactory.Validate("policyAgentClientAsyncFactory");

            this.traceType = environment.CreateTraceType("DisabledCoordinator");

            this.repairManager = repairManager.Validate("repairManager");
            this.healthClient  = healthClient.Validate("healthClient");

            this.configSection  = environment.Config;
            this.activityLogger = activityLogger.Validate("activityLogger");

            var assembly = this.GetType().GetTypeInfo().Assembly;

            assemblyFileVersion = FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion;
        }
Exemplo n.º 3
0
        public JobBlockingActionPolicy(CoordinatorEnvironment environment, IJobBlockingPolicyManager jobBlockingPolicyManager)
        {
            environment.Validate("environment");

            this.jobBlockingPolicyManager = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager");
            this.traceType = environment.CreateTraceType("PolicyJobBlocking");
        }
        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);
        }
Exemplo n.º 5
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();
        }
        public IInfrastructureCoordinator Create()
        {
            var repairManager = new ServiceFabricRepairManagerFactory(env, activityLogger).Create();

            if (repairManager == null)
            {
                const string message = "Unable to create Repair Manager client; cannot continue further.";
                TraceType.WriteWarning(message);
                throw new ManagementException(message);
            }

            var policyAgentClient = new PolicyAgentClient(env, policyAgentServiceWrapper, activityLogger);

            var retryPolicyFactory = new LinearRetryPolicyFactory(
                env.DefaultTraceType,
                InfrastructureService.Constants.BackoffPeriodInMilliseconds,
                InfrastructureService.Constants.MaxRetryAttempts,
                AzureHelper.IsRetriableException);

            string tenantSpecificStoreName = "{0}/{1}".ToString(InfrastructureService.Constants.StoreName, configSection.Name);

            var tenantSpecificVersionedPropertyStore = VersionedPropertyStore.CreateAsync(
                Guid.NewGuid(),
                env.CreateTraceType("PropertyStore"),
                new Uri(tenantSpecificStoreName),
                new PropertyManagerWrapper(),
                retryPolicyFactory).GetAwaiter().GetResult();

            // if this exists, job blocking policy manager will migrate job blocking policy properties
            // from this one to the tenant-specific store.
            var versionedPropertyStore = VersionedPropertyStore.CreateAsync(
                Guid.NewGuid(),
                env.CreateTraceType("PropertyStoreOld"),
                new Uri(InfrastructureService.Constants.StoreName),
                new PropertyManagerWrapper(),
                retryPolicyFactory).GetAwaiter().GetResult();

            var jobBlockingPolicyManager = JobBlockingPolicyManager.CreateAsync(
                env.CreateTraceType("JobBlockingPolicyManager"),
                tenantSpecificVersionedPropertyStore,
                versionedPropertyStore).GetAwaiter().GetResult();

            var allowActionMap = new AllowActionMap();
            var coordinatorCommandProcessor = new CoordinatorCommandProcessor(
                env,
                policyAgentClient,
                jobBlockingPolicyManager,
                allowActionMap);
            var mappedPolicyFactory = new DefaultActionPolicyFactory(env, jobBlockingPolicyManager, allowActionMap);

            var coordinator =
                new AzureParallelInfrastructureCoordinator(
                    env,
                    tenantId,
                    policyAgentClient,
                    repairManager,
                    new ServiceFabricHealthClient(),
                    coordinatorCommandProcessor,
                    jobBlockingPolicyManager,
                    mappedPolicyFactory,
                    activityLogger,
                    partitionId,
                    replicaId);

            return(coordinator);
        }
Exemplo n.º 7
0
 public JobClassifier(CoordinatorEnvironment environment)
 {
     this.config    = environment.Config;
     this.traceType = environment.CreateTraceType("JobClassifier");
 }
Exemplo n.º 8
0
 public ImpactTranslator(CoordinatorEnvironment environment)
 {
     environment.Validate("environment");
     this.configSection = environment.Config;
     this.tracer        = environment.CreateTraceType("ImpactTranslator");
 }
Exemplo n.º 9
0
 public JobThrottlingActionPolicy(CoordinatorEnvironment environment)
 {
     environment.Validate("environment");
     this.configSection = environment.Config;
     this.traceType     = environment.CreateTraceType("PolicyJobThrottling");
 }