@Override public boolean isActive() { return this.raw.isActive(); }
/** Rolls back this transaction. */ @Override public void rollback() { session.transaction.remove(); if (transaction.isActive()) { transaction.rollback(); } }
@Override public void rollback() { logger.finer("rollback"); if (tx == null) { return; } if (!tx.isActive()) { tx = null; return; } tx.rollback(); tx = null; logger.finer("done"); }
@Override public void exit() { Transaction currentTransaction = datastore.getCurrentTransaction(null); if (currentTransaction != null && currentTransaction.isActive()) { currentTransaction.rollback(); } }
/** Rolls back every operation in the current transaction. */ @Override public void rollback() { for (ResourceManager<Transaction> manager : managers.values()) { Transaction transaction = manager.transaction(); if (transaction.isActive()) { try { transaction.rollback(); } catch (Exception e) { logger.warning("Transaction [" + transaction.getId() + "]: Rollback failed due to [" + e + "]; Consistency will be ensured in read"); } } } }
@VisibleForTesting protected boolean isParentTransactionActive() { return ObjectifyService.ofy().getTransaction() == null ? false : ObjectifyService.ofy().getTransaction().isActive(); }
/** Commits this transaction with loose commitment protocol. */ @Override public void commit() throws IndoubtException { session.transaction.remove(); if (logs.size() == 0) { return; } try { for (Log log : logs) { if (log.operation() != Operation.GET) { if (transaction.isActive()) { transaction.commit(); } log.state(State.COMMITTED); } } } catch (Exception e) { throw new UncheckedException(e); } logger.fine("Transaction [" + id + "] committed"); }
public static void closeQuietly(Objectify objectify) { if (objectify.getTransaction().isActive()) objectify.getTransaction().rollback(); }
@Override public List<Key> call() { Transaction tx = dataStore.beginTransaction(); List<Key> keys; try { keys = dataStore.put(tx, shardedValues); tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } } return keys; } });
protected void assertActiveTransactions(Transaction... txs) { Collection<Transaction> transactions = service.getActiveTransactions(); assertNotNull(txs); Set<Transaction> expected = new HashSet<>(transactions); Set<Transaction> existing = new HashSet<>(Arrays.asList(txs)); assertEquals(expected, existing); for (Transaction tx : txs) { assertTrue(tx.isActive()); } }
public static Key putTempData(TempData data) { DatastoreService ds = DatastoreServiceFactory.getDatastoreService(); Transaction txn = ds.beginTransaction(TransactionOptions.Builder.withXG(true)); try { Class<? extends TempData> type = data.getClass(); String kind = getKind(type); Entity entity = new Entity(kind); for (Map.Entry<String, Object> entry : data.toProperties(ds).entrySet()) { entity.setProperty(entry.getKey(), entry.getValue()); } entity.setProperty(TEMP_DATA_READ_PROPERTY, false); data.prePut(ds); Key key = ds.put(txn, entity); data.postPut(ds); txn.commit(); return key; } catch (Exception e) { throw new IllegalStateException(e); } finally { if (txn.isActive()) { txn.rollback(); } } }
protected static void deleteTempDataInTx(DatastoreService ds, Entity entity, Class<? extends TempData> type) { Transaction txn = ds.beginTransaction(TransactionOptions.Builder.withXG(true)); try { TempData data = type.newInstance(); data.fromProperties(entity.getProperties()); data.preDelete(ds); ds.delete(txn, entity.getKey()); data.postDelete(ds); txn.commit(); } catch (Exception e) { throw new IllegalStateException(e); } finally { if (txn.isActive()) { txn.rollback(); } } }
@Override public boolean deleteObject(GcsFilename filename, long timeoutMillis) throws IOException { ensureInitialized(); Transaction tx = datastore.beginTransaction(); Key key = makeKey(filename); try { datastore.get(tx, key); datastore.delete(tx, key); blobstoreService.delete(getBlobKeyForFilename(filename)); } catch (EntityNotFoundException ex) { return false; } finally { if (tx.isActive()) { tx.commit(); } } return true; }
if (transaction.isActive()) { transaction.rollback();
private void saveEntity(Entity entity) { DatastoreService service = DatastoreServiceFactory.getDatastoreService(); Transaction tx = service.beginTransaction(); try { service.put(tx, entity); tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } } }