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

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


                    // Transaction table
                    Collection txnList = jdbcStore.getTransactions(brokerID);
                    Iterator txnItr = txnList.iterator();
                    while (txnItr.hasNext()) {
                        TransactionUID tid = (TransactionUID)txnItr.next();
                        TransactionInfo txnInfo = jdbcStore.getTransactionInfo(tid);
                        TransactionAcknowledgement txnAck[] =
                            jdbcStore.getTransactionAcks(tid);
                        bkrFS.storeTransaction(tid, txnInfo, false);
                        for (int i = 0, len = txnAck.length; i < len; i++) {
View Full Code Here


                    // Transaction table
                    Collection txnList = bkrFS.getTransactions(brokerID);
                    Iterator txnItr = txnList.iterator();
                    while (txnItr.hasNext()) {
                        TransactionUID tid = (TransactionUID)txnItr.next();
                        TransactionInfo txnInfo = bkrFS.getTransactionInfo(tid);
                        TransactionAcknowledgement txnAck[] =
                            bkrFS.getTransactionAcks(tid);
                        jdbcStore.storeTransaction(tid, txnInfo, sessionID);
                        for (int i = 0, len = txnAck.length; i < len; i++) {
View Full Code Here

                    // Process all msgs in the txn
                    processTxnRecMsgPart(dis, dstLoadedSet);

                    // Check to see if we need to commit the txn
                    if (tid > 0) {
                        TransactionUID tuid = new TransactionUID(tid);
                        int state = tidList.getTransactionStateValue(tuid);
                        if (state != TransactionState.NULL &&
                            state != TransactionState.COMMITTED) {
                            logger.log(logger.FORCE,
                                BrokerResources.I_COMMIT_TXNLOG_RECORD, tidStr);
                            tidList.updateTransactionState(tuid,
                                TransactionState.COMMITTED, false);
                        }
                    }

                    dis.close();
                    bis.close();
                }

                logger.log(logger.FORCE, BrokerResources.I_LOAD_MSG_TXNLOG,
                    String.valueOf(count));
                logger.flush();
            }

            // Note: the ack log file contains message(s) consume but
            // it can also contains message(s) produce and consume in the
            // same txn. Instead of creating another log file for this type
            // of record, we'll just store it the same file for simplicity.
            if (ackLogWriter.playBackRequired()) {
                storeNeedsRestart = true;
                logger.log(logger.FORCE, BrokerResources.I_PROCESS_ACK_TXNLOG);

                // All destinations need to be loaded
                Destination.init();
                Subscription.initSubscriptions();

                int count = 0;

                Iterator itr = ackLogWriter.iterator();
                while (itr.hasNext()) {
                    count++; // Keep track the number of records processed

                    // Read in the acks or msgs & acks
                    rec = (TransactionLogRecord)itr.next();

                    int recType = rec.getType();
                    if (!(recType == TransactionLogType.CONSUME_TRANSACTION ||
                        recType == TransactionLogType.PRODUCE_AND_CONSUME_TRANSACTION)) {
                        // shouldn't happens
                        logger.log(logger.ERROR,
                            BrokerResources.E_PROCESS_TXNLOG_RECORD_FAILED,
                            String.valueOf(rec.getSequence()),
                            "record type " + recType + " is invalid");
                        continue;
                    }

                    data = rec.getBody();
                    bis = new ByteArrayInputStream(data);
                    dis = new DataInputStream(bis);

                    long tid = dis.readLong(); // Transaction ID
                    String tidStr = String.valueOf(tid);

                    logger.log(logger.FORCE,
                        BrokerResources.I_PROCESS_TXNLOG_RECORD,
                        tidStr, String.valueOf(recType));

                    if (recType == TransactionLogType.PRODUCE_AND_CONSUME_TRANSACTION) {
                        // Process all msgs in the txn first!
                        processTxnRecMsgPart(dis, dstLoadedSet);
                    }

                    // Process all acks in the txn
                    processTxnRecAckPart(dis, dstLoadedSet);

                    // Check to see if we need to commit the txn
                    TransactionUID tuid = new TransactionUID(tid);
                    int state = tidList.getTransactionStateValue(tuid);
                    if (state != TransactionState.NULL &&
                        state != TransactionState.COMMITTED) {
                        logger.log(logger.FORCE,
                            BrokerResources.I_COMMIT_TXNLOG_RECORD, tidStr);
View Full Code Here

        boolean dobatch = dbMgr.supportsBatchUpdates() && !dbMgr.isHADB();
  PreparedStatement pstmt = null;
  Statement stmt = null;
  ResultSet rs = null;
  TransactionUID tid  = null;
    Exception myex = null;
  try {
      pstmt = conn.prepareStatement(insertTxnSQL);

            stmt = conn.createStatement();
      rs = stmt.executeQuery(getAllTxnsFromOldSQL);
      while (rs.next()) {
    long id = rs.getLong(1);
    tid = new TransactionUID(id);
    int state = rs.getInt(2);
   
    TransactionState txnState = (TransactionState)Util.readObject(rs, 3);
    if(DEBUG)
    {
      String msg = "reading transaction from old format: state="+state+
      " txnState = "+txnState;
      logger.log(Logger.DEBUG, msg);
    }
    txnState.setState(state);

    // insert in new table
    try {
                    pstmt.setLong( 1, id );
                    pstmt.setInt( 2, TransactionInfo.TXN_LOCAL );
                    pstmt.setInt( 3, state );
                    pstmt.setInt( 4, txnState.getType().intValue() );

                    JMQXid jmqXid = txnState.getXid();
                    if ( jmqXid != null ) {
                        pstmt.setString( 5, jmqXid.toString() );
                    } else {
                        pstmt.setNull( 5, Types.VARCHAR );
                    }

                    Util.setObject( pstmt, 6, txnState );
                    Util.setObject( pstmt, 7, null );
                    Util.setObject( pstmt, 8, null );                   

                    pstmt.setLong( 9, storeSessionID );
                    pstmt.setLong( 10, txnState.getExpirationTime() );
                    pstmt.setLong( 11, txnState.getLastAccessTime() );

        if (dobatch) {
      pstmt.addBatch();
        } else {
      pstmt.executeUpdate();
        }
    } catch (IOException e) {
        IOException ex = DBManager.wrapIOException(
                        "[" + insertTxnSQL + "]", e);
        throw ex;
    } catch (SQLException e) {
        SQLException ex = DBManager.wrapSQLException(
                        "[" + insertTxnSQL + "]", e);
        throw ex;
    }
      }

      if (dobatch) {
    pstmt.executeBatch();
      }
      conn.commit();

            // Only delete txn table after we upgrade txn ack!!!
  } catch (Exception e) {
        myex = e;
            String errorMsg = br.getKString(
                BrokerResources.X_JDBC_UPGRADE_TRANSACTIONS_FAILED,
                (tid == null ? "loading" : tid.toString()));
      logger.logStack(Logger.ERROR, errorMsg, e);
      throw new BrokerException(errorMsg, e);
  } finally {
            Util.close( rs, stmt, null, myex );
            Util.close( null, pstmt, null, myex );
View Full Code Here

        boolean dobatch = dbMgr.supportsBatchUpdates() && !dbMgr.isHADB();
  PreparedStatement pstmt = null;
  Statement stmt = null;
  ResultSet rs = null;
  TransactionUID tid  = null;
    Exception myex = null;
  try {
      pstmt = conn.prepareStatement(insertTxnAckSQL);

            stmt = conn.createStatement();
      rs = stmt.executeQuery(getAllTxnAcksFromOldSQL);
      while (rs.next()) {
    long id = rs.getLong(1);
    tid = new TransactionUID(id);
    TransactionAcknowledgement ack =
                    (TransactionAcknowledgement)Util.readObject(rs, 2);

    // insert in new table
    try {
                    pstmt.setLong( 1, id );
                    pstmt.setString( 2, ack.getSysMessageID().toString() );
                    pstmt.setLong( 3, ack.getStoredConsumerUID().longValue() );

        if (dobatch) {
      pstmt.addBatch();
        } else {
      pstmt.executeUpdate();
        }
    } catch (SQLException e) {
        SQLException ex = DBManager.wrapSQLException(
                        "[" + insertTxnAckSQL + "]", e);
        throw ex;
    }
      }

      if (dobatch) {
    pstmt.executeBatch();
      }
      conn.commit();

      if (store.upgradeNoBackup()) {
                dropTable(conn, oldTxnTable);
                dropTable(conn, oldAckTable);
      }
  } catch (Exception e) {
        myex = e;
            String errorMsg = br.getKString(
                BrokerResources.X_JDBC_UPGRADE_TXNACK_FAILED,
                (tid == null ? "loading" : tid.toString() ) );
      logger.logStack(Logger.ERROR, errorMsg, e);
      throw new BrokerException(errorMsg, e);
  } finally {
            Util.close( rs, stmt, null, myex );
            Util.close( null, pstmt, null, myex );
View Full Code Here

  void processStoredTxnOnStartup(BaseTransaction baseTxn) {
    if (Store.getDEBUG()) {
      String msg = getPrefix() + " processStoredTxnOnStartup " + baseTxn;
      logger.log(Logger.DEBUG, msg);
    }
    TransactionUID tid = baseTxn.getTid();
    int state = baseTxn.getState();
    if (state == TransactionState.COMMITTED
        || state == TransactionState.ROLLEDBACK) {
      addToCompleteStored(baseTxn);
View Full Code Here

    }
    LocalTransactionEvent localTxnEvent = (LocalTransactionEvent) txnEvent;
    // replay to store on commit
    LocalTransaction localTxn = localTxnEvent.localTransaction;
    int state = localTxn.getState();
    TransactionUID tid = localTxn.getTid();
    if (localTxnEvent.getSubType() == LocalTransactionEvent.Type1PCommitEvent) {
      //one phase commit
      //Just replay it now

      transactionLogManager.transactionLogReplayer.replayTransactionWork(localTxn
View Full Code Here

        IOException {
      if (DEBUG) {
        logger.log(Logger.DEBUG, getPrefix() + " convert txn "+baseTxn);
      }

      TransactionUID id = baseTxn.getTid();

      TransactionState ts = baseTxn.getTransactionState();

      int finalState = ts.getState();
View Full Code Here

    void convert(BaseTransaction baseTxn) throws BrokerException,
        IOException {

      ClusterTransaction clusterTxn = (ClusterTransaction) baseTxn;
      TransactionUID id = baseTxn.getTid();

      TransactionState ts = baseTxn.getTransactionState();

      int finalState = ts.getState();
View Full Code Here

  class RemoteTxnConverter extends TxnConverter {
    void convert(BaseTransaction baseTxn) throws BrokerException,
        IOException {

      RemoteTransaction remoteTxn = (RemoteTransaction) baseTxn;
      TransactionUID id = baseTxn.getTid();

      TransactionState ts = baseTxn.getTransactionState();

      store.storeRemoteTransaction(id, ts, remoteTxn.getTxnAcks(),
          remoteTxn.getTxnHomeBroker(), Destination.PERSIST_SYNC);
View Full Code Here

TOP

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

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.