コード例 #1
0
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.SparkPoolObject))
            {
                var resourceIdentifier = new ResourceIdentifier(this.SparkPoolObject.Id);
                this.WorkspaceName = resourceIdentifier.ParentResource;
                this.WorkspaceName = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.SparkPoolName = resourceIdentifier.ResourceName;
            }

            if (this.ReferenceFile != null)
            {
                for (int i = 0; i < this.ReferenceFile.Length; i++)
                {
                    this.ReferenceFile[i] = Utils.NormalizeUrl(this.ReferenceFile[i]);
                }
            }

            Utils.CategorizedFiles(this.ReferenceFile, out IList <string> jars, out IList <string> files);
            var livyRequest = new ExtendedLivySessionRequest
            {
                Name           = this.Name,
                Jars           = jars,
                Files          = files,
                Conf           = this.Configuration?.ToDictionary(),
                ExecutorMemory = SynapseConstants.ComputeNodeSizes[this.ExecutorSize].Memory + "g",
                ExecutorCores  = SynapseConstants.ComputeNodeSizes[this.ExecutorSize].Cores,
                DriverMemory   = SynapseConstants.ComputeNodeSizes[this.ExecutorSize].Memory + "g",
                DriverCores    = SynapseConstants.ComputeNodeSizes[this.ExecutorSize].Cores,
                NumExecutors   = this.ExecutorCount
            };

            var sparkSession = SynapseAnalyticsClient.CreateSparkSession(this.WorkspaceName, this.SparkPoolName, livyRequest, waitForCompletion: true);

            PSSynapseSparkSession psSparkSession = null;

            if (this.IsParameterBound(c => c.Language))
            {
                this.Language  = LanguageType.Parse(this.Language);
                psSparkSession = new PSSynapseSparkSession(this.Language, sparkSession);
            }
            else
            {
                psSparkSession = new PSSynapseSparkSession(sparkSession);
            }

            WriteObject(psSparkSession);
        }
 /// <summary>
 /// Create new spark session.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of the workspace to execute operations on.
 /// </param>
 /// <param name='sparkPoolName'>
 /// Name of the spark pool. "ondemand" targets the ondemand pool.
 /// </param>
 /// <param name='livyRequest'>
 /// Livy compatible batch job request payload.
 /// </param>
 /// <param name='detailed'>
 /// Optional query param specifying whether detailed response is returned
 /// beyond plain livy.
 /// </param>
 public static ExtendedLivySessionResponse Create(this ISparkSessionOperations operations, string workspaceName, string sparkPoolName, ExtendedLivySessionRequest livyRequest, bool?detailed = default(bool?))
 {
     return(operations.CreateAsync(workspaceName, sparkPoolName, livyRequest, detailed).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Create new spark session.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of the workspace to execute operations on.
 /// </param>
 /// <param name='sparkPoolName'>
 /// Name of the spark pool. "ondemand" targets the ondemand pool.
 /// </param>
 /// <param name='livyRequest'>
 /// Livy compatible batch job request payload.
 /// </param>
 /// <param name='detailed'>
 /// Optional query param specifying whether detailed response is returned
 /// beyond plain livy.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ExtendedLivySessionResponse> CreateAsync(this ISparkSessionOperations operations, string workspaceName, string sparkPoolName, ExtendedLivySessionRequest livyRequest, bool?detailed = default(bool?), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(workspaceName, sparkPoolName, livyRequest, detailed, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
コード例 #4
0
        public ExtendedLivySessionResponse CreateSparkSession(string workspaceName, string sparkPoolName, ExtendedLivySessionRequest livyRequest, bool waitForCompletion)
        {
            var session = _synapseClient.SparkSession.Create(workspaceName, sparkPoolName, livyRequest);

            if (!waitForCompletion)
            {
                return(session);
            }

            return(PollSparkSession(workspaceName, sparkPoolName, session));
        }