public void ConstructedWithEmptyDictionaryVerifyGettersReturnValues()
        {
            wlbPool = new WlbPoolConfiguration(new Dictionary<string, string>());
            PropertyInfo[] pi = wlbPool.GetType().GetProperties();

            Assert.AreEqual(NUMBER_OF_PROPERTIES, pi.Length, "Number of properties");

            List<string> fieldsToSkip = new List<string>()
                                          {
                                             "AutoBalanceAggressiveness", //Enum
                                             "AutoBalanceSeverity",       //Enum
                                             "ReportingSMTPServer",       //Not set
                                             "PoolAuditGranularity"       //Enum
                                          };

            foreach (PropertyInfo propertyInfo in pi)
            {
                if( !fieldsToSkip.Contains( propertyInfo.Name ))
                {
                    string extractedValue = propertyInfo.GetValue(wlbPool, null).ToString();
                    Assert.IsFalse(String.IsNullOrEmpty(extractedValue), "PB:" + propertyInfo.Name);
                }
            }

            Assert.IsNullOrEmpty(wlbPool.ReportingSMTPServer);

        }
        private void Build()
        {
            _poolConfiguration = RetrieveWLBConfiguration();

            if (null != _poolConfiguration)
            {
                verticalTabs.Items.Clear();
                verticalTabs.Items.Add(wlbOptimizationModePage);
                wlbOptimizationModePage.PoolConfiguration = _poolConfiguration;
                wlbOptimizationModePage.Pool = _pool;

                if (_poolConfiguration.IsMROrLater)
                {
                    verticalTabs.Items.Add(wlbAutomationPage);
                    wlbAutomationPage.Connection = _pool.Connection;
                    wlbAutomationPage.PoolConfiguration = _poolConfiguration;

                    //verticalTabs.Items.Add(wlbPowerManagementPage);
                    //wlbPowerManagementPage.Connection = _pool.Connection;
                    //wlbPowerManagementPage.PoolConfiguration = _poolConfiguration;
                }

                verticalTabs.Items.Add(wlbThresholdsPage);
                wlbThresholdsPage.Connection = _pool.Connection;
                wlbThresholdsPage.PoolConfiguration = _poolConfiguration;

                verticalTabs.Items.Add(wlbMetricWeightingPage);
                wlbMetricWeightingPage.Connection = _pool.Connection;
                wlbMetricWeightingPage.PoolConfiguration = _poolConfiguration;

                if (_poolConfiguration.IsMROrLater)
                {
                    verticalTabs.Items.Add(wlbHostExclusionPage);
                    wlbHostExclusionPage.PoolConfiguration = _poolConfiguration;
                    wlbHostExclusionPage.Connection = _pool.Connection;
                }

                verticalTabs.Items.Add(wlbAdvancedSettingsPage);
                wlbAdvancedSettingsPage.PoolConfiguration = _poolConfiguration;
                wlbAdvancedSettingsPage.Pool = _pool;

                verticalTabs.SelectedIndex = 0;
            }
            else
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }
Beispiel #3
0
        private void SaveWLBConfig(WlbPoolConfiguration PoolConfiguration)
        {
            Dictionary<string, string> completeConfiguration = PoolConfiguration.ToDictionary();
            SendWlbConfigurationKind kind = SendWlbConfigurationKind.SetPoolConfiguration;

            // check for host configurations in the pool configuration
            if (PoolConfiguration.HostConfigurations.Count > 0)
            {
                // add the flag denoting that there are host configs to be saved
                kind |= SendWlbConfigurationKind.SetHostConfiguration;
                // get the key for each host config (host.uuid)
                foreach (string key in PoolConfiguration.HostConfigurations.ToDictionary().Keys)
                {
                    //Drop any exising copy from the pool configuration
                    if (completeConfiguration.ContainsKey(key))
                    {
                        completeConfiguration.Remove(key);
                    }
                    // and add the task to the collection
                    completeConfiguration.Add(key, PoolConfiguration.HostConfigurations.ToDictionary()[key]);
                }
            }

            // check for scheduled tasks in the pool configuration
            if (PoolConfiguration.ScheduledTasks.TaskList.Count > 0)
            {
                // add the flag denoting that there are scheduled tasks to be saved
                kind |= SendWlbConfigurationKind.SetScheduledTask;
                // get the key for each scheduled task
                foreach (string key in PoolConfiguration.ScheduledTasks.ToDictionary().Keys)
                {
                    //Drop any exising copy from the pool configuration
                    if (completeConfiguration.ContainsKey(key))
                    {
                        completeConfiguration.Remove(key);
                    }
                    // and add the task to the collection
                    completeConfiguration.Add(key, PoolConfiguration.ScheduledTasks.ToDictionary()[key]);
                }
            }

            SendWlbConfigurationAction action = new SendWlbConfigurationAction(_pool, PoolConfiguration.ToDictionary(), kind);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
            dialog.ShowCancel = true;
            dialog.ShowDialog(this);
            Program.MainWindow.UpdateToolbars();
        }
Beispiel #4
0
        protected void action_Completed(object sender, EventArgs e)
        {
            // This seems to be called off the event thread
            AsyncAction action = (AsyncAction)sender;
            if (action.IsCompleted)
            {
                action.Completed -= action_Completed;
                if (action is EnableWLBAction || action is RetrieveWlbConfigurationAction || action is DisableWLBAction)
                {
                    if (action is EnableWLBAction)
                    {
                        EnableWLBAction thisAction = (EnableWLBAction)action;
                        _wlbPoolConfiguration = new WlbPoolConfiguration(thisAction.WlbConfiguration);
                    }
                    else if (action is RetrieveWlbConfigurationAction)
                    {
                        RetrieveWlbConfigurationAction thisAction = (RetrieveWlbConfigurationAction)action;
                        if (thisAction.Succeeded)
                        {
                            _wlbPoolConfiguration = new WlbPoolConfiguration(thisAction.WlbConfiguration);
                        }
                        else
                        {
                            //_statusError = thisAction.Exception.Message;
                            _wlbPoolConfiguration = null;
                        }
                    }
                    else if (action is DisableWLBAction)
                    {
                    }

                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        if (_pool != null && _pool.Connection == action.Connection)
                        {
                            RefreshControls();
                        }
                    });
                }
            }
        }
Beispiel #5
0
        internal void EditWLB(Pool pool)
        {
            // Do nothing if there is a WLB action in progress
            if (HelpersGUI.FindActiveWLBAction(pool.Connection) != null)
            {
                log.Debug("Not opening WLB dialog: an WLB action is in progress");
                return;
            }

            if (!pool.Connection.IsConnected)
            {
                log.Debug("Not opening WLB dialog: the connection to the pool is now closed");
                return;
            }

            try
            {
                WlbConfigurationDialog wlbConfigDialog = new WlbConfigurationDialog(pool);
                DialogResult dr = wlbConfigDialog.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    _wlbPoolConfiguration = wlbConfigDialog.WlbPoolConfiguration;

                    //check to see if the current opt mode matches the current schedule
                    if (_wlbPoolConfiguration.AutomateOptimizationMode)
                    {
                        WlbPoolPerformanceMode scheduledPerfMode = _wlbPoolConfiguration.ScheduledTasks.GetCurrentScheduledPerformanceMode();
                        if (scheduledPerfMode != _wlbPoolConfiguration.PerformanceMode)
                        {
                            string blurb = string.Format(Messages.WLB_PROMPT_FOR_MODE_CHANGE_BLURB, getOptModeText(scheduledPerfMode), getOptModeText(_wlbPoolConfiguration.PerformanceMode));
                            DialogResult drModeCheck = new ThreeButtonDialog(
                                new ThreeButtonDialog.Details(null, blurb, Messages.WLB_PROMPT_FOR_MODE_CHANGE_CAPTION),
                                ThreeButtonDialog.ButtonYes,
                                ThreeButtonDialog.ButtonNo).ShowDialog(this);

                            if (drModeCheck == DialogResult.Yes)
                            {
                                _wlbPoolConfiguration.PerformanceMode = scheduledPerfMode;
                            }
                        }
                    }
                    SaveWLBConfig(_wlbPoolConfiguration);
                }
            }
            catch (Exception ex)
            {
                log.Debug("Unable to open the WLB configuration dialog.", ex);
                return;
            }

            if (!(WlbServerState.GetState(_pool) == WlbServerState.ServerState.NotConfigured))
            {
                RetrieveConfiguration();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Retrieve subscriptions and set _subscriptionCollection
        /// </summary>
        private void SetSubscriptionCollection()
        {
            _subscriptionCollection = null;

            WlbPoolConfiguration poolConfiguration;
            RetrieveWlbConfigurationAction action = new RetrieveWlbConfigurationAction(_pool);
            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            if (action.Succeeded)
            {
                poolConfiguration = new WlbPoolConfiguration(action.WlbConfiguration);
                _isMROrLater = poolConfiguration.IsMROrLater;
                _isBostonOrLater = poolConfiguration.IsBostonOrLater;
                _isCreedenceOrLater = poolConfiguration.IsCreedenceOrLater;

                if (_isMROrLater && !_isBostonOrLater)
                {
                    _subscriptionCollection = new WlbReportSubscriptionCollection(action.WlbConfiguration);
                }

                if (_isBostonOrLater)
                {
                    this.splitContainerLeftPane.Panel2Collapsed = true;
                    this.wlbReportView1.btnSubscribe.Visible=false;
                }
            }
            else
            {
                throw (action.Exception);
            }
        }
 public void NullCtorThrows()
 {
    wlbPool = new WlbPoolConfiguration(null); 
 }
        public void OvercommitCPUsGetTheCorrectValueForDifferentModes()
        {
            Dictionary<string, string> inputData = new Dictionary<string, string>()
                                                       {
                                                           {"OverCommitCpuInDensityMode", "false"},
                                                           {"OverCommitCpuInPerfMode", "true"}
                                                       };

            wlbPool = new WlbPoolConfiguration(inputData);

            //Setter drops through if the key has not been added to the dictionary so won't set the values
            wlbPool.PerformanceMode = WlbPoolPerformanceMode.MaximizeDensity;
            //This should be false if the key were there
            Assert.IsTrue(wlbPool.OvercommitCPUs, "OvercommitCPUs in MaximizeDensity mode without key");

            //Add the key and set the data - this is now the default behaviour
            wlbPool.AddParameter("OptimizationMode", "MaximizeDensity");
            wlbPool.PerformanceMode = WlbPoolPerformanceMode.MaximizeDensity;
            Assert.IsFalse(wlbPool.OvercommitCPUs, "OvercommitCPUs in MaximizeDensity mode");

            wlbPool.PerformanceMode = WlbPoolPerformanceMode.MaximizePerformance;
            Assert.IsTrue(wlbPool.OvercommitCPUs, "OvercommitCPUs in MaximizePerformance");
        }