Пример #1
0
        public static void UploadDataToSite(int numBlobs, long sizeBlobs, string site, string containerName)
        {
            YCSBNumberofObjects = numBlobs;
            blobSizeInB         = sizeBlobs;

            Dictionary <string, CloudStorageAccount> accounts = Account.GetStorageAccounts(false);

            if (!accounts.ContainsKey(site))
            {
                return;
            }

            CloudStorageAccount account = accounts[site];

            blobClient = account.CreateCloudBlobClient();
            container  = blobClient.GetContainerReference(containerName);
            container.CreateIfNotExists();

            try
            {
                foreach (ICloudBlob blob in container.ListBlobs())
                {
                    blob.DeleteIfExists();
                }
            }
            catch
            {
            }

            ThreadPool.SetMaxThreads(50, 50);

            byte[] BlobDataBuffer = new byte[blobSizeInB];
            Random random         = new Random();

            random.NextBytes(BlobDataBuffer);
            List <string> keys = YCSBWorkload.GetAllKeys(numBlobs);


            for (int i = 0; i < keys.Count; i++)
            {
                Put(keys[i], BlobDataBuffer);
            }

            while (Interlocked.CompareExchange(ref concurrentWorkers, -1, 0) != -1)
            {
                Thread.Sleep(1000);
            }
        }
Пример #2
0
        /*
         * public static ServiceLevelAgreement CreateShoppingCartSla1()
         * {
         *  ServiceLevelAgreement sla = new ServiceLevelAgreement(""+1);
         *  SubSLA subSla1 = new SubSLA(130, Consistency.Strong, 0, 1);
         *  SubSLA subSla2 = new SubSLA(130, Consistency.ReadMyWrites, 0, .70f);
         *  SubSLA subSla3 = new SubSLA(250, Consistency.Eventual, 0, 0.5f);
         *  SubSLA subSla4 = new SubSLA(500, Consistency.Eventual, 0, 0.05f);
         *  sla.Add(subSla1);
         *  sla.Add(subSla2);
         *  sla.Add(subSla3);
         *  sla.Add(subSla4);
         *  return sla;
         * }
         */


        #region Client

        public static void RunClient(int tick)
        {
            Interlocked.Increment(ref concurrentWorkers);
            byte[] BlobDataBuffer = new byte[blobSizeInB];
            Random random         = new Random();

            random.NextBytes(BlobDataBuffer);

            Dictionary <string, CloudStorageAccount> accounts = Account.GetStorageAccounts(false);

            blobClient = accounts[testSite].CreateCloudBlobClient();
            container  = blobClient.GetContainerReference(containerName);
            container.CreateIfNotExists();

            try
            {
                YCSBWorkload workload = new YCSBWorkload(workloadType, 100);

                YCSBOperation op = workload.GetNextOperation();
                while (op != null)
                {
                    long       duration = 0;
                    ICloudBlob blob     = container.GetBlobReferenceFromServer(op.KeyName);

                    if (op.Type == YCSBOperationType.READ)
                    {
                        duration = GetBlob(blob);
                        if (PileusAppConstPool.ENABLE_CLIENT_READWRITE_OUTPUT)
                        {
                            Console.WriteLine("Performed Read for " + op.KeyName + " in " + duration);
                        }
                        sampler.AddSample("ReadCount", 1);
                        sampler.AddSample("ReadLatency", duration);
                        sampler.AddSample("concurrentWorkers", concurrentWorkers);
                    }
                    else if (op.Type == YCSBOperationType.UPDATE)
                    {
                        random.NextBytes(BlobDataBuffer);
                        duration = PutBlob(blob, BlobDataBuffer);
                        if (PileusAppConstPool.ENABLE_CLIENT_READWRITE_OUTPUT)
                        {
                            Console.WriteLine("Performed Write for " + op.KeyName + " in " + duration);
                        }
                        sampler.AddSample("WriteCount", 1);
                        sampler.AddSample("WriteLatency", duration);
                        sampler.AddSample("concurrentWorkers", concurrentWorkers);
                    }

                    op = workload.GetNextOperation();
                }
                if (PileusAppConstPool.ENABLE_CLIENT_READWRITE_OUTPUT)
                {
                    Console.WriteLine("Client Finished ...\n");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }


            Interlocked.Decrement(ref concurrentWorkers);

            if (((concurrentClientsPerTick - 1) >= concurrentWorkers) && (currentTick < totalExperimentLength))
            {
                //We want to keep total number of concurrent workers (i.e., concurrentWorkers) equals to "concurrentClientsPerTick".
                additionalCreatedClientsPerTick++;
                RunClient(currentTick);
            }
        }
Пример #3
0
        public static void UploadData(int numBlobs, long sizeBlobs, bool secure, string primary, string secondary, string configSite, bool wipe)
        {
            // TODO: generalize to any number of replicas

            YCSBNumberofObjects         = numBlobs;
            blobSizeInB                 = sizeBlobs;
            useHttps                    = secure;
            primarySite                 = primary;
            secondarySite               = secondary;
            configurationSite           = configSite;
            wipeEverythingBeforeLoading = wipe;

            Dictionary <string, CloudStorageAccount> accounts = Account.GetStorageAccounts(false);

            if (wipeEverythingBeforeLoading)
            {
                foreach (CloudStorageAccount account in accounts.Values)
                {
                    foreach (CloudBlobContainer cont in account.CreateCloudBlobClient().ListContainers())
                    {
                        try
                        {
                            foreach (ICloudBlob blob in cont.ListBlobs())
                            {
                                Console.WriteLine("removing " + blob.Name + " ...");
                                try
                                {
                                    blob.BreakLease(new TimeSpan(0));
                                }
                                catch
                                {
                                }
                                blob.DeleteIfExists();
                            }
                        }
                        catch
                        {
                        }
                        try
                        {
                            cont.BreakLease(new TimeSpan(0));
                        }
                        catch
                        {
                        }
                        cont.DeleteIfExists();
                    }

                    //Delete configuration blob for this name
                    account.CreateCloudBlobClient().GetContainerReference(ConstPool.CONFIGURATION_CONTAINER_PREFIX + containerName).DeleteIfExists();
                    //account.CreateCloudBlobClient().GetContainerReference(containerName).DeleteIfExists();

                    CloudTable table = account.CreateCloudTableClient().GetTableReference(ConstPool.SLA_CONFIGURATION_TABLE_NAME);
                    table.DeleteIfExists();
                    table = account.CreateCloudTableClient().GetTableReference(ConstPool.SESSION_STATE_CONFIGURATION_TABLE_NAME);
                    table.DeleteIfExists();
                }

                //We need to wait at least 30 seconds after removing a container.
                //In other words, it can take up to 30 seconds to remove a container in Azure!
                Console.WriteLine("removed everything, wait 40 seconds ...");
                Thread.Sleep(40000);
            }

            ThreadPool.SetMaxThreads(50, 50);

            byte[] BlobDataBuffer = new byte[blobSizeInB];
            Random random         = new Random();

            random.NextBytes(BlobDataBuffer);
            List <string> keys = YCSBWorkload.GetAllKeys(YCSBNumberofObjects);

            blobClient = accounts[primary].CreateCloudBlobClient();
            container  = blobClient.GetContainerReference(containerName);
            container.CreateIfNotExists();

            for (int i = 0; i < keys.Count; i++)
            {
                Put(keys[i], BlobDataBuffer);
            }

            blobClient = accounts[secondary].CreateCloudBlobClient();
            container  = blobClient.GetContainerReference(containerName);
            container.CreateIfNotExists();

            for (int i = 0; i < keys.Count; i++)
            {
                Put(keys[i], BlobDataBuffer);
            }

            while (Interlocked.CompareExchange(ref concurrentWorkers, -1, 0) != -1)
            {
                Console.WriteLine("Waiting for a thread because thread are " + concurrentWorkers + " threads.");
                Thread.Sleep(1000);
            }
        }