public async Task <string> UpdateJobStatusAsync(long id, UpdateJobStateDto dto) { var grain = _client.GetGrain <IJobGrain>(id); await grain.UpdateJobStateAsync(dto); return("success"); }
public async Task UpdateJobStateAsync(UpdateJobStateDto dto, bool outerCall = true) { if (dto.JobState == JobState.WaitingForActivation) { throw new Exception( $"cannot set {this.GetPrimaryKeyLong()}'s state to {JobState.WaitingForActivation}"); } if (outerCall && _state.CurrentJobState == JobState.WaitingForActivation) { throw new JobNotFoundException($"job Id not exist: {this.GetPrimaryKeyLong()}"); } if (_options.Value.CommonConfig.BlockStateUpdateAfterFinished && Helper.FinishedOrFaultedJobStates.Contains(_state.CurrentJobState)) { _logger.LogWarning( $"{this.GetPrimaryKeyLong()} append {dto.JobState} {dto.Message} with {_state.CurrentJobState} blocked"); return; } _state.StateChanges .Add(new StateChangeDto(dto.JobState, dto.Message)); await UpdateJobStatisticsAsync(); if (_state.ParentJobId.HasValue) { var parentGrain = GrainFactory.GetGrain <IJobGrainInMem>(_state.ParentJobId.Value); await parentGrain.OnChildStateChangeAsync(_state.JobId, _state.CurrentJobState); } await TryTriggerActionAsync(); }
public async Task <ReturnDto <string> > UpdateJobStatusInBufferAsync([FromRoute] Guid bufferId, [FromRoute] long id, [FromBody][Required] UpdateJobStateDto dto) { await _svc.UpdateJobStatusAsync(id, dto, bufferId); return(new ReturnDto <string>("OK")); }
public async Task UpdateJobStateAsync(UpdateJobStateDto dto, bool outerCall = true) { var beforeCategory = Helper.GetJobStateCategory(State.CurrentJobState); if (dto.JobState == JobState.WaitingForActivation) { throw new Exception( $"cannot set {this.GetPrimaryKeyLong()}'s state to {JobState.WaitingForActivation}"); } if (outerCall && State.CurrentJobState == JobState.WaitingForActivation) { throw new JobNotFoundException($"job Id not exist: {this.GetPrimaryKeyLong()}"); } if (_options.Value.CommonConfig.BlockStateUpdateAfterFinished && Helper.FinishedOrFaultedJobStates.Contains(State.CurrentJobState)) { _logger.LogWarning( $"{this.GetPrimaryKeyLong()} append {dto.JobState} {dto.Message} with {State.CurrentJobState} blocked"); return; } try { State.StateChanges .Add(new StateChangeDto(dto.JobState, dto.Message)); await UpdateJobStatisticsAsync(); var currentState = State.CurrentJobState; var currentCategory = Helper.GetJobStateCategory(currentState); if (State.ParentJobId.HasValue) { var parentGrain = GrainFactory.GetGrain <IJobGrain>(State.ParentJobId.Value); if (currentState == JobState.Running) { await parentGrain.OnChildRunningAsync(State.JobId); } if (beforeCategory != currentCategory) { await parentGrain.OnChildStateCategoryChangeAsync(State.JobId, currentCategory); } } await TryTriggerActionAsync(); } catch (Exception) { DeactivateOnIdle(); throw; } if (outerCall) { await WriteStateAsync(); } }
public override async Task UpdateJobStatesAsync(long id, UpdateJobStateDto dto) { var resp = await SendRequestAsync <string, UpdateJobStateDto>(HttpMethod.Put, $"api/jobTracker/update/{id}", dto); if (!resp.Result) { throw new Exception($"{nameof(UpdateJobStatesAsync)} failed {resp.Msg}"); } }
internal override async Task UpdateJobStatesWithBufferAsync(long id, UpdateJobStateDto dto, Guid bufferId) { var resp = await SendRequestAsync <string, UpdateJobStateDto>(HttpMethod.Put, $"api/bufferManager/{bufferId}/job/update/{id}", dto); if (!resp.Result) { throw new Exception($"{nameof(UpdateJobStatesWithBufferAsync)} failed {resp.Msg}"); } }
public async Task <string> UpdateJobStatusAsync(long id, UpdateJobStateDto dto) { var grain = _client.GetGrain <IJobGrain>(id); var job = await grain.GetJobEntityAsync(); if (dto.JobState == JobState.WaitingForActivation) { throw new Exception($"cannot set {id}'s state to {JobState.WaitingForActivation}"); } if (job.CurrentJobState == JobState.WaitingForActivation) { throw new Exception($"job Id not exist: {id}"); } await grain.UpdateJobStateAsync(dto); return("success"); }
public async Task UpdateJobStateAsync(UpdateJobStateDto dto, bool writeState = true) { var jobStateDto = new UpdateJobStateDtoInternal(dto); var previous = jobStateDto.JobState; if (Helper.FinishedOrWaitingForChildrenJobStates.Contains(jobStateDto.JobState)) { if (State.PendingChildrenCount > 0) { jobStateDto.JobState = JobState.WaitingForChildrenToComplete; } else { jobStateDto.JobState = State.FailedChildrenCount > 0 ? JobState.Faulted : JobState.RanToCompletion; } } if (previous != jobStateDto.JobState) { jobStateDto.AdditionMsg += $" (sys: {previous} -> {jobStateDto.JobState})"; } State.StateChanges .Add(new StateChangeDto(jobStateDto.JobState, jobStateDto.AdditionMsg)); if (State.ParentJobId.HasValue) { var summaryStateCategory = Helper.GetJobStateCategory(State.CurrentJobState); var parentGrain = GrainFactory.GetGrain <IJobGrain>(State.ParentJobId.Value); await parentGrain.OnChildStateChangeAsync(State.JobId, summaryStateCategory); } if (writeState) { await WriteStateAsync(); } }
public async Task <ReturnDto <string> > UpdateJobStatusAsync([FromRoute] long id, [FromBody][Required] UpdateJobStateDto dto) { return(new ReturnDto <string>(await _service.UpdateJobStatusAsync(id, dto))); }
internal abstract Task UpdateJobStatesWithBufferAsync(long id, UpdateJobStateDto dto, Guid bufferId);
public abstract Task UpdateJobStatesAsync(long id, UpdateJobStateDto dto);
public async Task UpdateJobStatesAsync(long id, UpdateJobStateDto dto) { await _client.UpdateJobStatesWithBufferAsync(id, dto, _scopeBufferId); }
public async Task UpdateJobStatusAsync(long id, UpdateJobStateDto dto, Guid bufferId) { RequestContext.Set(Constants.BufferIdKey, bufferId); var grain = _client.GetGrain <IJobGrainInMem>(id); await grain.UpdateJobStateAsync(dto); }
public UpdateJobStateDtoInternal(UpdateJobStateDto dto) { AdditionMsg = dto.Message; JobState = dto.JobState; }