This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new b2695def59 IGNITE-22525 .NET: Rename JobStatus to JobState and vice 
versa (#3999)
b2695def59 is described below

commit b2695def596eee4bc895b329679f36f1b21d56fa
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Thu Jun 27 14:56:42 2024 +0300

    IGNITE-22525 .NET: Rename JobStatus to JobState and vice versa (#3999)
---
 .../Apache.Ignite.Tests/Compute/ComputeTests.cs    | 30 +++++++-------
 .../dotnet/Apache.Ignite/Compute/IJobExecution.cs  |  2 +-
 .../dotnet/Apache.Ignite/Compute/JobState.cs       | 46 +++++++--------------
 .../dotnet/Apache.Ignite/Compute/JobStatus.cs      | 48 +++++++++++++++-------
 .../Apache.Ignite/Internal/Compute/Compute.cs      | 14 +++----
 .../Apache.Ignite/Internal/Compute/JobExecution.cs | 10 ++---
 6 files changed, 75 insertions(+), 75 deletions(-)

diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs 
b/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs
index c339fd19ea..1139619f86 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs
@@ -594,7 +594,7 @@ namespace Apache.Ignite.Tests.Compute
 
             var jobExecution = await Client.Compute.SubmitAsync(await 
GetNodeAsync(1), SleepJob, sleepMs);
 
-            await AssertJobStatus(jobExecution, JobState.Executing, 
beforeStart);
+            await AssertJobStatus(jobExecution, JobStatus.Executing, 
beforeStart);
         }
 
         [Test]
@@ -606,7 +606,7 @@ namespace Apache.Ignite.Tests.Compute
             var jobExecution = await Client.Compute.SubmitAsync(await 
GetNodeAsync(1), SleepJob, sleepMs);
             await jobExecution.GetResultAsync();
 
-            await AssertJobStatus(jobExecution, JobState.Completed, 
beforeStart);
+            await AssertJobStatus(jobExecution, JobStatus.Completed, 
beforeStart);
         }
 
         [Test]
@@ -617,14 +617,14 @@ namespace Apache.Ignite.Tests.Compute
             var jobExecution = await Client.Compute.SubmitAsync(await 
GetNodeAsync(1), ErrorJob, "unused");
             Assert.CatchAsync(async () => await jobExecution.GetResultAsync());
 
-            await AssertJobStatus(jobExecution, JobState.Failed, beforeStart);
+            await AssertJobStatus(jobExecution, JobStatus.Failed, beforeStart);
         }
 
         [Test]
         public async Task TestJobExecutionStatusNull()
         {
             var fakeJobExecution = new JobExecution<int>(
-                Guid.NewGuid(), Task.FromException<(int, JobStatus)>(new 
Exception("x")), (Compute)Client.Compute);
+                Guid.NewGuid(), Task.FromException<(int, JobState)>(new 
Exception("x")), (Compute)Client.Compute);
 
             var status = await fakeJobExecution.GetStatusAsync();
 
@@ -640,7 +640,7 @@ namespace Apache.Ignite.Tests.Compute
             var jobExecution = await Client.Compute.SubmitAsync(await 
GetNodeAsync(1), SleepJob, sleepMs);
             await jobExecution.CancelAsync();
 
-            await AssertJobStatus(jobExecution, JobState.Canceled, 
beforeStart);
+            await AssertJobStatus(jobExecution, JobStatus.Canceled, 
beforeStart);
         }
 
         [Test]
@@ -710,23 +710,23 @@ namespace Apache.Ignite.Tests.Compute
             Assert.AreEqual(expected, resVal);
         }
 
-        private static async Task AssertJobStatus<T>(IJobExecution<T> 
jobExecution, JobState state, Instant beforeStart)
+        private static async Task AssertJobStatus<T>(IJobExecution<T> 
jobExecution, JobStatus status, Instant beforeStart)
         {
-            JobStatus? status = await jobExecution.GetStatusAsync();
+            JobState? state = await jobExecution.GetStatusAsync();
 
-            Assert.IsNotNull(status);
-            Assert.AreEqual(jobExecution.Id, status!.Id);
-            Assert.AreEqual(state, status.State);
-            Assert.Greater(status.CreateTime, beforeStart);
-            Assert.Greater(status.StartTime, status.CreateTime);
+            Assert.IsNotNull(state);
+            Assert.AreEqual(jobExecution.Id, state!.Id);
+            Assert.AreEqual(status, state.Status);
+            Assert.Greater(state.CreateTime, beforeStart);
+            Assert.Greater(state.StartTime, state.CreateTime);
 
-            if (state is JobState.Canceled or JobState.Completed or 
JobState.Failed)
+            if (status is JobStatus.Canceled or JobStatus.Completed or 
JobStatus.Failed)
             {
-                Assert.Greater(status.FinishTime, status.StartTime);
+                Assert.Greater(state.FinishTime, state.StartTime);
             }
             else
             {
-                Assert.IsNull(status.FinishTime);
+                Assert.IsNull(state.FinishTime);
             }
         }
 
diff --git a/modules/platforms/dotnet/Apache.Ignite/Compute/IJobExecution.cs 
b/modules/platforms/dotnet/Apache.Ignite/Compute/IJobExecution.cs
index 5d050a1c2a..15ba72d0ca 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Compute/IJobExecution.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Compute/IJobExecution.cs
@@ -43,7 +43,7 @@ public interface IJobExecution<T>
     /// <returns>
     /// Job execution status. Can be <c>null</c> if the job status no longer 
exists due to exceeding the retention time limit.
     /// </returns>
-    Task<JobStatus?> GetStatusAsync();
+    Task<JobState?> GetStatusAsync();
 
     /// <summary>
     /// Cancels the job execution.
diff --git a/modules/platforms/dotnet/Apache.Ignite/Compute/JobState.cs 
b/modules/platforms/dotnet/Apache.Ignite/Compute/JobState.cs
index ada84bf8e6..de5f8f27cb 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Compute/JobState.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Compute/JobState.cs
@@ -17,38 +17,20 @@
 
 namespace Apache.Ignite.Compute;
 
+using System;
+using NodaTime;
+
 /// <summary>
 /// Compute job state.
 /// </summary>
-public enum JobState
-{
-    /// <summary>
-    /// The job is submitted and waiting for an execution start.
-    /// </summary>
-    Queued,
-
-    /// <summary>
-    /// The job is being executed.
-    /// </summary>
-    Executing,
-
-    /// <summary>
-    /// The job was unexpectedly terminated during execution.
-    /// </summary>
-    Failed,
-
-    /// <summary>
-    /// The job was executed successfully and the execution result was 
returned.
-    /// </summary>
-    Completed,
-
-    /// <summary>
-    /// The job has received the cancel command, but is still running.
-    /// </summary>
-    Canceling,
-
-    /// <summary>
-    /// The job was successfully cancelled.
-    /// </summary>
-    Canceled
-}
+/// <param name="Id">Job ID.</param>
+/// <param name="Status">Job status.</param>
+/// <param name="CreateTime">Create time.</param>
+/// <param name="StartTime">Start time (<c>null</c> when not yet 
started).</param>
+/// <param name="FinishTime">Finish time (<c>null</c> when not yet 
finished).</param>
+public sealed record JobState(
+    Guid Id,
+    JobStatus Status,
+    Instant CreateTime,
+    Instant? StartTime,
+    Instant? FinishTime);
diff --git a/modules/platforms/dotnet/Apache.Ignite/Compute/JobStatus.cs 
b/modules/platforms/dotnet/Apache.Ignite/Compute/JobStatus.cs
index b5bb9232d8..eca70d5111 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Compute/JobStatus.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Compute/JobStatus.cs
@@ -17,20 +17,38 @@
 
 namespace Apache.Ignite.Compute;
 
-using System;
-using NodaTime;
-
 /// <summary>
-/// Compute job status.
+/// Compute job state.
 /// </summary>
-/// <param name="Id">Job ID.</param>
-/// <param name="State">State.</param>
-/// <param name="CreateTime">Create time.</param>
-/// <param name="StartTime">Start time (<c>null</c> when not yet 
started).</param>
-/// <param name="FinishTime">Finish time (<c>null</c> when not yet 
finished).</param>
-public sealed record JobStatus(
-    Guid Id,
-    JobState State,
-    Instant CreateTime,
-    Instant? StartTime,
-    Instant? FinishTime);
+public enum JobStatus
+{
+    /// <summary>
+    /// The job is submitted and waiting for an execution start.
+    /// </summary>
+    Queued,
+
+    /// <summary>
+    /// The job is being executed.
+    /// </summary>
+    Executing,
+
+    /// <summary>
+    /// The job was unexpectedly terminated during execution.
+    /// </summary>
+    Failed,
+
+    /// <summary>
+    /// The job was executed successfully and the execution result was 
returned.
+    /// </summary>
+    Completed,
+
+    /// <summary>
+    /// The job has received the cancel command, but is still running.
+    /// </summary>
+    Canceling,
+
+    /// <summary>
+    /// The job was successfully cancelled.
+    /// </summary>
+    Canceled
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/Compute.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/Compute.cs
index c83b0007d7..947a88b1d5 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/Compute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/Compute.cs
@@ -136,7 +136,7 @@ namespace Apache.Ignite.Internal.Compute
         /// </summary>
         /// <param name="jobId">Job ID.</param>
         /// <returns>Status.</returns>
-        internal async Task<JobStatus?> GetJobStatusAsync(Guid jobId)
+        internal async Task<JobState?> GetJobStatusAsync(Guid jobId)
         {
             using var writer = ProtoCommon.GetMessageWriter();
             writer.MessageWriter.Write(jobId);
@@ -144,7 +144,7 @@ namespace Apache.Ignite.Internal.Compute
             using var res = await 
_socket.DoOutInOpAsync(ClientOp.ComputeGetStatus, writer).ConfigureAwait(false);
             return Read(res.GetReader());
 
-            JobStatus? Read(MsgPackReader reader) => reader.TryReadNil() ? 
null : ReadJobStatus(reader);
+            JobState? Read(MsgPackReader reader) => reader.TryReadNil() ? null 
: ReadJobStatus(reader);
         }
 
         /// <summary>
@@ -242,15 +242,15 @@ namespace Apache.Ignite.Internal.Compute
             });
         }
 
-        private static JobStatus ReadJobStatus(MsgPackReader reader)
+        private static JobState ReadJobStatus(MsgPackReader reader)
         {
             var id = reader.ReadGuid();
-            var state = (JobState)reader.ReadInt32();
+            var state = (JobStatus)reader.ReadInt32();
             var createTime = reader.ReadInstantNullable();
             var startTime = reader.ReadInstantNullable();
             var endTime = reader.ReadInstantNullable();
 
-            return new JobStatus(id, state, createTime.GetValueOrDefault(), 
startTime, endTime);
+            return new JobState(id, state, createTime.GetValueOrDefault(), 
startTime, endTime);
         }
 
         private IJobExecution<T> GetJobExecution<T>(PooledBuffer 
computeExecuteResult, bool readSchema)
@@ -267,13 +267,13 @@ namespace Apache.Ignite.Internal.Compute
 
             return new JobExecution<T>(jobId, resultTask, this);
 
-            static async Task<(T, JobStatus)> GetResult(NotificationHandler 
handler)
+            static async Task<(T, JobState)> GetResult(NotificationHandler 
handler)
             {
                 using var notificationRes = await 
handler.Task.ConfigureAwait(false);
                 return Read(notificationRes.GetReader());
             }
 
-            static (T, JobStatus) Read(MsgPackReader reader)
+            static (T, JobState) Read(MsgPackReader reader)
             {
                 var res = (T)reader.ReadObjectFromBinaryTuple()!;
                 var status = ReadJobStatus(reader);
diff --git 
a/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/JobExecution.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/JobExecution.cs
index 441f7068cd..1aa2a164df 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/JobExecution.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Compute/JobExecution.cs
@@ -27,11 +27,11 @@ using Ignite.Compute;
 /// <typeparam name="T">Job result type.</typeparam>
 internal sealed record JobExecution<T> : IJobExecution<T>
 {
-    private readonly Task<(T Result, JobStatus Status)> _resultTask;
+    private readonly Task<(T Result, JobState Status)> _resultTask;
 
     private readonly Compute _compute;
 
-    private volatile JobStatus? _finalStatus;
+    private volatile JobState? _finalStatus;
 
     /// <summary>
     /// Initializes a new instance of the <see cref="JobExecution{T}"/> class.
@@ -39,7 +39,7 @@ internal sealed record JobExecution<T> : IJobExecution<T>
     /// <param name="id">Job id.</param>
     /// <param name="resultTask">Result task.</param>
     /// <param name="compute">Compute.</param>
-    public JobExecution(Guid id, Task<(T Result, JobStatus Status)> 
resultTask, Compute compute)
+    public JobExecution(Guid id, Task<(T Result, JobState Status)> resultTask, 
Compute compute)
     {
         Id = id;
         _resultTask = resultTask;
@@ -60,7 +60,7 @@ internal sealed record JobExecution<T> : IJobExecution<T>
     }
 
     /// <inheritdoc/>
-    public async Task<JobStatus?> GetStatusAsync()
+    public async Task<JobState?> GetStatusAsync()
     {
         var finalStatus = _finalStatus;
         if (finalStatus != null)
@@ -69,7 +69,7 @@ internal sealed record JobExecution<T> : IJobExecution<T>
         }
 
         var status = await 
_compute.GetJobStatusAsync(Id).ConfigureAwait(false);
-        if (status is { State: JobState.Completed or JobState.Failed or 
JobState.Canceled })
+        if (status is { Status: JobStatus.Completed or JobStatus.Failed or 
JobStatus.Canceled })
         {
             // Can't be transitioned to another state, cache it.
             _finalStatus = status;

Reply via email to