Ejemplo n.º 1
0
        public async Task StateChanged(JobState jobState)
        {
            //TODO: Validate jobState
            if (jobState == null)
            {
                var ci = Context.GetClient();
                _logger.LogError($"{nameof(jobState)} is null from {ci}");
                return;
            }
            var oldJobState = await _store.GetJobState(jobState.TraceId, jobState.Client, jobState.Sharding);

            if (oldJobState == null)
            {
                var ci = Context.GetClient();
                _logger.LogError($"{ci} {jobState.TraceId}, {jobState.Client}, {jobState.Sharding} is not exists");
                return;
            }
            else
            {
                jobState.Id = oldJobState.Id;
                await _store.UpdateJobState(jobState);
            }

            switch (jobState.State)
            {
            case State.Exit:
                if (await _store.IsJobExited(jobState.JobId))
                {
                    await _store.ChangeJobState(jobState.JobId, State.Exit);
                }

                break;

            case State.Running:
                await _store.ChangeJobState(jobState.JobId, State.Running);

                break;
            }
        }