Package com.sleepycat.je.log.LogUtils

Examples of com.sleepycat.je.log.LogUtils.XidImpl


        try {
            /* Set up an repository of expected data. */
            Hashtable expectedData = new Hashtable();
           
            /* Insert all the data. */
      XidImpl xid = new XidImpl(1, "TwoPCTest1".getBytes(), null);
            Transaction txn = null;
      if (explicitTxn) {
    txn = env.beginTransaction(null, null);
    xaEnv.setXATransaction(xid, txn);
      } else {
View Full Code Here


     null);
            final Transaction txn2 =
    (explicitTxn ?
     env.beginTransaction(null, null) :
     null);
      final XidImpl xid1 = new XidImpl(1, "TwoPCTest1".getBytes(), null);
      final XidImpl xid2 = new XidImpl(1, "TwoPCTest2".getBytes(), null);

      Thread thread1 = new Thread() {
        public void run() {
      try {
          if (explicitTxn) {
View Full Code Here

  createXAEnvAndDbs(1 << 20, false, NUM_DBS);
  XAEnvironment xaEnv = (XAEnvironment) env;

        try {
      XidImpl xid = new XidImpl(1, "TwoPCTest1".getBytes(), null);
            Transaction txn = null;

      /* Check that only one of TMJOIN and TMRESUME can be set. */
      try {
    xaEnv.start(xid, XAResource.TMJOIN | XAResource.TMRESUME);
    fail("Expected XAException(XAException.XAER_INVAL)");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_INVAL);
      }

      /*
       * Check that only one of TMJOIN and TMRESUME can be set by passing
       * a bogus flag value (TMSUSPEND).
       */
      try {
    xaEnv.start(xid, XAResource.TMSUSPEND);
    fail("Expected XAException(XAException.XAER_INVAL)");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_INVAL);
      }

      xaEnv.start(xid, XAResource.TMNOFLAGS);
      try {
    xaEnv.start(xid, XAResource.TMNOFLAGS);
    fail("Expected XAER_DUPID");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_DUPID);
      }
      xaEnv.end(xid, XAResource.TMNOFLAGS);

      /*
       * Check that JOIN with a non-existant association throws NOTA.
       */
      try {
    xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);
    xaEnv.start(xid, XAResource.TMJOIN);
    fail("Expected XAER_NOTA");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_NOTA);
      }

      /*
       * Check that RESUME with a non-existant association throws NOTA.
       */
      try {
    xaEnv.start(xid, XAResource.TMRESUME);
    fail("Expected XAER_NOTA");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_NOTA);
      }

      /*
       * Check that start(JOIN) from a thread that is already associated
       * throws XAER_PROTO.
       */
      Xid xid2 = new XidImpl(1, "TwoPCTest3".getBytes(), null);
      xaEnv.start(xid2, XAResource.TMNOFLAGS);
      xaEnv.end(xid2, XAResource.TMNOFLAGS);
      xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);
      xaEnv.start(xid, XAResource.TMNOFLAGS);
      try {
    xaEnv.start(xid2, XAResource.TMJOIN);
    fail("Expected XAER_PROTO");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_PROTO);
      }

      /*
       * Check that start(RESUME) for an xid that is not suspended throws
       * XAER_PROTO.
       */
      try {
    xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);
    xaEnv.start(xid, XAResource.TMRESUME);
    fail("Expected XAER_PROTO");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_PROTO);
      }

      /*
       * Check that end(TMFAIL | TMSUCCESS) throws XAER_INVAL.
       */
      try {
    xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);
    xaEnv.end(xid, XAResource.TMFAIL | XAResource.TMSUCCESS);
    fail("Expected XAER_INVAL");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_INVAL);
      }

      /*
       * Check that end(TMFAIL | TMSUSPEND) throws XAER_INVAL.
       */
      try {
    xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);
    xaEnv.end(xid, XAResource.TMFAIL | XAResource.TMSUSPEND);
    fail("Expected XAER_INVAL");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_INVAL);
      }

      /*
       * Check that end(TMSUCCESS | TMSUSPEND) throws XAER_INVAL.
       */
      try {
    xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);
    xaEnv.end(xid, XAResource.TMSUCCESS | XAResource.TMSUSPEND);
    fail("Expected XAER_INVAL");
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_INVAL);
      }

      /*
       * Check that end(TMSUSPEND) actually works.
       */
      Xid xid4 = new XidImpl(1, "TwoPCTest4".getBytes(), null);
      xaEnv.start(xid4, XAResource.TMNOFLAGS);
      Transaction txn4 = xaEnv.getThreadTransaction();
      assertTrue(txn4 != null);
      xaEnv.end(xid4, XAResource.TMSUSPEND);
      assertTrue(xaEnv.getThreadTransaction() == null);
      Xid xid5 = new XidImpl(1, "TwoPCTest5".getBytes(), null);
      xaEnv.start(xid5, XAResource.TMNOFLAGS);
      Transaction txn5 = xaEnv.getThreadTransaction();
      xaEnv.end(xid5, XAResource.TMSUSPEND);
      assertTrue(xaEnv.getThreadTransaction() == null);
      xaEnv.start(xid4, XAResource.TMRESUME);
      assertTrue(xaEnv.getThreadTransaction().equals(txn4));
      xaEnv.end(xid4, XAResource.TMNOFLAGS);
      xaEnv.start(xid5, XAResource.TMRESUME);
      assertTrue(xaEnv.getThreadTransaction().equals(txn5));
      xaEnv.end(xid5, XAResource.TMNOFLAGS);

      /*
       * Check TMFAIL.
       */
      try {
    xid = new XidImpl(1, "TwoPCTest6".getBytes(), null);
    xaEnv.start(xid, XAResource.TMNOFLAGS);
    xaEnv.end(xid, XAResource.TMFAIL);
    xaEnv.commit(xid, false);
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XA_RBROLLBACK);
      }
      xaEnv.rollback(xid);

      /*
       * Check TMSUCCESS.
       */
      xid = new XidImpl(1, "TwoPCTest6".getBytes(), null);
      xaEnv.start(xid, XAResource.TMNOFLAGS);
      xaEnv.end(xid, XAResource.TMSUCCESS);
      xaEnv.commit(xid, false);

      /*
       * Check start(); end(SUSPEND); end(SUCCESS).  This is a case that
       * JBoss causes to happen.  It should succeed.
       */
      xid = new XidImpl(1, "TwoPCTest7".getBytes(), null);
      xaEnv.start(xid, XAResource.TMNOFLAGS);
      xaEnv.end(xid, XAResource.TMSUSPEND);
      xaEnv.end(xid, XAResource.TMSUCCESS);
      xaEnv.commit(xid, false);

      /*
       * Check end(SUSPEND); end(SUCCESS) [with no start() call.].
       * This should fail.
       */
      try {
    xid = new XidImpl(1, "TwoPCTest8".getBytes(), null);
    xaEnv.end(xid, XAResource.TMFAIL);
    xaEnv.commit(xid, false);
      } catch (XAException XAE) {
    /* Expect this. */
    assertTrue(XAE.errorCode == XAException.XAER_NOTA);
View Full Code Here

            throws Exception {

            if (xaEnv.getThreadTransaction() == null) {
                for (int i = 0;; i += 1) {
                    sequence += 1;
                    XidImpl xid = new XidImpl
                        (1, String.valueOf(sequence).getBytes(), null);
                    try {
                        xaEnv.start(xid, 0);
                        worker.doWork();
                        xaEnv.prepare(xid);
View Full Code Here

    public void testBasic2PC()
        throws Throwable {

  try {
      Transaction txn = env.beginTransaction(null, null);
      XidImpl xid = new XidImpl(1, "TwoPCTest1".getBytes(), null);
      env.setXATransaction(xid, txn);

      StringDbt key = new StringDbt("key");
      StringDbt data = new StringDbt("data");
      db.put(txn, key, data);
View Full Code Here

     */
    public void testTwicePreparedTransaction()
        throws Throwable {

  Transaction txn = env.beginTransaction(null, null);
  XidImpl xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);
  env.setXATransaction(xid, txn);
  StringDbt key = new StringDbt("key");
  StringDbt data = new StringDbt("data");
  db.put(txn, key, data);

View Full Code Here

  Transaction txn = env.beginTransaction(null, null);
  StringDbt key = new StringDbt("key");
  StringDbt data = new StringDbt("data");
  db.put(txn, key, data);
  XidImpl xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);

  try {
      env.rollback(xid);
      fail("should not be able to call rollback on an unknown xid");
  } catch (Exception E) {
View Full Code Here

  Transaction txn = env.beginTransaction(null, null);
  StringDbt key = new StringDbt("key");
  StringDbt data = new StringDbt("data");
  db.put(txn, key, data);
  XidImpl xid = new XidImpl(1, "TwoPCTest2".getBytes(), null);

  try {
      env.commit(xid, false);
      fail("should not be able to call commit on an unknown xid");
  } catch (Exception E) {
View Full Code Here

        } finally {
            cursor.close();
        }
        db.close();

  XidImpl xid =
      new XidImpl(1, "MakeLogEntryVersionData".getBytes(), null);
  env.start(xid, XAResource.TMNOFLAGS);
  env.prepare(xid);
  env.rollback(xid);

        env.close();
View Full Code Here

TOP

Related Classes of com.sleepycat.je.log.LogUtils.XidImpl

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.