コード例 #1
0
        /// <summary>
        /// Retrieve wlb optimize pool recommendation action complete handler.
        /// Populate optimize pool listview and enable controls properly.
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">e</param>
        protected void OptRecRetrieveAction_Completed(ActionBase sender)
        {
            AsyncAction action = (AsyncAction)sender;

            if (action.IsCompleted)
            {
                action.Completed -= OptRecRetrieveAction_Completed;

                if (action is WlbRetrieveRecommendationAction)
                {
                    WlbRetrieveRecommendationAction thisAction = (WlbRetrieveRecommendationAction)action;
                    _recommendations = thisAction.WLBOptPoolRecommendations;
                    if (_recommendations != null && IsGoodRecommendation(_recommendations) && _xenObject.Connection == action.Connection)
                    {
                        Program.Invoke(this, delegate()
                        {
                            PopulateData(_recommendations);

                            // In case optimizePoolListView is empty
                            if (optimizePoolListView.Items.Count == 0)
                            {
                                statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION;
                                EnableControls(true, false);
                            }
                            else
                            {
                                EnableControls(false, true);
                            }
                        });
                    }
                    else
                    {
                        Program.Invoke(this, delegate()
                        {
                            statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION;
                            EnableControls(true, false);
                        });
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// WLB Optimize Pool
        /// </summary>
        /// <param name="connection">May not be null.</param>
        /// <returns></returns>
        internal static AsyncAction FindActiveOptAction(IXenConnection connection)
        {
            Program.AssertOnEventThread();
            foreach (ActionBase action in ConnectionsManager.History)
            {
                if (action.IsCompleted)
                {
                    continue;
                }

                WlbOptimizePoolAction optAction = action as WlbOptimizePoolAction;
                if (optAction != null && optAction.Connection == connection)
                {
                    return(optAction);
                }

                WlbRetrieveRecommendationAction optRecAction = action as WlbRetrieveRecommendationAction;
                if (optRecAction != null && optRecAction.Connection == connection)
                {
                    return(optRecAction);
                }
            }
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Build optimize pool list view properly
        /// </summary>
        private void BuildRecList()
        {
            Program.AssertOnEventThread();

            if (_xenObject == null)
            {
                return;
            }

            if (Helpers.WlbEnabled(_xenObject.Connection))
            {
                try
                {
                    if (_xenObject is Pool)
                    {
                        _pool = (Pool)_xenObject;

                        // get any active WLB action
                        action = HelpersGUI.FindActiveWLBAction(_xenObject.Connection);

                        // make sure we are not initializing, starting or stopping WLB
                        if (action is DisableWLBAction || action is EnableWLBAction || action is InitializeWLBAction)
                        {
                            return;
                        }

                        optimizePoolListView.BeginUpdate();

                        // check whether optimize pool is running before load optimize pool listview
                        if ((action != null && action is WlbOptimizePoolAction) ||
                            (action == null && _pool.other_config.ContainsKey(WlbOptimizationRecommendation.OPTIMIZINGPOOL) &&
                             _pool.other_config[WlbOptimizationRecommendation.OPTIMIZINGPOOL] == Messages.IN_PROGRESS))
                        {
                            //statusLabel.Text = Messages.WLB_OPT_OPTIMIZING;
                            this.applyButton.Text = Messages.WLB_OPT_OPTIMIZING;
                            EnableControls(false, false);
                        }
                        else if (action == null || (action != null && action.GetType() != typeof(WlbRetrieveRecommendationAction)))
                        {
                            this.applyButton.Text = Messages.WLB_OPT_APPLY_RECOMMENDATIONS;
                            // retrieve recommendations, and load optimize pool listview properly
                            WlbRetrieveRecommendationAction optAction = new WlbRetrieveRecommendationAction(_pool);
                            optAction.Completed += this.OptRecRetrieveAction_Completed;
                            optAction.RunAsync();
                        }
                    }
                }
                catch (Failure f)
                {
                    statusLabel.Text = Messages.WLB_OPT_LOADING_ERROR;
                    log.Error(f, f);
                }
                catch (Exception e)
                {
                    statusLabel.Text = Messages.WLB_OPT_LOADING_ERROR;
                    log.ErrorFormat("There was an error calling retrieve_wlb_recommendations on pool {0}", _pool.name_label);
                    log.Error(e, e);
                }

                finally
                {
                    optimizePoolListView.EndUpdate();
                }
            }
            else
            {
                this.WLBOptDisable(true);
            }
        }