/// <summary>
 /// List the HDInsight clusters in a resource group.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <returns>
 /// The List Cluster operation response.
 /// </returns>
 public static ClusterListResponse ListByResourceGroup(this IClusterOperations operations, string resourceGroupName)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).ListByResourceGroupAsync(resourceGroupName);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
예제 #2
0
 /// <summary>
 /// Begins resizing the specified HDInsight cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='targetInstanceCount'>
 /// Required. The target instance count.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static HDInsightOperationResponse BeginResizing(this IClusterOperations operations, string resourceGroupName, string clusterName, int targetInstanceCount)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).BeginResizingAsync(resourceGroupName, clusterName, targetInstanceCount);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Resizes the specified HDInsight cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='resizeParameters'>
 /// Required. The parameters for the resize operation.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static HDInsightLongRunningOperationResponse Resize(this IClusterOperations operations, string resourceGroupName, string clusterName, ClusterResizeParameters resizeParameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).ResizeAsync(resourceGroupName, clusterName, resizeParameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Gets the connectivity settings for the specified cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <returns>
 /// The payload for a Configure HTTP settings request.
 /// </returns>
 public static HttpConnectivitySettings GetConnectivitySettings(this IClusterOperations operations, string resourceGroupName, string clusterName)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).GetConnectivitySettingsAsync(resourceGroupName, clusterName);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Gets the status of the Delete operation.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='operationStatusLink'>
 /// Required. Location value returned by the Begin operation.
 /// </param>
 /// <returns>
 /// The GetCluster operation response.
 /// </returns>
 public static ClusterGetResponse GetDeleteStatus(this IClusterOperations operations, string operationStatusLink)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).GetDeleteStatusAsync(operationStatusLink);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Gets the capabilities for the specified location.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='location'>
 /// Required. The location to get capabilities for.
 /// </param>
 /// <returns>
 /// The Get Capabilities operation response.
 /// </returns>
 public static CapabilitiesResponse GetCapabilities(this IClusterOperations operations, string location)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).GetCapabilitiesAsync(location);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Begins configuring the HTTP settings on the specified cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='httpSettingsParameters'>
 /// Required. The name of the resource group.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static HDInsightOperationResponse BeginConfiguringHttpSettings(this IClusterOperations operations, string resourceGroupName, string clusterName, HttpSettingsParameters httpSettingsParameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).BeginConfiguringHttpSettingsAsync(resourceGroupName, clusterName, httpSettingsParameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Creates a new HDInsight cluster with the specified parameters.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='clusterCreateParameters'>
 /// Required. The cluster create request.
 /// </param>
 /// <returns>
 /// The GetCluster operation response.
 /// </returns>
 public static ClusterGetResponse Create(this IClusterOperations operations, string resourceGroupName, string clusterName, ClusterCreateParametersExtended clusterCreateParameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).CreateAsync(resourceGroupName, clusterName, clusterCreateParameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
예제 #9
0
 /// <summary>
 /// Executes script actions on specified HDInsight Running cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='scriptActions'>
 /// Required. The list of script actions that needs to be executed.
 /// </param>
 /// <param name='persistOnSuccess'>
 /// Required. Flag indicating if the script needs to be persisted.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static OperationResource ExecuteScriptActions(this IClusterOperations operations, string resourceGroupName, string clusterName, IList <RuntimeScriptAction> scriptActions, bool persistOnSuccess)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).ExecuteScriptActionsAsync(resourceGroupName, clusterName, scriptActions, persistOnSuccess);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
예제 #10
0
 /// <summary>
 /// Configures the RDP settings on the specified cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='rdpParameters'>
 /// Required. The OS profile for RDP. Use null to turn RDP off.
 /// </param>
 /// <returns>
 /// The azure async operation response.
 /// </returns>
 public static OperationResource ConfigureRdpSettings(this IClusterOperations operations, string resourceGroupName, string clusterName, RDPSettingsParameters rdpParameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).ConfigureRdpSettingsAsync(resourceGroupName, clusterName, rdpParameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Initializes a new instance of the HDInsightManagementClient class.
 /// </summary>
 /// <param name='httpClient'>
 /// The Http client
 /// </param>
 public HDInsightManagementClient(HttpClient httpClient)
     : base(httpClient)
 {
     this._clusters   = new ClusterOperations(this);
     this._apiVersion = "2015-03-01-preview";
     this._longRunningOperationInitialTimeout = -1;
     this._longRunningOperationRetryTimeout   = -1;
     this.HttpClient.Timeout = TimeSpan.FromSeconds(300);
 }
예제 #12
0
        private async Task CancelJobAsync(IClusterOperations cluster)
        {
            Data.IsCanceled = true;
            Data.Timestamp  = DateTimeOffset.UtcNow;
            Data            = await cluster.PingAsync(Data).ConfigureAwait(false);

            var finishSignal = progressTracker.GetProgressFinishedSignal();

            signalPublisher.Publish(finishSignal);
        }
예제 #13
0
 /// <summary>
 /// Begins enabling RDP on the specified cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='rdpUsername'>
 /// Required. The RDP Username.
 /// </param>
 /// <param name='rdpPassword'>
 /// Required. The RDP password.
 /// </param>
 /// <param name='rdpExpiryDate'>
 /// Required. The expiry date of the RDP user.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static HDInsightOperationResponse BeginEnablingRdp(this IClusterOperations operations,
                                                           string resourceGroupName, string clusterName, string rdpUsername, string rdpPassword, DateTime rdpExpiryDate)
 {
     return
         (Task.Factory.StartNew(
              (object s) =>
              ((IClusterOperations)s).BeginEnablingRdpAsync(resourceGroupName, clusterName, rdpUsername,
                                                            rdpPassword, rdpExpiryDate), operations, CancellationToken.None, TaskCreationOptions.None,
              TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
예제 #14
0
        public async Task SyncInitialStateAsync(IClusterOperations cluster, CancellationToken cancellationToken = default)
        {
            Data = await cluster.PingAsync <TData>(cancellationToken);

            if (Data is null)
            {
                Data = BuildInitialData();
            }

            Data = DataOverride(Data);
        }
 /// <summary>
 /// Begins disabling HTTP on the specified cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static HDInsightOperationResponse BeginDisablingHttp(this IClusterOperations operations,
                                                             string resourceGroupName, string clusterName)
 {
     return
         (Task.Factory.StartNew(
              (object s) => ((IClusterOperations)s).BeginDisablingHttpAsync(resourceGroupName, clusterName),
              operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default)
          .Unwrap()
          .GetAwaiter()
          .GetResult());
 }
 /// <summary>
 /// Enables HTTP on the specified cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='username'>
 /// Required. The http username.
 /// </param>
 /// <param name='password'>
 /// Required. The http password.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static OperationResource EnableHttp(this IClusterOperations operations,
                                            string resourceGroupName, string clusterName, string username, string password)
 {
     return
         (Task.Factory.StartNew(
              (object s) =>
              ((IClusterOperations)s).EnableHttpAsync(resourceGroupName, clusterName, username, password),
              operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default)
          .Unwrap()
          .GetAwaiter()
          .GetResult());
 }
예제 #17
0
 public Task <JobExecutionStatus> RunAsync(IClusterOperations cluster, CancellationToken cancellationToken = default)
 {
     try
     {
         return(Task.Factory
                .ContinueWhenAll(new Task[] { SyncInitialStateAsync(cluster) }, _ => Task.CompletedTask)
                .ContinueWith(x => RunJob(cluster, cancellationToken))
                .Result);
     }
     catch (Exception)
     {
         return(Task.FromResult(JobExecutionStatus.Failed));
     }
 }
예제 #18
0
파일: CronusJob.cs 프로젝트: Elders/Cronus
 private Task <JobExecutionStatus> RunJobWithLoggerAsync(IClusterOperations cluster, CancellationToken cancellationToken = default)
 {
     try
     {
         using (logger.BeginScope(s => s
                                  .AddScope("cronus_job_data", System.Text.Json.JsonSerializer.Serialize <TData>(Data))))
         {
             logger.Info(() => "Job started...");
             return(RunJobAsync(cluster, cancellationToken));
         }
     }
     catch (Exception ex) when(logger.ErrorException(ex, () => "Error on RunJobWithLoggerAsync"))
     {
         return(Task.FromResult(JobExecutionStatus.Failed));
     }
 }
예제 #19
0
파일: CronusJob.cs 프로젝트: Elders/Cronus
        public Task <JobExecutionStatus> RunAsync(IClusterOperations cluster, CancellationToken cancellationToken = default)
        {
            try
            {
                using (logger.BeginScope(s => s.AddScope("cronus_job_name", Name)))
                {
                    logger.Info(() => "Initializing job...");

                    return(Task.Factory
                           .ContinueWhenAll(new Task[] { SyncInitialStateAsync(cluster, cancellationToken) }, _ => Task.CompletedTask)
                           .ContinueWith(x => RunJobWithLoggerAsync(cluster, cancellationToken))
                           .Result);
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex, () => "Job run has failed.");

                return(Task.FromResult(JobExecutionStatus.Failed));
            }
        }
        protected override async Task <JobExecutionStatus> RunJob(IClusterOperations cluster, CancellationToken cancellationToken = default)
        {
            bool hasMoreRecords = true;

            while (hasMoreRecords && Data.IsCompleted == false)
            {
                var result = eventStorePlayer.LoadAggregateCommits(Data.PaginationToken);
                foreach (var aggregateCommit in result.Commits)
                {
                    index.Index(aggregateCommit);
                }

                Data.PaginationToken = result.PaginationToken;
                Data = await cluster.PingAsync(Data).ConfigureAwait(false);

                hasMoreRecords = result.Commits.Any();
            }

            Data.IsCompleted = true;
            Data             = await cluster.PingAsync(Data).ConfigureAwait(false);

            return(JobExecutionStatus.Completed);
        }
예제 #21
0
        private async Task <bool> RebuildEventsAsync(string eventTypeId, IClusterOperations cluster, CancellationToken cancellationToken)
        {
            RebuildProjection_JobData.EventPaging paging = Data.EventTypePaging.Where(et => et.Type.Equals(eventTypeId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            unchecked
            {
                ulong pagingProcessedCount = Data.EventTypePaging.Select(p => p.ProcessedCount).DefaultIfEmpty().Aggregate((x, y) => x + y);
                progressTracker.Processed = pagingProcessedCount;
            }

            string paginationToken = paging?.PaginationToken;
            LoadIndexRecordsResult indexRecordsResult = await eventToAggregateIndex.EnumerateRecordsAsync(eventTypeId, paginationToken).ConfigureAwait(false); // TODO: Think about cassandra exception here. Such exceptions MUST be handled in the concrete impl of the IndexStore

            IEnumerable <EventStream> eventStreams = await rebuildingRepository.LoadEventsAsync(indexRecordsResult.Records, Data.Version).ConfigureAwait(false);

            await rebuildingRepository.SaveAggregateCommitsAsync(eventStreams, Data).ConfigureAwait(false);

            await NotifyClusterAsync(eventTypeId, indexRecordsResult.PaginationToken, cluster, cancellationToken).ConfigureAwait(false);

            var hasMoreRecords = indexRecordsResult.Records.Any();

            return(hasMoreRecords);
        }
예제 #22
0
파일: CronusJob.cs 프로젝트: Elders/Cronus
        public async Task SyncInitialStateAsync(IClusterOperations cluster, CancellationToken cancellationToken = default)
        {
            try
            {
                Data = await cluster.PingAsync <TData>(cancellationToken).ConfigureAwait(false);

                if (Data is null)
                {
                    Data = BuildInitialData();
                }

                Data = DataOverride(Data);

                using (logger.BeginScope(s => s
                                         .AddScope(Log.JobData, System.Text.Json.JsonSerializer.Serialize <TData>(Data))))
                {
                    logger.Info(() => "Job state synced.");
                }
            }
            catch (Exception ex) when(logger.ErrorException(ex, () => "Error when syncing initial state of a job"))
            {
            }
        }
        protected override async Task <JobExecutionStatus> RunJobAsync(IClusterOperations cluster, CancellationToken cancellationToken = default)
        {
            bool hasMoreRecords = true;

            while (hasMoreRecords && Data.IsCompleted == false)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    logger.Info(() => $"The job has been cancelled.");
                    return(JobExecutionStatus.Running);
                }

                LoadAggregateCommitsResult result = await eventStorePlayer.LoadAggregateCommitsAsync(Data.PaginationToken).ConfigureAwait(false);

                List <Task> indexTasks = new List <Task>();

                logger.Info(() => $"Loaded aggregate commits count ${result.Commits.Count} using pagination token {result.PaginationToken}");
                foreach (var aggregateCommit in result.Commits)
                {
                    indexTasks.Add(index.IndexAsync(aggregateCommit));
                }

                await Task.WhenAll(indexTasks).ConfigureAwait(false);

                Data.PaginationToken = result.PaginationToken;
                Data = await cluster.PingAsync(Data, cancellationToken).ConfigureAwait(false);

                hasMoreRecords = result.Commits.Any();
            }

            Data.IsCompleted = true;
            Data             = await cluster.PingAsync(Data, cancellationToken).ConfigureAwait(false);

            logger.Info(() => $"The job has been completed.");

            return(JobExecutionStatus.Completed);
        }
예제 #24
0
        protected override async Task <JobExecutionStatus> RunJobAsync(IClusterOperations cluster, CancellationToken cancellationToken = default)
        {
            Dictionary <int, string> processedAggregates = new Dictionary <int, string>();

            string eventTypeId    = Data.SourceEventTypeId;
            bool   hasMoreRecords = true;

            while (hasMoreRecords && Data.IsCompleted == false)
            {
                string paginationToken = Data.EventTypePaging?.PaginationToken;
                LoadIndexRecordsResult indexRecordsResult = await eventToAggregateIndex.EnumerateRecordsAsync(eventTypeId, paginationToken).ConfigureAwait(false);

                IEnumerable <IndexRecord> indexRecords = indexRecordsResult.Records;
                Type          publicEventType          = typeof(IPublicEvent);
                ReplayOptions opt = new ReplayOptions()
                {
                    AggregateIds = indexRecordsResult.Records.Select(indexRecord => AggregateUrn.Parse(Convert.ToBase64String(indexRecord.AggregateRootId), Urn.Base64)),
                    ShouldSelect = commit =>
                    {
                        bool result = (from publicEvent in commit.PublicEvents
                                       let eventType = publicEvent.GetType()
                                                       where publicEventType.IsAssignableFrom(eventType)
                                                       where eventType.GetContractId().Equals(eventTypeId)
                                                       select publicEvent)
                                      .Any();

                        return(result);
                    },
                    After  = Data.After,
                    Before = Data.Before
                };
                LoadAggregateCommitsResult foundAggregateCommits = await eventStorePlayer.LoadAggregateCommitsAsync(opt).ConfigureAwait(false);

                foreach (AggregateCommit arCommit in foundAggregateCommits.Commits)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        logger.Info(() => $"Job has been cancelled.");
                        return(JobExecutionStatus.Running);
                    }

                    foreach (IPublicEvent publicEvent in arCommit.PublicEvents)
                    {
                        if (publicEvent.GetType().GetContractId().Equals(eventTypeId))
                        {
                            var headers = new Dictionary <string, string>()
                            {
                                { MessageHeader.RecipientBoundedContext, Data.RecipientBoundedContext },
                                { MessageHeader.RecipientHandlers, Data.RecipientHandlers }
                            };
                            publicEventPublisher.Publish(publicEvent, headers);
                        }
                    }
                }

                var progress = new ReplayPublicEvents_JobData.EventTypePagingProgress(eventTypeId, indexRecordsResult.PaginationToken, 0, 0);
                Data.MarkEventTypeProgress(progress);
                Data.Timestamp = DateTimeOffset.UtcNow;
                Data           = await cluster.PingAsync(Data, cancellationToken).ConfigureAwait(false);

                hasMoreRecords = indexRecordsResult.Records.Any();
            }

            Data.IsCompleted = true;
            Data.Timestamp   = DateTimeOffset.UtcNow;

            Data = await cluster.PingAsync(Data).ConfigureAwait(false);

            logger.Info(() => $"The job has been completed.");

            return(JobExecutionStatus.Completed);
        }
예제 #25
0
 /// <summary>
 /// Enables RDP on the specified cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='rdpUsername'>
 /// Required. The RDP Username.
 /// </param>
 /// <param name='rdpPassword'>
 /// Required. The RDP password.
 /// </param>
 /// <param name='rdpExpiryDate'>
 /// Required. The expiry date of the RDP user.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static Task <HDInsightLongRunningOperationResponse> EnableRdpAsync(this IClusterOperations operations,
                                                                           string resourceGroupName, string clusterName, string rdpUsername, string rdpPassword, DateTime rdpExpiryDate)
 {
     return(operations.EnableRdpAsync(resourceGroupName, clusterName, rdpUsername, rdpPassword, rdpExpiryDate,
                                      CancellationToken.None));
 }
예제 #26
0
 /// <summary>
 /// Begins disabling RDP on the specified cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static Task <HDInsightOperationResponse> BeginDisablingRdpAsync(this IClusterOperations operations,
                                                                        string resourceGroupName, string clusterName)
 {
     return(operations.BeginDisablingRdpAsync(resourceGroupName, clusterName, CancellationToken.None));
 }
예제 #27
0
 protected abstract Task <JobExecutionStatus> RunJob(IClusterOperations cluster, CancellationToken cancellationToken = default);
예제 #28
0
        private async Task NotifyClusterAsync(string eventTypeId, string paginationToken, IClusterOperations cluster, CancellationToken cancellationToken)
        {
            var progress = new RebuildProjection_JobData.EventPaging(eventTypeId, paginationToken, progressTracker.Processed, progressTracker.TotalEvents);

            Data.MarkEventTypeProgress(progress);
            Data.Timestamp = DateTimeOffset.UtcNow;
            Data           = await cluster.PingAsync(Data, cancellationToken).ConfigureAwait(false);

            var progressSignal = progressTracker.GetProgressSignal();

            signalPublisher.Publish(progressSignal);
        }
예제 #29
0
        protected override async Task <JobExecutionStatus> RunJobAsync(IClusterOperations cluster, CancellationToken cancellationToken = default)
        {
            ProjectionVersion version = Data.Version;
            Type projectionType       = version.ProjectionName.GetTypeByContract();

            await progressTracker.InitializeAsync(version).ConfigureAwait(false);

            if (await projectionVersionHelper.ShouldBeRetriedAsync(version).ConfigureAwait(false))
            {
                return(JobExecutionStatus.Running);
            }

            if (await projectionVersionHelper.ShouldBeCanceledAsync(version, Data.DueDate).ConfigureAwait(false))
            {
                if (Data.IsCanceled == false)
                {
                    await CancelJobAsync(cluster).ConfigureAwait(false);
                }

                logger.Info(() => $"The job {version} has been cancelled.");
                return(JobExecutionStatus.Canceled);
            }

            await projectionStoreInitializer.InitializeAsync(version).ConfigureAwait(false);

            var startSignal = progressTracker.GetProgressStartedSignal();

            signalPublisher.Publish(startSignal);

            IEnumerable <Type> projectionHandledEventTypes = projectionVersionHelper.GetInvolvedEventTypes(projectionType);

            foreach (Type eventType in projectionHandledEventTypes)
            {
                string eventTypeId = eventType.GetContractId();

                bool hasMoreRecords = true;
                while (hasMoreRecords && Data.IsCompleted == false)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        logger.Info(() => $"The job {version} has been cancelled.");
                        return(JobExecutionStatus.Running);
                    }

                    if (Data.IsCanceled || await projectionVersionHelper.ShouldBeCanceledAsync(version, Data.DueDate).ConfigureAwait(false))
                    {
                        if (Data.IsCanceled == false)
                        {
                            await CancelJobAsync(cluster).ConfigureAwait(false);
                        }

                        logger.Info(() => $"The job {version} has been cancelled.");
                        return(JobExecutionStatus.Canceled);
                    }

                    hasMoreRecords = await RebuildEventsAsync(eventTypeId, cluster, cancellationToken).ConfigureAwait(false);
                }
            }

            Data.IsCompleted = true;
            Data.Timestamp   = DateTimeOffset.UtcNow;
            Data             = await cluster.PingAsync(Data).ConfigureAwait(false);

            var finishSignal = progressTracker.GetProgressFinishedSignal();

            signalPublisher.Publish(finishSignal);

            logger.Info(() => $"The job has been completed.");
            return(JobExecutionStatus.Completed);
        }
예제 #30
0
 /// <summary>
 /// Resizes the specified HDInsight cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='targetInstanceCount'>
 /// Required. The target instance count.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static Task <HDInsightLongRunningOperationResponse> ResizeAsync(this IClusterOperations operations, string resourceGroupName, string clusterName, int targetInstanceCount)
 {
     return(operations.ResizeAsync(resourceGroupName, clusterName, targetInstanceCount, CancellationToken.None));
 }