public SessionStateTableEntity(SessionState state, ServerMonitor monitor, Dictionary <string, ServerState> nonReplicaServers, string containerName, string epochId, string clientName)
        {
            this.secondaryReplicaServers = new Dictionary <string, ServerState>();
            this.primaryReplicaServers   = new Dictionary <string, ServerState>();
            this.nonReplicaServers       = new Dictionary <string, ServerState>();

            this.PartitionKey = containerName + epochId;
            this.RowKey       = clientName;

            // foreach (ServerState s in state.replicas.Values)
            foreach (ServerState s in monitor.GetAllServersState())
            {
                if (s.IsPrimary)
                {
                    primaryReplicaServers[s.Name] = s;
                }
                else
                {
                    secondaryReplicaServers[s.Name] = s;
                }
            }
            this.nonReplicaServers = nonReplicaServers;

            secondaryByte  = ToBytes(secondaryReplicaServers);
            primaryByte    = ToBytes(primaryReplicaServers);
            nonReplicaByte = ToBytes(nonReplicaServers);

            NumberOfReads  = state.GetNumberOfReadsPerMonth();
            NumberOfWrites = state.GetNumberOfWritesPerMonth();
        }
Пример #2
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));
        }
Пример #3
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));
        }