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

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


    ArrayList<TransactionUID> incmps = null;
    synchronized(incompleteUnstored) {
      incmps = new ArrayList<TransactionUID>(incompleteUnstored.keySet());
    }

    TransactionUID tid = null;
    BaseTransaction baseTxn = null;
    Iterator<TransactionUID> iter = incmps.iterator();
    while (iter.hasNext()) {
      tid = iter.next();
      if (!preparedTxnStore.containsTransaction(tid)) {
View Full Code Here


    synchronized(completeStored) {
      cmptids = new ArrayList(completeStored.keySet());
    }
    Iterator<TransactionUID> iter = cmptids.iterator();
    while (iter.hasNext()) {
      TransactionUID tid = iter.next();
      if (preparedTxnStore.containsTransaction(tid)) {
        preparedTxnStore.removeTransaction(tid, true);

        if (Store.getDEBUG()) {
          String msg = getPrefix() + " removed transaction " + tid;
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 type = rs.getInt(2);
                int state = rs.getInt(3);

                TransactionState txnState = (TransactionState)Util.readObject(rs, 4);
                txnState.setState(state);

                BrokerAddress txnHomeBroker = (BrokerAddress)Util.readObject(rs, 5);
                TransactionBroker[] txnBrokers = (TransactionBroker[])Util.readObject(rs, 6);

                long sessionID = rs.getLong(7);

    // insert in new table
    try {
                    pstmt.setLong( 1, id );
                    pstmt.setInt( 2, type );
                    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, txnHomeBroker );
                    Util.setObject( pstmt, 8, txnBrokers );

                    pstmt.setLong( 9, sessionID );
                    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();
  } 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

        Iterator itr = tidMap.entrySet().iterator();
        while (itr.hasNext()) {
            try {
                Map.Entry entry = (Map.Entry)itr.next();
                TransactionUID tid = (TransactionUID)entry.getKey();
                TransactionState ts = (TransactionState)entry.getValue();
                // Remove if not in prepared state
                    if (ts.getState() != state) {
                    // XXX PERF 12/7/2001 This operation updates disk
                    // with every call.
View Full Code Here

            pstmt = conn.prepareStatement( selectAllTransactionAcksSQL );
            rs = pstmt.executeQuery();

            while ( rs.next() ) {
                TransactionUID txnUID = new TransactionUID( rs.getLong( 1 ) );
                ConsumerUID conID = new ConsumerUID( rs.getLong( 2 ) );
                try {
                    SysMessageID msgID = SysMessageID.get( rs.getString( 3 ) );

                    List ackList = (List)data.get( txnUID );
                    if ( ackList == null ) {
                        // Create a new list of acks for this txn
                        ackList = new ArrayList(25);
                        data.put( txnUID, ackList );
                    }

                    // Added ack to the list of acks
                    ackList.add( new TransactionAcknowledgement( msgID, conID, conID ) );
                } catch ( Exception e ) {
                    // fail to parse one object; just log it
                    logger.logStack( Logger.ERROR,
                        BrokerResources.X_PARSE_TXNACK_FAILED, txnUID, e );
                }
            }
        } catch ( Exception e ) {
            myex = e;
            try {
                if ( (conn != null) && !conn.getAutoCommit() ) {
                    conn.rollback();
                }
            } catch ( SQLException rbe ) {
                logger.log( Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED, rbe );
            }

            Exception ex;
            if ( e instanceof BrokerException ) {
                throw (BrokerException)e;
            } else if ( e instanceof SQLException ) {
                ex = DBManager.wrapSQLException("[" + selectAllTransactionAcksSQL + "]", (SQLException)e);
            } else {
                ex = e;
            }

            throw new BrokerException(
                br.getKString( BrokerResources.X_LOAD_TXNACK_FAILED ), ex );
        } finally {
            if ( myConn ) {
                Util.close( rs, pstmt, conn, myex );
            } else {
                Util.close( rs, pstmt, null, myex );
            }
        }

        // Transforms HashMap value to TransactionAcknowledgement[] instead of List
        Set keySet = data.keySet();
        if ( !keySet.isEmpty() ) {
            Iterator itr = keySet.iterator();
            while ( itr.hasNext() ) {
                TransactionUID txnUID = (TransactionUID)itr.next();
                List ackList = (List)data.get( txnUID );
                data.put( txnUID, ackList.toArray(
                    new TransactionAcknowledgement[0] ) );
            }
        }
View Full Code Here

            pstmt = conn.prepareStatement( selectTxnStatesByBrokerSQL );
            pstmt.setString( 1, brokerID );

            rs = pstmt.executeQuery();
            while ( rs.next() ) {
                list.add( new TransactionUID( rs.getLong( 1 ) ) );
            }
        } catch ( Exception e ) {
            myex = e;
            try {
                if ( (conn != null) && !conn.getAutoCommit() ) {
View Full Code Here

                pstmt.setInt( 2, TransactionInfo.TXN_REMOTE );
            }

            rs = pstmt.executeQuery();
            while ( rs.next() ) {
                list.add( new TransactionUID( rs.getLong( 1 ) ) );
            }
        } catch ( Exception e ) {
            myex = e;
            try {
                if ( (conn != null) && !conn.getAutoCommit() ) {
View Full Code Here

                    txnState.setState( state );

                    TransactionBroker[] txnBrokers =
                        (TransactionBroker[])Util.readObject( rs, 5 );
                   
                    map.put( new TransactionUID( id ),
                             new TransactionInfo(txnState, null, txnBrokers, type) );
                } catch ( IOException e ) {
                    // fail to parse TransactionState object; just log it
                    logger.logStack( Logger.ERROR,
                        BrokerResources.X_PARSE_TRANSACTION_FAILED, e );
View Full Code Here

                        (TransactionState)Util.readObject( rs, 3 );

                    // update state in TransactionState object
                    txnState.setState( state );

                    map.put( new TransactionUID( id ), txnState );
                } catch ( IOException e ) {
                    // fail to parse TransactionState object; just log it
                    logger.logStack( Logger.ERROR,
                        BrokerResources.X_PARSE_TRANSACTION_FAILED, e );
                }
View Full Code Here

  }

  TransactionWorkInfo storeTransaction(BaseTransaction baseTxn, boolean sync)
      throws IOException, BrokerException {

    TransactionUID id = baseTxn.getTid();

    // just check the cached map; all messages should be
    // loaded before this is called
    if (transactionMap.containsKey(id)) {
      logger.log(logger.ERROR, br.E_MSG_EXISTS_IN_STORE, id,
          storeName);
      throw new BrokerException(br.getString(br.E_MSG_EXISTS_IN_STORE,
          id, storeName));
    }

    try {

      byte[] data = baseTxn.writeToBytes();

      int msgsize = data.length;
      if(sync&&Store.getDEBUG_SYNC())
      {
        String msg = " PreparedTxnStore storeTransaction sync " +baseTxn;
        Globals.getLogger().log(Logger.DEBUG, msg);
      }

      TransactionWorkInfo info = null;
      if (vrfile != null
          && (maxRecordSize == 0 || msgsize < maxRecordSize)) {

        // store in vrfil   
        info = new TransactionWorkInfo(this, vrfile, baseTxn, data, sync);
      } else {
        // store in individual file
        info = new TransactionWorkInfo(this, baseTxn, data, sync);
      }

      // cache it, make sure to use the cloned SysMessageID   
      transactionMap.put(info.getID(), info);

      // increate destination message count and byte count
      incrTxnCount(msgsize);

      return info;
    } catch (IOException e) {
      logger.log(logger.ERROR, br.X_PERSIST_MESSAGE_FAILED,
          id.toString(), e);
      throw e;
    }
  }
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.