/** * @param type Event type. */ protected void recordStateChangedEvent(int type){ assert near() && local(); GridEventStorageManager evtMgr = cctx.gridEvents(); if (!system() /* ignoring system tx */ && evtMgr.isRecordable(type)) evtMgr.record(new TransactionStateChangedEvent( cctx.discovery().localNode(), "Transaction state changed.", type, new TransactionEventProxyImpl((GridNearTxLocal)this))); }
/** * */ @Test public void testLabelFilledLocalGuarantee() throws Exception { Ignite ignite = startGrid(0); ignite.events().localListen((IgnitePredicate<Event>)e -> { assert e instanceof TransactionStateChangedEvent; TransactionStateChangedEvent evt = (TransactionStateChangedEvent)e; Transaction tx = evt.tx(); if (tx.label() == null) tx.setRollbackOnly(); return true; }, EVT_TX_STARTED); IgniteCache cache = ignite.getOrCreateCache(defaultCacheConfiguration()); try (Transaction tx = ignite.transactions().withLabel("test").txStart()) { cache.put(1, 1); tx.commit(); } try (Transaction tx = ignite.transactions().txStart()) { cache.put(1, 2); tx.commit(); fail("Should fail prior this line."); } catch (CacheException ignored) { // No-op. } }
Transaction tx = evt.tx();
Transaction tx = evt.tx();
/** * @param type Event type. */ protected void recordStateChangedEvent(int type){ assert near() && local(); GridEventStorageManager evtMgr = cctx.gridEvents(); if (!system() /* ignoring system tx */ && evtMgr.isRecordable(type)) evtMgr.record(new TransactionStateChangedEvent( cctx.discovery().localNode(), "Transaction state changed.", type, new TransactionEventProxyImpl((GridNearTxLocal)this))); }
Transaction tx = evt.tx();