Package org.neo4j.kernel.impl.transaction

Examples of org.neo4j.kernel.impl.transaction.XaDataSourceManager


        kernelStartTime = new Date().getTime();
    }

    public static NeoStoreXaDataSource getNeoDataSource( KernelData kernel )
    {
        XaDataSourceManager mgr = kernel.getConfig().getTxModule().getXaDataSourceManager();
        return (NeoStoreXaDataSource) mgr.getXaDataSource( "nioneodb" );
    }
View Full Code Here


    }

    @SuppressWarnings( "unchecked" )
    private SlaveContext slaveContextOf( GraphDatabaseService graphDb )
    {
        XaDataSourceManager dsManager =
                ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager();
        List<Pair<String, Long>> txs = new ArrayList<Pair<String,Long>>();
        for ( XaDataSource ds : dsManager.getAllRegisteredDataSources() )
        {
            txs.add( Pair.of( ds.getName(), ds.getLastCommittedTxId() ) );
        }
        return new SlaveContext( 0, 0, txs.toArray( new Pair[0] ) );
    }
View Full Code Here

    }

    @Override
    public SlaveContext getSlaveContext( int eventIdentifier )
    {
        XaDataSourceManager localDataSourceManager =
            getConfig().getTxModule().getXaDataSourceManager();
        Collection<XaDataSource> dataSources = localDataSourceManager.getAllRegisteredDataSources();
        @SuppressWarnings("unchecked")
        Pair<String, Long>[] txs = new Pair[dataSources.size()];
        int i = 0;
        for ( XaDataSource dataSource : dataSources )
        {
View Full Code Here

        }
    }

    private PropertyStore propertyStore()
    {
        XaDataSourceManager dsMgr = graphdb.getConfig().getTxModule().getXaDataSourceManager();
        return ( (NeoStoreXaConnection) dsMgr.getXaDataSource( "nioneodb" ).getXaConnection() ).getPropertyStore();
    }
View Full Code Here

    }
   
    public static SlaveContext rotateLogsAndStreamStoreFiles( GraphDatabaseService graphDb, StoreWriter writer )
    {
        File baseDir = getBaseDir( graphDb );
        XaDataSourceManager dsManager =
                ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager();
        Collection<XaDataSource> sources = dsManager.getAllRegisteredDataSources();
       
        @SuppressWarnings( "unchecked" )
        Pair<String, Long>[] appliedTransactions = new Pair[sources.size()];
        int i = 0;
        for ( XaDataSource ds : sources )
View Full Code Here

    public static <T> Response<T> packResponse( GraphDatabaseService graphDb,
            SlaveContext context, T response, Predicate<Long> filter )
    {
        List<Triplet<String, Long, TxExtractor>> stream = new ArrayList<Triplet<String, Long, TxExtractor>>();
        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 );
                            }
                        }
                    };
                    stream.add( Triplet.of( resourceName, txId, extractor ) );
                }
            }
        }
        StoreId storeId = ((NeoStoreXaDataSource) dsManager.getXaDataSource( Config.DEFAULT_DATA_SOURCE_NAME )).getStoreId();
        return new Response<T>( response, storeId, TransactionStream.create( resourceNames, stream ) );
    }
View Full Code Here

        }
    };

    public static <T> void applyReceivedTransactions( Response<T> response, GraphDatabaseService graphDb, TxHandler txHandler ) throws IOException
    {
        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 );
View Full Code Here

    public void panicTest() throws Exception
    {
        String path = "target/var/testdb";
        AbstractNeo4jTestCase.deleteFileOrDirectory( new File( path ) );
        EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase( path );
        XaDataSourceManager xaDs =
            graphDb.getConfig().getTxModule().getXaDataSourceManager();
       
        IllBehavingXaDataSource noob = new IllBehavingXaDataSource();
        xaDs.registerDataSource( "noob", noob, UTF8.encode( "554342" ) );
       
        Panic panic = new Panic();
        graphDb.registerKernelEventHandler( panic );
    
        org.neo4j.graphdb.Transaction gdbTx = graphDb.beginTx();
View Full Code Here

        config.put( Config.KEEP_LOGICAL_LOGS, "nioneodb" );
        String storeDir = "target/configdb";
        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.XaDataSourceManager

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.