public static int GetDoc(string[] args) { CoordinatorEnvironment env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(Constants.TraceType, new MockConfigStore(), "ConfigSection"), string.Empty, new MockInfrastructureAgentWrapper()); Uri zeroSdkUri = null; if (args.Length >= 2) { zeroSdkUri = new Uri(args[1], UriKind.Absolute); } var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var pac = new PolicyAgentClient(env, new PolicyAgentServiceWrapper(env, activityLogger, zeroSdkUri), activityLogger); IPolicyAgentDocumentForTenant doc = pac.GetDocumentAsync(Guid.NewGuid(), CancellationToken.None).GetAwaiter().GetResult(); Constants.TraceType.ConsoleWriteLine("Doc: {0}", doc); foreach (ITenantJob job in doc.Jobs) { Constants.TraceType.ConsoleWriteLine(job.ToJson()); } foreach (RoleInstanceHealthInfo health in doc.RoleInstanceHealthInfos) { Constants.TraceType.ConsoleWriteLine(health.ToJson()); } return(0); }
public static int CreateRepairTask(string[] args) { const string DefaultRepairTaskIdFormat = "InfrastructureService/{0}"; string repairTaskId = string.Format(CultureInfo.InvariantCulture, DefaultRepairTaskIdFormat, Guid.NewGuid()); var nodeNames = args[1].Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); var action = args[2]; var repairTask = new ClusterRepairTask(repairTaskId, action) // TODO { Description = "Manual repair task for testing", Target = new NodeRepairTargetDescription(nodeNames) }; var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var rm = new ServiceFabricRepairManagerFactory( new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(Constants.TraceType, new MockConfigStore(), "ConfigSection"), Constants.TraceTypeName, new MockInfrastructureAgentWrapper()), activityLogger, new [] { "paralleljobs1-bn-cs.cloudapp.net:19000" }).Create(); long status = rm.CreateRepairTaskAsync(Guid.NewGuid(), new ServiceFabricRepairTask(repairTask)).GetAwaiter().GetResult(); return((int)status); }
protected BaseWorkflowExecutor( IDictionary <string, string> configSettings = null, MockPolicyAgentService policyAgentService = null, MockRepairManager repairManager = null) { PolicyAgentService = policyAgentService ?? new MockPolicyAgentService(); 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()); var policyAgentClient = new PolicyAgentClient(env, PolicyAgentService, activityLogger); RepairManager = repairManager ?? new MockRepairManagerFactory().Create() as MockRepairManager; Coordinator = new MockInfrastructureCoordinatorFactory( configSettings, policyAgentClient, RepairManager).Create() as AzureParallelInfrastructureCoordinator; CompletedEvent = new ManualResetEvent(false); TestExecutionTimeInSeconds = 300; }
private static PolicyAgentClient CreatePolicyAgentClient() { CoordinatorEnvironment env = new CoordinatorEnvironment( ToolName, new NullConfigSection(), string.Empty, null); var traceType = new TraceType(ToolName); var activityLogger = new ActivityLoggerFactory().Create(traceType); var policyAgentServiceWrapper = new PolicyAgentServiceWrapper(env, activityLogger, new Uri("http://169.254.169.254:80/mrzerosdk")); var policyAgentClient = new PolicyAgentClient(env, policyAgentServiceWrapper, activityLogger); return(policyAgentClient); }
/// <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 static int AcknowledgeJob(string[] args) { CoordinatorEnvironment env = new CoordinatorEnvironment( "fabric:/System/InfrastructureService", new ConfigSection(Constants.TraceType, new MockConfigStore(), "ConfigSection"), string.Empty, new MockInfrastructureAgentWrapper()); Uri zeroSdkUri = null; if (args.Length >= 2) { zeroSdkUri = new Uri(args[1], UriKind.Absolute); } int incarnationNumber = int.Parse(args[2]); Guid jobId = Guid.Parse(args[3]); var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var pac = new PolicyAgentClient(env, new PolicyAgentServiceWrapper(env, activityLogger, zeroSdkUri), activityLogger); var jobResponseMap = new Dictionary <Guid, JobStepResponseEnum> { { jobId, JobStepResponseEnum.Acknowledged } }; try { pac.SendJobResponseAsync( Guid.NewGuid(), incarnationNumber, jobResponseMap, "{0} by operator command".ToString(JobStepResponseEnum.Acknowledged), CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine("{0} job response sent successfully", JobStepResponseEnum.Acknowledged); } catch (ManagementException ex) { Console.WriteLine("Error in management protocol while sending job response. Exception: {0}", ex); return(-1); } return(0); }
public IInfrastructureCoordinator Create() { string configSectionName = typeof(MockInfrastructureCoordinatorFactory).Name + "ConfigSection"; const string ConfigJobPollingIntervalInSecondsKeyName = Parallel.Constants.ConfigKeys.JobPollingIntervalInSeconds; var configStore = new MockConfigStore(); // loop faster in the ProcessManagementNotification loop of WindowsAzureInfrastructureCoordinator configStore.AddKeyValue(configSectionName, ConfigJobPollingIntervalInSecondsKeyName, "1"); foreach (var pair in configSettings) { configStore.AddKeyValue(configSectionName, pair.Key, pair.Value); } var partitionId = Guid.NewGuid(); var jobBlockingPolicyManager = new MockJobBlockingPolicyManager(); var activityLogger = new ActivityLoggerFactory().Create(Constants.TraceType); var configSection = new ConfigSection(Constants.TraceType, configStore, configSectionName); var allowActionMap = new AllowActionMap(); var env = new CoordinatorEnvironment("fabric:/System/InfrastructureService/Mock", configSection, "mytenant", new MockInfrastructureAgentWrapper()); var coordinatorCommandProcessor = new CoordinatorCommandProcessor(env, policyAgentClient, jobBlockingPolicyManager, allowActionMap); var coordinator = new AzureParallelInfrastructureCoordinator( env, "mytenant", policyAgentClient, repairManager, new MockHealthClient(), coordinatorCommandProcessor, jobBlockingPolicyManager, new DefaultActionPolicyFactory(env, jobBlockingPolicyManager, allowActionMap), activityLogger, partitionId, 0); return(coordinator); }