Package org.neo4j.kernel.impl.nioneo.store

Examples of org.neo4j.kernel.impl.nioneo.store.PropertyStore$Configuration


    }

    @Test
    public void flushIfBatchSizeIsExceeded() {
        final int batchSize = 5;
        final Configuration config = new Configuration() {
            @Override
            public int getOutputBatchSize() {
                return batchSize;
            }
        };
View Full Code Here


        verify(messages, times(1)).bulkIndex(eq(messageList.subList(0, batchSize)));
    }

    @Test
    public void dontFlushEmptyBuffer() {
        final Configuration config = new Configuration() {
            @Override
            public int getOutputBatchSize() {
                return 10;
            }
        };
View Full Code Here

public class SizeBasedRotationStrategyTest {

    @Test
    public void testRotate() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        final IndexStatistics stats = new IndexStatistics();
        final CommonStats commonStats = new CommonStats();
        commonStats.store = new StoreStats(1000, 0);
        stats.setPrimaries(commonStats);

        when(indices.getIndexStats("name")).thenReturn(stats);
        when(configuration.getElasticSearchMaxSizePerIndex()).thenReturn(100L);

        final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(configuration,
                                                                                       indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

    }


    @Test
    public void testDontRotate() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        final IndexStatistics stats = new IndexStatistics();
        final CommonStats commonStats = new CommonStats();
        commonStats.store = new StoreStats(1000, 0);
        stats.setPrimaries(commonStats);

        when(indices.getIndexStats("name")).thenReturn(stats);
        when(configuration.getElasticSearchMaxSizePerIndex()).thenReturn(100000L);

        final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(configuration,
                                                                                 indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

    }


    @Test
    public void testRotateFailed() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        when(indices.getIndexStats("name")).thenReturn(null);
        when(configuration.getElasticSearchMaxSizePerIndex()).thenReturn(100L);

        final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(configuration,
                                                                                 indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

public class MessageCountRotationStrategyTest {

    @Test
    public void testRotate() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        when(indices.numberOfMessages("name")).thenReturn(10L);
        when(configuration.getElasticSearchMaxDocsPerIndex()).thenReturn(5);

        final MessageCountRotationStrategy strategy = new MessageCountRotationStrategy(configuration,
                                                                                       indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

        assertEquals(true, rotate.shouldRotate());
    }

    @Test
    public void testDontRotate() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        when(indices.numberOfMessages("name")).thenReturn(1L);
        when(configuration.getElasticSearchMaxDocsPerIndex()).thenReturn(5);

        final MessageCountRotationStrategy strategy = new MessageCountRotationStrategy(configuration,
                                                                                       indices);

        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

    }


    @Test
    public void testIndexUnavailable() throws IndexNotFoundException {
        final Configuration configuration = mock(Configuration.class);
        final Indices indices = mock(Indices.class);

        when(indices.numberOfMessages("name")).thenThrow(IndexNotFoundException.class).thenReturn(1L);
        when(configuration.getElasticSearchMaxDocsPerIndex()).thenReturn(5);

        final MessageCountRotationStrategy strategy = new MessageCountRotationStrategy(configuration,
                                                                                       indices);
        final RotationStrategy.Result rotate = strategy.shouldRotate("name");
View Full Code Here

    {
        if ( properties == null || properties.isEmpty() )
        {
            return Record.NO_NEXT_PROPERTY.intValue();
        }
        PropertyStore propStore = getPropertyStore();
        List<PropertyRecord> propRecords = new ArrayList<PropertyRecord>();
        PropertyRecord currentRecord = new PropertyRecord( propStore.nextId() );
        currentRecord.setInUse( true );
        currentRecord.setCreated();
        propRecords.add( currentRecord );
        for ( Entry<String, Object> entry : properties.entrySet() )
        {
            int keyId = indexHolder.getKeyId( entry.getKey() );
            if ( keyId == -1 )
            {
                keyId = createNewPropertyIndex( entry.getKey() );
            }

            PropertyBlock block = new PropertyBlock();
            propStore.encodeValue( block, keyId, entry.getValue() );
            if ( currentRecord.size() + block.getSize() > PropertyType.getPayloadSize() )
            {
                // Here it means the current block is done for
                PropertyRecord prevRecord = currentRecord;
                // Create new record
                long propertyId = propStore.nextId();
                currentRecord = new PropertyRecord( propertyId );
                currentRecord.setInUse( true );
                currentRecord.setCreated();
                // Set up links
                prevRecord.setNextProp( propertyId );
                currentRecord.setPrevProp( prevRecord.getId() );
                propRecords.add( currentRecord );
                // Now current is ready to start picking up blocks
            }
            currentRecord.addPropertyBlock( block );
        }
        /*
         * Add the property records in reverse order, which means largest
         * id first. That is to make sure we expand the property store file
         * only once.
         */
        for ( int i = propRecords.size() - 1; i >= 0; i-- )
        {
            propStore.updateRecord( propRecords.get( i ) );
        }
        /*
         *  0 will always exist, if the map was empty we wouldn't be here
         *  and even one property will create at least one record.
         */
 
View Full Code Here

        return propRecords.get( 0 ).getId();
    }

    private void deletePropertyChain( long nextProp )
    {
        PropertyStore propStore = getPropertyStore();
        while ( nextProp != Record.NO_NEXT_PROPERTY.intValue() )
        {
            PropertyRecord propRecord = propStore.getRecord( nextProp );
            /*
             *  The only reason to loop over the blocks is to handle the dynamic
             *  records that possibly hang under them. Otherwise, we could just
             *  set the property record not in use and be done with it. The
             *  residue of the convenience is that we do not remove individual
             *  property blocks - we just mark the whole record as !inUse.
             */
            for ( PropertyBlock propBlock : propRecord.getPropertyBlocks() )
            {
                if ( propBlock.isLight() )
                {
                    propStore.makeHeavy( propBlock );
                }
                for ( DynamicRecord rec : propBlock.getValueRecords() )
                {
                    rec.setInUse( false );
                    propRecord.addDeletedRecord( rec );
                }
            }
            propRecord.setInUse( false );
            nextProp = propRecord.getNextProp();
            propStore.updateRecord( propRecord );
        }
    }
View Full Code Here

TOP

Related Classes of org.neo4j.kernel.impl.nioneo.store.PropertyStore$Configuration

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.