Skip to content

Commit

Permalink
Loom initial work (#125)
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Di Liberto Gasparin <[email protected]>
  • Loading branch information
mdg1349 authored Dec 22, 2023
1 parent 78a6b48 commit 659b1f1
Show file tree
Hide file tree
Showing 8 changed files with 893 additions and 279 deletions.
198 changes: 168 additions & 30 deletions src/main/java/com/ibm/as400/access/AS400JDBCCallableStatement.java

Large diffs are not rendered by default.

63 changes: 36 additions & 27 deletions src/main/java/com/ibm/as400/access/AS400JDBCConnectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Vector;
import java.util.concurrent.locks.Lock;
/* ifdef JDBC40 */
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.Executor;
Expand Down Expand Up @@ -106,7 +107,6 @@ public class AS400JDBCConnectionImpl
{

private class CancelLock extends Object {} //@C7A
private class HeldRequestsLock extends Object {} //@C7A

// Turn this flag on to prevent this Connection object from establishing an actual connection to the IBM i system. This is useful when doing multi-threaded stress testing on the Toolbox's built-in JDBC connection pool manager, where we create/delete massive numbers of connections.
// For production, this flag _must_ be set to 'false'.
Expand Down Expand Up @@ -194,7 +194,7 @@ private class HeldRequestsLock extends Object {} //@C7A
// @E2D private ConverterImplRemote graphicConverter_;
// @E2D private boolean graphicConverterLoaded_;
private Vector heldRequests_; // @E5A
private HeldRequestsLock heldRequestsLock_ = new HeldRequestsLock(); // @E5A@C7C
private Lock heldRequestsLock = new ReentrantLock(); // @E5A@C7C
private int holdability_ = AS400JDBCResultSet.HOLDABILITY_NOT_SPECIFIED; // @G4A
private int id_;
private AS400JDBCDatabaseMetaData metaData_;
Expand Down Expand Up @@ -1908,9 +1908,6 @@ public void postWarning (int id, int errorClass, int returnCode)
}
}




/**
Precompiles an SQL stored procedure call with optional input
and output parameters and stores it in a CallableStatement
Expand Down Expand Up @@ -2888,8 +2885,8 @@ void send (DBBaseRequestDS request, int id, boolean leavePending)
} // @ECA

DataStream actualRequest; // @E5A
synchronized(heldRequestsLock_)
{ // @E5A
try {
heldRequestsLock.lock();
if (heldRequests_ != null) // @E5A
actualRequest = new DBConcatenatedRequestDS(heldRequests_, request); // @E5A
else // @E5A
Expand All @@ -2898,7 +2895,9 @@ void send (DBBaseRequestDS request, int id, boolean leavePending)

server_.send(actualRequest); // @E5A @F7M
//@P1D requestPending_[id] = leavePending; //@P0A @F7M
} // @E5A
} finally {
heldRequestsLock.unlock();
}

// @E5D if (DEBUG_REQUEST_CHAINING_ == true) {
//@P0D if (leavePending) // @DAA
Expand Down Expand Up @@ -3032,11 +3031,14 @@ public void sendAndHold(DBBaseRequestDS request, int id)
request.compress(); // @ECA
} // @ECA

synchronized(heldRequestsLock_)
try
{
heldRequestsLock.lock();
if (heldRequests_ == null)
heldRequests_ = new Vector();
heldRequests_.addElement(request);
} finally {
heldRequestsLock.unlock();
}

//@P0D requestPending_.set(id); // @DAC
Expand Down Expand Up @@ -3129,17 +3131,19 @@ public DBReplyRequestedDS sendAndReceive (DBBaseRequestDS request, int id)
} // @ECA

DataStream actualRequest; // @E5A
synchronized(heldRequestsLock_)
{ // @E5A
try {
heldRequestsLock.lock();
if (heldRequests_ != null) // @E5A
actualRequest = new DBConcatenatedRequestDS(heldRequests_, request); // @E5A
actualRequest = new DBConcatenatedRequestDS(heldRequests_, request); // @E5A
else // @E5A
actualRequest = request; // @E5A
heldRequests_ = null; // @E5A

reply = (DBReplyRequestedDS)server_.sendAndReceive(actualRequest); // @E5C @F7M
//@P0D requestPending_.clear(id);
//@P1D requestPending_[id] = false; //@P0A @F7M
reply = (DBReplyRequestedDS) server_.sendAndReceive(actualRequest); // @E5C @F7M
// @P0D requestPending_.clear(id);
// @P1D requestPending_[id] = false; //@P0A @F7M
} finally {
heldRequestsLock.unlock();
} // @E5A

reply.parse(dataCompression_); // @E5A
Expand Down Expand Up @@ -3217,17 +3221,19 @@ public DBReplyRequestedDS sendAndMultiReceive (DBBaseRequestDS request)
request.compress(); // @ECA
} // @ECA

DataStream actualRequest; // @E5A
synchronized(heldRequestsLock_)
{ // @E5A
if (heldRequests_ != null) // @E5A
actualRequest = new DBConcatenatedRequestDS(heldRequests_, request); // @E5A
else // @E5A
actualRequest = request; // @E5A
heldRequests_ = null; // @E5A
//D2A- allowed correlation ID to be stored and used on multiple receive calls
correlationID_ = server_.send(actualRequest);
reply = (DBReplyRequestedDS)server_.receive(correlationID_);
DataStream actualRequest; // @E5A
try {
heldRequestsLock.lock();
if (heldRequests_ != null) // @E5A
actualRequest = new DBConcatenatedRequestDS(heldRequests_, request); // @E5A
else // @E5A
actualRequest = request; // @E5A
heldRequests_ = null; // @E5A
// D2A- allowed correlation ID to be stored and used on multiple receive calls
correlationID_ = server_.send(actualRequest);
reply = (DBReplyRequestedDS) server_.receive(correlationID_);
} finally {
heldRequestsLock.unlock();
} // @E5A

reply.parse(dataCompression_); // @E5A
Expand Down Expand Up @@ -3267,9 +3273,12 @@ public DBReplyRequestedDS receiveMoreData()
DBReplyRequestedDS reply = null;
try{
if(correlationID_ > 0){
synchronized(heldRequestsLock_)
try
{
heldRequestsLock.lock();
reply = (DBReplyRequestedDS)server_.receive(correlationID_);
} finally {
heldRequestsLock.unlock();
}
reply.parse(dataCompression_);
}
Expand Down
Loading

0 comments on commit 659b1f1

Please sign in to comment.