You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by jb...@apache.org on 2005/05/02 08:26:03 UTC
svn commit: r165585 [35/42] - in
/incubator/derby/code/trunk/java/client/org/apache/derby: client/
client/am/ client/net/ client/resources/ jdbc/
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXACallInfo.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXACallInfo.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXACallInfo.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXACallInfo.java Sun May 1 23:25:59 2005
@@ -36,113 +36,104 @@
**********************************************************************/
package org.apache.derby.client.net;
-import javax.transaction.xa.*;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
import org.apache.derby.client.am.Connection;
-public class NetXACallInfo
-{
- Xid xid_; // current xid
- int xaFlags_; // current xaFlags
- int xaState_; // used as a save area when switching connection
- // may not be needed!!!~~~
- int xaFunction_; // queued XA function being performed
- int xaRetVal_; // xaretval from server
- boolean xaInProgress_; // set at start(), reset at commit(),
- // rollback(), or prepare() on RDONLY
- boolean xaWasSuspended; // used to indicate an XA tyrans was suspended
- // one or more times, overrides empty transaction
- boolean currConnection_; // set when actualConn_ is the current connection
- boolean freeEntry_; // set when no actualConn_, entry is free / available
- boolean convReleased_; // release coversation, reuse successfull = true
- NetXAResource xaResource_; // NetXAResource containing this NetXACallInfo
- NetXAConnection actualConn_; // the actual connection object, not necessarily
- // the user's connection object
- /* only the first connection object is actually used. The other connection
- * objects are used only for their TCP/IP variables to simulate
- * suspend / resume
- */
-
- private byte[] crrtkn_;
- private java.io.InputStream in_;
- private java.io.OutputStream out_;
-
- private byte[] uowid_; // Unit of Work ID
-
- private boolean readOnlyTransaction_; // readOnlyTransaction Flag
-
- public NetXACallInfo()
- {
- xid_ = null;
- xaFlags_ = XAResource.TMNOFLAGS;
- xaState_ = Connection.XA_OPEN_IDLE;
- xaInProgress_ = false;
- currConnection_ = false;
- freeEntry_ = true;
- convReleased_ = false;
- actualConn_ = null;
- readOnlyTransaction_ = true;
- xaResource_ = null;
- xaRetVal_ = 0;
- xaWasSuspended = false;
- }
-
- public NetXACallInfo( Xid xid, int flags, int state,
- NetXAResource xares, NetXAConnection actualConn )
- {
- xid_ = xid;
- xaFlags_ = flags;
- xaState_ = state;
- xaInProgress_ = false;
- currConnection_ = false;
- freeEntry_ = true;
- actualConn_ = actualConn;
- readOnlyTransaction_ = true;
- xaResource_ = xares;
- xaRetVal_ = 0;
- xaWasSuspended = false;
- }
-
- public void saveConnectionVariables()
- {
- in_ = actualConn_.getInputStream();
- out_ = actualConn_.getOutputStream();
- crrtkn_ = actualConn_.getCorrelatorToken();
- }
-
- public java.io.InputStream getInputStream()
- {
- return in_;
- }
-
- public java.io.OutputStream getOutputStream()
- {
- return out_;
- }
-
- public byte[] getCorrelatorToken()
- {
- return crrtkn_;
- }
-
- protected void setUOWID(byte[] uowid)
- {
- uowid_ = uowid;
- }
-
- protected byte[] getUOWID()
- {
- return uowid_;
- }
-
- protected void setReadOnlyTransactionFlag(boolean flag)
- {
- readOnlyTransaction_ = flag;
- }
-
- protected boolean getReadOnlyTransactionFlag()
- {
- return readOnlyTransaction_;
- }
+public class NetXACallInfo {
+ Xid xid_; // current xid
+ int xaFlags_; // current xaFlags
+ int xaState_; // used as a save area when switching connection
+ // may not be needed!!!~~~
+ int xaFunction_; // queued XA function being performed
+ int xaRetVal_; // xaretval from server
+ boolean xaInProgress_; // set at start(), reset at commit(),
+ // rollback(), or prepare() on RDONLY
+ boolean xaWasSuspended; // used to indicate an XA tyrans was suspended
+ // one or more times, overrides empty transaction
+ boolean currConnection_; // set when actualConn_ is the current connection
+ boolean freeEntry_; // set when no actualConn_, entry is free / available
+ boolean convReleased_; // release coversation, reuse successfull = true
+ NetXAResource xaResource_; // NetXAResource containing this NetXACallInfo
+ NetXAConnection actualConn_; // the actual connection object, not necessarily
+ // the user's connection object
+ /* only the first connection object is actually used. The other connection
+ * objects are used only for their TCP/IP variables to simulate
+ * suspend / resume
+ */
+
+ private byte[] crrtkn_;
+ private java.io.InputStream in_;
+ private java.io.OutputStream out_;
+
+ private byte[] uowid_; // Unit of Work ID
+
+ private boolean readOnlyTransaction_; // readOnlyTransaction Flag
+
+ public NetXACallInfo() {
+ xid_ = null;
+ xaFlags_ = XAResource.TMNOFLAGS;
+ xaState_ = Connection.XA_OPEN_IDLE;
+ xaInProgress_ = false;
+ currConnection_ = false;
+ freeEntry_ = true;
+ convReleased_ = false;
+ actualConn_ = null;
+ readOnlyTransaction_ = true;
+ xaResource_ = null;
+ xaRetVal_ = 0;
+ xaWasSuspended = false;
+ }
+
+ public NetXACallInfo(Xid xid, int flags, int state,
+ NetXAResource xares, NetXAConnection actualConn) {
+ xid_ = xid;
+ xaFlags_ = flags;
+ xaState_ = state;
+ xaInProgress_ = false;
+ currConnection_ = false;
+ freeEntry_ = true;
+ actualConn_ = actualConn;
+ readOnlyTransaction_ = true;
+ xaResource_ = xares;
+ xaRetVal_ = 0;
+ xaWasSuspended = false;
+ }
+
+ public void saveConnectionVariables() {
+ in_ = actualConn_.getInputStream();
+ out_ = actualConn_.getOutputStream();
+ crrtkn_ = actualConn_.getCorrelatorToken();
+ }
+
+ public java.io.InputStream getInputStream() {
+ return in_;
+ }
+
+ public java.io.OutputStream getOutputStream() {
+ return out_;
+ }
+
+ public byte[] getCorrelatorToken() {
+ return crrtkn_;
+ }
+
+ protected void setUOWID(byte[] uowid) {
+ uowid_ = uowid;
+ }
+
+ protected byte[] getUOWID() {
+ return uowid_;
+ }
+
+ protected void setReadOnlyTransactionFlag(boolean flag) {
+ readOnlyTransaction_ = flag;
+ }
+
+ protected boolean getReadOnlyTransactionFlag() {
+ return readOnlyTransaction_;
+ }
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnection.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnection.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnection.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnection.java Sun May 1 23:25:59 2005
@@ -20,255 +20,242 @@
package org.apache.derby.client.net;
+import javax.transaction.xa.Xid;
+
import org.apache.derby.client.am.SqlException;
import org.apache.derby.client.am.Statement;
-import javax.transaction.xa.*;
-public class NetXAConnection extends org.apache.derby.client.net.NetConnection
-{
- //---------------------constructors/finalizer---------------------------------
- // For XA Connections
- public NetXAConnection (NetLogWriter netLogWriter,
- String user,
- String password,
- org.apache.derby.jdbc.ClientDataSource dataSource,
- int rmId,
- boolean isXAConn) throws SqlException
- {
- super (netLogWriter, user, password, dataSource, rmId, isXAConn);
- checkPlatformVersion();
- }
-
- protected void finalize () throws java.lang.Throwable
- {
- super.finalize();
- }
-
- public void setCorrelatorToken(byte[] crttoken)
- {
- crrtkn_ = crttoken;
- }
-
- public byte[] getCorrelatorToken()
- {
- return crrtkn_;
- }
-
- void setNetXAResource( NetXAResource xares )
- {
- xares_ = xares;
- }
-
- public void writeLocalXAStart_ () throws SqlException
- { netAgent_.netConnectionRequest_.writeLocalXAStart (this); }
- public void readLocalXAStart_ () throws SqlException
- { netAgent_.netConnectionReply_.readLocalXAStart (this); }
-
- public void writeLocalXACommit_ () throws SqlException
- { netAgent_.netConnectionRequest_.writeLocalXACommit (this); }
- public void readLocalXACommit_ () throws SqlException
- { netAgent_.netConnectionReply_.readLocalXACommit (this); }
-
- public void writeLocalXARollback_ () throws SqlException
- { netAgent_.netConnectionRequest_.writeLocalXARollback (this); }
- public void readLocalXARollback_ () throws SqlException
- { netAgent_.netConnectionReply_.readLocalXARollback (this); }
-
- public void writeTransactionStart(Statement statement) throws SqlException
- {
- //KATHEY remove below after checking that we don't need it.
- if( !isXAConnection_ )
- return; // not a XA connection
-
- // this is a XA connection
- int xaState = getXAState();
- xares_.exceptionsOnXA = null;
-
- if( xaState == XA_RECOVER )
- { // in recover, clean up and go to open-idle
- if (indoubtTransactions_ != null)
- {
- indoubtTransactions_.clear();
- indoubtTransactions_ = null;
- setXAState( XA_OPEN_IDLE );
- xaState = XA_OPEN_IDLE;
- }
- }
- // For derby we don't need to write transaction start for a local
- //transaction. If autocommit is off we are good to go.
- return;
- }
-
- public void setIndoubtTransactions(java.util.Hashtable indoubtTransactions)
- {
- if (indoubtTransactions_ != null)
- indoubtTransactions_.clear();
- indoubtTransactions_ = indoubtTransactions;
- }
-
- public byte[] getUOWID(Xid xid)
- {
- NetIndoubtTransaction indoubtTxn = (NetIndoubtTransaction) indoubtTransactions_.get(xid);
- if( indoubtTxn == null )
- return null;
- byte[] uowid = indoubtTxn.getUOWID();
- return uowid;
- }
-
-
- public int getPort(Xid xid)
- {
- NetIndoubtTransaction indoubtTxn = (NetIndoubtTransaction) indoubtTransactions_.get(xid);
- if( indoubtTxn == null )
- return -1;
- return indoubtTxn.getPort();
- }
-
- public void writeCommit () throws SqlException
- {
- // this logic must be in sync with willAutoCommitGenerateFlow() logic
- if (isXAConnection_)
- { // XA Connection
- int xaState = getXAState();
- if ((xaState == XA_OPEN_IDLE) ||
- (xaState == XA_LOCAL) ||
- (xaState == XA_LOCAL_START_SENT))
- {
- xares_.callInfoArray_[xares_.conn_.currXACallInfoOffset_].xid_ =
- xares_.nullXid;
- writeLocalXACommit_();
- }
- }
- else
- { // not XA connection
- writeLocalCommit_();
- }
- }
-
- public void readCommit () throws SqlException
- {
- if (isXAConnection_)
- { // XA Connection
- int xaState = getXAState();
- NetXACallInfo callInfo = xares_.callInfoArray_[currXACallInfoOffset_];
- callInfo.xaRetVal_ = NetXAResource.XARETVAL_XAOK; // initialize XARETVAL
- if ((xaState == XA_OPEN_IDLE) ||
- (xaState == XA_LOCAL) ||
- (xaState == XA_LOCAL_START_SENT))
- {
- readLocalXACommit_();
- setXAState( XA_OPEN_IDLE );
- }
- if( callInfo.xaRetVal_ != NetXAResource.XARETVAL_XAOK )
- { // xaRetVal has possible error, format it
- callInfo.xaFunction_ = NetXAResource.XAFUNC_COMMIT;
- xares_.xaRetValErrorAccumSQL( callInfo, 0 );
- callInfo.xaRetVal_ = NetXAResource.XARETVAL_XAOK; // re-initialize XARETVAL
- throw xares_.exceptionsOnXA;
- }
- }
- else
- // non-XA connections
- readLocalCommit_();
- }
-
- public void writeRollback () throws SqlException
- {
- if (isXAConnection_)
- {
- xares_.callInfoArray_[xares_.conn_.currXACallInfoOffset_].xid_ =
- xares_.nullXid;
- writeLocalXARollback_();
- }
- else
- writeLocalRollback_(); // non-XA
- }
-
- public void readRollback() throws SqlException
- {
- if (isXAConnection_)
- { // XA connections
- NetXACallInfo callInfo = xares_.callInfoArray_[currXACallInfoOffset_];
- callInfo.xaRetVal_ = NetXAResource.XARETVAL_XAOK; // initialize XARETVAL
- readLocalXARollback_();
-
- if( callInfo.xaRetVal_ != NetXAResource.XARETVAL_XAOK )
- { // xaRetVal has possible error, format it
- callInfo.xaFunction_ = NetXAResource.XAFUNC_ROLLBACK;
- xares_.xaRetValErrorAccumSQL( callInfo, 0 );
- callInfo.xaRetVal_ = NetXAResource.XARETVAL_XAOK; // re-initialize XARETVAL
- throw xares_.exceptionsOnXA;
- }
-
-
- // for all XA connectiions
- setXAState( XA_OPEN_IDLE );
- }
- else
- readLocalRollback_(); // non-XA connections
- }
-
- synchronized public void close () throws SqlException
- {
- // call super.close*() to do the close*
- super.close();
- if (open_) return; // still open, return
- if( xares_ != null )
- {
- xares_.removeXaresFromSameRMchain();
- }
- }
-
- synchronized public void closeX () throws SqlException
- {
- // call super.close*() to do the close*
- super.closeX();
- if (open_) return; // still open, return
- if( xares_ != null )
- {
- xares_.removeXaresFromSameRMchain();
- }
- }
-
- synchronized public void closeForReuse() throws SqlException
- {
- // call super.close*() to do the close*
- super.closeForReuse();
- if (open_) return; // still open, return
- if( xares_ != null )
- {
- xares_.removeXaresFromSameRMchain();
- }
- }
-
- synchronized public void closeResources () throws SqlException
- {
- // call super.close*() to do the close*
- super.closeResources();
- if (open_) return; // still open, return
- if( xares_ != null )
- {
- xares_.removeXaresFromSameRMchain();
- }
- }
-
- private void checkPlatformVersion() throws SqlException
- {
- int supportedVersion;
-
- supportedVersion = 8;
-
- if( xaHostVersion_ >= supportedVersion )
- { // supported version, return
- return;
- }
-
- // unsupported version for platform
- String platform = null;
- platform = "Linux, Unix, Windows";
- String versionMsg = "On " + platform + " XA supports version " +
- supportedVersion + " and above, this is version " +
- xaHostVersion_;
- throw new SqlException( agent_.logWriter_, versionMsg );
- }
+public class NetXAConnection extends org.apache.derby.client.net.NetConnection {
+ //---------------------constructors/finalizer---------------------------------
+ // For XA Connections
+ public NetXAConnection(NetLogWriter netLogWriter,
+ String user,
+ String password,
+ org.apache.derby.jdbc.ClientDataSource dataSource,
+ int rmId,
+ boolean isXAConn) throws SqlException {
+ super(netLogWriter, user, password, dataSource, rmId, isXAConn);
+ checkPlatformVersion();
+ }
+
+ protected void finalize() throws java.lang.Throwable {
+ super.finalize();
+ }
+
+ public void setCorrelatorToken(byte[] crttoken) {
+ crrtkn_ = crttoken;
+ }
+
+ public byte[] getCorrelatorToken() {
+ return crrtkn_;
+ }
+
+ void setNetXAResource(NetXAResource xares) {
+ xares_ = xares;
+ }
+
+ public void writeLocalXAStart_() throws SqlException {
+ netAgent_.netConnectionRequest_.writeLocalXAStart(this);
+ }
+
+ public void readLocalXAStart_() throws SqlException {
+ netAgent_.netConnectionReply_.readLocalXAStart(this);
+ }
+
+ public void writeLocalXACommit_() throws SqlException {
+ netAgent_.netConnectionRequest_.writeLocalXACommit(this);
+ }
+
+ public void readLocalXACommit_() throws SqlException {
+ netAgent_.netConnectionReply_.readLocalXACommit(this);
+ }
+
+ public void writeLocalXARollback_() throws SqlException {
+ netAgent_.netConnectionRequest_.writeLocalXARollback(this);
+ }
+
+ public void readLocalXARollback_() throws SqlException {
+ netAgent_.netConnectionReply_.readLocalXARollback(this);
+ }
+
+ public void writeTransactionStart(Statement statement) throws SqlException {
+ //KATHEY remove below after checking that we don't need it.
+ if (!isXAConnection_) {
+ return; // not a XA connection
+ }
+
+ // this is a XA connection
+ int xaState = getXAState();
+ xares_.exceptionsOnXA = null;
+
+ if (xaState == XA_RECOVER) { // in recover, clean up and go to open-idle
+ if (indoubtTransactions_ != null) {
+ indoubtTransactions_.clear();
+ indoubtTransactions_ = null;
+ setXAState(XA_OPEN_IDLE);
+ xaState = XA_OPEN_IDLE;
+ }
+ }
+ // For derby we don't need to write transaction start for a local
+ //transaction. If autocommit is off we are good to go.
+ return;
+ }
+
+ public void setIndoubtTransactions(java.util.Hashtable indoubtTransactions) {
+ if (indoubtTransactions_ != null) {
+ indoubtTransactions_.clear();
+ }
+ indoubtTransactions_ = indoubtTransactions;
+ }
+
+ public byte[] getUOWID(Xid xid) {
+ NetIndoubtTransaction indoubtTxn = (NetIndoubtTransaction) indoubtTransactions_.get(xid);
+ if (indoubtTxn == null) {
+ return null;
+ }
+ byte[] uowid = indoubtTxn.getUOWID();
+ return uowid;
+ }
+
+
+ public int getPort(Xid xid) {
+ NetIndoubtTransaction indoubtTxn = (NetIndoubtTransaction) indoubtTransactions_.get(xid);
+ if (indoubtTxn == null) {
+ return -1;
+ }
+ return indoubtTxn.getPort();
+ }
+
+ public void writeCommit() throws SqlException {
+ // this logic must be in sync with willAutoCommitGenerateFlow() logic
+ if (isXAConnection_) { // XA Connection
+ int xaState = getXAState();
+ if ((xaState == XA_OPEN_IDLE) ||
+ (xaState == XA_LOCAL) ||
+ (xaState == XA_LOCAL_START_SENT)) {
+ xares_.callInfoArray_[xares_.conn_.currXACallInfoOffset_].xid_ =
+ xares_.nullXid;
+ writeLocalXACommit_();
+ }
+ } else { // not XA connection
+ writeLocalCommit_();
+ }
+ }
+
+ public void readCommit() throws SqlException {
+ if (isXAConnection_) { // XA Connection
+ int xaState = getXAState();
+ NetXACallInfo callInfo = xares_.callInfoArray_[currXACallInfoOffset_];
+ callInfo.xaRetVal_ = NetXAResource.XARETVAL_XAOK; // initialize XARETVAL
+ if ((xaState == XA_OPEN_IDLE) ||
+ (xaState == XA_LOCAL) ||
+ (xaState == XA_LOCAL_START_SENT)) {
+ readLocalXACommit_();
+ setXAState(XA_OPEN_IDLE);
+ }
+ if (callInfo.xaRetVal_ != NetXAResource.XARETVAL_XAOK) { // xaRetVal has possible error, format it
+ callInfo.xaFunction_ = NetXAResource.XAFUNC_COMMIT;
+ xares_.xaRetValErrorAccumSQL(callInfo, 0);
+ callInfo.xaRetVal_ = NetXAResource.XARETVAL_XAOK; // re-initialize XARETVAL
+ throw xares_.exceptionsOnXA;
+ }
+ } else
+ // non-XA connections
+ {
+ readLocalCommit_();
+ }
+ }
+
+ public void writeRollback() throws SqlException {
+ if (isXAConnection_) {
+ xares_.callInfoArray_[xares_.conn_.currXACallInfoOffset_].xid_ =
+ xares_.nullXid;
+ writeLocalXARollback_();
+ } else {
+ writeLocalRollback_(); // non-XA
+ }
+ }
+
+ public void readRollback() throws SqlException {
+ if (isXAConnection_) { // XA connections
+ NetXACallInfo callInfo = xares_.callInfoArray_[currXACallInfoOffset_];
+ callInfo.xaRetVal_ = NetXAResource.XARETVAL_XAOK; // initialize XARETVAL
+ readLocalXARollback_();
+
+ if (callInfo.xaRetVal_ != NetXAResource.XARETVAL_XAOK) { // xaRetVal has possible error, format it
+ callInfo.xaFunction_ = NetXAResource.XAFUNC_ROLLBACK;
+ xares_.xaRetValErrorAccumSQL(callInfo, 0);
+ callInfo.xaRetVal_ = NetXAResource.XARETVAL_XAOK; // re-initialize XARETVAL
+ throw xares_.exceptionsOnXA;
+ }
+
+
+ // for all XA connectiions
+ setXAState(XA_OPEN_IDLE);
+ } else {
+ readLocalRollback_(); // non-XA connections
+ }
+ }
+
+ synchronized public void close() throws SqlException {
+ // call super.close*() to do the close*
+ super.close();
+ if (open_) {
+ return; // still open, return
+ }
+ if (xares_ != null) {
+ xares_.removeXaresFromSameRMchain();
+ }
+ }
+
+ synchronized public void closeX() throws SqlException {
+ // call super.close*() to do the close*
+ super.closeX();
+ if (open_) {
+ return; // still open, return
+ }
+ if (xares_ != null) {
+ xares_.removeXaresFromSameRMchain();
+ }
+ }
+
+ synchronized public void closeForReuse() throws SqlException {
+ // call super.close*() to do the close*
+ super.closeForReuse();
+ if (open_) {
+ return; // still open, return
+ }
+ if (xares_ != null) {
+ xares_.removeXaresFromSameRMchain();
+ }
+ }
+
+ synchronized public void closeResources() throws SqlException {
+ // call super.close*() to do the close*
+ super.closeResources();
+ if (open_) {
+ return; // still open, return
+ }
+ if (xares_ != null) {
+ xares_.removeXaresFromSameRMchain();
+ }
+ }
+
+ private void checkPlatformVersion() throws SqlException {
+ int supportedVersion;
+
+ supportedVersion = 8;
+
+ if (xaHostVersion_ >= supportedVersion) { // supported version, return
+ return;
+ }
+
+ // unsupported version for platform
+ String platform = null;
+ platform = "Linux, Unix, Windows";
+ String versionMsg = "On " + platform + " XA supports version " +
+ supportedVersion + " and above, this is version " +
+ xaHostVersion_;
+ throw new SqlException(agent_.logWriter_, versionMsg);
+ }
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java Sun May 1 23:25:59 2005
@@ -20,307 +20,286 @@
package org.apache.derby.client.net;
-import org.apache.derby.client.am.DisconnectException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
import org.apache.derby.client.am.ConnectionCallbackInterface;
-import javax.transaction.xa.*;
+import org.apache.derby.client.am.DisconnectException;
+
+public class NetXAConnectionReply extends NetResultSetReply {
+ NetXAConnectionReply(NetAgent netAgent, int bufferSize) {
+ super(netAgent, bufferSize);
+ }
+ //----------------------------- entry points ---------------------------------
+
+
+ public void readLocalXAStart(ConnectionCallbackInterface connection) throws DisconnectException {
+ }
+
+ public void readLocalXACommit(ConnectionCallbackInterface connection) throws DisconnectException {
+
+ startSameIdChainParse();
+ parseSYNCCTLreply(connection);
+ endOfSameIdChainData();
+
+ NetXACallInfo callInfo =
+ netAgent_.netConnection_.xares_.callInfoArray_[netAgent_.netConnection_.currXACallInfoOffset_];
+ callInfo.xaInProgress_ = false;
+ callInfo.xaWasSuspended = false;
+ connection.completeLocalCommit();
+ }
+
+ public void readLocalXARollback(ConnectionCallbackInterface connection) throws DisconnectException {
+ startSameIdChainParse();
+ parseSYNCCTLreply(connection);
+ endOfSameIdChainData();
+ connection.completeLocalRollback();
+ }
+
+ protected void readXaStartUnitOfWork(NetConnection conn) throws DisconnectException {
+ startSameIdChainParse();
+ parseSYNCCTLreply(conn);
+ endOfSameIdChainData();
+ }
+
+ protected int readXaEndUnitOfWork(NetConnection conn) throws DisconnectException {
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ int xaFlags = callInfo.xaFlags_;
+
+ startSameIdChainParse();
+ parseSYNCCTLreply(conn);
+ endOfSameIdChainData();
+ if (xaFlags == XAResource.TMFAIL) {
+ return javax.transaction.xa.XAException.XA_RBROLLBACK;
+ }
+ return javax.transaction.xa.XAResource.XA_OK;
+ }
+
+ protected int readXaPrepare(NetConnection conn) throws DisconnectException {
+ startSameIdChainParse();
+ int synctype = parseSYNCCTLreply(conn);
+ endOfSameIdChainData();
+
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ if (synctype == NetXAResource.XARETVAL_XARDONLY) { // xaretval of read-only, make sure flag agrees
+ callInfo.setReadOnlyTransactionFlag(true);
+ } else { // xaretval NOT read-only, make sure flag agrees
+ callInfo.setReadOnlyTransactionFlag(false);
+ }
+ return synctype;
+ }
+
+ protected void readXaCommit(NetConnection conn) throws DisconnectException {
+ startSameIdChainParse();
+ parseSYNCCTLreply(conn);
+ endOfSameIdChainData();
+
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ callInfo.xaInProgress_ = false;
+ conn.completeLocalCommit();
+ }
+
+ protected int readXaRollback(NetConnection conn) throws DisconnectException {
+ startSameIdChainParse();
+ parseSYNCCTLreply(conn);
+ endOfSameIdChainData();
+
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ callInfo.xaInProgress_ = false;
+ callInfo.xaWasSuspended = false;
+ conn.completeLocalRollback();
+
+ return javax.transaction.xa.XAResource.XA_OK;
+ }
+
+ protected void readXaRecover(NetConnection conn) throws DisconnectException {
+ startSameIdChainParse();
+ parseSYNCCTLreply(conn);
+ endOfSameIdChainData();
+ }
-public class NetXAConnectionReply extends NetResultSetReply
-{
- NetXAConnectionReply (NetAgent netAgent, int bufferSize)
- {
- super (netAgent, bufferSize);
- }
- //----------------------------- entry points ---------------------------------
-
-
- public void readLocalXAStart (ConnectionCallbackInterface connection) throws DisconnectException
- {
- }
-
- public void readLocalXACommit (ConnectionCallbackInterface connection) throws DisconnectException
- {
-
- startSameIdChainParse();
- parseSYNCCTLreply(connection);
- endOfSameIdChainData();
-
- NetXACallInfo callInfo =
- netAgent_.netConnection_.xares_.callInfoArray_[netAgent_.netConnection_.currXACallInfoOffset_];
- callInfo.xaInProgress_ = false;
- callInfo.xaWasSuspended = false;
- connection.completeLocalCommit();
- }
-
- public void readLocalXARollback (ConnectionCallbackInterface connection) throws DisconnectException
- {
- startSameIdChainParse();
- parseSYNCCTLreply(connection);
- endOfSameIdChainData();
- connection.completeLocalRollback();
- }
-
- protected void readXaStartUnitOfWork(NetConnection conn) throws DisconnectException
- {
- startSameIdChainParse();
- parseSYNCCTLreply(conn);
- endOfSameIdChainData();
- }
-
- protected int readXaEndUnitOfWork(NetConnection conn) throws DisconnectException
- {
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- int xaFlags = callInfo.xaFlags_;
-
- startSameIdChainParse();
- parseSYNCCTLreply(conn);
- endOfSameIdChainData();
- if (xaFlags == XAResource.TMFAIL)
- return javax.transaction.xa.XAException.XA_RBROLLBACK;
- return javax.transaction.xa.XAResource.XA_OK;
- }
-
- protected int readXaPrepare(NetConnection conn) throws DisconnectException
- {
- startSameIdChainParse();
- int synctype = parseSYNCCTLreply(conn);
- endOfSameIdChainData();
-
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- if( synctype == NetXAResource.XARETVAL_XARDONLY )
- { // xaretval of read-only, make sure flag agrees
- callInfo.setReadOnlyTransactionFlag( true );
- }
- else
- { // xaretval NOT read-only, make sure flag agrees
- callInfo.setReadOnlyTransactionFlag( false );
- }
- return synctype;
- }
-
- protected void readXaCommit(NetConnection conn) throws DisconnectException
- {
- startSameIdChainParse();
- parseSYNCCTLreply(conn);
- endOfSameIdChainData();
-
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- callInfo.xaInProgress_ = false;
- conn.completeLocalCommit();
- }
-
- protected int readXaRollback(NetConnection conn) throws DisconnectException
- {
- startSameIdChainParse();
- parseSYNCCTLreply(conn);
- endOfSameIdChainData();
-
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- callInfo.xaInProgress_ = false;
- callInfo.xaWasSuspended = false;
- conn.completeLocalRollback();
-
- return javax.transaction.xa.XAResource.XA_OK;
- }
-
- protected void readXaRecover(NetConnection conn) throws DisconnectException
- {
- startSameIdChainParse();
- parseSYNCCTLreply(conn);
- endOfSameIdChainData();
- }
-
- protected void readXaForget(NetConnection conn) throws DisconnectException
- {
- startSameIdChainParse();
- parseSYNCCTLreply(conn);
- endOfSameIdChainData();
- }
- //----------------------helper methods----------------------------------------
+ protected void readXaForget(NetConnection conn) throws DisconnectException {
+ startSameIdChainParse();
+ parseSYNCCTLreply(conn);
+ endOfSameIdChainData();
+ }
+ //----------------------helper methods----------------------------------------
- //--------------------- parse DDM Reply Data--------------------------------------
+ //--------------------- parse DDM Reply Data--------------------------------------
// The SYNCCRD Reply Mesage
- //
- // Returned from Server:
- // XARETVAL - required
- int parseSYNCCRD (ConnectionCallbackInterface connection) throws DisconnectException
- {
- boolean svrcodReceived = false;
- int svrcod = CodePoint.SVRCOD_INFO;
- int xaretval = 0;
- int synctype = 0;
- java.util.Hashtable indoubtTransactions = null;
- NetConnection conn = netAgent_.netConnection_;
-
- parseLengthAndMatchCodePoint (CodePoint.SYNCCRD);
- pushLengthOnCollectionStack();
- int peekCP = peekCodePoint();
-
- while (peekCP != Reply.END_OF_COLLECTION) {
-
- boolean foundInPass = false;
-
- if (peekCP == CodePoint.SVRCOD) {
- foundInPass = true;
- svrcodReceived = checkAndGetReceivedFlag (svrcodReceived);
- svrcod = parseSVRCOD (CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
- peekCP = peekCodePoint();
- }
+ //
+ // Returned from Server:
+ // XARETVAL - required
+ int parseSYNCCRD(ConnectionCallbackInterface connection) throws DisconnectException {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ int xaretval = 0;
+ int synctype = 0;
+ java.util.Hashtable indoubtTransactions = null;
+ NetConnection conn = netAgent_.netConnection_;
+
+ parseLengthAndMatchCodePoint(CodePoint.SYNCCRD);
+ pushLengthOnCollectionStack();
+ int peekCP = peekCodePoint();
+
+ while (peekCP != Reply.END_OF_COLLECTION) {
+
+ boolean foundInPass = false;
+
+ if (peekCP == CodePoint.SVRCOD) {
+ foundInPass = true;
+ svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
+ svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.XARETVAL) {
+ foundInPass = true;
+ xaretval = parseXARETVAL();
+ conn.xares_.callInfoArray_[conn.currXACallInfoOffset_].xaRetVal_ =
+ xaretval;
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.SYNCTYPE) {
+ foundInPass = true;
+ synctype = parseSYNCTYPE();
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.PRPHRCLST) {
+ foundInPass = true;
+ indoubtTransactions = parseIndoubtList();
+ conn.setIndoubtTransactions(indoubtTransactions);
+ peekCP = peekCodePoint();
+ }
+
+ if (!foundInPass) {
+ doPrmnsprmSemantics(peekCP);
+ }
+ }
+ popCollectionStack();
- if (peekCP == CodePoint.XARETVAL) {
- foundInPass = true;
- xaretval = parseXARETVAL();
- conn.xares_.callInfoArray_[conn.currXACallInfoOffset_].xaRetVal_ =
- xaretval;
- peekCP = peekCodePoint();
- }
- if (peekCP == CodePoint.SYNCTYPE) {
- foundInPass = true;
- synctype = parseSYNCTYPE();
- peekCP = peekCodePoint();
- }
+ return xaretval;
+
+ }
+
+ // Process XA return value
+ protected int parseXARETVAL() throws DisconnectException {
+ parseLengthAndMatchCodePoint(CodePoint.XARETVAL);
+ return readInt();
+ }
+
+ // Process XA return value
+ protected byte parseSYNCTYPE() throws DisconnectException {
+ parseLengthAndMatchCodePoint(CodePoint.SYNCTYPE);
+ return readByte();
+ }
+
+ // This method handles the parsing of all command replies and reply data
+ // for the SYNNCTL command.
+ protected int parseSYNCCTLreply(ConnectionCallbackInterface connection) throws DisconnectException {
+ int retval = 0;
+ int peekCP = peekCodePoint();
+
+ if (peekCP != CodePoint.SYNCCRD) {
+ parseSYNCCTLError(peekCP);
+ return -1;
+ }
+ retval = parseSYNCCRD(connection);
- if (peekCP == CodePoint.PRPHRCLST) {
- foundInPass = true;
- indoubtTransactions = parseIndoubtList();
- conn.setIndoubtTransactions(indoubtTransactions);
peekCP = peekCodePoint();
- }
+ while (peekCP == CodePoint.SQLSTT) {
+ String s = parseSQLSTT();
+ //JCFTMP, need to null out the client list?
+ netAgent_.netConnection_.xares_.addSpecialRegisters(s);
+ peekCP = peekCodePoint();
+ }
+
+ return retval;
+ }
- if (!foundInPass)
- doPrmnsprmSemantics (peekCP);
+
+ //------------------------parse DDM Scalars-----------------------------
+
+
+
+
+ private String parseSQLSTT() throws DisconnectException {
+ parseLengthAndMatchCodePoint(CodePoint.SQLSTT);
+ return parseSQLSTTGRPNOCMorNOCS();
+ }
+
+ private String parseSQLSTTGRPNOCMorNOCS() throws DisconnectException {
+ int mixedNullInd = readUnsignedByte();
+ int singleNullInd = 0;
+ String sqlsttString = null;
+ int stringLength = 0;
+
+ if (mixedNullInd == CodePoint.NULLDATA) {
+ singleNullInd = readUnsignedByte();
+ if (singleNullInd == CodePoint.NULLDATA) {
+ // throw DTAMCHRM
+ doDtamchrmSemantics();
+ }
+ // read 4-byte length
+ stringLength = readInt();
+ // read sqlstt string
+ sqlsttString = readString(stringLength, netAgent_.targetTypdef_.getCcsidSbcEncoding());
+ } else {
+ // read 4-byte length
+ stringLength = readInt();
+ // read sqlstt string
+ sqlsttString = readString(stringLength, netAgent_.targetTypdef_.getCcsidMbcEncoding());
+ // read null indicator
+ singleNullInd = readUnsignedByte();
+ }
+ return sqlsttString;
}
- popCollectionStack();
- return xaretval;
-
- }
-
- // Process XA return value
- protected int parseXARETVAL() throws DisconnectException
- {
- parseLengthAndMatchCodePoint (CodePoint.XARETVAL);
- return readInt();
- }
-
- // Process XA return value
- protected byte parseSYNCTYPE() throws DisconnectException
- {
- parseLengthAndMatchCodePoint (CodePoint.SYNCTYPE);
- return readByte();
- }
-
- // This method handles the parsing of all command replies and reply data
- // for the SYNNCTL command.
- protected int parseSYNCCTLreply (ConnectionCallbackInterface connection) throws DisconnectException
- {
- int retval = 0;
- int peekCP = peekCodePoint();
-
- if (peekCP != CodePoint.SYNCCRD) {
- parseSYNCCTLError (peekCP);
- return -1;
- }
- retval = parseSYNCCRD (connection);
-
- peekCP = peekCodePoint();
- while (peekCP == CodePoint.SQLSTT) {
- String s = parseSQLSTT ();
- //JCFTMP, need to null out the client list?
- netAgent_.netConnection_.xares_.addSpecialRegisters(s);
- peekCP = peekCodePoint();
- }
-
- return retval;
- }
-
-
- //------------------------parse DDM Scalars-----------------------------
-
-
-
-
- private String parseSQLSTT () throws DisconnectException {
- parseLengthAndMatchCodePoint (CodePoint.SQLSTT);
- return parseSQLSTTGRPNOCMorNOCS ();
- }
-
- private String parseSQLSTTGRPNOCMorNOCS () throws DisconnectException
- {
- int mixedNullInd = readUnsignedByte();
- int singleNullInd = 0;
- String sqlsttString = null;
- int stringLength = 0;
-
- if (mixedNullInd == CodePoint.NULLDATA) {
- singleNullInd = readUnsignedByte();
- if (singleNullInd == CodePoint.NULLDATA) {
- // throw DTAMCHRM
- doDtamchrmSemantics();
- }
- // read 4-byte length
- stringLength = readInt();
- // read sqlstt string
- sqlsttString = readString (stringLength, netAgent_.targetTypdef_.getCcsidSbcEncoding());
- }
- else {
- // read 4-byte length
- stringLength = readInt();
- // read sqlstt string
- sqlsttString = readString (stringLength, netAgent_.targetTypdef_.getCcsidMbcEncoding());
- // read null indicator
- singleNullInd = readUnsignedByte();
- }
- return sqlsttString;
- }
-
-
- protected int parseXIDCNT () throws DisconnectException
- {
- parseLengthAndMatchCodePoint (CodePoint.XIDCNT);
- return readUnsignedShort();
- }
-
- protected Xid parseXID () throws DisconnectException
- {
- parseLengthAndMatchCodePoint (CodePoint.XID);
- int formatId = readInt();
- int gtridLen = readInt();
- int bqualLen = readInt();
- byte[] gtrid = readBytes(gtridLen);
- byte[] bqual = readBytes(bqualLen);
-
- return new org.apache.derby.client.ClientXid(formatId, gtrid, bqual);
- }
-
- protected java.util.Hashtable parseIndoubtList() throws DisconnectException
- {
- boolean found = false;
- int port = 0;
- int numXid = 0;
- String sIpAddr = null;
- int peekCP = peekCodePoint();
- parseLengthAndMatchCodePoint (CodePoint.PRPHRCLST);
- peekCP = peekCodePoint();
- if (peekCP == CodePoint.XIDCNT) {
- found = true;
- numXid = parseXIDCNT();
- peekCP = peekCodePoint();
- }
-
- java.util.Hashtable indoubtTransactions = new java.util.Hashtable();
- while( peekCP == CodePoint.XID )
- {
- Xid xid = parseXID();
- indoubtTransactions.put(xid, new NetIndoubtTransaction(xid, null, null, null, sIpAddr, port));
- peekCP = peekCodePoint();
+ protected int parseXIDCNT() throws DisconnectException {
+ parseLengthAndMatchCodePoint(CodePoint.XIDCNT);
+ return readUnsignedShort();
}
- return indoubtTransactions;
- }
+ protected Xid parseXID() throws DisconnectException {
+ parseLengthAndMatchCodePoint(CodePoint.XID);
+ int formatId = readInt();
+ int gtridLen = readInt();
+ int bqualLen = readInt();
+ byte[] gtrid = readBytes(gtridLen);
+ byte[] bqual = readBytes(bqualLen);
+
+ return new org.apache.derby.client.ClientXid(formatId, gtrid, bqual);
+ }
+
+ protected java.util.Hashtable parseIndoubtList() throws DisconnectException {
+ boolean found = false;
+ int port = 0;
+ int numXid = 0;
+ String sIpAddr = null;
+ int peekCP = peekCodePoint();
+ parseLengthAndMatchCodePoint(CodePoint.PRPHRCLST);
+ peekCP = peekCodePoint();
+ if (peekCP == CodePoint.XIDCNT) {
+ found = true;
+ numXid = parseXIDCNT();
+ peekCP = peekCodePoint();
+ }
+
+ java.util.Hashtable indoubtTransactions = new java.util.Hashtable();
+ while (peekCP == CodePoint.XID) {
+ Xid xid = parseXID();
+ indoubtTransactions.put(xid, new NetIndoubtTransaction(xid, null, null, null, sIpAddr, port));
+ peekCP = peekCodePoint();
+ }
+
+ return indoubtTransactions;
+ }
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java Sun May 1 23:25:59 2005
@@ -20,297 +20,290 @@
package org.apache.derby.client.net;
-import org.apache.derby.client.am.SqlException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
-public class NetXAConnectionRequest extends NetResultSetRequest
-{
- NetXAConnectionRequest (NetAgent netAgent, CcsidManager ccsidManager, int bufferSize)
- {
- super (netAgent, ccsidManager, bufferSize);
- }
+import org.apache.derby.client.am.SqlException;
+
+public class NetXAConnectionRequest extends NetResultSetRequest {
+ NetXAConnectionRequest(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize) {
+ super(netAgent, ccsidManager, bufferSize);
+ }
- //----------------------------- entry points ---------------------------------
+ //----------------------------- entry points ---------------------------------
- //Build the SYNNCTL commit command
- public void writeLocalXACommit (NetConnection conn) throws SqlException
- {
- NetXACallInfo callInfo =
- conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- Xid xid = callInfo.xid_;
- buildSYNCCTLMigrate(); // xa migrate to resync server
- buildSYNCCTLCommit(CodePoint.TMLOCAL, xid); // xa local commit
- }
+ //Build the SYNNCTL commit command
+ public void writeLocalXACommit(NetConnection conn) throws SqlException {
+ NetXACallInfo callInfo =
+ conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ Xid xid = callInfo.xid_;
+ buildSYNCCTLMigrate(); // xa migrate to resync server
+ buildSYNCCTLCommit(CodePoint.TMLOCAL, xid); // xa local commit
+ }
- //Build the SYNNCTL rollback command
- public void writeLocalXARollback (NetConnection conn) throws SqlException
- {
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- buildSYNCCTLRollback(CodePoint.TMLOCAL); // xa local rollback
- }
+ //Build the SYNNCTL rollback command
+ public void writeLocalXARollback(NetConnection conn) throws SqlException {
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ buildSYNCCTLRollback(CodePoint.TMLOCAL); // xa local rollback
+ }
- public void writeXaStartUnitOfWork(NetConnection conn) throws SqlException
- {
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- Xid xid = callInfo.xid_;
- int xaFlags = callInfo.xaFlags_;
+ public void writeXaStartUnitOfWork(NetConnection conn) throws SqlException {
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ Xid xid = callInfo.xid_;
+ int xaFlags = callInfo.xaFlags_;
- // create DSS command with reply.
- createCommand ();
+ // create DSS command with reply.
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_NEW_UOW);
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_NEW_UOW);
- if (xid.getFormatId() != -1)
- writeXID(CodePoint.XID, xid);
- else
- // write the null XID for local transaction on XA connection
- writeNullXID(CodePoint.XID);
+ if (xid.getFormatId() != -1) {
+ writeXID(CodePoint.XID, xid);
+ } else
+ // write the null XID for local transaction on XA connection
+ {
+ writeNullXID(CodePoint.XID);
+ }
- writeXAFlags(CodePoint.XAFLAGS, xaFlags);
- updateLengthBytes();
- }
+ writeXAFlags(CodePoint.XAFLAGS, xaFlags);
+ updateLengthBytes();
+ }
- public void writeXaEndUnitOfWork(NetConnection conn) throws SqlException
- {
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- Xid xid = callInfo.xid_;
- int xaFlags = callInfo.xaFlags_;
+ public void writeXaEndUnitOfWork(NetConnection conn) throws SqlException {
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ Xid xid = callInfo.xid_;
+ int xaFlags = callInfo.xaFlags_;
- createCommand ();
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_END_UOW);
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_END_UOW);
- if (xid.getFormatId() != -1)
- writeXID(CodePoint.XID, xid);
- else
- // write the null XID for local transaction on XA connection
- writeNullXID(CodePoint.XID);
+ if (xid.getFormatId() != -1) {
+ writeXID(CodePoint.XID, xid);
+ } else
+ // write the null XID for local transaction on XA connection
+ {
+ writeNullXID(CodePoint.XID);
+ }
- writeXAFlags(CodePoint.XAFLAGS, xaFlags);
+ writeXAFlags(CodePoint.XAFLAGS, xaFlags);
- updateLengthBytes();
- }
+ updateLengthBytes();
+ }
- protected void writeXaPrepare(NetConnection conn) throws SqlException
- {
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- Xid xid = callInfo.xid_;
- // don't forget that xars.prepare() does not have flags, assume TMNOFLAGS
- int xaFlags = XAResource.TMNOFLAGS;
+ protected void writeXaPrepare(NetConnection conn) throws SqlException {
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ Xid xid = callInfo.xid_;
+ // don't forget that xars.prepare() does not have flags, assume TMNOFLAGS
+ int xaFlags = XAResource.TMNOFLAGS;
- createCommand ();
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_PREPARE);
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_PREPARE);
- if (xid.getFormatId() != -1)
- writeXID(CodePoint.XID, xid);
- else
- // write the null XID for local transaction on XA connection
- writeNullXID(CodePoint.XID);
+ if (xid.getFormatId() != -1) {
+ writeXID(CodePoint.XID, xid);
+ } else
+ // write the null XID for local transaction on XA connection
+ {
+ writeNullXID(CodePoint.XID);
+ }
- writeXAFlags(CodePoint.XAFLAGS, xaFlags);
- updateLengthBytes();
- }
+ writeXAFlags(CodePoint.XAFLAGS, xaFlags);
+ updateLengthBytes();
+ }
- protected void writeXaCommit(NetConnection conn, Xid xid) throws SqlException
- {
- NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
- int xaFlags = callInfo.xaFlags_;
+ protected void writeXaCommit(NetConnection conn, Xid xid) throws SqlException {
+ NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
+ int xaFlags = callInfo.xaFlags_;
- // create DSS command with no reply.
- createCommand ();
+ // create DSS command with no reply.
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_COMMITTED);
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_COMMITTED);
- if (xid.getFormatId() != -1)
- writeXID(CodePoint.XID, xid);
- else
- // write the null XID for local transaction on XA connection
- writeNullXID(CodePoint.XID);
+ if (xid.getFormatId() != -1) {
+ writeXID(CodePoint.XID, xid);
+ } else
+ // write the null XID for local transaction on XA connection
+ {
+ writeNullXID(CodePoint.XID);
+ }
- writeXAFlags(CodePoint.XAFLAGS, xaFlags);
- updateLengthBytes();
- }
+ writeXAFlags(CodePoint.XAFLAGS, xaFlags);
+ updateLengthBytes();
+ }
- protected void writeXaRollback(NetConnection conn, Xid xid) throws SqlException
- {
- int xaFlags = XAResource.TMNOFLAGS;
+ protected void writeXaRollback(NetConnection conn, Xid xid) throws SqlException {
+ int xaFlags = XAResource.TMNOFLAGS;
- // create DSS command with no reply.
- createCommand ();
+ // create DSS command with no reply.
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_ROLLBACK);
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_ROLLBACK);
- if (xid.getFormatId() != -1)
- writeXID(CodePoint.XID, xid);
- else
- // write the null XID for local transaction on XA connection
- writeNullXID(CodePoint.XID);
+ if (xid.getFormatId() != -1) {
+ writeXID(CodePoint.XID, xid);
+ } else
+ // write the null XID for local transaction on XA connection
+ {
+ writeNullXID(CodePoint.XID);
+ }
- writeXAFlags(CodePoint.XAFLAGS, xaFlags);
- updateLengthBytes();
- }
+ writeXAFlags(CodePoint.XAFLAGS, xaFlags);
+ updateLengthBytes();
+ }
- protected void writeXaRecover(NetConnection conn, int flag) throws SqlException
- {
- // create DSS command with no reply.
- createCommand ();
+ protected void writeXaRecover(NetConnection conn, int flag) throws SqlException {
+ // create DSS command with no reply.
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_INDOUBT);
- writeXAFlags(CodePoint.XAFLAGS, flag);
- updateLengthBytes();
- }
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_INDOUBT);
+ writeXAFlags(CodePoint.XAFLAGS, flag);
+ updateLengthBytes();
+ }
- protected void writeXaForget(NetConnection conn, Xid xid) throws SqlException
- {
+ protected void writeXaForget(NetConnection conn, Xid xid) throws SqlException {
- // create DSS command with no reply.
- createCommand ();
+ // create DSS command with no reply.
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_REQ_FORGET);
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_REQ_FORGET);
- writeXID(CodePoint.XID, xid);
+ writeXID(CodePoint.XID, xid);
- updateLengthBytes();
- }
+ updateLengthBytes();
+ }
- public void writeSYNCType(int codepoint, int syncType)
- {
- writeScalar1Byte (codepoint, syncType);
- }
+ public void writeSYNCType(int codepoint, int syncType) {
+ writeScalar1Byte(codepoint, syncType);
+ }
- public void writeForget(int codepoint, int value)
- {
- writeScalar1Byte (codepoint, value);
- }
+ public void writeForget(int codepoint, int value) {
+ writeScalar1Byte(codepoint, value);
+ }
- public void writeReleaseConversation(int codepoint, int value)
- {
- writeScalar1Byte (codepoint, value);
- }
+ public void writeReleaseConversation(int codepoint, int value) {
+ writeScalar1Byte(codepoint, value);
+ }
- void writeNullXID(int codepoint)
- {
- int nullXID = -1;
- writeScalar4Bytes (codepoint, nullXID);
- }
+ void writeNullXID(int codepoint) {
+ int nullXID = -1;
+ writeScalar4Bytes(codepoint, nullXID);
+ }
- void writeXID(int codepoint, Xid xid) throws SqlException
- {
- int len = 0;
- int formatId = xid.getFormatId();
- byte[] gtrid = xid.getGlobalTransactionId();
- byte[] bqual = xid.getBranchQualifier();
+ void writeXID(int codepoint, Xid xid) throws SqlException {
+ int len = 0;
+ int formatId = xid.getFormatId();
+ byte[] gtrid = xid.getGlobalTransactionId();
+ byte[] bqual = xid.getBranchQualifier();
- markLengthBytes(codepoint);
+ markLengthBytes(codepoint);
- len = 4; // length of formatId
- len += (bqual.length + 4); // bqual length
- len += (gtrid.length + 4); // gtrid length
+ len = 4; // length of formatId
+ len += (bqual.length + 4); // bqual length
+ len += (gtrid.length + 4); // gtrid length
- write4Bytes(formatId);
- write4Bytes(gtrid.length);
- write4Bytes(bqual.length);
+ write4Bytes(formatId);
+ write4Bytes(gtrid.length);
+ write4Bytes(bqual.length);
- // Mare sure request buffer has enough space to write this byte array.
- ensureLength (offset_ + gtrid.length);
- System.arraycopy(gtrid, 0, bytes_, offset_, gtrid.length);
- offset_ += gtrid.length;
+ // Mare sure request buffer has enough space to write this byte array.
+ ensureLength(offset_ + gtrid.length);
+ System.arraycopy(gtrid, 0, bytes_, offset_, gtrid.length);
+ offset_ += gtrid.length;
- ensureLength (offset_ + bqual.length);
- System.arraycopy(bqual, 0, bytes_, offset_, bqual.length);
- offset_ += bqual.length;
+ ensureLength(offset_ + bqual.length);
+ System.arraycopy(bqual, 0, bytes_, offset_, bqual.length);
+ offset_ += bqual.length;
- updateLengthBytes();
+ updateLengthBytes();
- }
+ }
- void writeXAFlags(int codepoint, int xaFlags)
- {
- writeScalar4Bytes (codepoint, xaFlags);
- }
+ void writeXAFlags(int codepoint, int xaFlags) {
+ writeScalar4Bytes(codepoint, xaFlags);
+ }
- //----------------------helper methods----------------------------------------
- // These methods are "private protected", which is not a recognized java privilege,
- // but means that these methods are private to this class and to subclasses,
- // and should not be used as package-wide friendly methods.
+ //----------------------helper methods----------------------------------------
+ // These methods are "private protected", which is not a recognized java privilege,
+ // but means that these methods are private to this class and to subclasses,
+ // and should not be used as package-wide friendly methods.
- void buildSYNCCTLMigrate() throws SqlException
- {
- }
+ void buildSYNCCTLMigrate() throws SqlException {
+ }
- void buildSYNCCTLCommit (int xaFlags, Xid xid) throws SqlException
- {
- createCommand ();
+ void buildSYNCCTLCommit(int xaFlags, Xid xid) throws SqlException {
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_COMMITTED);
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_COMMITTED);
- if (xid.getFormatId() != -1)
- writeXID(CodePoint.XID, xid);
- else
- // write the null XID for local transaction on XA connection
- writeNullXID(CodePoint.XID);
+ if (xid.getFormatId() != -1) {
+ writeXID(CodePoint.XID, xid);
+ } else
+ // write the null XID for local transaction on XA connection
+ {
+ writeNullXID(CodePoint.XID);
+ }
- writeXAFlags(CodePoint.XAFLAGS, xaFlags);
+ writeXAFlags(CodePoint.XAFLAGS, xaFlags);
- updateLengthBytes();
- }
+ updateLengthBytes();
+ }
- void buildSYNCCTLRollback (int xaFlags) throws SqlException
- {
- createCommand ();
+ void buildSYNCCTLRollback(int xaFlags) throws SqlException {
+ createCommand();
- // save the length bytes for later update
- markLengthBytes (CodePoint.SYNCCTL);
+ // save the length bytes for later update
+ markLengthBytes(CodePoint.SYNCCTL);
- // SYNCTYPE
- writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_ROLLBACK);
+ // SYNCTYPE
+ writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_ROLLBACK);
- // write the null XID for local transaction on XA connection
- writeNullXID(CodePoint.XID);
- writeXAFlags(CodePoint.XAFLAGS, xaFlags);
- updateLengthBytes();
- }
+ // write the null XID for local transaction on XA connection
+ writeNullXID(CodePoint.XID);
+ writeXAFlags(CodePoint.XAFLAGS, xaFlags);
+ updateLengthBytes();
+ }
}