Java Code Examples for org.apache.shardingsphere.transaction.core.TransactionType#BASE

The following examples show how to use org.apache.shardingsphere.transaction.core.TransactionType#BASE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackendConnection.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
/**
 * Close cached connection.
 *
 * @param forceClose force close flag
 * @throws SQLException SQL exception
 */
public synchronized void close(final boolean forceClose) throws SQLException {
    Collection<SQLException> exceptions = new LinkedList<>();
    MasterVisitedManager.clear();
    exceptions.addAll(closeResultSets());
    exceptions.addAll(closeStatements());
    if (!stateHandler.isInTransaction() || forceClose || TransactionType.BASE == transactionType) {
        exceptions.addAll(releaseConnections(forceClose));
    }
    stateHandler.doNotifyIfNecessary();
    throwSQLExceptionIfNecessary(exceptions);
}
 
Example 2
Source File: ShardingSphereConnectionTest.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
@Test
public void assertBASETransactionOperation() throws SQLException {
    connection = new ShardingSphereConnection(dataSourceMap, schemaContexts, TransactionType.BASE);
    connection.setAutoCommit(false);
    assertTrue(BASEShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.BEGIN));
    connection.commit();
    assertTrue(BASEShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.COMMIT));
    connection.rollback();
    assertTrue(BASEShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.ROLLBACK));
}
 
Example 3
Source File: SeataATOrderService.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
/**
 * Execute XA.
 *
 * @param count insert record count
 * @return transaction type
 */
@Transactional
@ShardingTransactionType(TransactionType.BASE)
public TransactionType insert(final int count) {
    return jdbcTemplate.execute("INSERT INTO t_order (user_id, status) VALUES (?, ?)", (PreparedStatementCallback<TransactionType>) preparedStatement -> {
        doInsert(count, preparedStatement);
        return TransactionTypeHolder.get();
    });
}
 
Example 4
Source File: SagaTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 5 votes vote down vote up
/**
 * process failure, XA transaction will be rollback.
 */
@Override
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processFailure() {
    springPojoService.processFailure();
}
 
Example 5
Source File: SagaTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 5 votes vote down vote up
/**
 * process success, XA transaction will be committed.
 */
@Override
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processSuccess() {
    springPojoService.processSuccess();
}
 
Example 6
Source File: SeataTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 4 votes vote down vote up
/**
 * process success.
 */
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processSuccess() {
    springPojoService.processSuccess();
}
 
Example 7
Source File: SeataTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 4 votes vote down vote up
/**
 * process failure.
 */
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processFailure() {
    springPojoService.processFailure();
}
 
Example 8
Source File: SeataTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 4 votes vote down vote up
/**
 * process success.
 */
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processSuccess() {
    jpaCommonService.processSuccess();
}
 
Example 9
Source File: SagaTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 4 votes vote down vote up
/**
 * process failure.
 */
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processFailure() {
    jpaCommonService.processFailure();
}
 
Example 10
Source File: SagaTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 4 votes vote down vote up
/**
 * process success, XA transaction will be committed.
 */
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processSuccess() {
    springPojoService.processSuccess();
}
 
Example 11
Source File: ShardingTransactionalTestService.java    From opensharding-spi-impl with Apache License 2.0 4 votes vote down vote up
@ShardingTransactionType(TransactionType.BASE)
public void testChangeTransactionTypeToBASE() {
}
 
Example 12
Source File: ShardingTransactionalTestService.java    From opensharding-spi-impl with Apache License 2.0 4 votes vote down vote up
@ShardingTransactionType(TransactionType.BASE)
public void testChangeTransactionTypeToBASE() {
    assertThat(TransactionTypeHolder.get(), is(TransactionType.BASE));
}
 
Example 13
Source File: ShardingTransactionalTestService.java    From opensharding-spi-impl with Apache License 2.0 4 votes vote down vote up
@ShardingTransactionType(TransactionType.BASE)
public void testChangeTransactionTypeToBASE() {
    assertThat(TransactionTypeHolder.get(), is(TransactionType.BASE));
}
 
Example 14
Source File: ShardingTransactionalTestService.java    From opensharding-spi-impl with Apache License 2.0 4 votes vote down vote up
@ShardingTransactionType(TransactionType.BASE)
public void testChangeTransactionTypeToBASE() {
}
 
Example 15
Source File: SeataATShardingTransactionManager.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Override
public TransactionType getTransactionType() {
    return TransactionType.BASE;
}
 
Example 16
Source File: SagaTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 4 votes vote down vote up
/**
 * process success.
 */
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processSuccess() {
    jpaCommonService.processSuccess();
}
 
Example 17
Source File: BASEShardingTransactionManagerFixture.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Override
public TransactionType getTransactionType() {
    return TransactionType.BASE;
}
 
Example 18
Source File: SagaTransactionalService.java    From opensharding-spi-impl-example with Apache License 2.0 4 votes vote down vote up
/**
 * process failure, XA transaction will be rollback.
 */
@ShardingTransactionType(TransactionType.BASE)
@Transactional
public void processFailure() {
    springPojoService.processFailure();
}
 
Example 19
Source File: MockService.java    From shardingsphere with Apache License 2.0 2 votes vote down vote up
/**
 * Execute BASE.
 *
 * @return transaction type
 */
@ShardingTransactionType(TransactionType.BASE)
public TransactionType executeBase() {
    return TransactionTypeHolder.get();
}
 
Example 20
Source File: CommandExecutorSelector.java    From shardingsphere with Apache License 2.0 2 votes vote down vote up
/**
 * Get executor service.
 *
 * @param isOccupyThreadForPerConnection is occupy thread for per connection or not
 * @param supportHint is support hint
 * @param transactionType transaction type
 * @param channelId channel ID
 * @return executor service
 */
public static ExecutorService getExecutor(final boolean isOccupyThreadForPerConnection, final boolean supportHint, final TransactionType transactionType, final ChannelId channelId) {
    return (isOccupyThreadForPerConnection || supportHint || TransactionType.XA == transactionType || TransactionType.BASE == transactionType)
            ? ChannelThreadExecutorGroup.getInstance().get(channelId) : UserExecutorGroup.getInstance().getExecutorService();
}