Examples of TransactionHandler


Examples of com.hp.hpl.jena.graph.TransactionHandler

        on some g they fail because they do not support the operation.
     */
    public void testHasTransactions()
    {
        Graph g = getGraph();
        TransactionHandler th = g.getTransactionHandler();
        th.transactionsSupported();
        try { th.begin(); } catch (UnsupportedOperationException x) {}
        try { th.abort(); } catch (UnsupportedOperationException x) {}
        try { th.begin(); th.commit(); } catch (UnsupportedOperationException x) {}
        /* */
        Command cmd = new Command()
        { @Override
            public Object execute() { return null; } };
            try { th.executeInTransaction( cmd ); }
            catch (UnsupportedOperationException x) {}
    }
View Full Code Here

Examples of com.hp.hpl.jena.graph.TransactionHandler

            catch (UnsupportedOperationException x) {}
    }

    public void testExecuteInTransactionCatchesThrowable()
    {Graph g = getGraph();
    TransactionHandler th = g.getTransactionHandler();
    if (th.transactionsSupported())
    {
        Command cmd = new Command()
        { @Override
            public Object execute() throws Error { throw new Error(); } };
            try { th.executeInTransaction( cmd ); }
            catch (JenaException x) {}
    }
    }
View Full Code Here

Examples of com.hp.hpl.jena.graph.TransactionHandler

        on some g they fail because they do not support the operation.
     */
    public void testHasTransactions()
    {
        Graph g = getGraph();
        TransactionHandler th = g.getTransactionHandler();
        th.transactionsSupported();
        try { th.begin(); } catch (UnsupportedOperationException x) {}
        try { th.abort(); } catch (UnsupportedOperationException x) {}
        try { th.begin(); th.commit(); } catch (UnsupportedOperationException x) {}
        /* */
        Command cmd = new Command()
        { @Override
            public Object execute() { return null; } };
            try { th.executeInTransaction( cmd ); }
            catch (UnsupportedOperationException x) {}
    }
View Full Code Here

Examples of com.hp.hpl.jena.graph.TransactionHandler

            catch (UnsupportedOperationException x) {}
    }

    public void testExecuteInTransactionCatchesThrowable()
    {Graph g = getGraph();
    TransactionHandler th = g.getTransactionHandler();
    if (th.transactionsSupported())
    {
        Command cmd = new Command()
        { @Override
            public Object execute() throws Error { throw new Error(); } };
            try { th.executeInTransaction( cmd ); }
            catch (JenaException x) {}
    }
    }
View Full Code Here

Examples of com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler

                         realstate != TransactionState.PREPARED &&
                         realstate != TransactionState.COMMITTED) ||
                         msgs == 0 && acks == 0) {
                        logger.log((DEBUG ? Logger.INFO:Logger.DEBUG),
                                    "Removing finished transaction " + tid);
                        TransactionHandler thandler = (TransactionHandler)
                            Globals.getPacketRouter(0).getHandler(PacketType.ROLLBACK_TRANSACTION);
                        thandler.doRollback(tid, null, null, state, null, null,
                                            RollbackReason.TAKEOVER_CLEANUP);
                        itr.remove();
                    } else if (realstate == TransactionState.ROLLEDBACK) {
                    }
                }
View Full Code Here

Examples of com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler

            ((Integer)cmd_props.get(MessageType.JMQ_MESSAGE_TYPE)).intValue();
        int status = Status.OK;
  String errMsg = null;
        TransactionUID tid = null;
        TransactionState ts = null;
        TransactionHandler thandler = null;

        // Get the packet handler that handles transaction packets
        if (parent.adminPktRtr != null) {
            thandler = (TransactionHandler)
            parent.adminPktRtr.getHandler(PacketType.ROLLBACK_TRANSACTION);
        }

  Long id = (Long)cmd_props.get(MessageType.JMQ_TRANSACTION_ID);

        HAMonitorService hamonitor = Globals.getHAMonitorService();
        if (hamonitor != null && hamonitor.inTakeover()) {
            status = Status.ERROR;
            errMsg =  rb.getString(rb.E_CANNOT_PROCEED_TAKEOVER_IN_PROCESS);

            logger.log(Logger.ERROR, this.getClass().getName() + ": " + errMsg);
  }

        if (id != null) {
            tid = new TransactionUID(id.longValue());
        } else {
            status = Status.BAD_REQUEST;
        }

        if (status == Status.OK) {
            ts = tl.retrieveState(tid);
            if (ts == null) {
                // Specified transaction did not exist
                status = Status.NOT_FOUND;
          errMsg = rb.getString(rb.E_NO_SUCH_TRANSACTION, tid);
            } else if (requestType == MessageType.COMMIT_TRANSACTION &&
                        ts.getState() != TransactionState.PREPARED) {
                status = Status.PRECONDITION_FAILED;
          errMsg = rb.getString(rb.E_TRANSACTION_NOT_PREPARED, tid);
            } else if (requestType == MessageType.ROLLBACK_TRANSACTION &&
                        (ts.getState() < TransactionState.STARTED ||
                         ts.getState() > TransactionState.PREPARED)) {
                status = Status.PRECONDITION_FAILED;
          errMsg = rb.getString(rb.E_INVALID_TXN_STATE_FOR_ROLLBACK, tid);
            } else {
                JMQXid xid = tl.UIDToXid(tid);

                if (xid == null &&
                    (!(Globals.getHAEnabled() &&
                       ts.getState() == TransactionState.PREPARED))) {
        /*
         * Need to pick the right error message:
         * If (action is ROLLBACK and state is one of {STARTED, FAILED,
         *      INCOMPLETE, COMPLETE})
         *  "Rollback of non-XA transaction 123456789 in non-PREPARED state
         *   is not supported."
         * else
                     *  "Could not find Xid for 123456789"
         */
                    if (requestType == MessageType.ROLLBACK_TRANSACTION &&
                        (ts.getState() >= TransactionState.STARTED &&
                         ts.getState() < TransactionState.PREPARED)) {
                        errMsg = rb.getString(rb.E_INTERNAL_BROKER_ERROR,
                            "Rollback of non-XA transaction "
        + tid
        + " in non-PREPARED state is not supported.") ;
                } else {
                        errMsg = rb.getString(rb.E_INTERNAL_BROKER_ERROR,
                            "Could not find Xid for " + tid) ;
                }

                    status = Status.ERROR;
                } else if (thandler == null) {
                    errMsg = rb.getString(rb.E_INTERNAL_BROKER_ERROR,
                        "Could not locate TransactionHandler") ;
                    status = Status.ERROR;
                } else {
                    if (requestType == MessageType.ROLLBACK_TRANSACTION) {
                  if ( DEBUG ) {
                            logger.log(Logger.DEBUG,
                                "Rolling back " + tid + " in state " + ts);
                        }
                        try {
                            thandler.doRollback(tid, xid, null, ts, null,
                                                con, RollbackReason.ADMIN);
                        } catch (BrokerException e) {
                            status = Status.ERROR;
                            errMsg = e.getMessage();
                        }
                    } else if (requestType == MessageType.COMMIT_TRANSACTION) {
                  if ( DEBUG ) {
                            logger.log(Logger.DEBUG,
                                "Committing " + tid + " in state " + ts);
                        }
                        try {
                            thandler.doCommit(tid, xid,
                                new Integer(XAResource.TMNOFLAGS), ts, null,
                            false, con, null);
                        } catch (BrokerException e) {
                            status = Status.ERROR;
                            errMsg = e.getMessage();
View Full Code Here

Examples of com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler

                    TransactionList.XA_TXN_DETACHED_RETAINALL_PROP, false);
            ArrayList timeoutTIDs = new ArrayList();
            TransactionList tl = Globals.getTransactionList();
            TransactionUID tid = null;
            boolean xaretainallLogged = false;
            TransactionHandler rollbackHandler = (TransactionHandler)
                                   Globals.getPacketRouter(0).getHandler(
                                          PacketType.ROLLBACK_TRANSACTION);
            TransactionUID[] tuids = (TransactionUID[])conlist.toArray(new TransactionUID[0]);
            for (int i = 0; i < tuids.length; i ++) {
                tid = (TransactionUID) tuids[i];
                TransactionState ts = Globals.getTransactionList().retrieveState(tid);
                if (ts == null) {
                    // nothing to do if no transaction state
                    continue;
                }
                int tstate = ts.getState();
                if (ts.getXid() != null) {
                    if (xaretainall) {
                        if (!xaretainallLogged) {
                        logger.log(Logger.INFO, Globals.getBrokerResources().getKString(
                                   BrokerResources.I_CONN_CLEANUP_RETAIN_XA));
                        xaretainallLogged = true;
                        }
                        continue;
                    }
                    if(tstate > TransactionState.COMPLETE) {
                       String[] args = { ""+tid+"(XID="+ts.getXid()+")",
                                         TransactionState.toString(tstate),
                                         getConnectionUID().toString() };
                        logger.log(Logger.INFO, Globals.getBrokerResources().getKString(
                                          BrokerResources.I_CONN_CLEANUP_KEEP_TXN, args));
                        continue;
                    }
                    if (tstate == TransactionState.INCOMPLETE ||
                        tstate == TransactionState.COMPLETE ) {
                        ts.detachedFromConnection();
                        timeoutTIDs.add(tid);
                        String[] args = { ""+tid+"(XID="+ts.getXid()+")",
                                          TransactionState.toString(tstate),
                                          getConnectionUID().toString() };
                        logger.log(Logger.INFO, Globals.getBrokerResources().getKString(
                                          BrokerResources.I_CONN_CLEANUP_KEEP_TXN, args));
                        continue;
                    }
                }
                if (tstate == TransactionState.PREPARED ||
                    tstate == TransactionState.COMMITTED ||
                    tstate == TransactionState.ROLLEDBACK) {
                    String[] args = { ""+tid,
                                      TransactionState.toString(tstate),
                                      getConnectionUID().toString() };
                    logger.log(Logger.INFO, Globals.getBrokerResources().getKString(
                               BrokerResources.I_CONN_CLEANUP_KEEP_TXN, args));
                    continue;
                }
                if (DEBUG || DEBUG_TXN) {
                    logger.log(Logger.INFO, "Cleanup connection ["+getConnectionUID()+
                    "]: cleaning up transaction "+tid+"["+TransactionState.toString(tstate)+"]");
                }
                try {
                     rollbackHandler.doRollback(tid, ts.getXid(), null, ts, conlist,
                                   null, RollbackReason.CONNECTION_CLEANUP);
                } catch (Exception e) {
                     String[] args = { ""+tid+"["+TransactionState.toString(tstate)+"]",
                                       getConnectionUID().toString(), e.getMessage() };
                     logger.logStack(logger.WARNING,
View Full Code Here

Examples of com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler

        public DetachedTransactionTimerTask(long timeout) {
            super();
            this.timeout = timeout*1000;
        }
        public void run() {
            TransactionHandler rbh = (TransactionHandler)
                                       Globals.getPacketRouter(0).getHandler(
                                               PacketType.ROLLBACK_TRANSACTION);
            long currentTime = System.currentTimeMillis();
            TransactionUID[] tids = getDetachedTIDs();
            for (int i = 0; (i < tids.length && !destroyed); i++) {
                TransactionState ts = translist.retrieveState(tids[i]);
                if (ts == null || !ts.isDetachedFromConnection() ||
                    (ts.getState() != TransactionState.INCOMPLETE &&
                     ts.getState() != TransactionState.COMPLETE)) {
                    removeDetachedTID(tids[i]);
                    continue;
                }
                if (timeout == 0) continue;
                long timeoutTime = ts.getDetachedTime()+timeout;
                if (currentTime > timeoutTime) {
                    try {
                        String[] args = { tids[i]+"["+TransactionState.toString(ts.getState())+"]",
                                          String.valueOf(ts.getCreationTime()),
                                          String.valueOf(ts.getDetachedTime()) };
                        Globals.getLogger().log(Logger.WARNING,
                        Globals.getBrokerResources().getKString(
                                BrokerResources.W_ROLLBACK_TIMEDOUT_DETACHED_TXN, args));
                        rbh.doRollback(tids[i], ts.getXid(), null, ts, null,
                                                null, RollbackReason.TIMEOUT);
                        removeDetachedTID(tids[i]);
                    } catch (Exception ex) {
                        Globals.getLogger().logStack(Logger.WARNING,
                               Globals.getBrokerResources().getKString(
View Full Code Here

Examples of com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler

      if (pr == null)  {
          throw new Exception(rb.getString(rb.E_INTERNAL_BROKER_ERROR,
          "Could not locate Packet Router"));
      }

      TransactionHandler thandler = (TransactionHandler)
            pr.getHandler(PacketType.ROLLBACK_TRANSACTION);

      if (thandler == null)  {
          throw new Exception(rb.getString(rb.E_INTERNAL_BROKER_ERROR,
          "Could not locate Transaction Handler"));
      }

      if (rollback)  {
          thandler.doRollback(tid, xid, null, ts, null, null, RollbackReason.ADMIN);
      } else  {
    thandler.doCommit(tid, xid, new Integer(XAResource.TMNOFLAGS), ts, null,
        false, null, null);
      }
  } catch(Exception e)  {
      String opName;
      if (rollback)  {
View Full Code Here

Examples of com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler

          if (DEBUG) {
          Globals.getLogger().log(Logger.INFO,
          "ProtocolImpl.END TRANSACTION:TID="+id+", XID="+xid+", xaFlags="+xaFlags);
          }
         
          TransactionHandler handler = (TransactionHandler)
                      pr.getHandler(PacketType.START_TRANSACTION);
          TransactionState ts = handler.getTransactionList().retrieveState(id);

          handler.doEnd(PacketType.END_TRANSACTION, xid,
                  xaFlags, ts, id);

     }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.