Package com.sun.messaging.jmq.jmsserver.data

Examples of com.sun.messaging.jmq.jmsserver.data.BaseTransaction


            // a) null (for single phase LOCAL transaction)
            // b) a prepared XA LOCAL transaction
            // c) a prepared (XA or not) CLUSTER transaction
           
            // currently, all cluster transactions are 2 phase
            BaseTransaction baseTransaction = doRemoteCommit(id, xaFlags, ts, s, msg, txnWork);
            if (Globals.isNewTxnLogEnabled()) {
          if (ts.getState() == TransactionState.PREPARED) {
            // commit called (from client) on 2-phase transaction
            //
     
            transactionType = BaseTransaction.LOCAL_TRANSACTION_TYPE;
            if (translist.isClusterTransaction(id)) {
              transactionType = BaseTransaction.CLUSTER_TRANSACTION_TYPE;
            }
            logTxnCompletion(id, TransactionState.COMMITTED,
                transactionType);
          } else if ((baseTransaction != null && baseTransaction
              .getState() == TransactionState.PREPARED)) {
            transactionType = baseTransaction.getType();
            logTxnCompletion(id, TransactionState.COMMITTED,
                transactionType);
          } else {

            // one phase commit
View Full Code Here


    public BaseTransaction doPrepare(TransactionUID id, Integer xaFlags,
                          TransactionState ts, int pktType,
                          boolean onephasePrepare, TransactionWork txnWork) throws BrokerException {

      BaseTransaction baseTransaction = null;
      boolean persist = true;
      if (Globals.isNewTxnLogEnabled()) {
       
        // don't persist transaction state as we are logging it instead
        persist=false;
      if (txnWork == null) {
        // prepare has been called directly from an end client
        // We need to construct the transactional work
       
        List plist = translist.retrieveSentMessages(id);
        HashMap cmap = translist.retrieveConsumedMessages(id);
        HashMap sToCmap = translist.retrieveStoredConsumerUIDs(id);
        txnWork = getTransactionWork2(plist, cmap, sToCmap);
       
      }
    }
     
        boolean prepared = false;
        int s = ts.nextState(pktType, xaFlags);
        try {
            TransactionState nextState = new TransactionState(ts);
            nextState.setState(s);
            baseTransaction = doRemotePrepare(id, ts, nextState, txnWork);
            if(baseTransaction==null)
            {
              // work not logged yet, so this must be a local broker transaction
              // (there are no remote acknowledgements) 
              // The end client must have called prepare
              if(Globals.isNewTxnLogEnabled())
                {          
                  baseTransaction= new LocalTransaction();
                baseTransaction.setTransactionWork(txnWork);
                baseTransaction.setTransactionState(nextState);
                baseTransaction.getTransactionDetails().setTid(id);
                baseTransaction.getTransactionDetails().setXid(ts.getXid());
                baseTransaction.getTransactionDetails().setState(TransactionState.PREPARED);
             
                logTxn(baseTransaction);                 
                }
            }
            translist.updateState(id, s, onephasePrepare, persist);
View Full Code Here

                                TransactionWork txnWork)
                                throws BrokerException {
        if (nextState != TransactionState.COMMITTED) {
            throw new BrokerException("Unexpected next state: "+nextState+" for transaction "+id);
        }
        BaseTransaction baseTransaction = null;
        if (ts.getState() != TransactionState.PREPARED) {
            if (retrieveConsumedRemoteMessages(id, true) != null) {
              // In this transaction messages that belong to a remote broker
              // have been acknowledged. These messages must be
              // acknowledged in the remote broker as part of the same transaction.
View Full Code Here

       
    // for now just read and sort into different types
    Enumeration<BaseTransaction> transactions = preparedTxnStore
        .txnEnumeration();
    while (transactions.hasMoreElements()) {
      BaseTransaction baseTxn = transactions.nextElement();
      // need to switch on all types
      int type = baseTxn.getType();
      BaseTransactionManager baseTxnMan = this
          .getTransactionManager(type);
      baseTxnMan.processStoredTxnOnStartup(baseTxn);
    }
View Full Code Here

    // for now just report on any transactions
    Enumeration<BaseTransaction> transactions = preparedTxnStore
        .txnEnumeration();
    List<BaseTransaction> committed = new ArrayList<BaseTransaction>();
    while (transactions.hasMoreElements()) {
      BaseTransaction baseTxn = transactions.nextElement();
      if (baseTxn.getState() == TransactionState.COMMITTED) {
        if (baseTxn.getType() == BaseTransaction.CLUSTER_TRANSACTION_TYPE
            && !baseTxn.getTransactionDetails().isComplete()) {
          if (Store.getDEBUG()) {
            String msg = getPrefix()
                + " not removing incomplete cluster transaction "
                + baseTxn.getTransactionDetails();
            logger.log(Logger.DEBUG, msg);
          }
        } else {
          if (Store.getDEBUG()) {
            String msg = getPrefix() + " removing transaction "
                + baseTxn.getTransactionDetails();
            logger.log(Logger.DEBUG, msg);
          }
          committed.add(baseTxn);
        }
      }

    }
    Iterator<BaseTransaction> iter = committed.iterator();
    while (iter.hasNext()) {
      BaseTransaction baseTxn = iter.next();
      TransactionUID tid = baseTxn.getTid();
      preparedTxnStore.removeTransaction(tid, true);
      if (Store.getDEBUG()) {
        String msg = getPrefix()
            + " removed committed transaction from preparedTxnStore. Tid="
            + tid;
View Full Code Here

              + tid);
    }
    try {
      store.txnLogSharedLock.lock();
      BaseTransactionManager txnMan = getTransactionManager(type);
      BaseTransaction existing = txnMan.processTxnCompletion(tid,
          completionState);
      TransactionEvent txnEvent = txnMan.generateEvent(existing, true);

      writeTransactionEvent(txnEvent);
    } catch (IOException ioe) {
View Full Code Here

      // b) stored incomplete (prepare occurred before last checkpoint,
      //    completion not written to prepared store yet)
      //    This should therefore be the last entry in log.
      // c) stored complete (prepare occurred before last checkpoint,
      //    and failure occurred after completion stored in prepared store
      BaseTransaction existingWork = null;
      if (incompleteUnstored.containsKey(tid)) {
        // a) unstored (prepare replayed earlier)
        if (state == TransactionState.ROLLEDBACK) {
          existingWork = removeFromIncompleteUnstored(tid);
        } else if (state == TransactionState.COMMITTED) {

          existingWork = incompleteUnstored.get(tid);
          existingWork.getTransactionDetails().setState(state);
          existingWork.getTransactionState().setState(state);
        }
       
      } else if (incompleteStored.containsKey(tid)) {
        // b) stored incomplete (prepare occurred before last checkpoint,
        //    completion not written to prepared store yet)

        existingWork = removeFromIncompleteStored(tid);

        updateStoredState(tid, state);

        addToCompleteStored(existingWork);
      } else if (completeStored.containsKey(tid)) {
        // c) stored complete (prepare occurred before last checkpoint,
        //    and failure occurred after completion stored in prepared store
        existingWork = completeStored.get(tid);
      }
      if (existingWork != null) {
        if (state == TransactionState.COMMITTED) {
          transactionLogManager.transactionLogReplayer.replayTransactionWork(existingWork
              .getTransactionWork(), tid, dstLoadedSet);
        }
      } else {
        logger.log(Logger.ERROR,
            "Could not find prepared work for completing two-phase transaction "
View Full Code Here

    parent = p;

    try {
      // parse message
      BaseTransaction txnWork = TransactionWorkFactory
          .readFromBytes(data);

      // cache message info
      this.msg = txnWork;
      tid = (TransactionUID) txnWork.getTid();

    } catch (BrokerException be) {
      be.printStackTrace();
      throw new IOException(be.getMessage());
    } catch (IOException e) {
View Full Code Here

    // sanity check done while VRecords are loaded

    try {
      // parse message
      BaseTransaction txnWork = parseTransactionWork(r);

      // cache message info
      this.msg = txnWork;
      tid = txnWork.getTid();

    } catch (IOException e) {
      // free the bad VRecord
      parent.getVRFile().free(vrecord);
View Full Code Here

              + ":failed to parse message from byte array", e);
          throw e;
        }
      }
    } else {
      BaseTransaction pkt = msg;
      msg = null;
      return pkt;
    }
  }
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.data.BaseTransaction

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.