コード例 #1
0
 public void run()
 {
     if (random.nextFloat() < CHANCE_LARGE_TX)
     {
         // Few large transactions
         using (Transaction tx = _outerInstance.db.beginTx())
         {
             for (int i = 0; i < LARGE_TX_SIZE; i++)
             {
                 // Nodes are created with properties here. Whereas the properties don't have a functional
                 // impact on this test they do affect timings so that the issue is (was) triggered more often
                 // and therefore have a positive effect on this test.
                 _outerInstance.db.createNode(randomLabels()).setProperty("name", randomUUID().ToString());
             }
             tx.Success();
         }
     }
     else
     {
         // Many small create/delete transactions
         Node node;
         using (Transaction tx = _outerInstance.db.beginTx())
         {
             node = _outerInstance.db.createNode(randomLabels());
             _nodeHeads.set(_guy, node);
             tx.Success();
         }
         if (random.nextFloat() < CHANCE_TO_DELETE_BY_SAME_THREAD)
         {
             // Most of the time delete in this thread
             if (_nodeHeads.getAndSet(_guy, null) != null)
             {
                 using (Transaction tx = _outerInstance.db.beginTx())
                 {
                     node.Delete();
                     tx.Success();
                 }
             }
             // Otherwise there will be other threads sitting there waiting for these nodes and deletes them if they can
         }
     }
 }
コード例 #2
0
            public void run()
            {
                int  guy  = random.Next(_numberOfCreators);
                Node node = _nodeHeads.getAndSet(guy, null);

                if (node != null)
                {
                    try
                    {
                        using (Transaction tx = _outerInstance.db.beginTx())
                        {
                            node.Delete();
                            tx.Success();
                        }
                    }
                    catch (NotFoundException)
                    {
                        // This is OK in this test
                    }
                }
            }