コード例 #1
0
        private Action <StoredProcedureWorkload> BuildWorkloadAction(IDataGenerator generator)
        {
            Action <StoredProcedureWorkload> workloadReloadAction = null;
            object payload = new String('a', 100);

            if (config.Type.Equals("HYBRID"))
            {
                int queryCount = config.QueryCount;
                workloadReloadAction = workload =>
                {
                    HybridYCSBWorkload hybridWorkload = workload as HybridYCSBWorkload;
                    for (int i = 0; i < queryCount; i++)
                    {
                        hybridWorkload.Keys[i]    = generator.NextIntKey();
                        hybridWorkload.Values[i]  = payload;
                        hybridWorkload.Queries[i] = generator.NextOperation();
                    }
                };
            }
            else
            {
                workloadReloadAction = workload =>
                {
                    YCSBWorkload ycsbWorkload = workload as YCSBWorkload;
                    ycsbWorkload.Type  = generator.NextOperation();
                    ycsbWorkload.Key   = generator.NextIntKey();
                    ycsbWorkload.Value = payload;
                };
            }
            return(workloadReloadAction);
        }
コード例 #2
0
        private void LoadDataSequentially(string dataFile)
        {
            long beginTicks = DateTime.Now.Ticks;

            using (StreamReader reader = new StreamReader(dataFile))
            {
                string line;
                int    count = 0;

                Queue <TransactionRequest> reqQueue = new Queue <TransactionRequest>();

                while ((line = reader.ReadLine()) != null)
                {
                    string[]     fields   = this.ParseCommandFormat(line);
                    YCSBWorkload workload = new YCSBWorkload(fields[0], TABLE_ID, fields[2], fields[3]);
                    count++;

                    string             sessionId = count.ToString();
                    TransactionRequest req       = new TransactionRequest(sessionId, workload, StoredProcedureType.YCSBStordProcedure);
                    reqQueue.Enqueue(req);
                    // ACTION(Tuple.Create(this.versionDb, workload));
                    if (count % 10000 == 0)
                    {
                        // Console.WriteLine("Loaded {0} records", count);
                        Console.WriteLine("Enqueued {0} tx insert request", count);
                    }
                    if (count == this.recordCount)
                    {
                        break;
                    }
                }

                TransactionExecutor executor = new TransactionExecutor(this.versionDb, null, reqQueue, 0, 0, 0,
                                                                       null, this.tables);
                // new a thread to run the executor
                Thread thread = new Thread(new ThreadStart(executor.Execute2));
                thread.Start();
                thread.Join();
                //while (!executor.AllRequestsFinished)
                //{
                //    // Console.WriteLine("Loaded {0} records", executor.CommittedTxs);
                //    //if (executor.CommittedTxs > 0 && executor.CommittedTxs % 500 == 0)
                //    //{
                //    //    // Console.WriteLine("Loaded {0} records", count);
                //    //    Console.WriteLine("Executed {0} tx insert request", executor.CommittedTxs);
                //    //}
                //}
                Console.WriteLine("Load records successfully, {0} records in total", executor.CommittedTxs);
                executor.Active = false;
                // executor.RecycleTxTableEntryAfterFinished();
                thread.Abort();
            }

            long endTicks = DateTime.Now.Ticks;

            Console.WriteLine("Elapsed time {0} seconds", ((endTicks - beginTicks) * 1.0 / 10000000));
        }
コード例 #3
0
        public override void Set(StoredProcedureWorkload baseWorkload)
        {
            YCSBWorkload workload = baseWorkload as YCSBWorkload;

            this.Type    = workload.Type;
            this.Key     = workload.Key;
            this.Value   = workload.Value;
            this.TableId = workload.TableId;
        }
コード例 #4
0
        public override void Start(
            string sessionId,
            StoredProcedureWorkload workload)
        {
            this.sessionId = sessionId;
            if (this.workload == null)
            {
                this.workload = new YCSBWorkload(null, null, null, null);
            }
            YCSBWorkload ycsbWorkload = workload as YCSBWorkload;

            this.workload.Set(ycsbWorkload);

            this.Start();
        }
コード例 #5
0
        public override void Reset()
        {
            this.sessionId = "";
            this.workload  = null;

            TransactionRequest transReq = null;

            while (this.txRequestGCQueue.Count > 0)
            {
                transReq = this.txRequestGCQueue.Dequeue();
                this.resourceManager.RecycleTransRequest(ref transReq);
            }

            base.Reset();
        }
コード例 #6
0
        // Reshuffle the workloads and make sure all workloads in the same executor
        // will have the same partition key
        private List <TransactionExecutor> ReshuffleFillWorkerQueue(string operationFile, int executorCount, int totalWorkloads)
        {
            // new transaction queues at first
            Queue <TransactionRequest>[] queueArray = new Queue <TransactionRequest> [executorCount];
            List <TransactionExecutor>   executors  = new List <TransactionExecutor>(executorCount);

            for (int i = 0; i < executorCount; i++)
            {
                queueArray[i] = new Queue <TransactionRequest>();
            }

            using (StreamReader reader = new StreamReader(operationFile))
            {
                string line;
                for (int i = 0; i < totalWorkloads; i++)
                {
                    line = reader.ReadLine();
                    string[] fields = this.ParseCommandFormat(line);

                    YCSBWorkload       workload  = new YCSBWorkload(fields[0], TABLE_ID, fields[2], fields[3]);
                    string             sessionId = (i + 1).ToString();
                    TransactionRequest req       = new TransactionRequest(sessionId, workload, StoredProcedureType.YCSBStordProcedure);

                    int pk = this.versionDb.PhysicalPartitionByKey(fields[2]);
                    queueArray[pk].Enqueue(req);
                }
            }

            for (int pk = 0; pk < executorCount; pk++)
            {
                Queue <TransactionRequest> txQueue = queueArray[pk];
                TxResourceManager          manager = this.versionDb.GetResourceManager(pk);

                executors.Add(
                    new TransactionExecutor(this.versionDb, null, txQueue, pk, pk, 0, manager, tables));

                Console.WriteLine("Executor {0} workloads count: {1}", pk, txQueue.Count);
            }

            return(executors);
        }
コード例 #7
0
        private List <TransactionExecutor> FillWorkerQueue(string operationFile)
        {
            List <TransactionExecutor> executors = new List <TransactionExecutor>();

            using (StreamReader reader = new StreamReader(operationFile))
            {
                string line;
                //int instanceIndex = 0;
                for (int i = 0; i < this.executorCount; i++)
                {
                    Queue <TransactionRequest> reqQueue = new Queue <TransactionRequest>();
                    for (int j = 0; j < this.txCountPerExecutor; j++)
                    {
                        line = reader.ReadLine();
                        string[]     fields   = this.ParseCommandFormat(line);
                        YCSBWorkload workload = new YCSBWorkload(fields[0], TABLE_ID, fields[2], fields[3]);
                        //Console.WriteLine("recordkey = {0}", fields[2]);
                        string             sessionId = ((i * this.txCountPerExecutor) + j + 1).ToString();
                        TransactionRequest req       = new TransactionRequest(sessionId, workload, StoredProcedureType.YCSBStordProcedure);
                        reqQueue.Enqueue(req);
                    }

                    //Console.WriteLine("Filled {0} executors", i + 1);

                    this.totalTasks += this.txCountPerExecutor;
                    int partition_index = i % this.versionDb.PartitionCount;
                    //executors.Add(new TransactionExecutor(this.versionDb, null, reqQueue, partition_index, i, 0,
                    //   null, tables, null, null, this.YCSBKeys, this.txCountPerExecutor));
                    executors.Add(new TransactionExecutor(this.versionDb, null, reqQueue, partition_index, i, 0,
                                                          null, tables, null, null, this.recordCount, this.txCountPerExecutor));
                }

                Console.WriteLine("Filled {0} executors", this.executorCount);

                return(executors);
            }
        }