Exemple #1
0
        public override double ComputeCost()
        {
            double result            = 0;
            double transactionalCost = CostModel.GetSecondaryTransactionalCost(numberOfReads);

            double syncCost    = CostModel.GetSyncCost(numberOfWrites, ConstPool.DEFAULT_SYNC_INTERVAL);
            double StorageCost = CostModel.GetStorageCost(ClientRegistry.GetMainPrimaryContainer(Configuration.Name));

            result = transactionalCost + syncCost + StorageCost;
            return(result);
        }
        public override double ComputeCost()
        {
            double           result = 0;
            DowngradePrimary p      = new DowngradePrimary(Configuration.Name, ServerName, 0, null, ConfigurationActionSource.Constraint, numberOfReads, numberOfWrites);

            if (Configuration.SecondaryServers.Contains(ServerName))
            {
                //all primaries will become secondary,
                result = Configuration.PrimaryServers.Count * p.ComputeCost();

                //a secondary will become primary:
                int secondarySyncPeriod = Configuration.GetSyncPeriod(ServerName);
                result += CostModel.GetPrimaryTransactionalCost(numberOfReads, numberOfWrites) - (CostModel.GetSecondaryTransactionalCost(numberOfReads) + CostModel.GetSyncCost(numberOfWrites, secondarySyncPeriod));
            }
            else if (Configuration.PrimaryServers.Contains(ServerName))
            {
                //all primaries except one will become secondary
                result = (Configuration.PrimaryServers.Count - 1) * p.ComputeCost();
            }
            else
            {
                // all primaries will become secondary
                result = Configuration.PrimaryServers.Count * p.ComputeCost();

                //one non-replica becomes primary
                result += CostModel.GetPrimaryTransactionalCost(numberOfReads, numberOfWrites) + CostModel.GetStorageCost(ClientRegistry.GetMainPrimaryContainer(Configuration.Name));
            }

            return(result);
        }
Exemple #3
0
        public override double ComputeCost()
        {
            double result = 0;

            if (NumberOfAddingReplica() == 0)
            {
                int secondarySyncPeriod = Configuration.GetSyncPeriod(ServerName);
                result = CostModel.GetPrimaryTransactionalCost(numberOfReads, numberOfWrites) - (CostModel.GetSecondaryTransactionalCost(numberOfReads) + CostModel.GetSyncCost(numberOfWrites, secondarySyncPeriod));
            }
            else
            {
                result = CostModel.GetPrimaryTransactionalCost(numberOfReads, numberOfWrites) + CostModel.GetStorageCost(ClientRegistry.GetMainPrimaryContainer(Configuration.Name));
            }

            return(result);
        }