Package org.neo4j.kernel.impl.transaction.xaframework

Examples of org.neo4j.kernel.impl.transaction.xaframework.XaDataSource


        Set<String> resourceNames = new HashSet<String>();
        XaDataSourceManager dsManager = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager();
        for ( Pair<String, Long> txEntry : context.lastAppliedTransactions() )
        {
            String resourceName = txEntry.first();
            final XaDataSource dataSource = dsManager.getXaDataSource( resourceName );
            if ( dataSource == null )
            {
                throw new RuntimeException( "No data source '" + resourceName + "' found" );
            }
            resourceNames.add( resourceName );
            long masterLastTx = dataSource.getLastCommittedTxId();
            for ( long txId = txEntry.other() + 1; txId <= masterLastTx; txId++ )
            {
                if ( filter.accept( txId ) )
                {
                    final long tx = txId;
                    TxExtractor extractor = new TxExtractor()
                    {
                        @Override
                        public ReadableByteChannel extract()
                        {
                            try
                            {
                                return dataSource.getCommittedTransaction( tx );
                            }
                            catch ( IOException e )
                            {
                                throw new RuntimeException( e );
                            }
                        }

                        @Override
                        public void extract( LogBuffer buffer )
                        {
                            try
                            {
                                dataSource.getCommittedTransaction( tx, buffer );
                            }
                            catch ( IOException e )
                            {
                                throw new RuntimeException( e );
                            }
View Full Code Here


    }
   
    public static <T> Response<T> packResponseWithoutTransactionStream( GraphDatabaseService graphDb,
            SlaveContext context, T response )
    {
        XaDataSource ds = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule()
                .getXaDataSourceManager().getXaDataSource( Config.DEFAULT_DATA_SOURCE_NAME );
        StoreId storeId = ((NeoStoreXaDataSource) ds).getStoreId();
        return new Response<T>( response, storeId, TransactionStream.EMPTY );
    }
View Full Code Here

    {
        XaDataSourceManager dataSourceManager = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager();
        for ( Triplet<String, Long, TxExtractor> tx : IteratorUtil.asIterable( response.transactions() ) )
        {
            String resourceName = tx.first();
            XaDataSource dataSource = dataSourceManager.getXaDataSource( resourceName );
            txHandler.accept( tx, dataSource );
            ReadableByteChannel txStream = tx.third().extract();
            try
            {
                dataSource.applyCommittedTransaction( tx.second(), txStream );
            }
            finally
            {
                txStream.close();
            }
View Full Code Here

            TxExtractor txGetter )
    {
        Transaction otherTx = suspendOtherAndResumeThis( context );
        try
        {
            XaDataSource dataSource = graphDbConfig.getTxModule().getXaDataSourceManager()
                    .getXaDataSource( resource );
            final long txId = dataSource.applyPreparedTransaction( txGetter.extract() );
            Predicate<Long> notThisTx = new Predicate<Long>()
            {
                public boolean accept( Long item )
                {
                    return item != txId;
View Full Code Here

    public Response<Integer> getMasterIdForCommittedTx( long txId )
    {
        try
        {
            XaDataSource nioneoDataSource = graphDbConfig.getTxModule().getXaDataSourceManager()
                    .getXaDataSource( Config.DEFAULT_DATA_SOURCE_NAME );
            return MasterUtil.packResponseWithoutTransactionStream( graphDb, SlaveContext.EMPTY,
                    nioneoDataSource.getMasterForCommittedTx( txId ) );
        }
        catch ( IOException e )
        {
            return MasterUtil.packResponseWithoutTransactionStream( graphDb, SlaveContext.EMPTY,
                    XaLogicalLog.MASTER_ID_REPRESENTING_NO_MASTER );
View Full Code Here

    {
        Collection<Pair<String, Long>> txs = new ArrayList<Pair<String, Long>>();
        for ( Pair<String, Long> txEntry : context.lastAppliedTransactions() )
        {
            String resourceName = txEntry.first();
            XaDataSource dataSource = graphDbConfig.getTxModule().getXaDataSourceManager()
                    .getXaDataSource( resourceName );
            if ( dataSource instanceof NeoStoreXaDataSource )
            {
                if ( txEntry.other() == 1 || txEntry.other() < dataSource.getLastCommittedTxId() )
                {
                    // No transactions and nothing has happened during the
                    // copying
                    return context;
                }
                // Put back slave one tx so that it gets one transaction
                txs.add( Pair.of( resourceName, dataSource.getLastCommittedTxId() - 1 ) );
//                System.out.println( "Pushed in one extra tx " + dataSource.getLastCommittedTxId() );
            }
            else
            {
                txs.add( Pair.of( resourceName, dataSource.getLastCommittedTxId() ) );
            }
        }
        return new SlaveContext( context.machineId(), context.getEventIdentifier(),
                txs.toArray( new Pair[0] ) );
View Full Code Here

        deleteFileOrDirectory( storeDir );
        EmbeddedGraphDatabase db = new EmbeddedGraphDatabase(
                storeDir, config );
        XaDataSourceManager xaDsMgr =
                db.getConfig().getTxModule().getXaDataSourceManager();
        XaDataSource xaDs = xaDsMgr.getXaDataSource( "nioneodb" );
        assertTrue( xaDs.isLogicalLogKept() );
        db.shutdown();
       
        config.remove( Config.KEEP_LOGICAL_LOGS );
        db = new EmbeddedGraphDatabase( storeDir, config );
        xaDsMgr = db.getConfig().getTxModule().getXaDataSourceManager();
        xaDs = xaDsMgr.getXaDataSource( "nioneodb" );
        assertTrue( !xaDs.isLogicalLogKept() );
        db.shutdown();

        config.put( Config.KEEP_LOGICAL_LOGS, "true" );
        db = new EmbeddedGraphDatabase( storeDir, config );
        xaDsMgr = db.getConfig().getTxModule().getXaDataSourceManager();
        xaDs = xaDsMgr.getXaDataSource( "nioneodb" );
        assertTrue( xaDs.isLogicalLogKept() );
    }
View Full Code Here

TOP

Related Classes of org.neo4j.kernel.impl.transaction.xaframework.XaDataSource

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.