Hadoop.Client/Jobs/IHadoopClientExtensions.cs
/// <summary>
/// Method that waits for a jobDetails to complete.
/// </summary>
/// <param name="client">The Hadoop client to use.</param>
/// <param name="jobId">The id of the job to wait for.</param>
/// <param name="duration">The duration to wait before timing out.</param>
/// <param name="cancellationToken">
/// The Cancellation Token for the request.
/// </param>
/// <returns>An awaitable task that represents the action.</returns>
Method that waits for a jobDetails to complete.
Method that waits for a jobDetails to complete .
public static async Task<JobDetails> WaitForJobCompletionAsync(
            this IHadoopJobClient client, string jobId, TimeSpan duration, CancellationToken cancellationToken)
        {
            var jobDetailsResults = new JobDetails {JobId = jobId, StatusCode = JobStatusCode.Unknown};
            var startTime = DateTime.UtcNow;
            var endTime = DateTime.UtcNow;
            while (ShouldRetryAgain(duration, jobDetailsResults, endTime, startTime))
            {                
                if (JobIsFinished(jobDetailsResults))
                    break;
                await TaskEx.Delay(PollingInterval, cancellationToken);
                jobDetailsResults = await GetJobWithRetry(client, jobId, cancellationToken);
                endTime = DateTime.UtcNow;
            }
            if (JobIsNotFinished(jobDetailsResults) && WaitingTimeExceded(duration, endTime, startTime))
                throw new TimeoutException("Timeout waiting for jobDetails completion");
            return jobDetailsResults;
        }
public static async Task < JobDetails > WaitForJobCompletionAsync ( this IHadoopJobClient client , string jobId , TimeSpan duration , CancellationToken cancellationToken ) { var jobDetailsResults = new JobDetails { JobId = jobId , StatusCode = JobStatusCode . Unknown } ; var startTime = DateTime . UtcNow ; var endTime = DateTime . UtcNow ; while ( ShouldRetryAgain ( duration , jobDetailsResults , endTime , startTime ) ) { if ( JobIsFinished ( jobDetailsResults ) ) break ; await TaskEx . Delay ( PollingInterval , cancellationToken ) ; jobDetailsResults = await GetJobWithRetry ( client , jobId , cancellationToken ) ; endTime = DateTime . UtcNow ; } if ( JobIsNotFinished ( jobDetailsResults ) && WaitingTimeExceded ( duration , endTime , startTime ) ) throw new TimeoutException ( " " ) ; return jobDetailsResults ; }
Method that waits for a jobDetails to complete.
Method that waits for a jobDetails to complete .
An awaitable task that represents the action.
An awaitable task that represents the action .
IHadoopJobClient
this
jobId
string
The id of the job to wait for.
The id of the job to wait for .
duration
TimeSpan
The duration to wait before timing out.
The duration to wait before timing out .
cancellationToken
CancellationToken
The Cancellation Token for the request.
The Cancellation Token for the request .
client
The Hadoop client to use.
The Hadoop client to use .