本文整理汇总了C#中BerkeleyDB.BTreeDatabase.Sync方法的典型用法代码示例。如果您正苦于以下问题:C# BTreeDatabase.Sync方法的具体用法?C# BTreeDatabase.Sync怎么用?C# BTreeDatabase.Sync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BerkeleyDB.BTreeDatabase
的用法示例。
在下文中一共展示了BTreeDatabase.Sync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestLockStats
//.........这里部分代码省略.........
Assert.AreEqual(0, stats.Objects);
Assert.AreEqual(0, stats.ObjectSteals);
Assert.AreEqual(0, stats.ObjectWait);
Assert.LessOrEqual(0, stats.PartitionLockNoWait);
Assert.AreEqual(0, stats.PartitionLockWait);
Assert.Less(0, stats.RegionNoWait);
Assert.AreNotEqual(0, stats.RegionSize);
Assert.AreEqual(0, stats.RegionWait);
Assert.AreNotEqual(0, stats.TableSize);
Assert.AreEqual(2000, stats.TxnTimeoutLength);
Assert.AreEqual(0, stats.TxnTimeouts);
env.PrintLockingSystemStats();
Transaction txn = env.BeginTransaction();
BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
dbConfig.Creation = CreatePolicy.IF_NEEDED;
dbConfig.Env = env;
dbConfig.FreeThreaded = true;
BTreeDatabase db = BTreeDatabase.Open(
testName + ".db", dbConfig, txn);
txn.Commit();
testLockStatsEnv = env;
testLockStatsDb = db;
// Use some locks, to ensure the stats work when populated.
txn = testLockStatsEnv.BeginTransaction();
for (int i = 0; i < 500; i++)
{
testLockStatsDb.Put(
new DatabaseEntry(BitConverter.GetBytes(i)),
new DatabaseEntry(ASCIIEncoding.ASCII.GetBytes(
Configuration.RandomString(i))), txn);
testLockStatsDb.Sync();
}
txn.Commit();
env.PrintLockingSystemStats();
stats = env.LockingSystemStats();
Assert.Less(0, stats.LastAllocatedLockerID);
Assert.Less(0, stats.LockDowngrades);
Assert.LessOrEqual(0, stats.LockerNoWait);
Assert.Less(0, stats.Lockers);
Assert.LessOrEqual(0, stats.LockerWait);
Assert.Less(0, stats.LockPuts);
Assert.Less(0, stats.LockRequests);
Assert.Less(0, stats.Locks);
Assert.LessOrEqual(0, stats.LockSteals);
Assert.LessOrEqual(0, stats.LockTimeouts);
Assert.LessOrEqual(0, stats.LockUpgrades);
Assert.Less(0, stats.MaxBucketLength);
Assert.Less(0, stats.MaxLockers);
Assert.Less(0, stats.MaxLocks);
Assert.Less(0, stats.MaxLocksInBucket);
Assert.LessOrEqual(0, stats.MaxLockSteals);
Assert.Less(0, stats.MaxObjects);
Assert.Less(0, stats.MaxObjectsInBucket);
Assert.LessOrEqual(0, stats.MaxObjectSteals);
Assert.LessOrEqual(0, stats.MaxPartitionLockNoWait);
Assert.LessOrEqual(0, stats.MaxPartitionLockWait);
Assert.Less(0, stats.MaxUnusedID);
Assert.LessOrEqual(0, stats.ObjectNoWait);
Assert.Less(0, stats.Objects);
Assert.LessOrEqual(0, stats.ObjectSteals);
Assert.LessOrEqual(0, stats.ObjectWait);
Assert.Less(0, stats.PartitionLockNoWait);
Assert.LessOrEqual(0, stats.PartitionLockWait);
Assert.Less(0, stats.RegionNoWait);
Assert.LessOrEqual(0, stats.RegionWait);
Assert.LessOrEqual(0, stats.TxnTimeouts);
// Force a deadlock to ensure the stats work.
txn = testLockStatsEnv.BeginTransaction();
testLockStatsDb.Put(new DatabaseEntry(BitConverter.GetBytes(10)),
new DatabaseEntry(ASCIIEncoding.ASCII.GetBytes(
Configuration.RandomString(200))), txn);
Thread thread1 = new Thread(GenerateDeadlock);
thread1.Start();
while (DeadlockDidPut == 0)
Thread.Sleep(10);
try
{
testLockStatsDb.Get(new DatabaseEntry(
BitConverter.GetBytes(100)), txn);
}
catch (DeadlockException) { }
// Abort unconditionally - we don't care about the transaction
txn.Abort();
thread1.Join();
stats = env.LockingSystemStats();
Assert.Less(0, stats.LockConflictsNoWait);
Assert.LessOrEqual(0, stats.LockConflictsWait);
db.Close();
env.Close();
}