Exemplo n.º 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.IsParameterBound(c => c.LivyId))
            {
                var result = new PSSynapseSparkSession(this.SynapseAnalyticsClient.GetSparkSession(this.LivyId));
                WriteObject(result);
            }
            else
            {
                var result = this.SynapseAnalyticsClient.ListSparkSessions().Select(r => new PSSynapseSparkSession(r));
                if (!string.IsNullOrEmpty(this.Name))
                {
                    result = result.Where(r => this.Name.Equals(r.Name, StringComparison.OrdinalIgnoreCase));
                }

                if (!string.IsNullOrEmpty(this.ApplicationId))
                {
                    result = result.Where(b => this.ApplicationId.Equals(b.AppId, StringComparison.OrdinalIgnoreCase));
                }

                WriteObject(result, true);
            }
        }
Exemplo n.º 2
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 SparkSessionOptions(this.Name)
            {
                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,
                ExecutorCount  = this.ExecutorCount
            };

            jars?.ForEach(item => livyRequest.Jars.Add(item));
            files?.ForEach(item => livyRequest.Files.Add(item));
            this.Configuration?.ToDictionary()?.ForEach(item => livyRequest.Configuration.Add(item));

            if (this.ShouldProcess(this.SparkPoolName, string.Format(Resources.StartingSynapseSparkSession, this.SparkPoolName, this.WorkspaceName)))
            {
                var sparkSession = SynapseAnalyticsClient.CreateSparkSession(livyRequest);

                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);
            }
        }
        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);
        }