Package com.atomikos.icatch.admin

Examples of com.atomikos.icatch.admin.AdminTransaction


        AdminTransaction[] template = new AdminTransaction[0];
        Vector vect = new Vector ();
        Enumeration enumm = service_.getCoordinatorImpVector ().elements ();
        while ( enumm.hasMoreElements () ) {
            CoordinatorImp c = (CoordinatorImp) enumm.nextElement ();
            AdminTransaction tx = new AdminTransactionImp ( c );
            vect.addElement ( tx );
        }
        ret = (AdminTransaction[]) vect.toArray ( template );

        return ret;
View Full Code Here


        Enumeration enumm = service_.getCoordinatorImpVector ().elements ();
        while ( enumm.hasMoreElements () ) {
            CoordinatorImp c = (CoordinatorImp) enumm.nextElement ();
            if ( filter.containsKey ( c.getCoordinatorId () ) ) {
                AdminTransaction tx = new AdminTransactionImp ( c );
                vect.addElement ( tx );
            }
        }
        ret = (AdminTransaction[]) vect.toArray ( temp );
View Full Code Here

        return 3;
    }

    public Object getValueAt ( int row , int column )
    {
        AdminTransaction tx = (AdminTransaction) data_.elementAt ( row );
        if ( column == 0 )
            return tx.getTid ();
        else if ( column == 1 )
            return AdminTool.convertState ( tx.getState () );
        else {
            if ( AdminTool.hasDetails ( tx.getState () ) )
                return new String ( "Click row for details." );
            else
                return new String ( "" );
        }
View Full Code Here

    private AdminTransaction[] filterHeuristics ( AdminTransaction[] txs )
    {
      List ret = new ArrayList();
      for ( int i = 0 ; i < txs.length ; i++ ) {
        AdminTransaction next = txs[i];
        switch ( next.getState() ) {
          case AdminTransaction.STATE_HEUR_ABORTED:
            ret.add ( next )
            break;
          case AdminTransaction.STATE_HEUR_COMMITTED:
            ret.add ( next );
View Full Code Here

        return new StateDescriptor ( state, msgs );
    }

    private static Vector getStateDescriptors ( Object admintx )
    {
        AdminTransaction tx = (AdminTransaction) admintx;
        Vector ret = new Vector ();
        StateDescriptor desc = null;

        desc = getStateDescriptor ( tx, AdminTransaction.STATE_HEUR_MIXED );
        if ( !(desc.messages == null || desc.messages.length == 0) )
View Full Code Here

    }

    private void forget ( Object part , int row )
    {

        AdminTransaction p = (AdminTransaction) part;
        p.forceForget ();
        model_.rowDeleted ( row );

    }
View Full Code Here

    }

    private void commit ( Object part , int row )
    {
        try {
            AdminTransaction p = (AdminTransaction) part;
            p.forceCommit ();
            model_.refresh ();
        } catch ( Exception e ) {
            e.printStackTrace ();
        }
    }
View Full Code Here

    }

    private void rollback ( Object part , int row )
    {
        try {
            AdminTransaction p = (AdminTransaction) part;
            p.forceRollback ();
            model_.refresh ();
        } catch ( Exception e ) {
            e.printStackTrace ();
        }
    }
View Full Code Here

    private String getMessages ( Object part )
    {
        HeuristicMessage[] msgs = null;
        StringBuffer ret = new StringBuffer ();

        AdminTransaction p = (AdminTransaction) part;
        Object state = convertState ( p.getState () );

        // in the general case, no distinction has to be made between different
        // outcomes of different participants.
        msgs = p.getHeuristicMessages ();

        if ( p.wasCommitted () )
            ret.append ( messages_.getString ( "commitAttemptedMessage" ) );
        else if ( p.getState () != AdminTransaction.STATE_PREPARED )
            ret.append ( messages_.getString ( "rollbackAttemptedMessage" ) );

        for ( int i = 0; i < msgs.length; i++ ) {
            ret.append ( msgs[i] );
            if ( i < msgs.length - 1 )
                ret.append ( " -- " );
        }
        if ( p.getState () == AdminTransaction.STATE_HEUR_MIXED
                || p.getState () == AdminTransaction.STATE_HEUR_HAZARD ) {

            // in this case, we should add extra information about
            // which task was in a different outcome
            ret.append ( messages_.getString ( "ofWhichMessage" ) );
            ret.append ( getHeuristicDetails ( p,
View Full Code Here

      ListSelectionModel lsm = (ListSelectionModel) e.getSource ();
      if ( lsm.isSelectionEmpty () ) {
          // no rows are selected
      } else {
          int selectedRow = lsm.getMinSelectionIndex ();
          AdminTransaction rec = (AdminTransaction) data_
                  .elementAt ( selectedRow );
          Object id = null;
          Object state = null;

          id = rec.getTid ();
          state = convertState ( rec.getState () );

          if ( !state.equals ( TxState.IN_DOUBT ) ) {
              if ( hasDetails ( rec.getState () ) ) {
                  Object[] options = {
                          messages_.getString ( "forgetNoArchiveOption" ),
                          messages_.getString ( "forgetAndArchiveOption" ),
                          messages_.getString ( "keepInLogOption" ) };
                  Vector descriptors = getStateDescriptors ( rec );
                  StateTableModel table = new StateTableModel ( descriptors );
                  PropertiesPanel panel = new PropertiesPanel ( table, true );
                  String outcome = null;
                  if ( rec.wasCommitted () )
                      outcome = messages_.getString ( "commitOutcomeMessage" );
                  else
                      outcome = messages_
                              .getString ( "rollbackOutcomeMessage" );
                  panel.addPropertyListener ( pListener_ );
                  int n = JOptionPane.showOptionDialog ( frame_, panel
                          .getPanel (), outcome + id.toString (),
                          JOptionPane.YES_NO_CANCEL_OPTION,
                          JOptionPane.QUESTION_MESSAGE, null, options,
                          options[2] );

                  if ( n == JOptionPane.YES_OPTION
                          || n == JOptionPane.NO_OPTION ) {
                      // System.out.println ( "Terminating transaction" );
                      if ( n == JOptionPane.NO_OPTION ) {
                          // ask user where to archive
                          fc_.setDialogTitle ( messages_
                                  .getString ( "appendDialogTitle" ) );
                          int ret = fc_.showOpenDialog ( frame_ );
                          if ( ret == JFileChooser.APPROVE_OPTION ) {
                              try {
                                  File file = fc_.getSelectedFile ();
                                  FileWriter writer = new FileWriter ( file
                                          .getPath (), true );
                                  writer
                                          .write ( messages_
                                                  .getString ( "rootTransactionMessage" )
                                                  + id.toString () + " " );
                                  writer.write ( getMessages ( data_
                                          .elementAt ( selectedRow ) ) );
                                  writer.write ( "\r" );
                                  writer.flush ();
                                  writer.close ();
                                  forget ( data_.elementAt ( selectedRow ),
                                          selectedRow );
                              } catch ( Exception err ) {
                                  err.printStackTrace ();
                              }
                          }
                      }

                      else {
                          // Forget no archive
                          forget ( data_.elementAt ( selectedRow ),
                                  selectedRow );
                      }
                  } else {
                      // CANCEL option -> just invalidate selection, to allow
                      // next pop-up to happen
                      lsm.removeSelectionInterval ( selectedRow, selectedRow );
                  }
              } else {
                //no details available -> show warning for the user
                String message = messages_.getString ( "noDetailsAvailableMessage" );
                String title = messages_.getString( "noDetailsAvailableTitle" );
                JOptionPane.showMessageDialog (
                          frame_ , message , title , JOptionPane.INFORMATION_MESSAGE );
              }
          } else {
              // indoubt instance -> present commit/rollback/keep option
              Object[] options = { messages_.getString ( "commitOption" ),
                      messages_.getString ( "rollbackOption" ),
                      messages_.getString ( "keepInLogOption" ) };
              AdminTransaction tx = (AdminTransaction) data_
                      .elementAt ( selectedRow );
              JPanel panel = getMessagePanel ( tx.getHeuristicMessages () );

              int n = JOptionPane
                      .showOptionDialog ( frame_, panel, messages_
                              .getString ( "selectedTransactionMessage" )
                              + id.toString (),
View Full Code Here

TOP

Related Classes of com.atomikos.icatch.admin.AdminTransaction

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.