finds the transactional branch of the current XAResource associated with
die XID
Close this XA XAResourceProgressState. All depending Connection are
closed
557242
public void close() {

        if (this.xaConnection != null) {
            this.xaConnection.doClose();
        }
        this.closed = true;
        this.notifyClosed();

        if (LOG.isDebugEnabled()) {
            LOG.debug("PhynixxXAResource[" + this.getId() + "]:closed ");
        }
    }
430901
protected XATransactionWrapper getXATransactionWrapper() throws ResourceException {

        final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled();

        if (isTracingEnabled && tc.isEntryEnabled()) {
            Tr.entry(this, tc, "getXATransactionWrapper");
        }

        if (xaTranWrapper == null) {
            boolean isJDBC41 = false;
            if (mc instanceof WSManagedConnection) {
                if (_managedConnectionFactory instanceof WSManagedConnectionFactory
                    && (((WSManagedConnectionFactory) _managedConnectionFactory).getJDBCRuntimeVersion().compareTo(new Version(4, 1, 0))) >= 0) {
                    isJDBC41 = true;
                }
            }
            if (isJDBC41) {
                xaTranWrapper = new AbortableXATransactionWrapper(this);
            } else {
                xaTranWrapper = new XATransactionWrapper(this);
            }
        }

        // Move the xaTranWrapper.initialize() call outside of the above "xaTranWrapper == null"
        // conditional.  Prior to this change, the xaResource within the xaTranWrapper was not
        // getting re-initialized for MCWrappers that were pulled from the MCWrapperPool.  This
        // call to initialize() for existing xaTranWrappers is safe and quick since we check
        // for an existing xaResource as the first thing in initialize().
        //
        xaTranWrapper.initialize();

        if (state == STATE_ACTIVE_INUSE) {
            state = STATE_TRAN_WRAPPER_INUSE;
            tranWrapperInUse = XATXWRAPPER;
        } else { // state not STATE_ACTIVE_INUSE
            if (state != STATE_TRAN_WRAPPER_INUSE) {
                IllegalStateException e = new IllegalStateException("getXATransactionWrapper: illegal state exception. State = " + getStateString() + " MCW = "
                                                                    + mcWrapperObject_hexString);
                Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", "getXATransactionWrapper", e);
                throw e;
            } else { // state is STATE_TRAN_WRAPPER_INUSE
                if (tranWrapperInUse == NONE) {
                    tranWrapperInUse = XATXWRAPPER;
                } else { //tranWrapperInUse is NOT NONE
                    if (tranWrapperInUse != XATXWRAPPER) {
                        // Need RAS and Trace here.
                        IllegalStateException e = new IllegalStateException("getXATransactionWrapper: illegal transaction state exception. State = "
                                                                            + getTranWrapperString());
                        Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", "getXATransactionWrapper", e);
                        throw e;
                    }
                }
            }
        }

        if (isTracingEnabled && tc.isEntryEnabled()) {
            Tr.exit(this, tc, "getXATransactionWrapper");
        }

        return xaTranWrapper;
    }
70770
public int rollback() {
      //log rolling back
      loggingDecision(false);

      //perform rollback
      try {
         tx.rollback();
      } catch (SystemException e) {
         //ignore exception (heuristic exceptions)
         //TODO logging
      } finally {
         perCacheTxTable.removeLocalTx(xid);
      }

      //log rolled back
      loggingCompleted(false);
      return XAException.XA_RBROLLBACK;
   }
994682
@Override
  public Connection getConnection() throws SQLException {
    Connection conn = super.getConnection();

    // When we're outside an XA transaction, autocommit
    // is supposed to be true, per usual JDBC convention.
    // When an XA transaction is in progress, it should be
    // false.
    if (state == State.IDLE) {
      conn.setAutoCommit(true);
    }

    /*
     * Wrap the connection in a proxy to forbid application from fiddling with transaction state
     * directly during an XA transaction
     */
    ConnectionHandler handler = new ConnectionHandler(conn);
    return (Connection) Proxy.newProxyInstance(getClass().getClassLoader(),
        new Class[]{Connection.class, PGConnection.class}, handler);
  }
631397
public final void rollback() throws XAException
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "rollback", _resource);
        if (tcSummary.isDebugEnabled()) Tr.debug(tcSummary, "rollback", this);

        try
        {
            _resource.rollback(_xid);

			// Record the vote.
			// _completedCommit defaults to false.
			_vote = JTAResourceVote.rollback;
        }
        catch(XAException xae)
        {
			// Record the completion XA return code
			_completionXARC = xae.errorCode;

			throw xae;
        }
        finally
        {
            if (tc.isEntryEnabled()) Tr.exit(tc, "rollback");
            if (tcSummary.isDebugEnabled()) Tr.debug(tcSummary, "rollback result: " + 
                                                                XAReturnCodeHelper.convertXACode(_completionXARC));
        }
    }
1177154
def close(self):
        
        from neobolt.exceptions import ConnectionExpired, CypherError, ServiceUnavailable
        try:
            if self.has_transaction():
                try:
                    self.rollback_transaction()
                except (CypherError, TransactionError, SessionError, ConnectionExpired, ServiceUnavailable):
                    pass
        finally:
            self._closed = True
        self._disconnect(sync=True)
296270
public void connectionClosed(Object linkLevelAttachement)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "connectionClosed", linkLevelAttachement);

      try
      {
         // Get hold of MFP and inform it of connection closure
         CompHandshake ch = (CompHandshake) CompHandshakeFactory.getInstance();
         ch.compClose(this);
      }
      catch (Exception e1)
      {
         // No FFDC code needed
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "MFP unable to create CompHandshake Singleton", e1);
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "connectionClosed");
   }
778713
public int getTransactionTimeout() throws XAException {

        final String methodName = "getTransactionTimeout";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        final int timeout = _siXaResource.getTransactionTimeout();

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName, timeout);
        }
        return timeout;

    }
995848
public final void commit_one_phase() throws XAException
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "commit_one_phase", _resource);
        if (tcSummary.isDebugEnabled()) Tr.debug(tcSummary, "commit_one_phase", this);

        //
        // Commit the one-phase resource.
        //
        try
        {
            _resource.commit(_xid, true);

			// Record the completion direction and Automatic vote.
			_completedCommit = true;
			_vote = JTAResourceVote.commit;
        }
        catch(XAException xae)
        {
			// Record the completion XA return code
			_completionXARC = xae.errorCode;

			throw xae;
        }
        finally
        {
            if (tc.isEntryEnabled()) Tr.exit(tc, "commit_one_phase", _completionXARC);
            if (tcSummary.isDebugEnabled()) Tr.debug(tcSummary, "commit_one_phase result: " + 
                                                                XAReturnCodeHelper.convertXACode(_completionXARC));
        }
    }
662366
function _close()
	{
		if ($this->transCnt) $this->RollbackTrans();
		$rez = @sqlsrv_close($this->_connectionID);
		$this->_connectionID = false;
		return $rez;
	}
1241114
boolean _close()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "_close");

    boolean closedNow = false;

    synchronized (this)
    {
      if (!_closed)
      {
        _closed = true;
        closedNow = true;
      }
    }

    if (closedNow)
    {
      /*
       * This must be done outside the synchronization as it will synchronize on
       * the set of producer sessions whilst detaching this producer and if not
       * done outside, this could cause a deadlock with methods that synchronize
       * on the set and then each producersession in the set in turn.
       */
      _inputHandler.detachProducer(this);
      _inputHandler = null;
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "_close", new Boolean(closedNow));

    return closedNow;
  }
193086
function Close()
    {
        if ($this->connected)
        {
            if ($this->inTransaction)
                $this->Commit();

            $this->db->close();
            /* $this->AssertSuccess(); */
            $this->connected = false;
        }
    }
868893
void rollbackResources()
    {
        final boolean traceOn = TraceComponent.isAnyTracingEnabled();

        if (traceOn && tc.isEntryEnabled())
            Tr.entry(tc, "rollbackResources", this);

        distributeEnd(XAResource.TMFAIL);
        _outcome = false;
        _retryRequired = distributeOutcome();

        if (traceOn && tc.isEntryEnabled())
            Tr.exit(tc, "rollbackResources", _retryRequired);
    }
421388
@Override
    public void afterCompletion(int status) {

        if (tc.isEntryEnabled()) {
            Tr.entry(this, tc, "afterCompletion");
        }

        if (tc.isDebugEnabled()) {
            Tr.debug(
                     tc,
                     "Using transaction wrapper@" + Integer.toHexString(this.hashCode()));
        }

        if (mcWrapper.isMCAborted()) {
            Tr.exit(tc, "Connection was aborted. Exiting afterCompletion.");
            return;
        }

        // When afterCompletionCode is called we need to reset the registeredForSync flag.
        registeredForSync = false;
        this.hasRollbackOccured = false;
        /*
         * Mark the transaction complete in the wrapper
         */
        // Do NOT catch runtime exections here.  Let them flow out of the component.
        mcWrapper.transactionComplete();

        if (tc.isDebugEnabled()) {
            if (mcWrapper.getHandleCount() != 0) {
                // Issue warning that Connections have not been closed by the end of the current UOW
                //  scope and will be closed by the CM.
                //            Tr.warning(this, tc,"HANDLE_NOT_CLOSED_J2CA0055");
                Tr.debug(this, tc, "Information:  handle not closed at end of UOW. Connection from pool " + mcWrapper.gConfigProps.getXpathId());
            }
        }

        // Do NOT catch the runtime exception which getConnectionManager might throw.
        // If this is thrown it is an internal bug and needs to be fixed.
        // Allow the rte to flow up to the container.
        boolean shareable = mcWrapper.getConnectionManager().shareable();

        //  - Simplified the following if/else construct taking advantage of the
        //             new releaseToPoolManger call on mcWrapper.
        //
        // If the connection is shareable, or it is non-shareable and the handleCount is
        // zero, then release it back to the poolManger, otherwise simply reset the
        // transaction related variables.
        //
        // Note: shareable connections are released at the end of transactions regardless of
        //  outstanding handles because we don't supports handled being associated to an active
        //  managedConnection outside of a sharing boundary.
        //
        //  if the MCWrapper is stale we will release the connection to the pool.
        //
        if ((shareable) || (!shareable && mcWrapper.getHandleCount() == 0) || mcWrapper.isStale()) {

            if (tc.isDebugEnabled()) {
                Tr.debug(this, tc,
                         "Releasing the connection to the pool. shareable = " + shareable + "  handleCount = " + mcWrapper.getHandleCount() + "  isStale = " + mcWrapper.isStale());
            }

            try {
                mcWrapper.releaseToPoolManager();
            } catch (Exception e) {
                // No need to rethrow this exception since nothing can be done about it,
                //  and the application has successfully finished its use of the connection.
                com.ibm.ws.ffdc.FFDCFilter.processException(
                                                            e,
                                                            "com.ibm.ejs.j2c.LocalTransactionWrapper.afterCompletion",
                                                            "711",
                                                            this);
                if (tc.isDebugEnabled()) {
                    Tr.debug(this, tc, "afterCompletionCode for datasource " + mcWrapper.gConfigProps.cfName + ":  caught Exception", e);
                }
            }

        } // end ((shareable) || (!shareable && mcWrapper.getHandleCount() == 0))
        else {
            /*
             * The cleanup of the coordinator enlisted flag should only be done for non sharable connections, in
             * other cases, the coord is set to null in mcWrapper.releaseToPoolManager(). We only need to worry about this
             * if the handleCount is greater than 0 (in which case the cleanup will be done by the poolManager). Same
             * thing for the tranFailed flag in the MCWrapper.
             */
            mcWrapper.setUOWCoordinator(null);
            // Reset the serialReuseCount since it is only valid for the duration of
            // the LTC. Note that the release path above will also reset it via mcWrapper.cleanup().
            enlisted = false;
        }

        if (tc.isEntryEnabled()) {
            Tr.exit(this, tc, "afterCompletion");
        }
    }
1288938
@Override
    public void rollback(Xid xid) throws XAException {

        if (tc.isEntryEnabled()) {
            Tr.entry(this, tc, "rollback");
        }

        /*
         *
         * if (this.xid != null && !xid.equals(this.xid)) {
         * final XAException e = new XAException(XAException.XAER_NOTA);
         * // What does this error really mean. Need to resolve
         * if (tc.isEventEnabled())
         * Tr.event(this, tc, "Error: Connection is already involved in different transaction.", e);
         * throw e;
         * }
         */
		 
        if (getMcWrapper().isMCAborted()) {
            Tr.exit(tc, "Connection was aborted. Exiting rollback.");
            return;
        }

        this.hasRollbackOccured = true;
        boolean exceptionCaught = false;
        try {
            localTransaction.rollback();
        } catch (Exception e) {
            if (!mcWrapper.isMCAborted())
                com.ibm.ws.ffdc.FFDCFilter.processException(e, getClass().getName(), "198", this);
            if (!mcWrapper.shouldBeDestroyed()) {
                mcWrapper.markTransactionError(); // Can't trust the connection since we don't know why it failed.
                Tr.error(tc, "XA_END_EXCP_J2CA0024", "rollback", xid, e, "XAException", mcWrapper.gConfigProps.getXpathId());
            }
            exceptionCaught = true;
            XAException xae = new XAException(XAException.XAER_RMFAIL);
            xae.initCause(e);
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "rollback", e);
            throw xae;
        } finally {
            //this.xid = null;
            try {
                if (registeredForSync == false) {
                    // Since we didn't register for synchronization for unshared/LTC/res-control=Application.
                    //  Instead of cleanup being done via after completion it will either happen at close or
                    //  commit/rollback which ever happens last.  This will allow the connection to be returned
                    //  to the pool prior to the end of the LTC scope allowing better utilization of the connection.
                    if (tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "rollback: calling afterCompletionCode() for cleanup");
                    }
                    afterCompletion(0);
                }
            } catch (Exception e) {
                if (tc.isDebugEnabled()) {
                    Tr.debug(this, tc, "rollback: caught exception in finally block: ", e);
                }
                if (exceptionCaught == false) {
                    XAException xae = new XAException(XAException.XAER_RMFAIL);
                    xae.initCause(e);
                    throw xae;
                }
            }
        } // end rollback
        if (tc.isEntryEnabled())
            Tr.exit(this, tc, "rollback");
    }
851380
@Override
    @FFDCIgnore(NoSuchMethodException.class)
    public XAResource getXAResource(Serializable xaresinfo) throws XAResourceNotAvailableException {
        XAResource xa = null;
        if (xaresinfo != null) {
            @SuppressWarnings("unchecked")
            ArrayList<Byte> byteList = (ArrayList<Byte>) xaresinfo;
            byte[] bytes = new byte[byteList.size()];
            int i = 0;
            for (Byte b : byteList)
                bytes[i++] = b;
            try {
                ActivationConfig config = (ActivationConfig) Utils.deserialize(bytes);
                Object activationSpec = createActivationSpec(config.getActivationConfigProps(),
                                                             config.getAuthenticationAlias(),
                                                             null,
                                                             config.getDestinationRef(),
                                                             null,
                                                             config.getApplicationName());
                if (qmidenabled) {
                    Class<? extends Object> mcImplClass = activationSpec.getClass();
                    try {
                        String qmid = config.getQmid();
                        Method m = mcImplClass.getMethod("setQmid", new Class[] { String.class });
                        m.invoke(activationSpec, qmid);
                    } catch (NoSuchMethodException nsme) {
                        qmidenabled = false;
                    } catch (InvocationTargetException ite) {
                        qmidenabled = false;
                    }
                }
                BootstrapContextImpl bootstrapContext = bootstrapContextRef.getServiceWithException();
                ActivationSpec[] actspecs = new ActivationSpec[] { (ActivationSpec) activationSpec };
                XAResource[] resources = bootstrapContext.resourceAdapter.getXAResources(actspecs);
                if (resources != null && resources.length == 1) {
                    xa = resources[0];
                } else if (resources != null && resources.length > 1) {
                    throw new IllegalStateException(Utils.getMessage("J2CA8800.multiple.xa.resources", bootstrapContext.getResourceAdapterName(), id));
                }
            } catch (Exception e) {
                throw new XAResourceNotAvailableException(e);
            }
        }
        return xa;
    }
726245
function closeProject(projectId, callback) {
            var prevBranchName = state.branchName;
            state.project = null;
            state.projectAccess = null;
            state.projectInfo = null;
            state.readOnlyProject = false;
            //TODO what if for some reason we are in transaction?
            storage.closeProject(projectId, function (err) {
                if (err) {
                    callback(err);
                    return;
                }

                state.core = null;
                state.branchName = null;
                state.commitHash = null;
                //self.dispatchEvent(null);
                state.patterns = {};
                //state.gHash = 0;
                state.nodes = {};
                state.loadNodes = {};
                state.loadError = 0;
                state.rootHash = null;
                //state.rootObject = null;
                state.transactions.opened = 0;
                state.transactions.callbacks = [];
                state.msg = '';

                cleanUsersTerritories();
                if (prevBranchName) {
                    self.dispatchEvent(CONSTANTS.BRANCH_CLOSED, prevBranchName);
                }

                self.dispatchEvent(CONSTANTS.BRANCH_CHANGED, null);
                self.dispatchEvent(CONSTANTS.PROJECT_CLOSED, projectId);

                callback(null);
            });
        }