/** * Sets the timeout. * <p/> * The timeout determines the maximum lifespan of a transaction. So if a transaction is configured with a * timeout of 2 minutes, then it will automatically rollback if it hasn't committed yet. * * @param timeout the timeout. * @param timeUnit the TimeUnit of the timeout. * @return the updated TransactionOptions * @throws IllegalArgumentException if timeout smaller or equal than 0, or timeUnit is null. * @see #getTimeoutMillis() */ public TransactionOptions setTimeout(long timeout, TimeUnit timeUnit) { if (timeout < 0) { throw new IllegalArgumentException("Timeout can not be negative!"); } if (timeUnit == null) { throw new IllegalArgumentException("timeunit can't be null"); } if (timeout == 0) { setDefaultTimeout(); } else { this.timeoutMillis = timeUnit.toMillis(timeout); } return this; }
/** * Sets the timeout. * <p/> * The timeout determines the maximum lifespan of a transaction. So if a transaction is configured with a * timeout of 2 minutes, then it will automatically rollback if it hasn't committed yet. * * @param timeout the timeout. * @param timeUnit the TimeUnit of the timeout. * @return the updated TransactionOptions * @throws IllegalArgumentException if timeout smaller or equal than 0, or timeUnit is null. * @see #getTimeoutMillis() */ public TransactionOptions setTimeout(long timeout, TimeUnit timeUnit) { if (timeout < 0) { throw new IllegalArgumentException("Timeout can not be negative!"); } if (timeUnit == null) { throw new IllegalArgumentException("timeunit can't be null"); } if (timeout == 0) { setDefaultTimeout(); } else { this.timeoutMillis = timeUnit.toMillis(timeout); } return this; }
/** * Creates a new default configured TransactionsOptions. * <p/> * It will be configured with a timeout of 2 minutes, durability of 1 and a TransactionType.TWO_PHASE. */ public TransactionOptions() { setDurability(1).setTransactionType(TransactionType.TWO_PHASE).setDefaultTimeout(); }
/** * Creates a new default configured TransactionsOptions. * <p/> * It will be configured with a timeout of 2 minutes, durability of 1 and a TransactionType.TWO_PHASE. */ public TransactionOptions() { setDurability(1).setTransactionType(TransactionType.TWO_PHASE).setDefaultTimeout(); }