/// <inheritdoc/> protected override void ProcessRecordInternal() { RepairTargetDescriptionBase repairTargetDescriptionBase = null; if (this.Node.IsPresent) { repairTargetDescriptionBase = new NodeRepairTargetDescription( nodeNames: this.NodeNames); } RepairImpactDescriptionBase repairImpactDescriptionBase = null; if (this.Node.IsPresent) { repairImpactDescriptionBase = new NodeRepairImpactDescription( nodeImpactList: this.NodeImpactList); } var repairTaskHistory = new RepairTaskHistory( createdUtcTimestamp: this.CreatedUtcTimestamp, claimedUtcTimestamp: this.ClaimedUtcTimestamp, preparingUtcTimestamp: this.PreparingUtcTimestamp, approvedUtcTimestamp: this.ApprovedUtcTimestamp, executingUtcTimestamp: this.ExecutingUtcTimestamp, restoringUtcTimestamp: this.RestoringUtcTimestamp, completedUtcTimestamp: this.CompletedUtcTimestamp, preparingHealthCheckStartUtcTimestamp: this.PreparingHealthCheckStartUtcTimestamp, preparingHealthCheckEndUtcTimestamp: this.PreparingHealthCheckEndUtcTimestamp, restoringHealthCheckStartUtcTimestamp: this.RestoringHealthCheckStartUtcTimestamp, restoringHealthCheckEndUtcTimestamp: this.RestoringHealthCheckEndUtcTimestamp); var repairTask = new RepairTask( taskId: this.TaskId, state: this.State, action: this.Action, version: this.Version, description: this.Description, flags: this.Flags, target: repairTargetDescriptionBase, executor: this.Executor, executorData: this.ExecutorData, impact: repairImpactDescriptionBase, resultStatus: this.ResultStatus, resultCode: this.ResultCode, resultDetails: this.ResultDetails, history: repairTaskHistory, preparingHealthCheckState: this.PreparingHealthCheckState, restoringHealthCheckState: this.RestoringHealthCheckState, performPreparingHealthCheck: this.PerformPreparingHealthCheck, performRestoringHealthCheck: this.PerformRestoringHealthCheck); var result = this.ServiceFabricClient.Repairs.UpdateRepairExecutionStateAsync( repairTask: repairTask, cancellationToken: this.CancellationToken).GetAwaiter().GetResult(); if (result != null) { this.WriteObject(this.FormatOutput(result)); } }
/// <summary> /// Serializes the object to JSON. /// </summary> /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="obj">The object to serialize to JSON.</param> internal static void Serialize(JsonWriter writer, NodeRepairTargetDescription obj) { // Required properties are always serialized, optional properties are serialized when not null. writer.WriteStartObject(); writer.WriteProperty(obj.Kind.ToString(), "Kind", JsonWriterExtensions.WriteStringValue); if (obj.NodeNames != null) { writer.WriteEnumerableProperty(obj.NodeNames, "NodeNames", (w, v) => writer.WriteStringValue(v)); } writer.WriteEndObject(); }
/// <summary> /// Gets the target node name for repair tasks. /// </summary> /// <param name="repairTask"></param> /// <returns>The target node name or <c>null</c> if the repair task didn't match the expected format.</returns> public static IList <string> GetTargetNodeNames(this IRepairTask repairTask) { repairTask.Validate("repairTask"); if (repairTask.Target == null || repairTask.Target.Kind != RepairTargetKind.Node) { Constants.TraceType.WriteInfo("Repair task {0}: ignoring unknown target type {1}", repairTask.TaskId, repairTask.Target); return(null); } NodeRepairTargetDescription targetDescription = (NodeRepairTargetDescription)repairTask.Target; return(targetDescription.Nodes); }
private static string GetTargetNodeName(RepairTask repairTask) { if (repairTask.Target == null || repairTask.Target.Kind != RepairTargetKind.Node) { Trace.WriteInfo(TraceType, "Repair task {0}: ignoring unknown target type {1}", repairTask.TaskId, repairTask.Target); return(null); } NodeRepairTargetDescription targetDescription = (NodeRepairTargetDescription)repairTask.Target; if (targetDescription.Nodes.Count != 1) { Trace.WriteInfo(TraceType, "Repair task {0}: ignoring bad target count {1}", repairTask.TaskId, targetDescription.Nodes.Count); return(null); } string targetNodeName = targetDescription.Nodes[0]; return(targetNodeName); }
public async Task ExecuteAsync(IRepairManager repairManager) { string taskId = GenerateTaskId(this.record.RecordId, DateTime.UtcNow); var repairTask = repairManager.NewRepairTask(taskId, this.record.RepairType.ToString()); repairTask.State = RepairTaskState.Preparing; repairTask.Executor = this.serviceName; var target = new NodeRepairTargetDescription(this.record.MachineName); repairTask.Target = target; var impact = new NodeRepairImpactDescription(); impact.ImpactedNodes.Add(new NodeImpact(this.record.MachineName, this.impactLevel)); repairTask.Impact = impact; repairTask.PerformPreparingHealthCheck = this.performHealthCheck; await repairManager.CreateRepairTaskAsync(Guid.Empty, repairTask); }