public void DeleteSparkSessionJob() { using (var context = MockContext.Start(this.GetType())) using (var client = this.CommonData.GetHDInsightSparkJobClient(context)) { //create session SparkSessionJobRequest createRequest = new SparkSessionJobRequest { Kind = SessionJobKind.Spark }; var createResponse = client.Job.SubmitSparkSessionJob(createRequest); Assert.NotNull(createResponse); Assert.Equal("starting", createResponse.State); var originalResponse = client.Job.ListSparkSessionJob(); Assert.NotNull(originalResponse); //delete session client.Job.DeleteSparkSessionJob((int)createResponse.Id); var checkResponse = client.Job.ListSparkSessionJob(); Assert.NotNull(checkResponse); Assert.Equal(originalResponse.Total - 1, checkResponse.Total); } }
public void ListSparkSessionJob() { using (var context = MockContext.Start(this.GetType())) using (var client = this.CommonData.GetHDInsightSparkJobClient(context)) { var originalResponse = client.Job.ListSparkSessionJob(); Assert.NotNull(originalResponse); SparkSessionJobRequest createRequest = new SparkSessionJobRequest { Kind = SessionJobKind.Spark }; var createResponse = client.Job.SubmitSparkSessionJob(createRequest); Assert.NotNull(createResponse); Assert.Equal("starting", createResponse.State); TestUtilities.Wait(10000); var checkResponse = client.Job.ListSparkSessionJob(); Assert.NotNull(checkResponse); Assert.Equal(originalResponse.Total + 1, checkResponse.Total); var specifySizeResponse = client.Job.ListSparkSessionJob(1, 0); Assert.NotNull(checkResponse); Assert.Equal(1, specifySizeResponse.FromProperty); Assert.Equal(0, specifySizeResponse.Sessions.Count); client.Job.DeleteSparkSessionJob((int)createResponse.Id); } }
public void SparkStatmentJobLifecycle() { using (var context = MockContext.Start(this.GetType())) using (var client = this.CommonData.GetHDInsightSparkJobClient(context)) { //create session SparkSessionJobRequest createRequest = new SparkSessionJobRequest { Kind = SessionJobKind.Spark }; var createResponse = client.Job.SubmitSparkSessionJob(createRequest); Assert.NotNull(createResponse); Assert.Equal("starting", createResponse.State); TestUtilities.Wait(10000); var originalResponse = client.Job.ListSparkStatementJob((int)createResponse.Id); Assert.NotNull(originalResponse); //create statements SparkStatementRequest statementRequest = new SparkStatementRequest { Code = "1+1" }; var statementResponse = client.Job.SubmitSparkStatementJob((int)createResponse.Id, statementRequest); Assert.NotNull(statementResponse); Assert.Equal("waiting", statementResponse.State); var checkcreateResponse = client.Job.ListSparkStatementJob((int)createResponse.Id); Assert.NotNull(checkcreateResponse); Assert.Equal(originalResponse.Statements.Count + 1, checkcreateResponse.Statements.Count); TestUtilities.Wait(10000); //delete statements var cancelResponse = client.Job.DeleteSparkStatementJob((int)createResponse.Id, (int)statementResponse.Id); Assert.Equal("canceled", cancelResponse.CancelMessage); //delete session client.Job.DeleteSparkSessionJob((int)createResponse.Id); } }
public void GetSparkSessionJob() { using (var context = MockContext.Start(this.GetType())) using (var client = this.CommonData.GetHDInsightSparkJobClient(context)) { SparkSessionJobRequest createRequest = new SparkSessionJobRequest { Kind = SessionJobKind.Spark }; var createResponse = client.Job.SubmitSparkSessionJob(createRequest); Assert.NotNull(createResponse); Assert.Equal("starting", createResponse.State); TestUtilities.Wait(10000); var response = client.Job.GetSparkSessionJob((int)createResponse.Id); Assert.NotNull(response); client.Job.DeleteSparkSessionJob((int)createResponse.Id); } }
/// <summary> /// Create a new spark session. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='sparkSessionJobRequest'> /// Livy compatible session job request payload. /// </param> /// <param name='requestedBy'> /// Add default value for X-Requested-By in header. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <SparkSessionJob> SubmitSparkSessionJobAsync(this IJobOperations operations, SparkSessionJobRequest sparkSessionJobRequest, string requestedBy = "ambari", CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.SubmitSparkSessionJobWithHttpMessagesAsync(sparkSessionJobRequest, requestedBy, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create a new spark session. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='sparkSessionJobRequest'> /// Livy compatible session job request payload. /// </param> /// <param name='requestedBy'> /// Add default value for X-Requested-By in header. /// </param> public static SparkSessionJob SubmitSparkSessionJob(this IJobOperations operations, SparkSessionJobRequest sparkSessionJobRequest, string requestedBy = "ambari") { return(operations.SubmitSparkSessionJobAsync(sparkSessionJobRequest, requestedBy).GetAwaiter().GetResult()); }