package com.alibaba.rocketmq.store.transaction.jdbc;

import com.alibaba.rocketmq.common.config.Config;
import com.alibaba.rocketmq.common.config.TransactionConfig;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.dbcp2.BasicDataSource;

/**
 * 每个broker单库单表的时候使用
 */
public class SimpleJdbcTransactionStore extends AbstractJdbcTransactionStore {

    public SimpleJdbcTransactionStore(Config config) {
        super(config);
    }

    @Override
    public boolean start() {
        TransactionConfig transactionConfig = config.transactionConfig;

        if (CollectionUtils.isEmpty(transactionConfig.urls)) {
            log.error("must config urls in transaction config.");
            return false;
        }

        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setUsername(transactionConfig.userName);
        dataSource.setPassword(transactionConfig.password);
        dataSource.setDriverClassName(transactionConfig.driverClassName);
        dataSource.setInitialSize(transactionConfig.initialSize);
        dataSource.setMaxTotal(transactionConfig.maxTotal);
        dataSource.setMaxIdle(transactionConfig.maxIdle);
        dataSource.setMinIdle(transactionConfig.minIdle);
        dataSource.setMaxWaitMillis(transactionConfig.maxWaitMillis);

        dataSource.setUrl(transactionConfig.urls.get(0));

        setDataSource(dataSource);

        return true;
    }

    @Override
    public boolean shutdown() {
        try {
            ((BasicDataSource)getDataSource()).close();
        } catch (Exception e) {
            log.warn("", e);
        }

        return true;
    }
}

@@ -763,17 +763,22 @@
 aSource 
-d
+basicD
 ataSourc
@@ -804,33 +804,38 @@
 urce();%0A        
-d
+basicD
 ataSource.setUse
@@ -869,33 +869,38 @@
 rName);%0A        
-d
+basicD
 ataSource.setPas
@@ -934,33 +934,38 @@
 sword);%0A        
-d
+basicD
 ataSource.setDri
@@ -1013,33 +1013,38 @@
 sName);%0A        
-d
+basicD
 ataSource.setIni
@@ -1084,33 +1084,38 @@
 lSize);%0A        
-d
+basicD
 ataSource.setMax
@@ -1149,33 +1149,38 @@
 Total);%0A        
-d
+basicD
 ataSource.setMax
@@ -1212,33 +1212,38 @@
 xIdle);%0A        
-d
+basicD
 ataSource.setMin
@@ -1275,33 +1275,38 @@
 nIdle);%0A        
-d
+basicD
 ataSource.setMax
@@ -1359,17 +1359,22 @@
         
-d
+basicD
 ataSourc
@@ -1437,17 +1437,22 @@
 aSource(
-d
+basicD
 ataSourc

add doDispatch transaction put retry, retry forever now