Пример #1
0
        private void installSLA1Button_Click(object sender, EventArgs e)
        {
            DemoLib.SetCurrentSLA("Fast or Strong");
            ServiceLevelAgreement sla = DemoLib.GetCurrentSLA();

            DisplaySLA(sla);
        }
Пример #2
0
        private void installSLA2Button_Click(object sender, EventArgs e)
        {
            DemoLib.SetCurrentSLA("Shopping Cart");
            ServiceLevelAgreement sla = DemoLib.GetCurrentSLA();

            DisplaySLA(sla);
        }
Пример #3
0
        private void DisplaySLA(ServiceLevelAgreement sla)
        {
            List <string> slaConsistency = new List <string>();
            List <string> slaLatency     = new List <string>();
            List <string> slaUtility     = new List <string>();

            foreach (SubSLA sub in sla)
            {
                string consistency = sub.Consistency.ToString();
                if (sub.Bound != 0)
                {
                    consistency += " (" + sub.Bound.ToString() + " sec)";
                }
                slaConsistency.Add(consistency);
                slaLatency.Add(sub.Latency.ToString() + " ms.");
                slaUtility.Add(sub.Utility.ToString());
            }
            slaConsistencyListBox.DataSource = null;
            slaConsistencyListBox.DataSource = slaConsistency;
            slaConsistencyListBox.ClearSelected();
            slaLatencyListBox.DataSource = null;
            slaLatencyListBox.DataSource = slaLatency;
            slaLatencyListBox.ClearSelected();
            slaUtilityListBox.DataSource = null;
            slaUtilityListBox.DataSource = slaUtility;
            slaUtilityListBox.ClearSelected();

            Sampler sampler = initialConfig ? initialSampler : reconfigSampler;

            slaDeliveredUtility.Text = DemoLib.GetCurrentSLAUtility().ToString("F2");
            slaReadTime.Text         = sampler.GetSampleValue("slaLatency").ToString("F2");
        }
 public ServiceLevelAgreementTableEntity(ServiceLevelAgreement sla, string containerName, string epochId, string clientName)
 {
     this.SetSLA(sla);
     this.ClientName   = clientName;
     this.PartitionKey = containerName + epochId;
     this.RowKey       = clientName + sla.Id;
 }
 public ServiceLevelAgreement GetSLA()
 {
     if (_sla == null)
     {
         _sla = FromBytes(byteSLA);
     }
     return(_sla);
 }
Пример #6
0
        public static ServiceLevelAgreement CreateBoundedConsistencySla(int bound)
        {
            ServiceLevelAgreement sla = new ServiceLevelAgreement("Bounded");
            SubSLA subSla1            = new SubSLA(2000, Consistency.Bounded, bound, 1);

            sla.Add(subSla1);
            return(sla);
        }
Пример #7
0
        public static ServiceLevelAgreement CreateConsistencySla(Consistency cons, int latency, string Name)
        {
            ServiceLevelAgreement sla = new ServiceLevelAgreement(Name);
            SubSLA subSla1            = new SubSLA(latency, cons, 0, 1);

            sla.Add(subSla1);
            return(sla);
        }
Пример #8
0
        /// <summary>
        /// Creates a simple SLA with a single desired consistency and a large latency.
        /// This forces reads to be performed at the closest replica with that consistency.
        /// </summary>
        /// <param name="cons"></param>
        /// <returns></returns>
        public static ServiceLevelAgreement CreateConsistencySla(Consistency cons)
        {
            ServiceLevelAgreement sla = new ServiceLevelAgreement(cons.ToString("g"));
            SubSLA subSla1            = new SubSLA(2000, cons, 0, 1);

            sla.Add(subSla1);
            return(sla);
        }
Пример #9
0
 //Delete
 public void DeleteSLA(ServiceLevelAgreement SLA)
 {
     //Call SLA  If SLA Exiss then throw Exception before Deleting
     if (SLAInPackage(SLA) == false)
     {
         SLA_Ctr.Delete(SLA);
     }
 }
        public List <Package> Read()
        {
            DataHandler dh = new DataHandler();

            List <Package> packageList = new List <Package>();
            //                     0           1         2              3             4                   5               6                            7                  8                        9
            string query = "SELECT P.PackageID, P.pName, P.pDescription, S.ServiceID, S.expectedDuration, S.sDescription, SLA.ServiceLevelAgreementID, SLA.slaDescription, P.EquipmentCategoryID , EC.CategoryName FROM Package P " +
                           "LEFT JOIN Service S ON S.ServiceID = P.ServiceID " +
                           "LEFT JOIN ServiceLevelAgreement SLA ON SLA.ServiceLevelAgreementID = P.ServiceLevelAgreementID " +
                           "LEFT JOIN EquipmentCategory EC ON EC.EquipmentCategoryID = P.EquipmentCategoryID ";

            SqlDataReader         read = dh.Select(query);
            EquipmentCategory     category;
            Service               service;
            ServiceLevelAgreement serviceLevelAgreement;
            Package               package;

            if (read.HasRows)
            {
                while (read.Read())
                {
                    service = new Service(
                        read.GetString(5),
                        read.GetInt32(4)
                        );
                    service.Id = read.GetInt32(3);

                    serviceLevelAgreement = new ServiceLevelAgreement(
                        read.GetString(7)
                        );
                    serviceLevelAgreement.Id = read.GetInt32(6);


                    category = new EquipmentCategory(
                        read.GetString(9)
                        );
                    category.Id = read.GetInt32(8);


                    package = new Package(
                        read.GetString(1),
                        read.GetString(2),
                        service,
                        serviceLevelAgreement,
                        category
                        );

                    package.Id = read.GetInt32(0);

                    packageList.Add(package);
                }
            }

            dh.Dispose();

            return(packageList);
        }
        public frmEditSLA(ServiceLevelAgreement sla)
        {
            InitializeComponent();

            this.Sla = sla;


            txtSLaDescription.Text = sla.Description;
        }//Construct the SLA FROm and arse a cliet from frmservice Contract
Пример #12
0
        public static void Initialize()
        {
            // get list of Azure storage accounts
            accounts = PileusApp.Account.GetStorageAccounts(false);
            ClientRegistry.Init(accounts, accounts[configStorageSite]);

            // delete cloud configuration if desired
            if (clearConfiguration)
            {
                ReplicaConfiguration    configToDelete = new ReplicaConfiguration(containerName);
                ConfigurationCloudStore backingStore   = new ConfigurationCloudStore(accounts[configStorageSite], configToDelete);
                Log("Deleting configuration in Azure...");
                backingStore.DeleteConfiguration();
                Log("Done.  Now waiting for it to really take effect...");
                Thread.Sleep(40000);  // give system a chance to complete delete
            }

            // read/create configuration
            Log("Creating/reading configuration...");
            config = new ReplicaConfiguration(containerName, PrimaryServers, SecondaryServers, NonReplicaServers, ReadOnlySecondaryServers, cloudBackedConfiguration, stableConfiguration);
            ClientRegistry.AddConfiguration(config);

            // upload data into containers if desired
            if (reloadDatabase)
            {
                CreateDatabase(numBlobs);
            }

            // create SLAs
            slas                 = new Dictionary <string, ServiceLevelAgreement>();
            slas["strong"]       = CreateConsistencySla(Consistency.Strong);
            slas["causal"]       = CreateConsistencySla(Consistency.Causal);
            slas["bounded"]      = CreateBoundedConsistencySla(boundInSeconds);
            slas["readmywrites"] = CreateConsistencySla(Consistency.ReadMyWrites);
            slas["monotonic"]    = CreateConsistencySla(Consistency.MonotonicReads);
            slas["eventual"]     = CreateConsistencySla(Consistency.Eventual);
            currentSLA           = CreateFastOrStrongSla();
            slas["sla"]          = currentSLA;

            // get/create replicated container
            Log("Creating replicated container...");
            Dictionary <string, CloudBlobContainer> containers = new Dictionary <string, CloudBlobContainer>();

            foreach (string site in accounts.Keys)
            {
                CloudBlobClient    blobClient    = accounts[site].CreateCloudBlobClient();
                CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);
                blobContainer.CreateIfNotExists();
                containers.Add(site, blobContainer);
            }
            container = new CapCloudBlobContainer(containers, PrimaryServers.First());
            container.Configuration = config;
            container.Monitor       = new ServerMonitor(config);

            configurator = new Configurator(containerName);
        }
Пример #13
0
        public static ServiceLevelAgreement CreateShoppingCartSla2()
        {
            ServiceLevelAgreement sla = new ServiceLevelAgreement("" + 2);
            SubSLA subSla1            = new SubSLA(800, Consistency.Strong, 0, 1);
            SubSLA subSla2            = new SubSLA(920, Consistency.ReadMyWrites, 0, 1f);
            SubSLA subSla3            = new SubSLA(1070, Consistency.Eventual, 0, 1f);

            sla.Add(subSla1);
            sla.Add(subSla2);
            sla.Add(subSla3);
            return(sla);
        }
        private void btnAddPackage1_Click(object sender, EventArgs e)
        {
            //Here we call from the Service Contract logic
            if (txtPDiscript.Text.Equals(""))
            {
                MessageBox.Show("Please enter Package description details", "EMPTY FIELDS!!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }//Data validation
            if (txtPName.Text.Equals(""))
            {
                MessageBox.Show("Please enter package name details", "EMPTY FIELDS!!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }//Data Validation
            if (cmbPService.SelectedIndex < 0)
            {
                MessageBox.Show("Please Select a Service", "EMPTY VALUE!!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (cmbPSLA.SelectedIndex < 0)
            {
                MessageBox.Show("Please Select a Service Level Agreemnt", "EMPTY VALUE!!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Description = txtPDiscript.Text;
                Name        = txtPName.Text;

                service = Placeholder_Service_List[cmbPService.SelectedIndex];
                sla     = Placeholder_SLA_List[cmbPSLA.SelectedIndex];
                EQC     = Placeholder_EQC_List[cbxEquitptmentCatagory.SelectedIndex];


                /*
                 * ! You were here last
                 *
                 */



                newPackage = new Package(Name, Description, service, sla, EQC);

                P_L.Addpackage(newPackage);

                MessageBox.Show("Service successfully Added", " ADD",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Perform Fom transition
                Hide();
                frmServiceContract form = new frmServiceContract();
                form.ShowDialog();
            }
        }//Add a Package
Пример #15
0
        public static ServiceLevelAgreement CreateFastOrStrongSla()
        {
            ServiceLevelAgreement sla = new ServiceLevelAgreement("Fast or Strong");
            SubSLA subSla1            = new SubSLA(100, Consistency.Strong, 0, 1);
            SubSLA subSla2            = new SubSLA(100, Consistency.Bounded, boundInSeconds, 0.8f);
            SubSLA subSla3            = new SubSLA(100, Consistency.Eventual, 0, 0.5f);
            SubSLA subSla4            = new SubSLA(2000, Consistency.Strong, 0, 0.25f);

            sla.Add(subSla1);
            sla.Add(subSla2);
            sla.Add(subSla3);
            sla.Add(subSla4);
            return(sla);
        }
Пример #16
0
        public static ServiceLevelAgreement CreateShoppingCartSla()
        {
            ServiceLevelAgreement sla = new ServiceLevelAgreement("Shopping Cart");
            SubSLA subSla1            = new SubSLA(300, Consistency.Strong, 0, 1);
            SubSLA subSla2            = new SubSLA(300, Consistency.ReadMyWrites, 0, 0.75f);
            SubSLA subSla3            = new SubSLA(300, Consistency.Eventual, 0, 0.5f);
            SubSLA subSla4            = new SubSLA(800, Consistency.Eventual, 0, 0.25f);

            sla.Add(subSla1);
            sla.Add(subSla2);
            sla.Add(subSla3);
            sla.Add(subSla4);
            return(sla);
        }
Пример #17
0
        public static PSServiceLevelAgreement ToPSServiceLevelAgreement(this ServiceLevelAgreement sdkServiceLevelAgreement)
        {
            if (sdkServiceLevelAgreement == null)
            {
                return(null);
            }

            return(new PSServiceLevelAgreement
            {
                StartTime = sdkServiceLevelAgreement.StartTime,
                ExpirationTime = sdkServiceLevelAgreement.ExpirationTime,
                SlaMinutes = sdkServiceLevelAgreement.SlaMinutes
            });
        }
Пример #18
0
        public bool  SLAInPackage(ServiceLevelAgreement SLA)
        {
            bool Found = false;

            foreach (Package package in new PackageController().Read())
            {
                if (package.Sla.Equals(SLA))
                {
                    Found = true;
                    throw new SLAExistsException(package);
                }
            }
            return(Found);
        }//Check if service is in packages
        }//Load the SLA into the list view when form loads

        private void btnRemove_Click(object sender, EventArgs e)
        {
            //If a item is selected in the list view perform delete

            bool Valid = true;

            //If a item is selected in the list view perform delete
            if (lstSLA.SelectedItems.Count > 0)
            {
                //Ask user for conformation
                DialogResult deleteI = MessageBox.Show("Are you sure you want to delete this SLA?", "WARNING: DELETE Package",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                //Get user for conformation


                if (deleteI == DialogResult.Yes)
                {
                    ServiceLevelAgreement RSLA = lstSLA.SelectedItems[0].Tag as ServiceLevelAgreement;

                    //Parse the object to the Service logic to perform action

                    try
                    {
                        SLAL.DeleteSLA(RSLA);
                    }
                    catch (SLAExistsException ex)
                    {
                        MessageBox.Show(string.Format("DELETION ANOMOLY {0}", ex));

                        Valid = false;
                    }
                    if (Valid == true)
                    {
                        MessageBox.Show("SLA successfully deleted", " DELETED",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lstSLA.Clear();
                    }

                    frmServiceContract form = new frmServiceContract();
                    DialogResult       res  = form.ShowDialog();
                    LoadServices();
                }
            }
            else
            {
                MessageBox.Show("No Record was selected", "SELECTION",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }//Remove SLA
Пример #20
0
        public static void SetCurrentSLA(string name)
        {
            switch (name)
            {
            case "Fast or Strong":
                currentSLA  = CreateFastOrStrongSla();
                slas["sla"] = currentSLA;
                break;

            case "Shopping Cart":
                currentSLA  = CreateShoppingCartSla();
                slas["sla"] = currentSLA;
                break;

            default:
                // do nothing
                break;
            }
        }
Пример #21
0
        /// <summary>
        /// Picks a new configuration given a single SLA and single client's session state
        /// </summary>
        /// <param name="sla">The SLA for which the new configuration should be tailored</param>
        /// <param name="ss">The session state</param>
        /// <param name="constraints">The constraints</param>
        /// <returns>a set of reconfiguration actions</returns>
        public float ComputeUtilityGainFromNewConfiguration(string containerName, ServiceLevelAgreement sla, SessionState ss, ServerMonitor monitor, ReplicaConfiguration config, List <ConfigurationAction> actions)
        {
            Dictionary <string, ClientUsageData> clientData = new Dictionary <string, ClientUsageData>();
            ClientUsageData usage = new ClientUsageData("local");

            // Convert args into client data
            usage.SLAs.Add(sla);
            usage.NumberOfReads  = ss.GetNumberOfReadsPerMonth();
            usage.NumberOfWrites = ss.GetNumberOfWritesPerMonth();
            usage.ServerRTTs     = new Dictionary <string, LatencyDistribution>();
            foreach (ServerState server in monitor.GetAllServersState())
            {
                usage.ServerRTTs.Add(server.Name, server.RTTs);
            }

            // Use client data for a single user
            clientData.Add(usage.ClientName, usage);

            return(ComputeUtilityGain(config, actions, clientData));
        }
Пример #22
0
        private float ExpectedUtilityForSla(ReplicaConfiguration config, ServiceLevelAgreement sla, Dictionary <string, LatencyDistribution> serverRTTs)
        {
            float         utility        = 0;
            float         cumulativeProb = 0;
            float         prob           = 0;
            List <string> allServers     = config.GetServers(true, true, false);

            foreach (SubSLA sub in sla)
            {
                foreach (string server in allServers)
                {
                    prob = allServers.Max(s => serverRTTs[s].ProbabilityOfFindingValueLessThanGiven(sub.Latency)
                                          * ProbabilityOfServerConsistency(config, s, sub.Consistency, sub.Bound));
                }
                float subUtility = (1 - cumulativeProb) * prob * sub.Utility;
                utility        += subUtility;
                cumulativeProb += (1 - cumulativeProb) * prob;
            }
            return(utility);
        }
Пример #23
0
        /// <summary>
        /// Picks a new configuration given a single SLA and single client's session state
        /// </summary>
        /// <param name="sla">The SLA for which the new configuration should be tailored</param>
        /// <param name="ss">The session state</param>
        /// <param name="constraints">The constraints</param>
        /// <returns>a set of reconfiguration actions</returns>
        public List <ConfigurationAction> PickNewConfiguration(string containerName, ServiceLevelAgreement sla, SessionState ss, ServerMonitor monitor, ReplicaConfiguration config, List <ConfigurationConstraint> constraints)
        {
            Dictionary <string, ClientUsageData> clientData = new Dictionary <string, ClientUsageData>();
            ClientUsageData usage = new ClientUsageData("local");

            // Convert args into client data
            usage.SLAs.Add(sla);
            usage.NumberOfReads  = ss.GetNumberOfReadsPerMonth();
            usage.NumberOfWrites = ss.GetNumberOfWritesPerMonth();
            usage.ServerRTTs     = new Dictionary <string, LatencyDistribution>();
            foreach (ServerState server in monitor.GetAllServersState())
            {
                usage.ServerRTTs.Add(server.Name, server.RTTs);
            }

            // Use client data for a single user
            clientData.Add(usage.ClientName, usage);

            // Choose actions to produce a better configuration
            return(ChooseReconfigActions(clientData, constraints, config));
        }
        }//Load the SLA from SLA logic

        private void btnAddSLA_Click(object sender, EventArgs e)
        {
            //Here we call from the SLA Contract logic

            if (txtSLADescript.Text.Equals(""))
            {
                MessageBox.Show("Please enter Service Level Agreement description details", "EMPTY FIELDS!!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }//Data validation
            else
            {
                SlaDescription = txtSLADescript.Text;
                NewSla         = new ServiceLevelAgreement(SlaDescription);

                Sl.AddSLA(NewSla);
                MessageBox.Show("Service successfully Added", " ADD",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                Hide();
                frmServiceContract form = new frmServiceContract();
                form.ShowDialog();
            } //Add the SLA
        }     //Validate inputs and add SLA
Пример #25
0
        public static void CheckAction(ConfigurationAction action, ServiceLevelAgreement SLA, ClientUsageData usage, ReplicaConfiguration currentConfig)
        {
            ReplicaConfiguration newConfig = action.IfApply(currentConfig);

            foreach (SubSLA s in SLA)
            {
                float currentProbability = GetApplicableServers(s, currentConfig, usage).Max(server => server.ProbabilityOfFindingValueLessThanGiven(s.Latency));
                //probability of new state should be computed in pessimistic mode. I.e., if there is no entry in the distribution of session state, instead of returning 1, we return 0.
                float newProbability = GetApplicableServers(s, newConfig, usage).Max(server => server.ProbabilityOfFindingValueLessThanGiven(s.Latency, false));

                /*
                 * // Not sure why the utility is multiplied by hits or misses
                 * if (newProbability > currentProbability)
                 * {
                 *  action.AddUtility((newProbability - currentProbability) * s.NumberOfMisses * s.Utility);
                 * }
                 * else
                 * {
                 *  action.AddUtility((newProbability - currentProbability) * s.NumberOfHits * s.Utility);
                 * }
                 * */
                action.AddUtility((newProbability - currentProbability) * s.Utility);
            }
        }
        }//Remove SLA

        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (lstSLA.SelectedItems.Count > 0)
            {
                //Ask user for conformation
                DialogResult deleteI = MessageBox.Show("Are you sure you want to edit this SLA?", "WARNING: Edit SLA",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                //Get user for conformation
                if (deleteI == DialogResult.Yes)
                {
                    //Hide this form and dispay the Dialog for the Service Contract Manu

                    ServiceLevelAgreement sla  = lstSLA.SelectedItems[0].Tag as ServiceLevelAgreement;
                    frmEditSLA            form = new frmEditSLA(sla);
                    DialogResult          res  = form.ShowDialog();
                    LoadServices();
                }
            }
            else
            {
                MessageBox.Show("No Record was selected", "SELECTION",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }//Edit the SLA
 public void SetSLA(ServiceLevelAgreement sla)
 {
     _sla    = sla;
     byteSLA = sla.ToBytes();
 }
Пример #28
0
        }//View Service //Return a list of services

        //Update
        public void UpdateSla(ServiceLevelAgreement SLA)
        {
            SLA_Ctr.Update(SLA);
        }
Пример #29
0
        private void getCurrentSLAButton_Click(object sender, EventArgs e)
        {
            ServiceLevelAgreement sla = DemoLib.GetCurrentSLA();

            DisplaySLA(sla);
        }
Пример #30
0
 //Insert
 public void AddSLA(ServiceLevelAgreement SLA)
 {
     SLA_Ctr.Create(SLA);
 }