private async Task StartJobTaskAsync(CancellationToken cancellationToken) { traceType.WriteInfo("Starting job task."); var activityId = Guid.NewGuid(); try { await ProcessPolicyAgentDocumentAsync(cancellationToken).ConfigureAwait(false); activityLogger.LogOperation(activityId, this.coordinatorRunAsyncStartTime); } catch (OperationCanceledException) { traceType.WriteInfo("Start job task canceled."); activityLogger.LogOperation(activityId, this.coordinatorRunAsyncStartTime); } catch (Exception ex) { traceType.WriteWarning("Error processing policy agent document in StartJobTask. Exiting process. Exception: {0}", ex); activityLogger.LogOperation(activityId, this.coordinatorRunAsyncStartTime, OperationResult.Failure, ex); // the Program's Main method is waiting on this global event. Once set, it exits the process. // Workaround over using Environment.Exit which isn't supported on CoreCLR. Please see this // method's comments for more. ProcessCloser.ExitEvent.Set(); } }
public async Task <IPolicyAgentDocumentForTenant> GetDocumentAsync(Guid activityId, CancellationToken cancellationToken) { var startTime = DateTimeOffset.UtcNow; try { byte[] responseBytes = await GetDocumentFromWireServerAsync().ConfigureAwait(false); var doc = responseBytes.GetBondObjectFromPayload <PolicyAgentDocumentForTenant>(); traceType.WriteInfo("Successfully got policy agent document ({0} bytes)", responseBytes.Length); activityLogger.LogOperation(activityId, startTime); // Absence of the JobInfo property indicates that the tenant is not configured in parallel mode. if (doc.JobInfo == null) { traceType.WriteWarning("Policy agent document does not contain job info."); return(null); } return(new PolicyAgentDocumentForTenantWrapper(doc)); } catch (Exception ex) { string text = "Unable to get policy document. Error: {0}".ToString(ex); traceWriteConditionalWarning("{0}", text); activityLogger.LogOperation(activityId, startTime, OperationResult.Failure, ex); throw new ManagementException(text, ex); } }
public async Task RemoveNodeStateAsync(Guid activityId, string nodeName, TimeSpan timeout, CancellationToken cancellationToken) { nodeName.Validate("nodeName"); var startTime = DateTimeOffset.UtcNow; try { await this.fabricClient.ClusterManager.RemoveNodeStateAsync(nodeName, timeout, cancellationToken); traceType.WriteInfo("RemoveNodeState succeeded for {0}", nodeName); activityLogger.LogOperation(activityId, startTime, OperationResult.Success, null, nodeName); } catch (Exception ex) { traceType.WriteWarning("RemoveNodeState failed for {0}: {1}", nodeName, ex); activityLogger.LogOperation(activityId, startTime, OperationResult.Failure, ex, nodeName); throw; } }