// Path: src/main/java/com/elong/pb/newdda/client/constants/ThreadPoolConstants.java
// public class ThreadPoolConstants {
// 
//     public final static int CORE_SIZE = Runtime.getRuntime().availableProcessors();
// 
// 
// 
// }
// 
// Path: src/main/java/com/elong/pb/newdda/client/executor/wrapper/PreparedStatementExecutorWrapper.java
// public class PreparedStatementExecutorWrapper {
// 
//     private final PreparedStatement preparedStatement;
// 
//     private final SqlExecutionUnit sqlExecutionUnit;
// 
//     private final List<Object> parameters;
// 
//     public PreparedStatementExecutorWrapper(final PreparedStatement preparedStatement, List<Object> parameters, final SqlExecutionUnit sqlExecutionUnit) {
//         this.preparedStatement = preparedStatement;
//         this.parameters = parameters;
//         this.sqlExecutionUnit = sqlExecutionUnit;
//     }
// 
//     //==================================================get method start ==================================================
// 
//     public PreparedStatement getPreparedStatement() {
//         return preparedStatement;
//     }
// 
//     public SqlExecutionUnit getSqlExecutionUnit() {
//         return sqlExecutionUnit;
//     }
// 
//     public List<Object> getParameters() {
//         return parameters;
//     }
// 
//     //==================================================get method end ==================================================
// 
// }


import com.elong.pb.newdda.client.constants.ThreadPoolConstants;
import com.elong.pb.newdda.client.executor.wrapper.PreparedStatementExecutorWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
package com.elong.pb.newdda.client.executor;



public final class PreparedStatementExecutor {

    private final static Logger logger = LoggerFactory.getLogger(PreparedStatementExecutor.class);

    private final Object flushLock = new Object();

    private final static int MAX_SIZE = ThreadPoolConstants.CORE_SIZE * 2 + 1;

    private final static int KEEP_ALIVE_TIME = 600;

    private final static int EXECUTE_MAX_TIME = 10;

    private final boolean IS_EXCEPTION_THROWN = true;

    private static ThreadPoolExecutor prepareThreadPoolExecutor = new ThreadPoolExecutor(
            ThreadPoolConstants.CORE_SIZE,
            MAX_SIZE,
            KEEP_ALIVE_TIME,
            TimeUnit.SECONDS,
            new ArrayBlockingQueue<Runnable>(100000),
            new ThreadFactory() {
                private AtomicInteger threadIndex = new AtomicInteger(0);

                @Override
                public Thread newThread(Runnable r) {
                    return new Thread(r, "PrepareStatementExecutor_" + this.threadIndex.incrementAndGet());
                }
            },
            new ThreadPoolExecutor.CallerRunsPolicy()
    );

// Path: src/main/java/com/elong/pb/newdda/client/constants/ThreadPoolConstants.java
// public class ThreadPoolConstants {
// 
//     public final static int CORE_SIZE = Runtime.getRuntime().availableProcessors();
// 
// 
// 
// }
// 
// Path: src/main/java/com/elong/pb/newdda/client/executor/wrapper/PreparedStatementExecutorWrapper.java
// public class PreparedStatementExecutorWrapper {
// 
//     private final PreparedStatement preparedStatement;
// 
//     private final SqlExecutionUnit sqlExecutionUnit;
// 
//     private final List<Object> parameters;
// 
//     public PreparedStatementExecutorWrapper(final PreparedStatement preparedStatement, List<Object> parameters, final SqlExecutionUnit sqlExecutionUnit) {
//         this.preparedStatement = preparedStatement;
//         this.parameters = parameters;
//         this.sqlExecutionUnit = sqlExecutionUnit;
//     }
// 
//     //==================================================get method start ==================================================
// 
//     public PreparedStatement getPreparedStatement() {
//         return preparedStatement;
//     }
// 
//     public SqlExecutionUnit getSqlExecutionUnit() {
//         return sqlExecutionUnit;
//     }
// 
//     public List<Object> getParameters() {
//         return parameters;
//     }
// 
//     //==================================================get method end ==================================================
// 
// }


// Path: src/main/java/com/elong/pb/newdda/client/executor/PreparedStatementExecutor.java
import com.elong.pb.newdda.client.constants.ThreadPoolConstants;
import com.elong.pb.newdda.client.executor.wrapper.PreparedStatementExecutorWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;

package com.elong.pb.newdda.client.executor;



public final class PreparedStatementExecutor {

    private final static Logger logger = LoggerFactory.getLogger(PreparedStatementExecutor.class);

    private final Object flushLock = new Object();

    private final static int MAX_SIZE = ThreadPoolConstants.CORE_SIZE * 2 + 1;

    private final static int KEEP_ALIVE_TIME = 600;

    private final static int EXECUTE_MAX_TIME = 10;

    private final boolean IS_EXCEPTION_THROWN = true;

    private static ThreadPoolExecutor prepareThreadPoolExecutor = new ThreadPoolExecutor(
            ThreadPoolConstants.CORE_SIZE,
            MAX_SIZE,
            KEEP_ALIVE_TIME,
            TimeUnit.SECONDS,
            new ArrayBlockingQueue<Runnable>(100000),
            new ThreadFactory() {
                private AtomicInteger threadIndex = new AtomicInteger(0);

                @Override
                public Thread newThread(Runnable r) {
                    return new Thread(r, "PrepareStatementExecutor_" + this.threadIndex.incrementAndGet());
                }
            },
            new ThreadPoolExecutor.CallerRunsPolicy()
    );

    private List<PreparedStatementExecutorWrapper> preparedStatementExecutorWrappers;