private void createCache() throws Exception { Properties p = new Properties(); p.setProperty("mcast-port", "0"); // loner this.cache = (GemFireCacheImpl)CacheFactory.create(DistributedSystem.connect(p)); createRegion(); this.txMgr = this.cache.getCacheTransactionManager(); this.listenerAfterCommit = 0; this.listenerAfterFailedCommit = 0; this.listenerAfterRollback = 0; this.listenerClose = 0; }
private void createCache() throws CacheException { Properties p = new Properties(); p.setProperty("mcast-port", "0"); // loner // p.setProperty("log-level", getGemFireLogLevel()); // p.setProperty(DistributionConfig.LOG_FILE_NAME, "TXExpiryTest_system.log"); this.cache = (GemFireCacheImpl)CacheFactory.create(DistributedSystem.connect(p)); AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); // this.region = this.cache.createRegion("TXExpiryTest", af.create()); this.txMgr = this.cache.getCacheTransactionManager(); } private void closeCache() {
/** * Dump all TX states to the given StringBuilder. */ public static void dumpAllTXStates(final StringBuilder msg, final String logPrefix) { final InternalDistributedSystem sys = InternalDistributedSystem .getConnectedInstance(); final GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); if (sys == null || cache == null) { return; } final TXManagerImpl txMgr = cache.getCacheTransactionManager(); final String lineSep = ClientSharedUtils.lineSeparator; msg.append(lineSep).append(logPrefix).append(':'); for (TXStateProxy txProxy : txMgr.getHostedTransactionsInProgress()) { msg.append(' '); txProxy.getTransactionId().appendToString(msg, sys); msg.append(",state=").append(txProxy.state) .append('{').append(txProxy.getIsolationLevel()).append('}'); msg.append('{').append(txProxy.creatorThread.toString()).append('}'); } }
private void createCache() throws CacheException { Properties p = new Properties(); p.setProperty("mcast-port", "0"); // loner this.cache = (GemFireCacheImpl)new CacheFactory(p).create(); AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setIndexMaintenanceSynchronous(true); this.region = this.cache.createRegion("TXTest", af.create()); this.txMgr = this.cache.getCacheTransactionManager(); this.listenerAfterCommit = 0; this.listenerAfterFailedCommit = 0; this.listenerAfterRollback = 0; this.listenerClose = 0; }
VersionTag tag = null; assert this.dataPolicy != DataPolicy.REPLICATE; TransactionId txId = cache.getCacheTransactionManager().suspend(); try { boolean retry = true; cache.getCacheTransactionManager().resume(txId);
@Override protected boolean operateOnTX(TXStateProxy txProxy, DistributionManager dm) { // remove from hosted TXStates upfront so that there is no scope for a stray // message to create anything related to this TX final GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); final TXManagerImpl txMgr; if (cache != null && (txMgr = cache.getCacheTransactionManager()) != null) { txProxy = txMgr.removeHostedTXState(getTXId(), Boolean.FALSE); } if (txProxy != null) { txProxy.rollback(null, this.callbackArg); } return true; }
public static void waitForPendingCommitsForTest() { final TXManagerImpl txMgr = GemFireCacheImpl.getExisting() .getCacheTransactionManager(); TXStateProxy[] hostedTXs = new TXStateProxy[txMgr.hostedTXStates.size()]; hostedTXs = txMgr.hostedTXStates.values().toArray(hostedTXs); for (TXStateProxy tx : hostedTXs) { if (TXStateProxy.LOG_FINE) { LogWriterI18n logger = txMgr.getLogger(); logger.info(LocalizedStrings.DEBUG, " TX is: " + tx); } tx.waitForLocalTXCommit(null, 0); } }
@Override public void run2() { final TXManagerImpl mgr = GemFireCacheImpl.getExisting() .getCacheTransactionManager(); TXStateInterface tx = mgr.suspendedTXs.remove(this.txId); if (tx != null) { final LogWriterI18n logger = mgr.getLogger(); try { if (logger.fineEnabled()) { logger .fine("TX: Expiry task rolling back transaction:" + this.txId); } tx.rollback(null); } catch (GemFireException e) { if (logger.warningEnabled()) { logger.warning(LocalizedStrings .TXManagerImpl_EXCEPTION_IN_TRANSACTION_TIMEOUT, this.txId, e); } } } }
return; this.cache.getCacheTransactionManager().clearTXState(); if (tx != null) { tx.rollback(null);
public Object call() throws Exception { Region ref = getCache().getRegion(D_REFERENCE); Region empty = getCache().getRegion(EMPTY_REGION); getGemfireCache().getCacheTransactionManager().begin(); ref.put("one", "value1"); empty.put("eone", "valueOne"); getCache().getLogger().info("SWAP:callingCommit"); getGemfireCache().getCacheTransactionManager().commit(); assertTrue(ref.containsKey("one")); assertEquals("value1", ref.get("one")); assertFalse(empty.containsKey("eone")); assertNull(empty.get("eone")); return null; } });
@Override protected boolean operateOnTX(final TXStateProxy txProxy, DistributionManager dm) { if (txProxy != null) { txProxy.setCommitVersionSources(this.commitTime, this.regionDiskVersionSources); txProxy.addToBePublishedEvents(this.memberTailKeysMap); txProxy.commit(null /* indicates remote commit */, this.callbackArg); return true; } else { // if no TXState was created (e.g. due to only getEntry/size operations // that don't start remote TX) then ignore, but try to remove from hosted // txStates neverthless final GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); final TXManagerImpl txMgr; if (cache != null && (txMgr = cache.getCacheTransactionManager()) != null) { txMgr.removeHostedTXState(getTXId(), Boolean.TRUE); } return true; } }
@Override public void run2() throws CacheException { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_ACK); af.setConcurrencyChecksEnabled(true); Region r1 = createRootRegion("r1", af.create()); TXManagerImpl ctm = getGemfireCache().getCacheTransactionManager(); ctm.begin(); r1.create("createKey", "createValue"); if (doDestroy) { try { r1.localDestroy("createKey"); fail("expected exception not thrown"); } catch (UnsupportedOperationInTransactionException e) { assertEquals(e.getMessage(), LocalizedStrings.TXStateProxy_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION.toLocalizedString()); } } else { try { r1.localInvalidate("createKey"); fail("expected exception not thrown"); } catch (UnsupportedOperationInTransactionException e) { assertEquals(e.getMessage(), LocalizedStrings.TXStateProxy_LOCAL_INVALIDATE_NOT_ALLOWED_IN_TRANSACTION.toLocalizedString()); } } ctm.commit(); TXManagerImpl.waitForPendingCommitForTest(); } });
/** * getAll should now be supported */ public void testGetAllSupported() throws Exception { CacheTransactionManager ctm = this.cache.getCacheTransactionManager(); AttributesFactory af = new AttributesFactory(); Region r = this.cache.createRegion("dRegion", af.create()); PartitionAttributes pa = new PartitionAttributesFactory() .setRedundantCopies(0) .setTotalNumBuckets(1) .create(); af.setPartitionAttributes(pa); Region pr = this.cache.createRegion("prRegion", af.create()); List list = new ArrayList(); list.add("stuff"); list.add("stuff2"); ctm.begin(); pr.getAll(list); r.getAll(list); ctm.commit(); // now we aren't in tx so these shouldn't throw pr.getAll(list); r.getAll(list); }
.getCacheTransactionManager(); final ImageState imgState = this.region.getImageState(); final CachePerfStats stats = this.region.getCachePerfStats();
VersionTag tag = null; assert this.dataPolicy != DataPolicy.REPLICATE; final TXManagerImpl txMgr = this.cache.getCacheTransactionManager(); TXId txId = txMgr.suspend(); try {
final TXStateProxy txProxy; if (!cache.getMyId().equals(sender) && (txProxy = cache.getCacheTransactionManager().getHostedTXState( this.txId)) != null) { if (this.isDirty) {
public static void START_SNAPSHOT_TXID(Boolean delayRollover, String[] txid) throws SQLException, StandardException { TXManagerImpl txManager = Misc.getGemFireCache().getCacheTransactionManager(); TXManagerImpl.TXContext context = TXManagerImpl.getOrCreateTXContext();
/** * make sure that we do not expose BucketRegion on transactionListener events * @throws Exception */ public void testInternalRegionNotExposed() throws Exception { TransactionListenerForRegionTest tl = new TransactionListenerForRegionTest(); CacheTransactionManager ctm = this.cache.getCacheTransactionManager(); ctm.addListener(tl); CacheListenerForRegionTest cl = new CacheListenerForRegionTest(); AttributesFactory af = new AttributesFactory(); PartitionAttributes pa = new PartitionAttributesFactory() .setRedundantCopies(0) .setTotalNumBuckets(1) .create(); af.setPartitionAttributes(pa); af.addCacheListener(cl); Region pr = this.cache.createRegion("testTxEventForRegion", af.create()); pr.put(2, "tw"); pr.put(3, "three"); pr.put(4, "four"); ctm.begin(); pr.put(1, "one"); pr.put(2, "two"); pr.invalidate(3); pr.destroy(4); ctm.commit(); assertFalse(tl.exceptionOccurred); assertFalse(cl.exceptionOccurred); }
CacheTransactionManager ctm = this.cache.getCacheTransactionManager(); AttributesFactory af = new AttributesFactory(); Region r = this.cache.createRegion("dRegion", af.create());
public Object call() throws Exception { Region custRegion = getGemfireCache().getRegion(CUSTOMER); CacheTransactionManager mgr = getGemfireCache().getCacheTransactionManager(); CustId custId = new CustId(6); Customer customer = new Customer("customer6", "address6");