|
|
|
@ -18,6 +18,7 @@ import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
import com.fr.third.org.jboss.logging.Logger; |
|
|
|
|
|
|
|
|
@ -187,10 +188,14 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
|
|
|
|
LOG.tracev( "Closing JDBC container [{0}]", this ); |
|
|
|
|
Connection connection; |
|
|
|
|
try { |
|
|
|
|
if ( currentBatch != null ) { |
|
|
|
|
LOG.closingUnreleasedBatch(); |
|
|
|
|
currentBatch.release(); |
|
|
|
|
LOG.closingUnreleasedBatch(); |
|
|
|
|
for(Map.Entry<BatchKey, Batch> e : batchMap.entrySet()){ |
|
|
|
|
e.getValue().release(); |
|
|
|
|
} |
|
|
|
|
// if ( currentBatch != null ) {
|
|
|
|
|
// LOG.closingUnreleasedBatch();
|
|
|
|
|
// currentBatch.release();
|
|
|
|
|
// }
|
|
|
|
|
cleanup(); |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
@ -199,35 +204,55 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
|
|
|
|
return connection; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<BatchKey, Batch> batchMap = new ConcurrentHashMap<BatchKey, Batch>(); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Batch getBatch(BatchKey key) { |
|
|
|
|
if ( currentBatch != null ) { |
|
|
|
|
if ( currentBatch.getKey().equals( key ) ) { |
|
|
|
|
return currentBatch; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
currentBatch.execute(); |
|
|
|
|
currentBatch.release(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
currentBatch = batchBuilder().buildBatch( key, this ); |
|
|
|
|
return currentBatch; |
|
|
|
|
Batch batch = batchMap.get(key); |
|
|
|
|
if(batch == null) { |
|
|
|
|
batch = batchBuilder().buildBatch( key, this ); |
|
|
|
|
batchMap.put(key, batch); |
|
|
|
|
} |
|
|
|
|
return batch; |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// if ( currentBatch != null ) {
|
|
|
|
|
// if ( currentBatch.getKey().equals( key ) ) {
|
|
|
|
|
// return currentBatch;
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// currentBatch.execute();
|
|
|
|
|
// currentBatch.release();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// currentBatch = batchBuilder().buildBatch( key, this );
|
|
|
|
|
// return currentBatch;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void executeBatch() { |
|
|
|
|
if ( currentBatch != null ) { |
|
|
|
|
currentBatch.execute(); |
|
|
|
|
// needed?
|
|
|
|
|
currentBatch.release(); |
|
|
|
|
for(Map.Entry<BatchKey, Batch> e : batchMap.entrySet()){ |
|
|
|
|
e.getValue().execute(); |
|
|
|
|
e.getValue().release(); |
|
|
|
|
} |
|
|
|
|
// if ( currentBatch != null ) {
|
|
|
|
|
// currentBatch.execute();
|
|
|
|
|
// // needed?
|
|
|
|
|
// currentBatch.release();
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void abortBatch() { |
|
|
|
|
if ( currentBatch != null ) { |
|
|
|
|
currentBatch.release(); |
|
|
|
|
|
|
|
|
|
for(Map.Entry<BatchKey, Batch> e : batchMap.entrySet()){ |
|
|
|
|
e.getValue().release(); |
|
|
|
|
} |
|
|
|
|
// if ( currentBatch != null ) {
|
|
|
|
|
// currentBatch.release();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private transient StatementPreparer statementPreparer; |
|
|
|
|