/// <summary>
        /// Runs email mining and schedules next job.
        /// </summary>
        /// <param name="userConnection">User connection.</param>
        /// <param name="parameters">Job parameters.</param>
        public void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
        {
            int timeShiftMinutes = 0;

            try {
                if (!SysSettings.GetValue <bool>(userConnection, EnableEmailMiningSysSettingsName, true))
                {
                    _log.InfoFormat("Email mining is disabled. See system settings value {0}",
                                    EnableEmailMiningSysSettingsName);
                    return;
                }
                RunMiner(userConnection);
            } catch (IncorrectConfigurationException ex) {
                _log.Error(ex.Message);
                timeShiftMinutes = IncorrectConfigurationTimeShiftMinutes;
            } catch (Exception ex) {
                LogError(ex);
                throw;
            } finally {
                int periodMin = SysSettings.GetValue(userConnection, JobPeriodSysSettingsName, 0);
                if (periodMin == 0)
                {
                    _log.Info($"SysSetting {JobPeriodSysSettingsName} equals to zero. Job will not be rescheduled.");
                }
                else
                {
                    if (timeShiftMinutes > 0)
                    {
                        _log.Warn($"Next job will be run in {periodMin + timeShiftMinutes} minutes");
                    }
                    SchedulerUtils.ScheduleNextRun(userConnection, EmailMiningAppListener.TargetJobGroupName, this,
                                                   periodMin + timeShiftMinutes);
                }
            }
        }
Example #2
0
 /// <exception cref="System.IO.IOException"/>
 private void DoneApplicationAttempt(ApplicationAttemptId applicationAttemptId, RMAppAttemptState
                                     rmAppAttemptFinalState, bool keepContainers)
 {
     lock (this)
     {
         FiCaSchedulerApp attempt = GetApplicationAttempt(applicationAttemptId);
         SchedulerApplication <FiCaSchedulerApp> application = applications[applicationAttemptId
                                                                            .GetApplicationId()];
         if (application == null || attempt == null)
         {
             throw new IOException("Unknown application " + applicationAttemptId + " has completed!"
                                   );
         }
         // Kill all 'live' containers
         foreach (RMContainer container in attempt.GetLiveContainers())
         {
             if (keepContainers && container.GetState().Equals(RMContainerState.Running))
             {
                 // do not kill the running container in the case of work-preserving AM
                 // restart.
                 Log.Info("Skip killing " + container.GetContainerId());
                 continue;
             }
             CompletedContainer(container, SchedulerUtils.CreateAbnormalContainerStatus(container
                                                                                        .GetContainerId(), SchedulerUtils.CompletedApplication), RMContainerEventType.Kill
                                );
         }
         // Clean up pending requests, metrics etc.
         attempt.Stop(rmAppAttemptFinalState);
     }
 }
Example #3
0
        public override void ExecuteCmdlet()
        {
            string status = string.Empty;

            WriteObject(SMClient.CreateHttpJob(new PSCreateJobParams
            {
                Region            = Location,
                JobCollectionName = JobCollectionName,
                JobName           = JobName,
                Method            = Method,
                Headers           = Headers,
                Uri                       = URI,
                Body                      = RequestBody,
                StartTime                 = StartTime,
                Interval                  = Interval,
                Frequency                 = Frequency,
                EndTime                   = EndTime,
                ExecutionCount            = ExecutionCount,
                JobState                  = JobState,
                ErrorActionMethod         = ErrorActionMethod,
                ErrorActionBody           = ErrorActionRequestBody,
                ErrorActionHeaders        = ErrorActionHeaders,
                ErrorActionUri            = ErrorActionURI,
                ErrorActionStorageAccount = ErrorActionStorageAccount,
                ErrorActionQueueName      = ErrorActionStorageQueue,
                ErrorActionQueueBody      = ErrorActionQueueMessageBody,
                ErrorActionSasToken       = ErrorActionSASToken,
                HttpAuthType              = HttpAuthenticationType ?? string.Empty,
                ClientCertPfx             = ClientCertificatePfx == null ? null : SchedulerUtils.GetCertData(this.ResolvePath(ClientCertificatePfx.ToString()), ClientCertificatePassword),
                ClientCertPassword        = ClientCertificatePassword
            }, out status), true);
            WriteObject(status);
        }
    static void __OnCompletedRead(IAsyncResult asyncResult)
    {
        var asyncState = (AsyncState)asyncResult.AsyncState;

        try
        {
            int bytesRead = asyncState.fileStream.EndRead(asyncResult);
            if (bytesRead == asyncState.buffer.Length)
            {
                if (asyncState.callback != null)
                {
                    // callback on main thread
                    SchedulerUtils.MainThread_Invoke(() => {
                        asyncState.callback(asyncState.buffer);
                    });
                }
            }
            else
            {
                Log.Error("[FileUtils] async end read bytes from file {0} error", asyncState.fileStream.Name);
            }
        }
        catch (IOException e)
        {
            Log.Error("[FileUtils] async end read bytes from file {0} error, {1}", asyncState.fileStream.Name, e.Message);
        }
        finally
        {
            asyncState.fileStream.Close();
        }
    }
        private void ScheduleEmailMiningJob()
        {
            SchedulerUtils.DeleteOldJobs(TargetJobGroupName);
            SysUserInfo currentUser = UserConnection.CurrentUser;

            _schedulerWraper.ScheduleImmediateJob <EmailMiningJob>(TargetJobGroupName, UserConnection.Workspace.Name,
                                                                   currentUser.Name, null, true);
        }
        public virtual IDictionary <AccessType, AccessControlList> GetAcls(string queue)
        {
            IDictionary <AccessType, AccessControlList> acls = new Dictionary <AccessType, AccessControlList
                                                                               >();

            foreach (QueueACL acl in QueueACL.Values())
            {
                acls[SchedulerUtils.ToAccessType(acl)] = GetAcl(queue, acl);
            }
            return(acls);
        }
Example #7
0
        private void simpleButton4_Click(object sender, EventArgs e)
        {
            SchedulerUtils oSchedulerUtils = new SchedulerUtils();

            oSchedulerUtils.startAsync(500, 100, false, () =>
            {
                FormUtilsEx.invoke4Control(this, () =>
                {
                    SysUserLogUtils.debug4Sys("Module1", "debug");
                });
            });
        }
Example #8
0
        public override Allocation Allocate(ApplicationAttemptId applicationAttemptId, IList
                                            <ResourceRequest> ask, IList <ContainerId> release, IList <string> blacklistAdditions
                                            , IList <string> blacklistRemovals)
        {
            FiCaSchedulerApp application = GetApplicationAttempt(applicationAttemptId);

            if (application == null)
            {
                Log.Error("Calling allocate on removed " + "or non existant application " + applicationAttemptId
                          );
                return(EmptyAllocation);
            }
            // Sanity check
            SchedulerUtils.NormalizeRequests(ask, resourceCalculator, clusterResource, minimumAllocation
                                             , GetMaximumResourceCapability());
            // Release containers
            ReleaseContainers(release, application);
            lock (application)
            {
                // make sure we aren't stopping/removing the application
                // when the allocate comes in
                if (application.IsStopped())
                {
                    Log.Info("Calling allocate on a stopped " + "application " + applicationAttemptId
                             );
                    return(EmptyAllocation);
                }
                if (!ask.IsEmpty())
                {
                    Log.Debug("allocate: pre-update" + " applicationId=" + applicationAttemptId + " application="
                              + application);
                    application.ShowRequests();
                    // Update application requests
                    application.UpdateResourceRequests(ask);
                    Log.Debug("allocate: post-update" + " applicationId=" + applicationAttemptId + " application="
                              + application);
                    application.ShowRequests();
                    Log.Debug("allocate:" + " applicationId=" + applicationAttemptId + " #ask=" + ask
                              .Count);
                }
                application.UpdateBlacklist(blacklistAdditions, blacklistRemovals);
                SchedulerApplicationAttempt.ContainersAndNMTokensAllocation allocation = application
                                                                                         .PullNewlyAllocatedContainersAndNMTokens();
                Org.Apache.Hadoop.Yarn.Api.Records.Resource headroom = application.GetHeadroom();
                application.SetApplicationHeadroomForMetrics(headroom);
                return(new Allocation(allocation.GetContainerList(), headroom, null, null, null,
                                      allocation.GetNMTokenList()));
            }
        }
Example #9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AutofacConfiguration.ConfigureContainer();
            SchedulerUtils.ConfigureScheduler();
            LogManager.Adapter = new TraceLoggerFactoryAdapter
            {
                Level = LogLevel.Info
            };

            // start the keep-alive scheduler
            _keepAliveScheduler = new Scheduler();
            _keepAliveScheduler.Start(KeepAliveConstants.CheckFrequency);
        }
Example #10
0
        /// <summary>
        /// Utility method to validate a list resource requests, by insuring that the
        /// requested memory/vcore is non-negative and not greater than max
        /// </summary>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.InvalidResourceRequestException
        ///     "/>
        public static void NormalizeAndValidateRequests(IList <ResourceRequest> ask, Resource
                                                        maximumResource, string queueName, YarnScheduler scheduler, RMContext rmContext
                                                        )
        {
            QueueInfo queueInfo = null;

            try
            {
                queueInfo = scheduler.GetQueueInfo(queueName, false, false);
            }
            catch (IOException)
            {
            }
            foreach (ResourceRequest resReq in ask)
            {
                SchedulerUtils.NormalizeAndvalidateRequest(resReq, maximumResource, queueName, scheduler
                                                           , rmContext, queueInfo);
            }
        }
Example #11
0
        /// <summary>
        /// Executes the job's task.
        /// </summary>
        /// <param name="userConnection">User connection.</param>
        /// <param name="parameters">Job parameters.</param>
        public void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
        {
            int frequency = SysSettings.GetValue(userConnection, JobPeriodSysSettingsName, 0);

            if (frequency == 0)
            {
                _log.Info($"SysSetting {JobPeriodSysSettingsName} equals to zero. Task cancelled and job will not be rescheduled.");
                return;
            }
            try {
                ProcessAllModels(userConnection);
            } catch (IncorrectConfigurationException ex) {
                _log.Error(ex.Message);
            } catch (Exception ex) {
                _log.ErrorFormat("Exception was thrown during ML model batch prediction job", ex);
                throw;
            } finally {
                SchedulerUtils.ScheduleNextRun(userConnection, nameof(MLBatchPredictionJob), this, frequency);
            }
        }
Example #12
0
 /// <summary>
 /// Runs ML model trainings and schedules next job.
 /// </summary>
 /// <param name="userConnection">User connection.</param>
 /// <param name="parameters">Job parameters.</param>
 public void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
 {
     try {
         _trainingManager.ProcessAllModels(userConnection);
     } catch (IncorrectConfigurationException ex) {
         _log.Error(ex.Message);
     } catch (Exception ex) {
         LogError(ex);
         throw;
     } finally {
         int frequency = SysSettings.GetValue(userConnection, JobPeriodSysSettingsName, 0);
         if (frequency == 0)
         {
             _log.Info($"SysSetting {JobPeriodSysSettingsName} equals to zero. Job will not be rescheduled.");
         }
         else
         {
             SchedulerUtils.ScheduleNextRun(userConnection, nameof(MLModelTrainerJob), this, frequency);
         }
     }
 }
Example #13
0
 private void RemoveNode(RMNode nodeInfo)
 {
     lock (this)
     {
         FiCaSchedulerNode node = GetNode(nodeInfo.GetNodeID());
         if (node == null)
         {
             return;
         }
         // Kill running containers
         foreach (RMContainer container in node.GetRunningContainers())
         {
             CompletedContainer(container, SchedulerUtils.CreateAbnormalContainerStatus(container
                                                                                        .GetContainerId(), SchedulerUtils.LostContainer), RMContainerEventType.Kill);
         }
         //Remove the node
         Sharpen.Collections.Remove(this.nodes, nodeInfo.GetNodeID());
         UpdateMaximumAllocation(node, false);
         // Update cluster metrics
         Resources.SubtractFrom(clusterResource, node.GetTotalResource());
     }
 }
Example #14
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.InvalidResourceRequestException
 ///     "/>
 private ResourceRequest ValidateAndCreateResourceRequest(ApplicationSubmissionContext
                                                          submissionContext, bool isRecovery)
 {
     // Validation of the ApplicationSubmissionContext needs to be completed
     // here. Only those fields that are dependent on RM's configuration are
     // checked here as they have to be validated whether they are part of new
     // submission or just being recovered.
     // Check whether AM resource requirements are within required limits
     if (!submissionContext.GetUnmanagedAM())
     {
         ResourceRequest amReq = submissionContext.GetAMContainerResourceRequest();
         if (amReq == null)
         {
             amReq = BuilderUtils.NewResourceRequest(RMAppAttemptImpl.AmContainerPriority, ResourceRequest
                                                     .Any, submissionContext.GetResource(), 1);
         }
         // set label expression for AM container
         if (null == amReq.GetNodeLabelExpression())
         {
             amReq.SetNodeLabelExpression(submissionContext.GetNodeLabelExpression());
         }
         try
         {
             SchedulerUtils.NormalizeAndValidateRequest(amReq, scheduler.GetMaximumResourceCapability
                                                            (), submissionContext.GetQueue(), scheduler, isRecovery, rmContext);
         }
         catch (InvalidResourceRequestException e)
         {
             Log.Warn("RM app submission failed in validating AM resource request" + " for application "
                      + submissionContext.GetApplicationId(), e);
             throw;
         }
         SchedulerUtils.NormalizeRequest(amReq, scheduler.GetResourceCalculator(), scheduler
                                         .GetClusterResource(), scheduler.GetMinimumResourceCapability(), scheduler.GetMaximumResourceCapability
                                             (), scheduler.GetMinimumResourceCapability());
         return(amReq);
     }
     return(null);
 }
Example #15
0
        private void _init()
        {
            var o = new Stopwatch();

            o.Start();
            for (int i = 0; i < 50; i++)
            {
                var oLabel = new Label();
                oLabel.Name     = "label" + i;
                oLabel.Text     = "label" + i;
                oLabel.Location = new Point(10, 20 * i);
                this.Controls.Add(oLabel);

                var oTextBox = new TextBox();
                oTextBox.Name     = "name" + i;
                oTextBox.Text     = "text" + i;
                oTextBox.Location = new Point(50, 20 * i);
                this.Controls.Add(oTextBox);
            }
            o.Stop();
            Console.WriteLine("TEXT:" + o.ElapsedMilliseconds);
            o.Start();
            for (int i = 50; i < 100; i++)
            {
                var oCombo = new ComboBox();
                oCombo.Name = "name" + i;
                oCombo.Text = "1";
                oCombo.Items.Add("1");
                oCombo.Items.Add("2");
                oCombo.Items.Add("3");
                oCombo.Location = new Point(10, 20 * i);
                this.Controls.Add(oCombo);
            }
            o.Stop();
            Console.WriteLine("COMBO:" + o.ElapsedMilliseconds);

            var oSchedulerUtils = new SchedulerUtils();

            oSchedulerUtils.startAsync(100, 100, false, () =>
            {
                FormUtilsEx.invoke4Control(this, () =>
                {
                    var o1 = new Stopwatch();
                    o1.Start();
                    for (int i = 0; i < 50; i++)
                    {
                        var oTextBox  = this.Controls.Find("name" + i, false)[0];
                        oTextBox.Text = IDUtilsEx.gen();
                    }
                    o1.Stop();
                    Console.WriteLine("REFRESH:" + o1.ElapsedMilliseconds);
                });
            });

            var oSchedulerUtils2 = new SchedulerUtils();

            oSchedulerUtils2.startAsync(100, 100, false, () =>
            {
                FormUtilsEx.invoke4Control(this, () =>
                {
                    this.simpleButton1.Text = IDUtilsEx.gen();
                });
            });
        }
Example #16
0
 public virtual bool HasAccess(QueueACL acl, UserGroupInformation user)
 {
     return(authorizer.CheckPermission(SchedulerUtils.ToAccessType(acl), queueEntity,
                                       user));
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            Response.BufferOutput = true;
            SetPageTitle(L10n.Term("Schedulers.LBL_MODULE_TITLE"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *               " + ControlChars.CrLf
                           + "     , '' as DATE_RANGE" + ControlChars.CrLf
                           + "  from vwSCHEDULERS    " + ControlChars.CrLf
                           + " where 1 = 1           " + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                        }

                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                foreach (DataRow row in dt.Rows)
                                {
                                    string   sJOB_INTERVAL     = Sql.ToString(row["JOB_INTERVAL"]);
                                    DateTime dtDATE_TIME_START = Sql.ToDateTime(row["DATE_TIME_START"]);
                                    DateTime dtDATE_TIME_END   = Sql.ToDateTime(row["DATE_TIME_END"]);
                                    DateTime dtLAST_RUN        = Sql.ToDateTime(row["LAST_RUN"]);
                                    row["JOB_INTERVAL"] = sJOB_INTERVAL + "<br>" + SchedulerUtils.CronDescription(L10n, sJOB_INTERVAL);
                                    if (dtDATE_TIME_START != DateTime.MinValue)
                                    {
                                        row["DATE_RANGE"] = T10n.FromServerTime(dtDATE_TIME_START).ToString() + "-";
                                    }
                                    if (dtDATE_TIME_END == DateTime.MinValue)
                                    {
                                        row["DATE_RANGE"] += L10n.Term("Schedulers.LBL_PERENNIAL");
                                    }
                                    else
                                    {
                                        row["DATE_RANGE"] += T10n.FromServerTime(dtDATE_TIME_END).ToString();
                                    }
                                    if (dtLAST_RUN != DateTime.MinValue)
                                    {
                                        row["LAST_RUN"] = T10n.FromServerTime(dtLAST_RUN);
                                    }
                                    row["STATUS"] = L10n.Term(".scheduler_status_dom.", row["STATUS"]);
                                }
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                if (!IsPostBack)
                                {
                                    grdMain.SortColumn = "NAME";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
 protected internal virtual void UpdateFormCaption()
 {
     this.Text = SchedulerUtils.FormatAppointmentFormCaption(controller.AllDay, controller.Subject, false);
 }
Example #19
0
 public override CSAssignment AssignContainers(Resource clusterResource, FiCaSchedulerNode
                                               node, ResourceLimits resourceLimits)
 {
     lock (this)
     {
         CSAssignment assignment = new CSAssignment(Resources.CreateResource(0, 0), NodeType
                                                    .NodeLocal);
         ICollection <string> nodeLabels = node.GetLabels();
         // if our queue cannot access this node, just return
         if (!SchedulerUtils.CheckQueueAccessToNode(accessibleLabels, nodeLabels))
         {
             return(assignment);
         }
         while (CanAssign(clusterResource, node))
         {
             if (Log.IsDebugEnabled())
             {
                 Log.Debug("Trying to assign containers to child-queue of " + GetQueueName());
             }
             // Are we over maximum-capacity for this queue?
             // This will also consider parent's limits and also continuous reservation
             // looking
             if (!base.CanAssignToThisQueue(clusterResource, nodeLabels, resourceLimits, minimumAllocation
                                            , Resources.CreateResource(GetMetrics().GetReservedMB(), GetMetrics().GetReservedVirtualCores
                                                                           ())))
             {
                 break;
             }
             // Schedule
             CSAssignment assignedToChild = AssignContainersToChildQueues(clusterResource, node
                                                                          , resourceLimits);
             assignment.SetType(assignedToChild.GetType());
             // Done if no child-queue assigned anything
             if (Resources.GreaterThan(resourceCalculator, clusterResource, assignedToChild.GetResource
                                           (), Resources.None()))
             {
                 // Track resource utilization for the parent-queue
                 base.AllocateResource(clusterResource, assignedToChild.GetResource(), nodeLabels);
                 // Track resource utilization in this pass of the scheduler
                 Resources.AddTo(assignment.GetResource(), assignedToChild.GetResource());
                 Log.Info("assignedContainer" + " queue=" + GetQueueName() + " usedCapacity=" + GetUsedCapacity
                              () + " absoluteUsedCapacity=" + GetAbsoluteUsedCapacity() + " used=" + queueUsage
                          .GetUsed() + " cluster=" + clusterResource);
             }
             else
             {
                 break;
             }
             if (Log.IsDebugEnabled())
             {
                 Log.Debug("ParentQ=" + GetQueueName() + " assignedSoFarInThisIteration=" + assignment
                           .GetResource() + " usedCapacity=" + GetUsedCapacity() + " absoluteUsedCapacity="
                           + GetAbsoluteUsedCapacity());
             }
             // Do not assign more than one container if this isn't the root queue
             // or if we've already assigned an off-switch container
             if (!rootQueue || assignment.GetType() == NodeType.OffSwitch)
             {
                 if (Log.IsDebugEnabled())
                 {
                     if (rootQueue && assignment.GetType() == NodeType.OffSwitch)
                     {
                         Log.Debug("Not assigning more than one off-switch container," + " assignments so far: "
                                   + assignment);
                     }
                 }
                 break;
             }
         }
         return(assignment);
     }
 }
Example #20
0
        public override void Handle(SchedulerEvent @event)
        {
            switch (@event.GetType())
            {
            case SchedulerEventType.NodeAdded:
            {
                NodeAddedSchedulerEvent nodeAddedEvent = (NodeAddedSchedulerEvent)@event;
                AddNode(nodeAddedEvent.GetAddedRMNode());
                RecoverContainersOnNode(nodeAddedEvent.GetContainerReports(), nodeAddedEvent.GetAddedRMNode
                                            ());
                break;
            }

            case SchedulerEventType.NodeRemoved:
            {
                NodeRemovedSchedulerEvent nodeRemovedEvent = (NodeRemovedSchedulerEvent)@event;
                RemoveNode(nodeRemovedEvent.GetRemovedRMNode());
                break;
            }

            case SchedulerEventType.NodeResourceUpdate:
            {
                NodeResourceUpdateSchedulerEvent nodeResourceUpdatedEvent = (NodeResourceUpdateSchedulerEvent
                                                                             )@event;
                UpdateNodeResource(nodeResourceUpdatedEvent.GetRMNode(), nodeResourceUpdatedEvent
                                   .GetResourceOption());
                break;
            }

            case SchedulerEventType.NodeUpdate:
            {
                NodeUpdateSchedulerEvent nodeUpdatedEvent = (NodeUpdateSchedulerEvent)@event;
                NodeUpdate(nodeUpdatedEvent.GetRMNode());
                break;
            }

            case SchedulerEventType.AppAdded:
            {
                AppAddedSchedulerEvent appAddedEvent = (AppAddedSchedulerEvent)@event;
                AddApplication(appAddedEvent.GetApplicationId(), appAddedEvent.GetQueue(), appAddedEvent
                               .GetUser(), appAddedEvent.GetIsAppRecovering());
                break;
            }

            case SchedulerEventType.AppRemoved:
            {
                AppRemovedSchedulerEvent appRemovedEvent = (AppRemovedSchedulerEvent)@event;
                DoneApplication(appRemovedEvent.GetApplicationID(), appRemovedEvent.GetFinalState
                                    ());
                break;
            }

            case SchedulerEventType.AppAttemptAdded:
            {
                AppAttemptAddedSchedulerEvent appAttemptAddedEvent = (AppAttemptAddedSchedulerEvent
                                                                      )@event;
                AddApplicationAttempt(appAttemptAddedEvent.GetApplicationAttemptId(), appAttemptAddedEvent
                                      .GetTransferStateFromPreviousAttempt(), appAttemptAddedEvent.GetIsAttemptRecovering
                                          ());
                break;
            }

            case SchedulerEventType.AppAttemptRemoved:
            {
                AppAttemptRemovedSchedulerEvent appAttemptRemovedEvent = (AppAttemptRemovedSchedulerEvent
                                                                          )@event;
                try
                {
                    DoneApplicationAttempt(appAttemptRemovedEvent.GetApplicationAttemptID(), appAttemptRemovedEvent
                                           .GetFinalAttemptState(), appAttemptRemovedEvent.GetKeepContainersAcrossAppAttempts
                                               ());
                }
                catch (IOException ie)
                {
                    Log.Error("Unable to remove application " + appAttemptRemovedEvent.GetApplicationAttemptID
                                  (), ie);
                }
                break;
            }

            case SchedulerEventType.ContainerExpired:
            {
                ContainerExpiredSchedulerEvent containerExpiredEvent = (ContainerExpiredSchedulerEvent
                                                                        )@event;
                ContainerId containerid = containerExpiredEvent.GetContainerId();
                CompletedContainer(GetRMContainer(containerid), SchedulerUtils.CreateAbnormalContainerStatus
                                       (containerid, SchedulerUtils.ExpiredContainer), RMContainerEventType.Expire);
                break;
            }

            case SchedulerEventType.ContainerRescheduled:
            {
                ContainerRescheduledEvent containerRescheduledEvent = (ContainerRescheduledEvent)
                                                                      @event;
                RMContainer container = containerRescheduledEvent.GetContainer();
                RecoverResourceRequestForContainer(container);
                break;
            }

            default:
            {
                Log.Error("Invalid eventtype " + @event.GetType() + ". Ignoring!");
                break;
            }
            }
        }
Example #21
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList.Schedulers"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                // 11/28/2005 Paul.  We must always populate the table, otherwise it will disappear during event processing.
                //if ( !IsPostBack )
                {
                    if (!Sql.IsEmptyGuid(gID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *           " + ControlChars.CrLf
                                   + "  from vwSCHEDULERS" + ControlChars.CrLf
                                   + " where ID = @ID    " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@ID", gID);
                                con.Open();

                                if (bDebug)
                                {
                                    RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                                }

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]);
                                        SetPageTitle(L10n.Term(".moduleList.Schedulers") + " - " + ctlModuleHeader.Title);

                                        string   sJOB_INTERVAL     = Sql.ToString(rdr["JOB_INTERVAL"]);
                                        DateTime dtDATE_TIME_START = Sql.ToDateTime(rdr["DATE_TIME_START"]);
                                        DateTime dtDATE_TIME_END   = Sql.ToDateTime(rdr["DATE_TIME_END"]);
                                        DateTime dtTIME_FROM       = Sql.ToDateTime(rdr["TIME_FROM"]);
                                        DateTime dtTIME_TO         = Sql.ToDateTime(rdr["TIME_TO"]);
                                        DateTime dtLAST_RUN        = Sql.ToDateTime(rdr["LAST_RUN"]);
                                        JOB.Text             = Sql.ToString(rdr["JOB"]);
                                        STATUS.Text          = Sql.ToString(L10n.Term(".scheduler_status_dom.", rdr["STATUS"]));
                                        DATE_TIME_START.Text = (dtDATE_TIME_START == DateTime.MinValue) ? L10n.Term("Schedulers.LBL_PERENNIAL") : T10n.FromServerTime(dtDATE_TIME_START).ToString();
                                        DATE_TIME_END.Text   = (dtDATE_TIME_END == DateTime.MinValue) ? L10n.Term("Schedulers.LBL_PERENNIAL") : T10n.FromServerTime(dtDATE_TIME_END).ToString();
                                        LAST_RUN.Text        = (dtLAST_RUN == DateTime.MinValue) ? L10n.Term("Schedulers.LBL_NEVER") : T10n.FromServerTime(dtLAST_RUN).ToString();
                                        TIME_FROM.Text       = (dtTIME_FROM == DateTime.MinValue) ? L10n.Term("Schedulers.LBL_ALWAYS") : dtTIME_FROM.ToShortTimeString();
                                        TIME_TO.Text         = (dtTIME_TO == DateTime.MinValue) ? L10n.Term("Schedulers.LBL_ALWAYS") : dtTIME_TO.ToShortTimeString();
                                        CATCH_UP.Text        = Sql.ToBoolean(rdr["CATCH_UP"])           ? L10n.Term("Schedulers.LBL_ALWAYS") : L10n.Term("Schedulers.LBL_NEVER");
                                        JOB_INTERVAL.Text    = sJOB_INTERVAL + "<br>" + SchedulerUtils.CronDescription(L10n, sJOB_INTERVAL);
                                        DATE_ENTERED.Text    = T10n.FromServerTime(Sql.ToDateTime(rdr["DATE_ENTERED"])).ToString() + " " + L10n.Term(".LBL_BY") + " " + Sql.ToString(rdr["CREATED_BY"]);
                                        DATE_MODIFIED.Text   = T10n.FromServerTime(Sql.ToDateTime(rdr["DATE_MODIFIED"])).ToString() + " " + L10n.Term(".LBL_BY") + " " + Sql.ToString(rdr["MODIFIED_BY"]);
                                    }
                                }
                            }
                        }
                    }
                }
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlDetailButtons.ErrorText = ex.Message;
            }
        }
Example #22
0
        void UpdateContainerCaption(string subject)
        {
            string str = SchedulerUtils.FormatAppointmentFormCaption(this.Controller.AllDay, this.Controller.Subject, false);

            SchedulerFormBehavior.SetTitle(this, str);
        }
Example #23
0
        public virtual void TestExpireWhileRunning()
        {
            DrainDispatcher drainDispatcher = new DrainDispatcher();
            EventHandler <RMAppAttemptEvent> appAttemptEventHandler = Org.Mockito.Mockito.Mock
                                                                      <EventHandler>();
            EventHandler generic = Org.Mockito.Mockito.Mock <EventHandler>();

            drainDispatcher.Register(typeof(RMAppAttemptEventType), appAttemptEventHandler);
            drainDispatcher.Register(typeof(RMNodeEventType), generic);
            drainDispatcher.Init(new YarnConfiguration());
            drainDispatcher.Start();
            NodeId               nodeId       = BuilderUtils.NewNodeId("host", 3425);
            ApplicationId        appId        = BuilderUtils.NewApplicationId(1, 1);
            ApplicationAttemptId appAttemptId = BuilderUtils.NewApplicationAttemptId(appId, 1
                                                                                     );
            ContainerId containerId            = BuilderUtils.NewContainerId(appAttemptId, 1);
            ContainerAllocationExpirer expirer = Org.Mockito.Mockito.Mock <ContainerAllocationExpirer
                                                                           >();
            Resource  resource  = BuilderUtils.NewResource(512, 1);
            Priority  priority  = BuilderUtils.NewPriority(5);
            Container container = BuilderUtils.NewContainer(containerId, nodeId, "host:3465",
                                                            resource, priority, null);
            RMApplicationHistoryWriter writer = Org.Mockito.Mockito.Mock <RMApplicationHistoryWriter
                                                                          >();
            SystemMetricsPublisher publisher = Org.Mockito.Mockito.Mock <SystemMetricsPublisher
                                                                         >();
            RMContext rmContext = Org.Mockito.Mockito.Mock <RMContext>();

            Org.Mockito.Mockito.When(rmContext.GetDispatcher()).ThenReturn(drainDispatcher);
            Org.Mockito.Mockito.When(rmContext.GetContainerAllocationExpirer()).ThenReturn(expirer
                                                                                           );
            Org.Mockito.Mockito.When(rmContext.GetRMApplicationHistoryWriter()).ThenReturn(writer
                                                                                           );
            Org.Mockito.Mockito.When(rmContext.GetSystemMetricsPublisher()).ThenReturn(publisher
                                                                                       );
            Org.Mockito.Mockito.When(rmContext.GetYarnConfiguration()).ThenReturn(new YarnConfiguration
                                                                                      ());
            RMContainer rmContainer = new RMContainerImpl(container, appAttemptId, nodeId, "user"
                                                          , rmContext);

            NUnit.Framework.Assert.AreEqual(RMContainerState.New, rmContainer.GetState());
            NUnit.Framework.Assert.AreEqual(resource, rmContainer.GetAllocatedResource());
            NUnit.Framework.Assert.AreEqual(nodeId, rmContainer.GetAllocatedNode());
            NUnit.Framework.Assert.AreEqual(priority, rmContainer.GetAllocatedPriority());
            Org.Mockito.Mockito.Verify(writer).ContainerStarted(Matchers.Any <RMContainer>());
            Org.Mockito.Mockito.Verify(publisher).ContainerCreated(Matchers.Any <RMContainer>(
                                                                       ), Matchers.AnyLong());
            rmContainer.Handle(new RMContainerEvent(containerId, RMContainerEventType.Start));
            drainDispatcher.Await();
            NUnit.Framework.Assert.AreEqual(RMContainerState.Allocated, rmContainer.GetState(
                                                ));
            rmContainer.Handle(new RMContainerEvent(containerId, RMContainerEventType.Acquired
                                                    ));
            drainDispatcher.Await();
            NUnit.Framework.Assert.AreEqual(RMContainerState.Acquired, rmContainer.GetState()
                                            );
            rmContainer.Handle(new RMContainerEvent(containerId, RMContainerEventType.Launched
                                                    ));
            drainDispatcher.Await();
            NUnit.Framework.Assert.AreEqual(RMContainerState.Running, rmContainer.GetState());
            NUnit.Framework.Assert.AreEqual("http://host:3465/node/containerlogs/container_1_0001_01_000001/user"
                                            , rmContainer.GetLogURL());
            // In RUNNING state. Verify EXPIRE and associated actions.
            Org.Mockito.Mockito.Reset(appAttemptEventHandler);
            ContainerStatus containerStatus = SchedulerUtils.CreateAbnormalContainerStatus(containerId
                                                                                           , SchedulerUtils.ExpiredContainer);

            rmContainer.Handle(new RMContainerFinishedEvent(containerId, containerStatus, RMContainerEventType
                                                            .Expire));
            drainDispatcher.Await();
            NUnit.Framework.Assert.AreEqual(RMContainerState.Running, rmContainer.GetState());
            Org.Mockito.Mockito.Verify(writer, Org.Mockito.Mockito.Never()).ContainerFinished
                (Matchers.Any <RMContainer>());
            Org.Mockito.Mockito.Verify(publisher, Org.Mockito.Mockito.Never()).ContainerFinished
                (Matchers.Any <RMContainer>(), Matchers.AnyLong());
        }
Example #24
0
        public virtual void TestReleaseWhileRunning()
        {
            DrainDispatcher drainDispatcher = new DrainDispatcher();
            EventHandler <RMAppAttemptEvent> appAttemptEventHandler = Org.Mockito.Mockito.Mock
                                                                      <EventHandler>();
            EventHandler generic = Org.Mockito.Mockito.Mock <EventHandler>();

            drainDispatcher.Register(typeof(RMAppAttemptEventType), appAttemptEventHandler);
            drainDispatcher.Register(typeof(RMNodeEventType), generic);
            drainDispatcher.Init(new YarnConfiguration());
            drainDispatcher.Start();
            NodeId               nodeId       = BuilderUtils.NewNodeId("host", 3425);
            ApplicationId        appId        = BuilderUtils.NewApplicationId(1, 1);
            ApplicationAttemptId appAttemptId = BuilderUtils.NewApplicationAttemptId(appId, 1
                                                                                     );
            ContainerId containerId            = BuilderUtils.NewContainerId(appAttemptId, 1);
            ContainerAllocationExpirer expirer = Org.Mockito.Mockito.Mock <ContainerAllocationExpirer
                                                                           >();
            Resource  resource  = BuilderUtils.NewResource(512, 1);
            Priority  priority  = BuilderUtils.NewPriority(5);
            Container container = BuilderUtils.NewContainer(containerId, nodeId, "host:3465",
                                                            resource, priority, null);
            ConcurrentMap <ApplicationId, RMApp> rmApps = Org.Mockito.Mockito.Spy(new ConcurrentHashMap
                                                                                  <ApplicationId, RMApp>());
            RMApp rmApp = Org.Mockito.Mockito.Mock <RMApp>();

            Org.Mockito.Mockito.When(rmApp.GetRMAppAttempt((ApplicationAttemptId)Matchers.Any
                                                               ())).ThenReturn(null);
            Org.Mockito.Mockito.DoReturn(rmApp).When(rmApps)[(ApplicationId)Matchers.Any()];
            RMApplicationHistoryWriter writer = Org.Mockito.Mockito.Mock <RMApplicationHistoryWriter
                                                                          >();
            SystemMetricsPublisher publisher = Org.Mockito.Mockito.Mock <SystemMetricsPublisher
                                                                         >();
            RMContext rmContext = Org.Mockito.Mockito.Mock <RMContext>();

            Org.Mockito.Mockito.When(rmContext.GetDispatcher()).ThenReturn(drainDispatcher);
            Org.Mockito.Mockito.When(rmContext.GetContainerAllocationExpirer()).ThenReturn(expirer
                                                                                           );
            Org.Mockito.Mockito.When(rmContext.GetRMApplicationHistoryWriter()).ThenReturn(writer
                                                                                           );
            Org.Mockito.Mockito.When(rmContext.GetRMApps()).ThenReturn(rmApps);
            Org.Mockito.Mockito.When(rmContext.GetSystemMetricsPublisher()).ThenReturn(publisher
                                                                                       );
            Org.Mockito.Mockito.When(rmContext.GetYarnConfiguration()).ThenReturn(new YarnConfiguration
                                                                                      ());
            RMContainer rmContainer = new RMContainerImpl(container, appAttemptId, nodeId, "user"
                                                          , rmContext);

            NUnit.Framework.Assert.AreEqual(RMContainerState.New, rmContainer.GetState());
            NUnit.Framework.Assert.AreEqual(resource, rmContainer.GetAllocatedResource());
            NUnit.Framework.Assert.AreEqual(nodeId, rmContainer.GetAllocatedNode());
            NUnit.Framework.Assert.AreEqual(priority, rmContainer.GetAllocatedPriority());
            Org.Mockito.Mockito.Verify(writer).ContainerStarted(Matchers.Any <RMContainer>());
            Org.Mockito.Mockito.Verify(publisher).ContainerCreated(Matchers.Any <RMContainer>(
                                                                       ), Matchers.AnyLong());
            rmContainer.Handle(new RMContainerEvent(containerId, RMContainerEventType.Start));
            drainDispatcher.Await();
            NUnit.Framework.Assert.AreEqual(RMContainerState.Allocated, rmContainer.GetState(
                                                ));
            rmContainer.Handle(new RMContainerEvent(containerId, RMContainerEventType.Acquired
                                                    ));
            drainDispatcher.Await();
            NUnit.Framework.Assert.AreEqual(RMContainerState.Acquired, rmContainer.GetState()
                                            );
            rmContainer.Handle(new RMContainerEvent(containerId, RMContainerEventType.Launched
                                                    ));
            drainDispatcher.Await();
            NUnit.Framework.Assert.AreEqual(RMContainerState.Running, rmContainer.GetState());
            NUnit.Framework.Assert.AreEqual("http://host:3465/node/containerlogs/container_1_0001_01_000001/user"
                                            , rmContainer.GetLogURL());
            // In RUNNING state. Verify RELEASED and associated actions.
            Org.Mockito.Mockito.Reset(appAttemptEventHandler);
            ContainerStatus containerStatus = SchedulerUtils.CreateAbnormalContainerStatus(containerId
                                                                                           , SchedulerUtils.ReleasedContainer);

            rmContainer.Handle(new RMContainerFinishedEvent(containerId, containerStatus, RMContainerEventType
                                                            .Released));
            drainDispatcher.Await();
            NUnit.Framework.Assert.AreEqual(RMContainerState.Released, rmContainer.GetState()
                                            );
            NUnit.Framework.Assert.AreEqual(SchedulerUtils.ReleasedContainer, rmContainer.GetDiagnosticsInfo
                                                ());
            NUnit.Framework.Assert.AreEqual(ContainerExitStatus.Aborted, rmContainer.GetContainerExitStatus
                                                ());
            NUnit.Framework.Assert.AreEqual(ContainerState.Complete, rmContainer.GetContainerState
                                                ());
            Org.Mockito.Mockito.Verify(writer).ContainerFinished(Matchers.Any <RMContainer>());
            Org.Mockito.Mockito.Verify(publisher).ContainerFinished(Matchers.Any <RMContainer>
                                                                        (), Matchers.AnyLong());
            ArgumentCaptor <RMAppAttemptContainerFinishedEvent> captor = ArgumentCaptor.ForClass
                                                                         <RMAppAttemptContainerFinishedEvent>();

            Org.Mockito.Mockito.Verify(appAttemptEventHandler).Handle(captor.Capture());
            RMAppAttemptContainerFinishedEvent cfEvent = captor.GetValue();

            NUnit.Framework.Assert.AreEqual(appAttemptId, cfEvent.GetApplicationAttemptId());
            NUnit.Framework.Assert.AreEqual(containerStatus, cfEvent.GetContainerStatus());
            NUnit.Framework.Assert.AreEqual(RMAppAttemptEventType.ContainerFinished, cfEvent.
                                            GetType());
            // In RELEASED state. A FINIHSED event may come in.
            rmContainer.Handle(new RMContainerFinishedEvent(containerId, SchedulerUtils.CreateAbnormalContainerStatus
                                                                (containerId, "FinishedContainer"), RMContainerEventType.Finished));
            NUnit.Framework.Assert.AreEqual(RMContainerState.Released, rmContainer.GetState()
                                            );
        }