Package com.taobao.metamorphosis.transaction

Examples of com.taobao.metamorphosis.transaction.XATransactionId


    public void testBeginXAPrepare() throws Exception {
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);

        final XATransactionId id = XIDGenerator.createXID(1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);

        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.start(id, XAResource.TMNOFLAGS);
View Full Code Here


    public void testBeginXACommit() throws Exception {
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);

        final XATransactionId id = XIDGenerator.createXID(1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);

        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.start(id, XAResource.TMNOFLAGS);
View Full Code Here

    public void testBeginXARollback() throws Exception {
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);

        final XATransactionId id = XIDGenerator.createXID(1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.ROLLBACK), null);

        OpaqueGenerator.resetOpaque();
        this.replay();
View Full Code Here

    public void testBeginXAEndPrepareRollback() throws Exception {
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);

        final XATransactionId id = XIDGenerator.createXID(1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);
        this.mockSend(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.END));
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.PREPARE),
            String.valueOf(XAResource.XA_OK));
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.ROLLBACK), null);
View Full Code Here

    public void testCommitUnBeginXA() throws Exception {
        // ��������ģ�������recover����������
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);
        final XATransactionId id = XIDGenerator.createXID(1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.COMMIT_TWO_PHASE),
            null);
        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.commit(id, false);
View Full Code Here

    public void testPrepareUnBeginXA() throws Exception {
        // ��������ģ�������recover����������
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);
        final XATransactionId id = XIDGenerator.createXID(1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.PREPARE),
            String.valueOf(XAResource.XA_OK));
        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.prepare(id);
View Full Code Here

    @Test
    public void testRecover() throws Exception {
        final String serverURL1 = "meta://localhost:8123";
        final String serverURL2 = "meta://localhost:8124";
        final XATransactionId id1 = XIDGenerator.createXID(1);
        final XATransactionId id2 = XIDGenerator.createXID(2);
        final XATransactionId id3 = XIDGenerator.createXID(3);
        final XATransactionId id4 = XIDGenerator.createXID(4);

        this.mockInvokeSuccess(serverURL1, new TransactionInfo(null, this.sessionId, TransactionType.RECOVER),
            id2.getTransactionKey() + "\r\n" + id3.getTransactionKey());
        this.mockInvokeSuccess(serverURL2, new TransactionInfo(null, this.sessionId, TransactionType.RECOVER),
            id1.getTransactionKey() + "\r\n" + id4.getTransactionKey());
        this.replay();
        OpaqueGenerator.resetOpaque();
        this.context.setXareresourceURLs(new String[] { serverURL1, serverURL2 });
        final Xid[] xids = this.context.recover(XAResource.TMNOFLAGS);
        assertEquals(4, xids.length);
View Full Code Here


    public static XATransactionId createXID(final int formatId) {
        final byte[] branchQualifier = randomBytes();
        final byte[] globalTransactionId = randomBytes();
        final XATransactionId xid =
                new XATransactionId(formatId, branchQualifier, globalTransactionId, UNIQUE_QUALIFIER);
        return xid;
    }
View Full Code Here

    public void commit(final Xid xid, final boolean onePhase) throws XAException {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Commit: " + xid);
        }

        XATransactionId x;
        if (xid == null || this.equals(this.associatedXid, xid)) {
            throw new XAException(XAException.XAER_PROTO);
        }
        else {
            x = new XATransactionId(xid, this.uniqueQualifier);
        }

        MetaStatLog.addStat(null, StatConstants.TX_COMMIT);
        this.checkConnectionConnected();
        try {
View Full Code Here

    public void forget(final Xid xid) throws XAException {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Forget: " + xid);
        }

        XATransactionId x;
        if (xid == null) {
            throw new XAException(XAException.XAER_PROTO);
        }
        if (this.equals(this.associatedXid, xid)) {
            x = (XATransactionId) this.transactionId;
        }
        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

TOP

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

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.