예제 #1
0
        /// <summary>
        /// Queue a txn job.
        /// </summary>
        /// <param name="preconditions">The triples that must be present for txn to succeed</param>
        /// <param name="notExistsPreconditions">The triples that must not be present for txn to succeed</param>
        /// <param name="deletePatterns"></param>
        /// <param name="insertData"></param>
        /// <param name="defaultGraphUri"></param>
        /// <param name="format"></param>
        /// <param name="jobLabel"></param>
        /// <returns></returns>
        public Guid ProcessTransaction(string preconditions, string notExistsPreconditions, string deletePatterns, string insertData, string defaultGraphUri, string format, string jobLabel = null)
        {
            Logging.LogDebug("ProcessTransaction");
            var jobId = Guid.NewGuid();
            var job   = new GuardedUpdateTransaction(jobId, jobLabel, this, preconditions, notExistsPreconditions,
                                                     deletePatterns, insertData, defaultGraphUri);

            QueueJob(job);
            return(jobId);
        }
예제 #2
0
        public void TestRecoverTransactionData()
        {
            // create a store
            var sid = CreateStore();

            // initialise and start the store worker
            var storeWorker = new StoreWorker(Configuration.StoreLocation, sid);
            storeWorker.Start();

            // execute transactions
            const string data = @"<http://www.networkedplanet.com/people/gra> <http://www.networkedplanet.com/types/worksfor> <http://www.networkedplanet.com/companies/np>";

            var jobId = storeWorker.ProcessTransaction("", "", "", data, Constants.DefaultGraphUri, "nt");

            JobExecutionStatus jobStatus = storeWorker.GetJobStatus(jobId.ToString());
            while (jobStatus.JobStatus != JobStatus.CompletedOk)
            {
                Thread.Sleep(1000);
                jobStatus = storeWorker.GetJobStatus(jobId.ToString());
            }

            var transactionLog = storeWorker.TransactionLog;
            var transactionList = transactionLog.GetTransactionList();

            var i = 0;
            while (transactionList.MoveNext())
            {
                i++;
            }

            Assert.AreEqual(1, i);

            // now get txn data
            var txnList = storeWorker.TransactionLog.GetTransactionList();
            txnList.MoveNext();
            var tinfo = txnList.Current;
            Assert.IsNotNull(tinfo);
            Assert.AreEqual(TransactionType.GuardedUpdateTransaction, tinfo.TransactionType);
            Assert.AreEqual(TransactionStatus.CompletedOk, tinfo.TransactionStatus);
            Assert.IsTrue(tinfo.TransactionStartTime < DateTime.UtcNow);

            var job = new GuardedUpdateTransaction(Guid.NewGuid(), null, storeWorker);
            using (var tdStream = storeWorker.TransactionLog.GetTransactionData(tinfo.DataStartPosition))
            {
                job.ReadTransactionDataFromStream(tdStream);
            }
            Assert.IsNotNull(job);
            Assert.AreEqual(data, job.InsertData);
            
        }
예제 #3
0
 /// <summary>
 /// Queue a txn job.
 /// </summary>
 /// <param name="preconditions">The triples that must be present for txn to succeed</param>
 /// <param name="notExistsPreconditions">The triples that must not be present for txn to succeed</param>
 /// <param name="deletePatterns"></param>
 /// <param name="insertData"></param>
 /// <param name="defaultGraphUri"></param>
 /// <param name="format"></param>
 /// <param name="jobLabel"></param>
 /// <returns></returns>
 public Guid ProcessTransaction(string preconditions, string notExistsPreconditions, string deletePatterns, string insertData, string defaultGraphUri, string format, string jobLabel= null)
 {
     Logging.LogDebug("ProcessTransaction");
     var jobId = Guid.NewGuid();
     var job = new GuardedUpdateTransaction(jobId, jobLabel, this, preconditions, notExistsPreconditions,
                                            deletePatterns, insertData, defaultGraphUri);
     QueueJob(job);
     return jobId;
 }