Пример #1
0
        public async Task <LivyBatchResponse> ExecuteWorkflowAsync(LivyBatchRequest batch, TimeSpan waitTime)
        {
            LivyBatchResponse response = await Post <LivyBatchRequest, LivyBatchResponse>("batches", batch);

            DateTime  startTime     = DateTime.UtcNow;
            Exception lastException = null;

            while (
                (response == null) ||
                (response.State != SparkJobState.Dead && response.State != SparkJobState.Error && response.State != SparkJobState.Success))
            {
                TimeSpan length = DateTime.UtcNow - startTime;

                if (response != null)
                {
                    Debug.WriteLine("session id: {0}, state: {1}, length: {2}", response.SessionId, response.State, length);
                }
                else
                {
                    Debug.WriteLine("no response received, will try again");
                }

                if (length > waitTime)
                {
                    throw new TimeoutException("the workflow has timed out", lastException);
                }

                await Task.Delay(TimeSpan.FromSeconds(10));

                try
                {
                    response = await GetBatchStateAsync(response.SessionId);
                }
                catch (Exception ex)
                {
                    lastException = ex;
                    Debug.WriteLine("unexpected livy error: " + ex.ToString());
                }
            }

            return(response);
        }
Пример #2
0
        /// <summary>
        /// Executes a Livy job using a storage jar
        /// </summary>
        public async Task <LivyBatchResponse> ExecuteAsync(LivyBatchRequest batch)
        {
            LivyBatchResponse response = await Post <LivyBatchRequest, LivyBatchResponse>("batches", batch);

            return(response);
        }