scope.Complete ();*/
}
- irm.Check ( 0, 0, 0, 1, 0, "irm" );
+ irm.Check ( 0, 0, 0, 1, 0, 0, 0, "irm" );
}
[Test]
public void Vol0_Dur1 ()
{
IntResourceManager irm = new IntResourceManager (1);
- irm.Volatile = false;
+ irm.Type = ResourceManagerType.Durable;
irm.UseSingle = true;
using (TransactionScope scope = new TransactionScope ()) {
/* Durable resource enlisted with a IEnlistedNotification
* object
*/
- irm.Volatile = false;
+ irm.Type = ResourceManagerType.Durable;
using (TransactionScope scope = new TransactionScope ()) {
irm.Value = 2;
/* Durable resource enlisted with a IEnlistedNotification
* object
*/
- irm.Volatile = false;
+ irm.Type = ResourceManagerType.Durable;
irm.FailSPC = true;
irm.UseSingle = true;
try {
}
}
catch (TransactionAbortedException) {
- irm.Check ( 1, 0, 0, 0, 0, "irm" );
+ irm.Check ( 1, 0, 0, 0, 0, 0, 0, "irm" );
return;
}
irm [2] = new IntResourceManager ( 5 );
irm [3] = new IntResourceManager ( 7 );
- irm [0].Volatile = false;
+ irm [0].Type = ResourceManagerType.Durable;
for ( int i = 0; i < 4; i++ )
irm [i].UseSingle = true;
irm [2] = new IntResourceManager (5);
irm [3] = new IntResourceManager (7);
- irm [0].Volatile = false;
+ irm [0].Type = ResourceManagerType.Durable;
irm [0].FailSPC = true;
for ( int i = 0; i < 4; i++ )
irm [0].CheckSPC ( "irm [0]" );
/* Volatile RMs get 2PC Prepare, and then get rolled back */
for (int i = 1; i < 4; i++)
- irm [i].Check ( 0, 1, 0, 1, 0, "irm [" + i + "]" );
+ irm [i].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [" + i + "]" );
}
}
irm [2] = new IntResourceManager (5);
irm [3] = new IntResourceManager (7);
- irm [0].Volatile = false;
+ irm [0].Type = ResourceManagerType.Durable;
irm [0].IgnoreSPC = true;
for ( int i = 0; i < 4; i++ )
/* Volatile RMs get 2PC Prepare, and then get rolled back */
for (int i = 1; i < 4; i++)
- irm [i].Check ( 0, 1, 0, 1, 0, "irm [" + i + "]" );
+ irm [i].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [" + i + "]" );
exception = ex;
}
irm[3] = new IntResourceManager(7);
irm[0].IgnoreSPC = true;
- irm[1].Volatile = false;
+ irm[1].Type = ResourceManagerType.Durable;
for (int i = 0; i < 4; i++)
irm[i].UseSingle = true;
/* Volatile RMs get 2PC Prepare, and then get rolled back */
for (int i = 1; i < 4; i++)
- irm[i].Check(0, 1, 0, 1, 0, "irm [" + i + "]");
+ irm[i].Check(0, 1, 0, 1, 0, 0, 0, "irm [" + i + "]");
exception = ex;
}
irm [2] = new IntResourceManager ( 5 );
irm [3] = new IntResourceManager ( 7 );
- irm [0].Volatile = false;
+ irm [0].Type = ResourceManagerType.Durable;
irm [2].FailPrepare = true;
for ( int i = 0; i < 4; i++ )
}
}
catch (TransactionAbortedException) {
- irm [0].Check ( 0, 0, 0, 1, 0, "irm [0]");
+ irm [0].Check ( 0, 0, 0, 1, 0, 0, 0, "irm [0]");
/* irm [1] & [2] get prepare,
* [2] -> ForceRollback,
* [1] & [3] get rollback,
* [0](durable) gets rollback */
- irm [1].Check ( 0, 1, 0, 1, 0, "irm [1]" );
- irm [2].Check ( 0, 1, 0, 0, 0, "irm [2]" );
- irm [3].Check ( 0, 0, 0, 1, 0, "irm [3]" );
+ irm [1].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [1]" );
+ irm [2].Check ( 0, 1, 0, 0, 0, 0, 0, "irm [2]" );
+ irm [3].Check ( 0, 0, 0, 1, 0, 0, 0, "irm [3]" );
return;
}
irm [0] = new IntResourceManager ( 1 );
irm [1] = new IntResourceManager ( 3 );
- irm [0].Volatile = false;
+ irm [0].Type = ResourceManagerType.Durable;
irm [0].FailSPC = true;
irm [0].FailWithException = true;
Assert.IsNotNull ( e.InnerException, "Expected e.InnerException == NotSupportedException, but got None");
Assert.AreEqual ( typeof ( NotSupportedException ), e.InnerException.GetType (), "Expected e.InnerException == NotSupportedException, but got " + e.GetType () );
- irm [0].Check ( 1, 0, 0, 0, 0, "irm [0]" );
- irm [1].Check ( 0, 1, 0, 1, 0, "irm [1]" );
+ irm [0].Check ( 1, 0, 0, 0, 0, 0, 0, "irm [0]" );
+ irm [1].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [1]" );
return;
}
irm [1] = new IntResourceManager ( 3 );
Transaction.Current = ct;
- irm [0].Volatile = false;
+ irm [0].Type = ResourceManagerType.Durable;
irm [0].FailSPC = true;
irm [0].FailWithException = true;
Assert.IsNotNull ( e.InnerException, "Expected e.InnerException == NotSupportedException, but got None" );
Assert.AreEqual ( typeof ( NotSupportedException ), e.InnerException.GetType (), "Expected e.InnerException == NotSupportedException, but got " + e.GetType () );
- irm [0].Check ( 1, 0, 0, 0, 0, "irm [0]" );
- irm [1].Check ( 0, 1, 0, 1, 0, "irm [1]" );
+ irm [0].Check ( 1, 0, 0, 0, 0, 0, 0, "irm [0]" );
+ irm [1].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [1]" );
try {
ct.Commit ();
}
#endregion
+ #region Promotable Single Phase Enlistment
+ [Test]
+ public void Vol0_Dur0_Pspe1 ()
+ {
+ IntResourceManager irm = new IntResourceManager (1);
+ irm.Type = ResourceManagerType.Promotable;
+ using (TransactionScope scope = new TransactionScope ()) {
+ irm.Value = 2;
+
+ scope.Complete ();
+ }
+ irm.Check ( 1, 0, 0, 0, 0, 1, 0, "irm" );
+ }
+
+ [Test]
+ public void Vol1_Dur0_Pspe1 ()
+ {
+ IntResourceManager irm0 = new IntResourceManager (1);
+ IntResourceManager irm1 = new IntResourceManager (1);
+ irm1.Type = ResourceManagerType.Promotable;
+ using (TransactionScope scope = new TransactionScope ()) {
+ irm0.Value = 2;
+ irm1.Value = 8;
+
+ scope.Complete ();
+ }
+ irm1.Check ( 1, 0, 0, 0, 0, 1, 0, "irm1" );
+ }
+
+ [Test]
+ public void Vol0_Dur1_Pspe1 ()
+ {
+ IntResourceManager irm0 = new IntResourceManager (1);
+ IntResourceManager irm1 = new IntResourceManager (1);
+ irm0.Type = ResourceManagerType.Durable;
+ irm0.UseSingle = true;
+ irm1.Type = ResourceManagerType.Promotable;
+ using (TransactionScope scope = new TransactionScope ()) {
+ irm0.Value = 8;
+ irm1.Value = 2;
+ Assert.AreEqual(0, irm1.NumEnlistFailed, "PSPE enlist did not fail although durable RM was already enlisted");
+ }
+ }
+
+ [Test]
+ public void Vol0_Dur0_Pspe2 ()
+ {
+ IntResourceManager irm0 = new IntResourceManager (1);
+ IntResourceManager irm1 = new IntResourceManager (1);
+ irm0.Type = ResourceManagerType.Promotable;
+ irm1.Type = ResourceManagerType.Promotable;
+ using (TransactionScope scope = new TransactionScope ()) {
+ irm0.Value = 8;
+ irm1.Value = 2;
+ Assert.AreEqual(0, irm1.NumEnlistFailed, "PSPE enlist did not fail although PSPE RM was already enlisted");
+ }
+ }
+ #endregion
+
#region Others
/* >1vol
* > 1 durable, On .net this becomes a distributed transaction
irm [0] = new IntResourceManager ( 1 );
irm [1] = new IntResourceManager ( 3 );
- irm [0].Volatile = false;
- irm [1].Volatile = false;
+ irm [0].Type = ResourceManagerType.Durable;
+ irm [1].Type = ResourceManagerType.Durable;
for ( int i = 0; i < 2; i++ )
irm [i].UseSingle = true;
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager (1);
- irm.Volatile = false;
+ irm.Type = ResourceManagerType.Durable;
ct.Dispose ();
irm.Check (0, 0, 0, 0, "Dispose transaction");