private bool CheckIfVinAlreadyExists(TransactionExecutor transactionExecutor, string vin)
        {
            IIonValue ionVin       = this.valueFactory.NewString(vin);
            IResult   selectResult = transactionExecutor.Execute("SELECT VIN FROM VehicleRegistration AS v WHERE v.VIN = ?", ionVin);

            return(selectResult.Any(x => x.GetField("VIN").StringValue == vin));
        }
Ejemplo n.º 2
0
        private bool CheckIfPersonAlreadyExists(TransactionExecutor transactionExecutor, string govId)
        {
            IIonValue ionGovId = this.valueFactory.NewString(govId);
            IEnumerable <IIonValue> selectResult = transactionExecutor.Execute("SELECT GovId FROM Person AS p WHERE p.GovId = ?", ionGovId);

            return(selectResult.Any(x => x.GetField("GovId").StringValue == govId));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public string GetDocumentId(TransactionExecutor transactionExecutor, string tableName, string identifer, string value)
        {
            IIonValue ionValue     = this.valueFactory.NewString(value);
            IResult   selectResult =
                transactionExecutor.Execute($"SELECT metadata.id FROM _ql_committed_{tableName} AS p WHERE p.data.{identifer} = ?", ionValue);

            IEnumerable <string> documentIds = selectResult.Select(x => x.GetField("id").StringValue).ToList();

            return(documentIds.Any() ? documentIds.First() : string.Empty);
        }
        private IEnumerable <string> GetSecondaryOwners(TransactionExecutor transactionExecutor, string vin)
        {
            IIonValue ionVin       = this.valueFactory.NewString(vin);
            IResult   selectResult = transactionExecutor.Execute("SELECT Owners.SecondaryOwners FROM VehicleRegistration AS v WHERE v.VIN = ?", ionVin);

            IIonList secondaryOwners = selectResult.First().GetField("SecondaryOwners") as IIonList;

            if (secondaryOwners != null)
            {
                List <string> secondaryOwnerIds = new List <string>();
                foreach (var owner in secondaryOwners)
                {
                    secondaryOwnerIds.Add(owner?.GetField("PersonId")?.StringValue);
                }
                return(secondaryOwnerIds);
            }
            else
            {
                return(Enumerable.Empty <string>());
            }
        }
Ejemplo n.º 6
0
        public void ProcessWithData(InnerData data, TransactionExecutor executor)
        {
            Logger.Logger.Instance.Debug(string.Format("Mainlogic: process data = {0}", data.Transaction.EventHash));

            var dest = _distributor.GetDestination(data, GetCountServers(data));

            if (dest == null)
            {
                Logger.Logger.Instance.Debug(string.Format("Mainlogic: dont found destination, process data = {0}",
                                                           data.Transaction.EventHash));
                data.Transaction.SetError();
                data.Transaction.AddErrorDescription(Errors.NotAvailableServersForWrite);
            }
            else
            {
                data.Transaction.Destination = new List <ServerId>(dest);
            }
            if (data.Transaction.OperationName != OperationName.Read)
            {
                _cache.AddToCache(data.Transaction.CacheKey, data.Transaction);
            }
            if (!data.Transaction.IsError)
            {
                data.Transaction.Distributor = _distributor.LocalForDb;

                _transaction.ProcessSyncWithExecutor(data, executor);

                if (data.Transaction.IsError)
                {
                    if (data.Transaction.OperationName != OperationName.Read)
                    {
                        _cache.Update(data.Transaction.CacheKey, data.Transaction);
                    }
                    if (data.Transaction.OperationType == OperationType.Sync)
                    {
                        ProcessSyncTransaction(data.Transaction);
                    }
                }
            }
            else
            {
                Logger.Logger.Instance.Debug(string.Format("Mainlogic: process data = {0}, result = {1}",
                                                           data.Transaction.EventHash, !data.Transaction.IsError));

                if (data.Transaction.OperationName != OperationName.Read)
                {
                    _cache.Update(data.Transaction.CacheKey, data.Transaction);
                }

                if (data.Transaction.OperationType == OperationType.Sync)
                {
                    ProcessSyncTransaction(data.Transaction);
                }


                data.Transaction.PerfTimer.Complete();

                PerfCounters.DistributorCounters.Instance.ProcessPerSec.OperationFinished();
                PerfCounters.DistributorCounters.Instance.TransactionFailCount.Increment();
            }
        }
Ejemplo n.º 7
0
 public void SetupTest()
 {
     transactionExecutor = new TransactionExecutor(mockTransaction.Object);
 }
Ejemplo n.º 8
0
 static void testAction(TransactionExecutor executor) => executor.GetType();
Ejemplo n.º 9
0
 static string testFunc(TransactionExecutor txn)
 {
     txn.Execute("testStatement");
     return("test");
 }