Package com.taobao.metamorphosis.transaction

Examples of com.taobao.metamorphosis.transaction.TransactionInfo


        final TransactionCommand cmd = (TransactionCommand) this.decoder.decode(buf, null);
        assertNotNull(cmd);
        assertEquals(100, (int) cmd.getOpaque());
        assertEquals(0, cmd.getTransactionInfo().getTimeout());
        assertEquals("unique-qualifier", cmd.getTransactionInfo().getUniqueQualifier());
        final TransactionInfo info = cmd.getTransactionInfo();
        assertNotNull(info);
        assertNotNull(info.getTransactionId());
        assertTrue(info.getTransactionId().isLocalTransaction());
        final LocalTransactionId id = (LocalTransactionId) info.getTransactionId();
        assertEquals("sessionId", id.getSessionId());
        assertEquals(99, id.getValue());
    }
View Full Code Here


        final TransactionCommand cmd = (TransactionCommand) this.decoder.decode(buf, null);
        assertNotNull(cmd);
        assertEquals(100, (int) cmd.getOpaque());
        assertEquals(3, cmd.getTransactionInfo().getTimeout());
        assertEquals("unique-qualifier", cmd.getTransactionInfo().getUniqueQualifier());
        final TransactionInfo info = cmd.getTransactionInfo();
        assertNotNull(info);
        assertNotNull(info.getTransactionId());
        assertTrue(info.getTransactionId().isLocalTransaction());
        final LocalTransactionId id = (LocalTransactionId) info.getTransactionId();
        assertEquals("sessionId", id.getSessionId());
        assertEquals(99, id.getValue());
    }
View Full Code Here

                    switch (sa.length) {
                    case 7:
                        // Both include timeout and unique qualifier.
                        int timeout = Integer.valueOf(sa[4]);
                        String uniqueQualifier = sa[5];
                        TransactionInfo info =
                                new TransactionInfo(transactionId, sa[2], type, uniqueQualifier, timeout);
                        return new TransactionCommand(info, Integer.parseInt(sa[6]));
                    case 6:
                        // Maybe timeout or unique qualifier
                        if (StringUtils.isNumeric(sa[4])) {
                            timeout = Integer.valueOf(sa[4]);
                            info = new TransactionInfo(transactionId, sa[2], type, null, timeout);
                            return new TransactionCommand(info, Integer.parseInt(sa[5]));
                        }
                        else {
                            uniqueQualifier = sa[4];
                            info = new TransactionInfo(transactionId, sa[2], type, uniqueQualifier, 0);
                            return new TransactionCommand(info, Integer.parseInt(sa[5]));
                        }
                    case 5:
                        // Without timeout and unique qualifier.
                        info = new TransactionInfo(transactionId, sa[2], type, null);
                        return new TransactionCommand(info, Integer.parseInt(sa[4]));
                    default:
                        throw new MetaCodecException("Invalid transaction command:" + StringUtils.join(sa));
                    }
View Full Code Here

        MetaStatLog.addStat(null, StatConstants.TX_COMMIT);
        this.checkConnectionConnected();
        try {

            // Notify the server that the tx was committed back
            final TransactionInfo info =
                    new TransactionInfo(x, this.sessionId, onePhase ? TransactionInfo.TransactionType.COMMIT_ONE_PHASE
                            : TransactionInfo.TransactionType.COMMIT_TWO_PHASE, this.uniqueQualifier);

            this.syncSendXATxCommand(info);
        }
        finally {
View Full Code Here

        }
        else {
            x = new XATransactionId(xid, this.uniqueQualifier);
        }

        final TransactionInfo info =
                new TransactionInfo(x, this.sessionId, TransactionInfo.TransactionType.FORGET, this.uniqueQualifier);
        this.syncSendXATxCommand(info);
    }
View Full Code Here

        else {
            x = new XATransactionId(xid, this.uniqueQualifier);
        }
        MetaStatLog.addStat(null, StatConstants.TX_PREPARE);

        final TransactionInfo info =
                new TransactionInfo(x, this.sessionId, TransactionInfo.TransactionType.PREPARE, this.uniqueQualifier);

        final BooleanCommand response = this.syncSendXATxCommand(info);
        final int result = Integer.parseInt(response.getErrorMsg());
        if (XAResource.XA_RDONLY == result) {
            if (LOG.isDebugEnabled()) {
View Full Code Here

    @Override
    public Xid[] recover(final int flag) throws XAException {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Recover with flag: " + flag);
        }
        final TransactionInfo info =
                new TransactionInfo(null, this.sessionId, TransactionInfo.TransactionType.RECOVER, this.uniqueQualifier);
        try {
            final List<XATransactionId> xidList = new ArrayList<XATransactionId>();
            if (this.xareresourceURLs == null || this.xareresourceURLs.length == 0) {
                throw new XAException(XAException.XAER_RMFAIL);
            }
View Full Code Here

        }
        MetaStatLog.addStat(null, StatConstants.TX_ROLLBACK);
        this.checkConnectionConnected();
        try {

            final TransactionInfo info =
                    new TransactionInfo(x, this.sessionId, TransactionInfo.TransactionType.ROLLBACK,
                        this.uniqueQualifier);
            this.syncSendXATxCommand(info);
        }
        finally {
            this.associatedSession.removeContext(this);
View Full Code Here


    private void endXATransaction() throws XAException {
        if (this.transactionId != null) {
            MetaStatLog.addStat(null, StatConstants.TX_END);
            final TransactionInfo info =
                    new TransactionInfo(this.transactionId, this.sessionId, TransactionInfo.TransactionType.END,
                        this.uniqueQualifier);
            try {
                this.remotingClient.sendToGroup(this.serverUrl,
                    new TransactionCommand(info, OpaqueGenerator.getNextOpaque()), END_XA_TX_LISTENER,
                    this.transactionRequestTimeoutInMills, TimeUnit.MILLISECONDS);
View Full Code Here

    private void startXATransaction(final Xid xid) throws XAException {
        MetaStatLog.addStat(null, StatConstants.TX_BEGIN);
        this.associatedXid = xid;
        this.transactionId = new XATransactionId(xid, this.uniqueQualifier);

        final TransactionInfo info =
                new TransactionInfo(this.transactionId, this.sessionId, TransactionInfo.TransactionType.BEGIN,
                    this.uniqueQualifier, this.transactionTimeout);
        this.syncSendXATxCommand(info);
    }
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.transaction.TransactionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.