Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.TransactionFailureException


        {
            if ( useExisting )
            {
                return xaDsMgr.getXaDataSource( name );
            }
            throw new TransactionFailureException( "Data source[" + name
                + "] has already been registered" );
        }
        try
        {
            XaDataSource dataSource = xaDsMgr.create( className, params );
            xaDsMgr.registerDataSource( name, dataSource, resourceId );
            return dataSource;
        }
        catch ( Exception e )
        {
            throw new TransactionFailureException(
                "Could not create data source " + name + "[" + name + "]", e );
        }
    }
View Full Code Here


     */
    public final void addCommand( XaCommand command )
    {
        if ( committed )
        {
            throw new TransactionFailureException(
                "Cannot add command to committed transaction" );
        }
        if ( rolledback )
        {
            throw new TransactionFailureException(
                "Cannot add command to rolled back transaction" );
        }
        doAddCommand( command );
        try
        {
            log.writeCommand( command, identifier );
        }
        catch ( IOException e )
        {
            throw new TransactionFailureException(
                "Unable to write command to logical log.", e );
        }
    }
View Full Code Here

                    return sourceIdMapping.get( name );
                }
            }
            catch ( XAException e )
            {
                throw new TransactionFailureException(
                    "Unable to check is same resource", e );
            }
        }
        throw new TransactionFailureException(
            "Unable to find mapping for XAResource[" + xaResource + "]" );
    }
View Full Code Here

    synchronized XAResource getXaResource( byte branchId[] )
    {
        XaDataSource dataSource = branchIdMapping.get( UTF8.decode( branchId ) );
        if ( dataSource == null )
        {
            throw new TransactionFailureException(
                "No mapping found for branchId[0x" +
                UTF8.decode( branchId ) + "]" );
        }
        return dataSource.getXaConnection().getXaResource();
    }
View Full Code Here

        {
            transactionManager.begin();
        }
        catch ( NotSupportedException e )
        {
            throw new TransactionFailureException(
                "Unable to begin transaction.", e );
        }
        catch ( SystemException e )
        {
            throw new TransactionFailureException(
                "Unable to begin transaction.", e );
        }
    }
View Full Code Here

        {
            transactionManager.commit();
        }
        catch ( SecurityException e )
        {
            throw new TransactionFailureException( "Failed to commit.", e );
        }
        catch ( IllegalStateException e )
        {
            throw new TransactionFailureException( "Failed to commit.", e );
        }
        catch ( RollbackException e )
        {
            throw new TransactionFailureException( "Failed to commit.", e );
        }
        catch ( HeuristicMixedException e )
        {
            throw new TransactionFailureException( "Failed to commit.", e );
        }
        catch ( HeuristicRollbackException e )
        {
            throw new TransactionFailureException( "Failed to commit.", e );
        }
        catch ( SystemException e )
        {
            throw new TransactionFailureException( "Failed to commit.", e );
        }
    }
View Full Code Here

        {
            return tm.getTransaction();
        }
        catch ( SystemException e )
        {
            throw new TransactionFailureException(
                "Could not get current transaction.", e );
        }
    }
View Full Code Here

                fc.close();
                String currentTxLog = txLogDir + separator
                    + UTF8.decode( fileName ).trim();
                if ( !new File( currentTxLog ).exists() )
                {
                    throw new TransactionFailureException(
                        "Unable to start TM, " + "active tx log file[" +
                        currentTxLog + "] not found." );
                }
                txLog = new TxLog( currentTxLog );
                msgLog.logMessage( "TM opening log: " + currentTxLog, true );
            }
            else
            {
                if ( new File( txLogDir + separator + txLog1FileName ).exists()
                    || new File( txLogDir + separator + txLog2FileName )
                        .exists() )
                {
                    throw new TransactionFailureException(
                        "Unable to start TM, "
                        + "no active tx log file found but found either "
                        + txLog1FileName + " or " + txLog2FileName
                        + " file, please set one of them as active or "
                        + "remove them." );
                }
                ByteBuffer buf = ByteBuffer.wrap( txLog1FileName
                    .getBytes( "UTF-8" ) );
                FileChannel fc = new RandomAccessFile( logSwitcherFileName,
                    "rw" ).getChannel();
                fc.write( buf );
                txLog = new TxLog( txLogDir + separator + txLog1FileName );
                msgLog.logMessage( "TM new log: " + txLog1FileName, true );
                fc.force( true );
                fc.close();
            }
            Iterator<List<TxLog.Record>> danglingRecordList =
                txLog.getDanglingRecords();
            if ( danglingRecordList.hasNext() )
            {
                log.info( "Unresolved transactions found, " +
                    "recovery started ..." );
                recover( danglingRecordList );
                log.info( "Recovery completed, all transactions have been " +
                    "resolved to a consistent state." );
                msgLog.logMessage( "Recovery completed, all transactions have been " +
                    "resolved to a consistent state." );           
            }
            getTxLog().truncate();
            tmOk = true;
        }
        catch ( IOException e )
        {
            log.severe( "Unable to start TM" );
            throw new TransactionFailureException( "Unable to start TM", e );
        }
    }
View Full Code Here

                    recoveredXidsList.remove( xids[i] );
                    Resource resource = new Resource( xids[i]
                        .getBranchQualifier() );
                    if ( !resourceMap.containsKey( resource ) )
                    {
                        throw new TransactionFailureException(
                            "Couldn't find XAResource for " + xids[i] );
                    }
                    log.fine( "Commiting tx seq[" + seq + "][" +
                        xids[i] + "] ... " );
                    msgLog.logMessage( "TM: Committing tx " + xids[i], true );
                    resourceMap.get( resource ).commit( xids[i], false );
                }
            }
            // rollback the rest
            Iterator<Xid> rollbackItr = recoveredXidsList.iterator();
            while ( rollbackItr.hasNext() )
            {
                Xid xid = rollbackItr.next();
                Resource resource = new Resource( xid.getBranchQualifier() );
                if ( !resourceMap.containsKey( resource ) )
                {
                    throw new TransactionFailureException(
                        "Couldn't find XAResource for " + xid );
                }
                log.fine( "Rollback " + xid + " ... " );
                msgLog.logMessage( "TM: no match found for " + xid + " removing", true );
                resourceMap.get( resource ).rollback( xid );
            }
            if ( rollbackList.size() > 0 )
            {
                log.fine( "TxLog contained unresolved "
                    + "xids that needed rollback. They couldn't be matched to "
                    + "any of the XAResources recover list. " + "Assuming "
                    + rollbackList.size()
                    + " transactions already rolled back." );
                msgLog.logMessage( "TM: no match found for in total " + rollbackList.size() +
                        " transaction that should have been rolled back", true );
            }
        }
        catch ( XAException e )
        {
            throw new TransactionFailureException( "Recovery failed." + e );
        }
    }
View Full Code Here

            Iterator<TxLog.Record> dListItr =
                danglingRecordList.next().iterator();
            TxLog.Record startRecord = dListItr.next();
            if ( startRecord.getType() != TxLog.TX_START )
            {
                throw new TransactionFailureException(
                    "First record not a start record, type="
                        + startRecord.getType() );
            }
            // get branches & commit status
            HashSet<Resource> branchSet = new HashSet<Resource>();
            int markedCommit = -1;
            while ( dListItr.hasNext() )
            {
                TxLog.Record record = dListItr.next();
                if ( record.getType() == TxLog.BRANCH_ADD )
                {
                    if ( markedCommit != -1 )
                    {
                        throw new TransactionFailureException(
                            "Already marked commit " + startRecord );
                    }
                    branchSet.add( new Resource( record.getBranchId() ) );
                }
                else if ( record.getType() == TxLog.MARK_COMMIT )
                {
                    if ( markedCommit != -1 )
                    {
                        throw new TransactionFailureException(
                            "Already marked commit " + startRecord );
                    }
                    markedCommit = record.getSequenceNumber();
                }
                else
                {
                    throw new TransactionFailureException(
                        "Illegal record type[" + record.getType() + "]" );
                }
            }
            Iterator<Resource> resourceItr = branchSet.iterator();
            List<Xid> xids = new LinkedList<Xid>();
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.TransactionFailureException

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.