Create a default set of options with a custom number of retry attempts.

@param numberOfAttempts The number of execution attempts.
@return The TransactionOptions object.
10076
@Nonnull
  public static TransactionOptions create(int numberOfAttempts) {
    Preconditions.checkArgument(numberOfAttempts > 0, "You must allow at least one attempt");
    return new TransactionOptions(numberOfAttempts, null, null);
  }
1191273
public final synchronized void rollbackIncrementReferenceCount(PersistentTransaction transaction) throws SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "rollbackIncrementReferenceCount");

        if (_referenceCount < 1)
        {
        	SevereMessageStoreException e = new SevereMessageStoreException("Reference count increment cannot be rolled back");
            FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.cache.links.ItemLink.rollbackIncrementReferenceCount", "1:212:1.104.1.1");
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Reference count increment cannot be rolled back");
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "rollbackIncrementReferenceCount");
            throw e;
        }
        _referenceCount--;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "rollbackIncrementReferenceCount");
    }
10142
def retryable_transaction(attempts=3, exceptions=(OperationalError,)):
    """"""
    assert len(exceptions) > 0
    assert attempts > 0

    def wrapper(f):
        @functools.wraps(f)
        def wrapped(*args, **kwargs):
            for i in xrange(attempts):
                try:
                    return f(*args, **kwargs)
                except exceptions, e:
                    if i == (attempts - 1):
                        raise
                    logging.warning(
                        'Retryable error in transaction on attempt %d. %s: %s',
                        i + 1, e.__class__.__name__, e)
                    db.session.rollback()

        return wrapped

    return wrapper
1077200
def p_retry_option_list(p):
    
    if len(p) == 4:
        p[0] = merge_map(p[1], p[3])
    elif len(p) == 2:
        p[0] = p[1]
    else:
        raise RuntimeError("Invalid production in 'retry_option_list'")
261735
private CompletableFuture<Void> commitTransactions(String scope, String stream, List<Long> segments,
                                                                     List<UUID> transactionsToCommit) {
        // Chain all transaction commit futures one after the other. This will ensure that order of commit
        // if honoured and is based on the order in the list.
        CompletableFuture<Void> future = CompletableFuture.completedFuture(null);
        for (UUID txnId : transactionsToCommit) {
            log.debug("Committing transaction {} on stream {}/{}", txnId, scope, stream);
            // commit transaction in segment store
            future = future
                    // Note, we can use the same segments and transaction id as only
                    // primary id is taken for creation of txn-segment name and secondary part is erased and replaced with
                    // transaction's epoch.
                    // And we are creating duplicates of txn epoch keeping the primary same.
                    .thenCompose(v -> streamMetadataTasks.notifyTxnCommit(scope, stream, segments, txnId));
        }
        return future;
    }
1261525
public static TransactionAware of(Collection<TransactionAware> transactionAwares) {
    // this is most common case, trying to optimize
    if (transactionAwares.size() == 1) {
      return transactionAwares.iterator().next();
    }

    TransactionAwareCollection result = new TransactionAwareCollection();
    result.addAll(transactionAwares);

    return result;
  }
1118350
public void doCommit(DefaultTransactionStatus status) throws TransactionException {
		CompensatingTransactionObject txObject = (CompensatingTransactionObject) status.getTransaction();
		txObject.getHolder().getTransactionOperationManager().commit();

	}
451441
public function tryWithTransaction(callable $callable, int $maxAttempts)
    {
        for ($attempt = 1; $attempt <= $maxAttempts; $attempt++) {
            try {
                return $this->withTransaction($callable);
            } catch (Throwable $e) {
                if ($attempt == $maxAttempts) {
                    throw $e;
                }
            }
        }
        throw new RuntimeException('Number of attempts must be greater than 0');
    }
1068795
public int getAttempts() {
        String attempts = this.properties.get("attempts");
        if (attempts == null) {
            attempts = "0";
        }

        return Integer.parseInt(attempts);
    }
435760
public void setOriginatingTransactionId(byte[] t) {
        if (t != null && t.length != 4)
            throw new IllegalArgumentException("TransactionId leng must be 4 bytes, found: " + t.length);
        this.originatingTransactionId = t;

    }
1374723
private void resetTailSequenceNumber()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "resetTailSequenceNumber"
                            );

        for (int i = 0; i < subListTokens.length; i++) {
            subLists[i] = ((ConcurrentSubList) subListTokens[i].getManagedObject());
            // In case another thread is currently removing the tail, take a safe copy.
            Token tailToken = subLists[i].tail;
            // Establish the highest existing tailSequenceNumber.
            if (tailToken != null) {
                ConcurrentSubList.Link tail = (ConcurrentSubList.Link) tailToken.getManagedObject();
                tailSequenceNumber = Math.max(tailSequenceNumber,
                                              tail.sequenceNumber);
            } // if (tailToken != null).
        } // for subList.

        tailSequenceNumberSet = true;

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "resetHeadSequenceNumber"
                            );
    }
249270
public Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest) throws ProposalException, InvalidArgumentException {

        return sendProposal(transactionProposalRequest, getEndorsingPeers());
    }
643201
@Override
    public long count() throws PersistenceException {
        logger.debug("enter - count()");
        try {
            Transaction xaction = Transaction.getInstance(true);
            Counter counter = getCounter(null);

            try {
                Map<String,Object> results;
                long count;

                results = xaction.execute(counter, new HashMap<String,Object>(0), readDataSource);
                count = ((Number)results.get("count")).longValue();
                xaction.commit();
                return count;
            }
            finally {
                xaction.rollback();
            }
        }
        finally {
            logger.debug("exit - count()");
        }
    }
409627
public static CreateObjectOptions objectOptionsFromFileOptions(CreateFileOptions options) {
    return new CreateObjectOptions(
        options.overwriteExisting(), options.getContentType(), options.getAttributes());
  }
709046
@SuppressWarnings("unchecked")
  public RetryPolicy<R> abortOn(Class<? extends Throwable>... failures) {
    Assert.notNull(failures, "failures");
    Assert.isTrue(failures.length > 0, "Failures cannot be empty");
    return abortOn(Arrays.asList(failures));
  }
1197484
public void setDefaultTransactionTimeout(int timeoutSecs) throws Exception {
        final Address address = Address.root().add(SUBSYSTEM, TRANSACTIONS);
        final ModelNode req = createWriteAttributeRequest("default-timeout", String.valueOf(timeoutSecs), address);
        final ModelNode response = execute(req);

        if (!isSuccess(response)) {
            throw new FailureException(response);
        }
        return;
    }
88277
function createTransaction(dbInfo, mode, callback, retries) {
    if (retries === undefined) {
        retries = 1;
    }

    try {
        var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
        callback(null, tx);
    } catch (err) {
        if (retries > 0 && (!dbInfo.db || err.name === 'InvalidStateError' || err.name === 'NotFoundError')) {
            return Promise$1.resolve().then(function () {
                if (!dbInfo.db || err.name === 'NotFoundError' && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
                    // increase the db version, to create the new ObjectStore
                    if (dbInfo.db) {
                        dbInfo.version = dbInfo.db.version + 1;
                    }
                    // Reopen the database for upgrading.
                    return _getUpgradedConnection(dbInfo);
                }
            }).then(function () {
                return _tryReconnect(dbInfo).then(function () {
                    createTransaction(dbInfo, mode, callback, retries - 1);
                });
            })["catch"](callback);
        }

        callback(err);
    }
}