📄 t_xa.java
字号:
* <p> * @exception StandardException Standard exception policy. **/ void XATest_3( commit_method commit_method) throws StandardException, T_Fail { REPORT("(XATest_3) starting"); ContextManager cm = ContextService.getFactory().getCurrentContextManager(); // ABORT AN IDLE TRANSACTION. // Start a global transaction XATransactionController xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // commit an idle transaction - using onePhase optimization. commit_method.rollback(42, global_id, branch_id, xa_tc); // done with this xact. xa_tc.destroy(); // ABORT AN UPDATE ONLY TRANSACTION. // Start a global transaction xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // Create a heap conglomerate. T_AccessRow template_row = new T_AccessRow(1); long conglomid = xa_tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, //column sort order - not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary // commit an idle transaction - using onePhase optimization. commit_method.rollback(42, global_id, branch_id, xa_tc); // done with this xact. xa_tc.destroy(); // ABORT A READ ONLY TRANSACTION. // Start a global transaction xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // Create a heap conglomerate. template_row = new T_AccessRow(1); conglomid = xa_tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, //column sort order - not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary // commit an idle transaction - using onePhase optimization. commit_method.commit(true, 42, global_id, branch_id, xa_tc); // done with this xact. xa_tc.destroy(); // Start a global transaction xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // Open a scan on the conglomerate. ScanController scan1 = xa_tc.openScan( conglomid, false, // don't hold 0, // not for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // all columns, all as objects null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. scan1.next(); scan1.close(); // commit an idle transaction - using onePhase optimization. commit_method.rollback(42, global_id, branch_id, xa_tc); // done with this xact. xa_tc.destroy(); REPORT("(XATest_3) finishing"); } /** * Test aborts of prepared two phase commit xa transaction. * <p> * @exception StandardException Standard exception policy. **/ void XATest_4( commit_method commit_method) throws StandardException, T_Fail { REPORT("(XATest_4) starting"); ContextManager cm = ContextService.getFactory().getCurrentContextManager(); // ABORT AN IDLE TRANSACTION. // Start a global transaction XATransactionController xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // This prepare will commit the idle transaction. if (xa_tc.xa_prepare() != XATransactionController.XA_RDONLY) { throw T_Fail.testFailMsg( "prepare of idle xact did not return XA_RDONLY."); } // nothing to do, will just abort the next current idle xact. // after prepare/readonly we cna continue to use transaction commit_method.commit(true, 42, null, null, xa_tc); // should not be able to find this global xact, it has been committed if (((XAResourceManager) store.getXAResourceManager()).find( new XAXactId(42, global_id, branch_id)) != null) { throw T_Fail.testFailMsg( "A XA_RDONLY prepare-committed xact should not be findable."); } // done with this xact. xa_tc.destroy(); // ABORT AN UPDATE ONLY TRANSACTION. // Start a global transaction xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // Create a heap conglomerate. T_AccessRow template_row = new T_AccessRow(1); long conglomid = xa_tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, //column sort order - not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary // Open a scan on the conglomerate, to verify the create happened, // and to show that the same openScan done after abort fails. ScanController scan1 = xa_tc.openScan( conglomid, false, // don't hold 0, // not for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // all columns, all as objects null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. scan1.next(); scan1.close(); // prepare the update xact. if (xa_tc.xa_prepare() != XATransactionController.XA_OK) { throw T_Fail.testFailMsg( "prepare of update xact did not return XA_OK."); } try { // Open a scan on the conglomerate. scan1 = xa_tc.openScan( conglomid, false, // don't hold 0, // not for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // all columns, all as objects null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. scan1.next(); scan1.close(); throw T_Fail.testFailMsg( "Should not be able to do anything on xact after prepare."); } catch (StandardException se) { // expected exception, fall through. } // commit an idle transaction - using onePhase optimization. commit_method.rollback(42, global_id, branch_id, xa_tc); commit_method.commit(true, 42, null, null, xa_tc); // should not be able to find this global xact, it has been committed if (((XAResourceManager) store.getXAResourceManager()).find( new XAXactId(42, global_id, branch_id)) != null) { throw T_Fail.testFailMsg( "A xa_rollbacked xact should not be findable."); } // done with this xact. xa_tc.destroy(); // Start a global transaction xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); try { // Open a scan on the conglomerate. scan1 = xa_tc.openScan( conglomid, false, // don't hold 0, // not for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // all columns, all as objects null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. scan1.next(); scan1.close(); throw T_Fail.testFailMsg( "Should not be able to open conglom, the create was aborted."); } catch (StandardException se) { // expected exception, fall through. } xa_tc.destroy(); // ABORT A READ ONLY TRANSACTION. // Start a global transaction xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // Create a heap conglomerate. template_row = new T_AccessRow(1); conglomid = xa_tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, //column sort order - not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary commit_method.commit(true, 42, global_id, branch_id, xa_tc); xa_tc.destroy(); // Start a global transaction xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // Open a scan on the conglomerate. scan1 = xa_tc.openScan( conglomid, false, // don't hold 0, // not for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // all columns, all as objects null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. scan1.next(); scan1.close(); // This prepare will commit the idle transaction. if (xa_tc.xa_prepare() != XATransactionController.XA_RDONLY) { throw T_Fail.testFailMsg( "prepare of idle xact did not return XA_RDONLY."); } // commit an idle transaction - using onePhase optimization. commit_method.commit(true, 42, null, null, xa_tc); // should not be able to find this global xact, it has been committed if (((XAResourceManager) store.getXAResourceManager()).find( new XAXactId(42, global_id, branch_id)) != null) { throw T_Fail.testFailMsg( "A XA_RDONLY prepare-committed xact should not be findable."); } // done with this xact. xa_tc.destroy(); REPORT("(XATest_5) finishing"); } /** * Very simple testing of the recover() call. * <p> * @exception StandardException Standard exception policy. **/ void XATest_5( commit_method commit_method) throws StandardException, T_Fail { REPORT("(XATest_5) starting"); // Should be no prepared transactions when we first start. if (((XAResourceManager) store.getXAResourceManager()).recover( XAResource.TMSTARTRSCAN).length != 0) { throw T_Fail.testFailMsg( "recover incorrectly returned prepared xacts."); } // Should be no prepared transactions when we first start. if (((XAResourceManager) store.getXAResourceManager()).recover( XAResource.TMNOFLAGS).length != 0) { throw T_Fail.testFailMsg("NOFLAGS should always return 0."); } ContextManager cm = ContextService.getFactory().getCurrentContextManager(); // COMMIT AN IDLE TRANSACTION. // Start a global transaction XATransactionController xa_tc = (XATransactionController) store.startXATransaction( cm, 42, // fake format id global_id, branch_id); // Should be no prepared transactions, there is one idle global xact. if (((XAResourceManager) store.getXAResourceManager()).recover( XAResource.TMSTARTRSCAN).length != 0) { throw T_Fail.testFailMsg( "recover incorrectly returned prepared xacts."); } // commit an idle transaction - using onePhase optimization. commit_method.commit(true, 42, global_id, branch_id, xa_tc); // done with this xact. xa_tc.destroy(); // COMMIT AN UPDATE ONLY TRANSACTION. // Start a global transaction xa_tc = (XATransactionController)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -