Exemplo n.º 1
0
        public YCSBWorkload(YCSBWorkloadType type, int numberOfObjects)
        {
            string traceDir = Directory.GetCurrentDirectory() + "\\YCSB\\";

            if (type == YCSBWorkloadType.Workload_a)
            {
                traceDir += "workloada\\";
            }
            else if (type == YCSBWorkloadType.Workload_b)
            {
                traceDir += "workloadb\\";
            }
            else if (type == YCSBWorkloadType.Workload_c)
            {
                traceDir += "workloadb\\";
            }

            Random rand        = new Random(Interlocked.Increment(ref seed));
            int    traceNumber = rand.Next(1, YCSBConst.NUMBER_OF_AVAILABLE_TRACES);

            traceDir += traceNumber;

            operations = new List <YCSBOperation>();

            string[] lines = File.ReadAllLines(traceDir);

            foreach (string line in lines)
            {
                string command = line.Split(' ')[2];
                command = command.Replace(YCSBConst.YCSB_KEY_PREFIX, "");
                if (Convert.ToInt32(command) > numberOfObjects || command.Equals(""))
                {
                    continue;
                }

                if (line.Contains("READ"))
                {
                    operations.Add(new YCSBOperation(line.Split(' ')[2], YCSBOperationType.READ));
                }
                else if (line.Contains("UPDATE"))
                {
                    operations.Add(new YCSBOperation(line.Split(' ')[2], YCSBOperationType.UPDATE));
                }
            }
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.CancelKeyPress += new ConsoleCancelEventHandler(StoreLog);

            Dictionary <string, Sampler.OutputType> sampleNames = new Dictionary <string, Sampler.OutputType>();

            sampleNames["Utility"]           = Sampler.OutputType.Average;
            sampleNames["concurrentWorkers"] = Sampler.OutputType.Average;
            sampleNames["ReadLatency"]       = Sampler.OutputType.Average;
            sampleNames["WriteLatency"]      = Sampler.OutputType.Average;
            sampleNames["ReadCount"]         = Sampler.OutputType.Total;
            sampleNames["WriteCount"]        = Sampler.OutputType.Total;

            sampler = new Sampler(true, sampleNames, GetEmulationTime);

            if (args.Length == 0)
            {
                args = new string[11];

                // the result folder name
                args[0] = "folder1";

                // workload type
                args[1] = "b";

                // number of clients @ pick time
                args[2] = "15";

                // the blob size in Byte
                args[3] = "1024";

                // use https or not
                args[4] = "false";

                //sleep time between ticks in milliseconds.
                args[5] = "90000";

                //interval length in ticks
                args[6] = "24";

                //duration of experiment in ticks
                args[7] = "24";

                //storage account locating configuration of given container
                args[8] = "dbtsouthstorage"; // "devstoreaccount1";

                //container  name
                args[9] = "testcontainer";

                //emulation start time at UTC
                args[10] = "9";
            }

            resultFileFolderName = args[0];
            if (args[1].Equals("a"))
            {
                workloadType = YCSBWorkloadType.Workload_a;
            }
            else if (args[1].Equals("b"))
            {
                workloadType = YCSBWorkloadType.Workload_b;
            }
            else if (args[1].Equals("c"))
            {
                workloadType = YCSBWorkloadType.Workload_c;
            }
            else
            {
                throw new Exception("Unkown workload");
            }
            numberOfClientAtPickTime = Int32.Parse(args[2]);
            blobSizeInB = Int32.Parse(args[3]);
            useHttps    = bool.Parse(args[4]);

            sleepTimeBetweenTicks = Int32.Parse(args[5]);
            intervalLength        = Int32.Parse(args[6]);
            totalExperimentLength = Int32.Parse(args[7]);

            testSite      = args[8];
            containerName = args[9];

            currentEmulationHour = Int32.Parse(args[10]);

            if (!Directory.Exists(resultFileFolderName))
            {
                Directory.CreateDirectory(resultFileFolderName);
            }

            resultFile = string.Format(@"{5}\{6}_{0}_{1}_{2}_{3}_{4}.csv", blobSizeInB, parallelRequestsPerBlob, numberOfClientAtPickTime, useHttps, workloadType, resultFileFolderName, Dns.GetHostName());

            ClientDistribution distribution    = new ClientDistribution(intervalLength, intervalLength / 2, 4);
            double             probabilityMean = distribution.GetNextProbability(intervalLength / 2);


            #region Adjust times to local times

            //VM times are all in UTC, so we need to hardcode timing.
            int localTime;

            if (Dns.GetHostName().Contains("westus"))
            {
                localTime = currentEmulationHour - 7;
            }
            else if (Dns.GetHostName().Contains("westeurope"))
            {
                localTime = currentEmulationHour + 1;
            }
            else if (Dns.GetHostName().Contains("eastasia"))
            {
                localTime = currentEmulationHour + 9;
            }
            else
            {
                localTime = currentEmulationHour - 7;
            }
            #endregion

            currentTick            = localTime % intervalLength;
            totalExperimentLength += currentTick;

            //decreament by one. Increament inside while again.
            //Note that you cannot simply decreament at the end of while loop because samples will be saved with a wrong hour.
            currentEmulationHour--;
            Console.WriteLine("Starting Tick : " + currentTick + "   @  " + Dns.GetHostName());
            while (currentTick < totalExperimentLength)
            {
                currentEmulationHour++;
                double prob = (distribution.GetNextProbability(currentTick) * numberOfClientAtPickTime) / probabilityMean;
                concurrentClientsPerTick        = Convert.ToInt32(prob);
                additionalCreatedClientsPerTick = 0;
                if (concurrentClientsPerTick == 0)
                {
                    concurrentClientsPerTick = 1;
                }
                Console.WriteLine(">>>>>>>>>>>>>>>>TICK IS : " + currentTick + " <<<<<<<<<<<<<<<<" + " REQUIRED CLIENTS: " + concurrentClientsPerTick);
                for (int m = 0; m < (concurrentClientsPerTick - concurrentWorkers); m++)
                {
                    Task.Factory.StartNew(() => { RunClient(currentTick); });
                }
                currentTick++;
                Thread.Sleep(sleepTimeBetweenTicks);
            }

            //Execution is done. Wait until all client return.
            while (Interlocked.CompareExchange(ref concurrentWorkers, -1, 0) != -1)
            {
                Console.WriteLine("Waiting for a thread because thread are " + concurrentWorkers + " threads.");
                Thread.Sleep(5000);
            }

            StoreLog(null, null);

            return;
        }